Fix protect ranges dialog

This commit is contained in:
Julia Radzhabova 2021-06-23 12:20:24 +03:00
parent d564b24dd4
commit 897c3ca1ac

View file

@ -170,14 +170,13 @@ define([
el : $('#id-range-txt'), el : $('#id-range-txt'),
name : 'range', name : 'range',
style : 'width: 100%;', style : 'width: 100%;',
allowBlank : true, allowBlank : false,
btnHint : this.textSelectData, btnHint : this.textSelectData,
blankError : this.txtEmpty, blankError : this.txtEmpty,
validateOnChange: true, validateOnChange: true,
validation : function(value) { validation : function(value) {
if (_.isEmpty(value)) { var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.ConditionalFormattingRule, value, false);
return true; return (isvalid!==Asc.c_oAscError.ID.DataRangeError) ? true : me.textInvalidRange;
}
} }
}); });
this.txtDataRange.on('button:click', _.bind(this.onSelectData, this)); this.txtDataRange.on('button:click', _.bind(this.onSelectData, this));
@ -217,6 +216,10 @@ define([
this.inputRangeName.focus(); this.inputRangeName.focus();
return; return;
} }
if (this.txtDataRange && this.txtDataRange.checkValidate() !== true) {
this.txtDataRange.focus();
return;
}
if (this.inputPwd.checkValidate() !== true) { if (this.inputPwd.checkValidate() !== true) {
this.inputPwd.focus(); this.inputPwd.focus();
return; return;
@ -227,7 +230,7 @@ define([
return; 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(); this.close();
@ -235,6 +238,7 @@ define([
_setDefaults: function (props) { _setDefaults: function (props) {
this.optionsList && this.updateOptionsList(props); this.optionsList && this.updateOptionsList(props);
(this.type=='range') && this.updateRangeSettings(props);
}, },
onItemChanged: function (view, record) { onItemChanged: function (view, record) {
@ -297,6 +301,12 @@ define([
// listView.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true, suppressScrollX: true}); // 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) { updateOptionsList: function(props) {
var optionsArr = [ var optionsArr = [
@ -378,7 +388,8 @@ define([
win.setSettings({ win.setSettings({
api : me.api, api : me.api,
range : (!_.isEmpty(me.txtDataRange.getValue()) && (me.txtDataRange.checkValidate()==true)) ? me.txtDataRange.getValue() : me.dataRangeValid, 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;}
}); });
} }
}, },