[SSE] Show data validation settings
This commit is contained in:
parent
080b21ba8f
commit
351286c8d1
|
@ -606,7 +606,7 @@ define([
|
|||
if (b.value !== undefined)
|
||||
newBtns[b.value] = {text: b.caption, cls: 'custom' + ((b.primary || options.primary==b.value) ? ' primary' : '')};
|
||||
} else {
|
||||
newBtns[b] = {text: (b=='custom') ? options.customButtonText : arrBtns[b], cls: (options.primary==b) ? 'primary' : ''};
|
||||
newBtns[b] = {text: (b=='custom') ? options.customButtonText : arrBtns[b], cls: (options.primary==b || _.indexOf(options.primary, b)>-1) ? 'primary' : ''};
|
||||
if (b=='custom')
|
||||
newBtns[b].cls += ' custom';
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ define([
|
|||
'spreadsheeteditor/main/app/view/DataTab',
|
||||
'spreadsheeteditor/main/app/view/SortDialog',
|
||||
'spreadsheeteditor/main/app/view/RemoveDuplicatesDialog',
|
||||
'spreadsheeteditor/main/app/view/DataValidationDialog',
|
||||
'common/main/lib/view/OptionsDialog'
|
||||
], function () {
|
||||
'use strict';
|
||||
|
@ -90,7 +91,8 @@ define([
|
|||
'data:hide': this.onHideClick,
|
||||
'data:groupsettings': this.onGroupSettings,
|
||||
'data:sortcustom': this.onCustomSort,
|
||||
'data:remduplicates': this.onRemoveDuplicates
|
||||
'data:remduplicates': this.onRemoveDuplicates,
|
||||
'data:datavalidation': this.onDataValidation
|
||||
},
|
||||
'Statusbar': {
|
||||
'sheet:changed': this.onApiSheetChanged
|
||||
|
@ -279,7 +281,6 @@ define([
|
|||
width: 500,
|
||||
title: this.txtRemDuplicates,
|
||||
msg: this.txtExpandRemDuplicates,
|
||||
|
||||
buttons: [ {caption: this.txtExpand, primary: true, value: 'expand'},
|
||||
{caption: this.txtRemSelected, primary: true, value: 'remove'},
|
||||
'cancel'],
|
||||
|
@ -313,6 +314,48 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
onDataValidation: function() {
|
||||
var me = this;
|
||||
if (this.api) {
|
||||
var res = this.api.asc_getDataValidationProps();
|
||||
if (typeof res !== 'object') {
|
||||
var config = {
|
||||
maxwidth: 500,
|
||||
title: this.txtDataValidation,
|
||||
msg: res===Asc.c_oAscError.ID.MoreOneTypeDataValidate ? this.txtExtendDataValidation : this.txtRemoveDataValidation,
|
||||
buttons: res===Asc.c_oAscError.ID.MoreOneTypeDataValidate ? ['yes', 'no', 'cancel'] : ['ok', 'cancel'],
|
||||
primary: res===Asc.c_oAscError.ID.MoreOneTypeDataValidate ? ['yes', 'no'] : 'ok',
|
||||
callback: function(btn){
|
||||
if (btn == 'yes' || btn == 'no' || btn == 'ok') {
|
||||
setTimeout(function(){
|
||||
var props = me.api.asc_getDataValidationProps(btn == 'yes');
|
||||
me.showDataValidation(props);
|
||||
},1);
|
||||
}
|
||||
}
|
||||
};
|
||||
Common.UI.alert(config);
|
||||
} else
|
||||
me.showDataValidation(res);
|
||||
}
|
||||
},
|
||||
|
||||
showDataValidation: function(props) {
|
||||
var me = this;
|
||||
if (props) {
|
||||
(new SSE.Views.DataValidationDialog({
|
||||
title: this.txtDataValidation,
|
||||
props: props,
|
||||
api: me.api,
|
||||
handler: function (result, settings) {
|
||||
if (me && me.api && result == 'ok') {
|
||||
me.api.asc_setDataValidation(settings);
|
||||
}
|
||||
}
|
||||
})).show();
|
||||
}
|
||||
},
|
||||
|
||||
onWorksheetLocked: function(index,locked) {
|
||||
if (index == this.api.asc_getActiveWorksheetIndex()) {
|
||||
Common.Utils.lockControls(SSE.enumLock.sheetLock, locked, {array: this.view.btnsSortDown.concat(this.view.btnsSortUp, this.view.btnCustomSort, this.view.btnGroup, this.view.btnUngroup)});
|
||||
|
@ -332,7 +375,10 @@ define([
|
|||
txtExpand: 'Expand',
|
||||
txtRemSelected: 'Remove in selected',
|
||||
textRows: 'Rows',
|
||||
textColumns: 'Columns'
|
||||
textColumns: 'Columns',
|
||||
txtDataValidation: 'Data Validation',
|
||||
txtExtendDataValidation: 'The selection contains some cells without Data Validation settings.<br>Do you want to extend Data Validation to these cells?',
|
||||
txtRemoveDataValidation: 'The selection contains more than one type of validation.<br>Erase current settings and continue?'
|
||||
|
||||
}, SSE.Controllers.DataTab || {}));
|
||||
});
|
|
@ -2410,7 +2410,7 @@ define([
|
|||
}
|
||||
need_disable = this._state.controlsdisabled.filters || (val===null);
|
||||
toolbar.lockToolbar(SSE.enumLock.ruleFilter, need_disable,
|
||||
{ array: toolbar.btnsSetAutofilter.concat(toolbar.btnCustomSort, toolbar.btnTableTemplate, toolbar.btnInsertTable, toolbar.btnRemoveDuplicates) });
|
||||
{ array: toolbar.btnsSetAutofilter.concat(toolbar.btnCustomSort, toolbar.btnTableTemplate, toolbar.btnInsertTable, toolbar.btnRemoveDuplicates, toolbar.btnDataValidation) });
|
||||
|
||||
toolbar.lockToolbar(SSE.enumLock.tableHasSlicer, filterInfo && filterInfo.asc_getIsSlicerAdded(), { array: toolbar.btnsSetAutofilter });
|
||||
|
||||
|
@ -2446,12 +2446,12 @@ define([
|
|||
|
||||
this._state.inpivot = !!info.asc_getPivotTableInfo();
|
||||
toolbar.lockToolbar(SSE.enumLock.editPivot, this._state.inpivot, { array: toolbar.btnsSetAutofilter.concat(toolbar.btnCustomSort,
|
||||
toolbar.btnMerge, toolbar.btnInsertHyperlink, toolbar.btnInsertTable, toolbar.btnRemoveDuplicates)});
|
||||
toolbar.btnMerge, toolbar.btnInsertHyperlink, toolbar.btnInsertTable, toolbar.btnRemoveDuplicates, toolbar.btnDataValidation)});
|
||||
toolbar.lockToolbar(SSE.enumLock.noSlicerSource, !(this._state.inpivot || formatTableInfo), { array: [toolbar.btnInsertSlicer]});
|
||||
|
||||
need_disable = !this.appConfig.canModifyFilter;
|
||||
toolbar.lockToolbar(SSE.enumLock.cantModifyFilter, need_disable, { array: toolbar.btnsSetAutofilter.concat(toolbar.btnsSortDown, toolbar.btnsSortUp, toolbar.btnCustomSort, toolbar.btnTableTemplate,
|
||||
toolbar.btnClearStyle.menu.items[0], toolbar.btnClearStyle.menu.items[2], toolbar.btnInsertTable, toolbar.btnRemoveDuplicates)});
|
||||
toolbar.btnClearStyle.menu.items[0], toolbar.btnClearStyle.menu.items[2], toolbar.btnInsertTable, toolbar.btnRemoveDuplicates, toolbar.btnDataValidation)});
|
||||
|
||||
}
|
||||
|
||||
|
@ -3340,6 +3340,7 @@ define([
|
|||
me.toolbar.btnsClearAutofilter = datatab.getButtons('clear-filter');
|
||||
me.toolbar.btnCustomSort = datatab.getButtons('sort-custom');
|
||||
me.toolbar.btnRemoveDuplicates = datatab.getButtons('rem-duplicates');
|
||||
me.toolbar.btnDataValidation = datatab.getButtons('data-validation');
|
||||
|
||||
var formulatab = me.getApplication().getController('FormulaDialog');
|
||||
formulatab.setConfig({toolbar: me});
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<div id="id-data-validation-settings" class="settings-panel active">
|
||||
<div class="inner-content">
|
||||
<table cols="1" style="width: 100%;">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div id="id-data-validation-input" class="settings-panel">
|
||||
<div class="inner-content">
|
||||
<table cols="1" style="width: 100%;">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div id="id-data-validation-error" class="settings-panel">
|
||||
<div class="inner-content">
|
||||
<table cols="1" style="width: 100%;">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
|
@ -211,6 +211,7 @@
|
|||
<div class="group">
|
||||
<span class="btn-slot text x-huge" id="slot-btn-text-column"></span>
|
||||
<span class="btn-slot text x-huge" id="slot-btn-rem-duplicates"></span>
|
||||
<span class="btn-slot text x-huge" id="slot-btn-data-validation"></span>
|
||||
</div>
|
||||
<div class="separator long"></div>
|
||||
<div class="group">
|
||||
|
|
|
@ -69,6 +69,9 @@ define([
|
|||
me.btnRemoveDuplicates.on('click', function (b, e) {
|
||||
me.fireEvent('data:remduplicates');
|
||||
});
|
||||
me.btnDataValidation.on('click', function (b, e) {
|
||||
me.fireEvent('data:datavalidation');
|
||||
});
|
||||
// isn't used for awhile
|
||||
// me.btnShow.on('click', function (b, e) {
|
||||
// me.fireEvent('data:show');
|
||||
|
@ -179,6 +182,16 @@ define([
|
|||
});
|
||||
this.lockedControls.push(this.btnRemoveDuplicates);
|
||||
|
||||
this.btnDataValidation = new Common.UI.Button({
|
||||
parentEl: $host.find('#slot-btn-data-validation'),
|
||||
cls: 'btn-toolbar x-huge icon-top',
|
||||
iconCls: 'toolbar__icon btn-data-validation',
|
||||
caption: this.capBtnTextDataValidation,
|
||||
disabled: true,
|
||||
lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.sheetLock]
|
||||
});
|
||||
this.lockedControls.push(this.btnDataValidation);
|
||||
|
||||
this.btnCustomSort = new Common.UI.Button({
|
||||
parentEl: $host.find('#slot-btn-custom-sort'),
|
||||
cls: 'btn-toolbar x-huge icon-top',
|
||||
|
@ -240,6 +253,7 @@ define([
|
|||
|
||||
me.btnTextToColumns.updateHint(me.tipToColumns);
|
||||
me.btnRemoveDuplicates.updateHint(me.tipRemDuplicates);
|
||||
me.btnDataValidation.updateHint(me.tipDataValidation);
|
||||
|
||||
me.btnsSortDown.forEach( function(btn) {
|
||||
btn.updateHint(me.toolbar.txtSortAZ);
|
||||
|
@ -277,6 +291,8 @@ define([
|
|||
return this.btnsClearAutofilter;
|
||||
else if (type == 'rem-duplicates')
|
||||
return this.btnRemoveDuplicates;
|
||||
else if (type == 'data-validation')
|
||||
return this.btnDataValidation;
|
||||
else if (type===undefined)
|
||||
return this.lockedControls;
|
||||
return [];
|
||||
|
@ -308,7 +324,9 @@ define([
|
|||
capBtnTextCustomSort: 'Custom Sort',
|
||||
tipCustomSort: 'Custom sort',
|
||||
capBtnTextRemDuplicates: 'Remove Duplicates',
|
||||
tipRemDuplicates: 'Remove duplicate rows from a sheet'
|
||||
tipRemDuplicates: 'Remove duplicate rows from a sheet',
|
||||
capBtnTextDataValidation: 'Data Validation',
|
||||
tipDataValidation: 'Data validation'
|
||||
}
|
||||
}()), SSE.Views.DataTab || {}));
|
||||
});
|
||||
|
|
129
apps/spreadsheeteditor/main/app/view/DataValidationDialog.js
Normal file
129
apps/spreadsheeteditor/main/app/view/DataValidationDialog.js
Normal file
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2010-2020
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* DataValidationDialog.js
|
||||
*
|
||||
* Created by Julia Radzhabova on 11.11.2020
|
||||
* Copyright (c) 2020 Ascensio System SIA. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
define([ 'text!spreadsheeteditor/main/app/template/DataValidationDialog.template',
|
||||
'common/main/lib/util/utils',
|
||||
'common/main/lib/component/InputField',
|
||||
'common/main/lib/component/ComboBox',
|
||||
'common/main/lib/component/CheckBox',
|
||||
'common/main/lib/view/AdvancedSettingsWindow'
|
||||
], function (contentTemplate) { 'use strict';
|
||||
|
||||
SSE.Views.DataValidationDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({
|
||||
options: {
|
||||
contentWidth: 284,
|
||||
height: 350,
|
||||
toggleGroup: 'data-validation-group',
|
||||
storageName: 'sse-data-validation-category'
|
||||
},
|
||||
|
||||
initialize : function(options) {
|
||||
var me = this;
|
||||
|
||||
_.extend(this.options, {
|
||||
title: this.options.title,
|
||||
items: [
|
||||
{panelId: 'id-data-validation-settings', panelCaption: this.strSettings},
|
||||
{panelId: 'id-data-validation-input', panelCaption: this.strInput},
|
||||
{panelId: 'id-data-validation-error', panelCaption: this.strError}
|
||||
],
|
||||
contentTemplate: _.template(contentTemplate)({
|
||||
scope: this
|
||||
})
|
||||
}, options);
|
||||
|
||||
this.api = options.api;
|
||||
this.handler = options.handler;
|
||||
this.props = options.props;
|
||||
|
||||
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
Common.Views.AdvancedSettingsWindow.prototype.render.call(this);
|
||||
var me = this;
|
||||
|
||||
this.afterRender();
|
||||
},
|
||||
|
||||
afterRender: function() {
|
||||
this._setDefaults(this.props);
|
||||
if (this.storageName) {
|
||||
var value = Common.localStorage.getItem(this.storageName);
|
||||
this.setActiveCategory((value!==null) ? parseInt(value) : 0);
|
||||
}
|
||||
},
|
||||
|
||||
show: function() {
|
||||
Common.Views.AdvancedSettingsWindow.prototype.show.apply(this, arguments);
|
||||
},
|
||||
|
||||
_setDefaults: function (props) {
|
||||
if (props) {
|
||||
}
|
||||
},
|
||||
|
||||
getSettings: function () {
|
||||
var props = new Asc.CDataValidation();
|
||||
return props;
|
||||
},
|
||||
|
||||
onDlgBtnClick: function(event) {
|
||||
var me = this;
|
||||
var state = (typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event;
|
||||
if (state == 'ok') {
|
||||
this.handler && this.handler.call(this, state, (state == 'ok') ? this.getSettings() : undefined);
|
||||
}
|
||||
|
||||
this.close();
|
||||
},
|
||||
|
||||
onPrimary: function() {
|
||||
this.onDlgBtnClick('ok');
|
||||
return false;
|
||||
},
|
||||
|
||||
strSettings: 'Settings',
|
||||
strInput: 'Input Message',
|
||||
strError: 'Error Alert'
|
||||
|
||||
}, SSE.Views.DataValidationDialog || {}))
|
||||
});
|
Loading…
Reference in a new issue