[SSE] Check data range for rules

This commit is contained in:
Julia Radzhabova 2021-03-10 21:38:58 +03:00
parent f02dcad3f7
commit 306a537dd5

View file

@ -454,10 +454,15 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa
disabled : !item.get('activeSheet'), disabled : !item.get('activeSheet'),
validateOnChange: true validateOnChange: true
}).on('changed:after', function(input, newValue, oldValue, e) { }).on('changed:after', function(input, newValue, oldValue, e) {
rule.dataRangeValid = newValue; if (rule.dataRangeValid !== newValue) {
rule.txtDataRange.setValue(rule.dataRangeValid); if (me.isRangeValid(newValue)) {
item.set('ruleChanged', true); rule.dataRangeValid = newValue;
item.get('props').asc_setLocation(rule.dataRangeValid); item.set('ruleChanged', true);
item.get('props').asc_setLocation(rule.dataRangeValid);
} else
rule.txtDataRange.setValue(rule.dataRangeValid);
}
}).on('button:click', _.bind(this.onSelectData, this, rule, item)); }).on('button:click', _.bind(this.onSelectData, this, rule, item));
var val = item.get('range'); var val = item.get('range');
@ -488,16 +493,21 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa
props.asc_getPreview(this.rules[rule.get('ruleIndex')].previewDiv, text); props.asc_getPreview(this.rules[rule.get('ruleIndex')].previewDiv, text);
}, },
isRangeValid: function(range) {
return (Asc.c_oAscError.ID.No === this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.ConditionalFormattingRule, range, true));
},
onSelectData: function(rule, item) { onSelectData: function(rule, item) {
var me = this; var me = this;
if (me.api) { if (me.api) {
var handlerDlg = function(dlg, result) { var handlerDlg = function(dlg, result) {
if (result == 'ok') { if (result == 'ok') {
rule.dataRangeValid = dlg.getSettings(); if (me.isRangeValid(dlg.getSettings())) {
rule.dataRangeValid = dlg.getSettings();
item.set('ruleChanged', true);
item.get('props').asc_setLocation(rule.dataRangeValid);
}
rule.txtDataRange.setValue(rule.dataRangeValid); rule.txtDataRange.setValue(rule.dataRangeValid);
rule.txtDataRange.checkValidate();
item.set('ruleChanged', true);
item.get('props').asc_setLocation(rule.dataRangeValid);
} }
}; };
@ -512,8 +522,9 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa
win.show(xy.left + 160, xy.top + 125); win.show(xy.left + 160, xy.top + 125);
win.setSettings({ win.setSettings({
api : me.api, api : me.api,
range : (!_.isEmpty(rule.txtDataRange.getValue()) && (rule.txtDataRange.checkValidate()==true)) ? rule.txtDataRange.getValue() : rule.dataRangeValid, range : !_.isEmpty(rule.txtDataRange.getValue()) ? rule.txtDataRange.getValue() : rule.dataRangeValid,
type : Asc.c_oAscSelectionDialogType.ConditionalFormattingRule type : Asc.c_oAscSelectionDialogType.ConditionalFormattingRule,
validation: function() {return true;}
}); });
} }
}, },