[DE] Refactoring applying form settings

This commit is contained in:
Julia Radzhabova 2020-12-24 16:26:20 +03:00
parent 5327fdd403
commit de7d627141

View file

@ -653,14 +653,20 @@ define([
this.labelFormName.text(this.textImage); this.labelFormName.text(this.textImage);
} else } else
data = this.api.asc_GetTextFormKeys(); data = this.api.asc_GetTextFormKeys();
var arr = []; if (!this._state.arrKey || _.difference(this._state.arrKey, data).length>0) {
data.forEach(function(item) { var arr = [];
arr.push({ displayValue: item, value: item }); data.forEach(function(item) {
}); arr.push({ displayValue: item, value: item });
this.cmbKey.setData(arr); });
this.cmbKey.setData(arr);
this._state.arrKey=data;
}
val = formPr.get_Key(); val = formPr.get_Key();
this.cmbKey.setValue(val ? val : ''); if (this._state.Key!==val) {
this.cmbKey.setValue(val ? val : '');
this._state.Key=val;
}
if (val) { if (val) {
val = this.api.asc_GetFormsCountByKey(val); val = this.api.asc_GetFormsCountByKey(val);
@ -678,12 +684,20 @@ define([
val = specProps.get_GroupKey(); val = specProps.get_GroupKey();
var ischeckbox = (typeof val !== 'string'); var ischeckbox = (typeof val !== 'string');
if (!ischeckbox) { if (!ischeckbox) {
var arr = []; data = this.api.asc_GetRadioButtonGroupKeys();
this.api.asc_GetRadioButtonGroupKeys().forEach(function(item) { if (!this._state.arrGroupKey || _.difference(this._state.arrGroupKey, data).length>0) {
arr.push({ displayValue: item, value: item }); var arr = [];
}); data.forEach(function(item) {
this.cmbGroupKey.setData(arr); arr.push({ displayValue: item, value: item });
this.cmbGroupKey.setValue(val ? val : ''); });
this.cmbGroupKey.setData(arr);
this._state.arrGroupKey=data;
}
if (this._state.groupKey!==val) {
this.cmbGroupKey.setValue(val ? val : '');
this._state.groupKey=val;
}
} }
this.labelFormName.text(ischeckbox ? this.textCheckbox : this.textRadiobox); this.labelFormName.text(ischeckbox ? this.textCheckbox : this.textRadiobox);
@ -719,7 +733,10 @@ define([
val = formTextPr.get_MaxCharacters(); val = formTextPr.get_MaxCharacters();
this.chMaxChars.setValue(val && val>=0); this.chMaxChars.setValue(val && val>=0);
this.spnMaxChars.setDisabled(!val || val<0); this.spnMaxChars.setDisabled(!val || val<0);
this.spnMaxChars.setValue(val && val>=0 ? val : 10); if ( (val===undefined || this._state.MaxChars===undefined)&&(this._state.MaxChars!==val) || Math.abs(this._state.MaxChars-val)>0.1) {
this.spnMaxChars.setValue(val && val>=0 ? val : 10, true);
this._state.MaxChars=val;
}
var brd = formTextPr.get_CombBorder(); var brd = formTextPr.get_CombBorder();
if (brd) { if (brd) {