From 897c3ca1ac2a7b834b96be2e14ade55bb869ec67 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Jun 2021 12:20:24 +0300 Subject: [PATCH] Fix protect ranges dialog --- .../main/app/view/ProtectDialog.js | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js index d6648ee17..3c0164bef 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js @@ -170,14 +170,13 @@ define([ el : $('#id-range-txt'), name : 'range', style : 'width: 100%;', - allowBlank : true, + allowBlank : false, btnHint : this.textSelectData, blankError : this.txtEmpty, validateOnChange: true, validation : function(value) { - if (_.isEmpty(value)) { - return true; - } + var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.ConditionalFormattingRule, value, false); + return (isvalid!==Asc.c_oAscError.ID.DataRangeError) ? true : me.textInvalidRange; } }); this.txtDataRange.on('button:click', _.bind(this.onSelectData, this)); @@ -217,6 +216,10 @@ define([ this.inputRangeName.focus(); return; } + if (this.txtDataRange && this.txtDataRange.checkValidate() !== true) { + this.txtDataRange.focus(); + return; + } if (this.inputPwd.checkValidate() !== true) { this.inputPwd.focus(); return; @@ -227,7 +230,7 @@ define([ return; } } - this.handler.call(this, state, this.inputPwd.getValue(), this.getSettings()); + this.handler.call(this, state, this.inputPwd.getValue(), (state == 'ok') ? this.getSettings() : undefined); } this.close(); @@ -235,6 +238,7 @@ define([ _setDefaults: function (props) { this.optionsList && this.updateOptionsList(props); + (this.type=='range') && this.updateRangeSettings(props); }, onItemChanged: function (view, record) { @@ -297,6 +301,12 @@ define([ // listView.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true, suppressScrollX: true}); } }, + updateRangeSettings: function (props) { + if (props) { + this.inputRangeName.setValue(props.asc_getName()); + this.txtDataRange.setValue(props.asc_getSqref()); + } + }, updateOptionsList: function(props) { var optionsArr = [ @@ -378,7 +388,8 @@ define([ win.setSettings({ api : me.api, range : (!_.isEmpty(me.txtDataRange.getValue()) && (me.txtDataRange.checkValidate()==true)) ? me.txtDataRange.getValue() : me.dataRangeValid, - type : Asc.c_oAscSelectionDialogType.Chart + type : Asc.c_oAscSelectionDialogType.ConditionalFormattingRule, + validation: function() {return true;} }); } },