Merge pull request #622 from ONLYOFFICE/fix/data-validation
Fix/data validation
This commit is contained in:
commit
acc2a52666
|
@ -168,6 +168,8 @@ define([
|
||||||
|
|
||||||
this.settings.argvalues[this.settings.argindex] = val;
|
this.settings.argvalues[this.settings.argindex] = val;
|
||||||
this.api.asc_insertArgumentsInFormula(this.settings.argvalues);
|
this.api.asc_insertArgumentsInFormula(this.settings.argvalues);
|
||||||
|
} else if (this.settings.type == Asc.c_oAscSelectionDialogType.DataValidation) {
|
||||||
|
this.inputRange.setValue('=' + name);
|
||||||
} else
|
} else
|
||||||
this.inputRange.setValue(name);
|
this.inputRange.setValue(name);
|
||||||
if (this.inputRange.cmpEl.hasClass('error'))
|
if (this.inputRange.cmpEl.hasClass('error'))
|
||||||
|
|
|
@ -321,7 +321,7 @@ define([ 'text!spreadsheeteditor/main/app/template/DataValidationDialog.templ
|
||||||
win.setSettings({
|
win.setSettings({
|
||||||
api : me.api,
|
api : me.api,
|
||||||
range : input.getValue(),
|
range : input.getValue(),
|
||||||
type : Asc.c_oAscSelectionDialogType.Chart,
|
type : Asc.c_oAscSelectionDialogType.DataValidation,
|
||||||
validation: function() {return true;}
|
validation: function() {return true;}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -446,11 +446,12 @@ define([ 'text!spreadsheeteditor/main/app/template/DataValidationDialog.templ
|
||||||
var me = this;
|
var me = this;
|
||||||
var state = (typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event;
|
var state = (typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event;
|
||||||
if (state == 'ok') {
|
if (state == 'ok') {
|
||||||
if (!this.isRangeValid()) return;
|
this.isRangeValid(function() {
|
||||||
this.handler && this.handler.call(this, state, (state == 'ok') ? this.getSettings() : undefined);
|
me.handler && me.handler.call(me, state, (state == 'ok') ? me.getSettings() : undefined);
|
||||||
}
|
me.close();
|
||||||
|
});
|
||||||
this.close();
|
} else
|
||||||
|
this.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
onPrimary: function() {
|
onPrimary: function() {
|
||||||
|
@ -512,7 +513,8 @@ define([ 'text!spreadsheeteditor/main/app/template/DataValidationDialog.templ
|
||||||
this.lblRangeMax.text(str2);
|
this.lblRangeMax.text(str2);
|
||||||
},
|
},
|
||||||
|
|
||||||
isRangeValid: function() {
|
isRangeValid: function(callback) {
|
||||||
|
var me = this;
|
||||||
var isvalid = Asc.c_oAscError.ID.No;
|
var isvalid = Asc.c_oAscError.ID.No;
|
||||||
var type = this.cmbAllow.getValue();
|
var type = this.cmbAllow.getValue();
|
||||||
if (type!==Asc.c_oAscEDataValidationType.None) {
|
if (type!==Asc.c_oAscEDataValidationType.None) {
|
||||||
|
@ -520,51 +522,91 @@ define([ 'text!spreadsheeteditor/main/app/template/DataValidationDialog.templ
|
||||||
lblField,
|
lblField,
|
||||||
error,
|
error,
|
||||||
minVisible = this.inputRangeMin.isVisible();
|
minVisible = this.inputRangeMin.isVisible();
|
||||||
|
var callback2 = function(isvalid) {
|
||||||
|
if (isvalid === Asc.c_oAscError.ID.No) {
|
||||||
|
isvalid = me.props.asc_checkValid();
|
||||||
|
(isvalid !== Asc.c_oAscError.ID.No) && (focusedInput = minVisible ? me.inputRangeMin : me.inputRangeSource);
|
||||||
|
}
|
||||||
|
switch (isvalid) {
|
||||||
|
case Asc.c_oAscError.ID.DataValidateNotNumeric:
|
||||||
|
error = Common.Utils.String.format(me.errorNotNumeric, lblField.text());
|
||||||
|
break;
|
||||||
|
case Asc.c_oAscError.ID.DataValidateNegativeTextLength:
|
||||||
|
error = Common.Utils.String.format(me.errorNegativeTextLength, me.cmbAllow.getDisplayValue(me.cmbAllow.getSelectedRecord()));
|
||||||
|
break;
|
||||||
|
case Asc.c_oAscError.ID.DataValidateMustEnterValue:
|
||||||
|
error = minVisible ? Common.Utils.String.format(me.errorMustEnterBothValues, me.lblRangeMin.text(), me.lblRangeMax.text()) :
|
||||||
|
Common.Utils.String.format(me.errorMustEnterValue, me.lblRangeSource.text());
|
||||||
|
break;
|
||||||
|
case Asc.c_oAscError.ID.DataValidateMinGreaterMax:
|
||||||
|
error = Common.Utils.String.format(me.errorMinGreaterMax, me.lblRangeMin.text(), me.lblRangeMax.text());
|
||||||
|
break;
|
||||||
|
case Asc.c_oAscError.ID.DataValidateInvalid:
|
||||||
|
error = Common.Utils.String.format((type==Asc.c_oAscEDataValidationType.Time) ? me.errorInvalidTime : ((type==Asc.c_oAscEDataValidationType.Date) ? me.errorInvalidDate : me.errorInvalid), lblField.text());
|
||||||
|
break;
|
||||||
|
case Asc.c_oAscError.ID.NamedRangeNotFound:
|
||||||
|
error = me.errorNamedRange;
|
||||||
|
break;
|
||||||
|
case Asc.c_oAscError.ID.DataValidateInvalidList:
|
||||||
|
error = me.errorInvalidList;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
error && Common.UI.warning({
|
||||||
|
msg: error,
|
||||||
|
maxwidth: 600,
|
||||||
|
callback: function(btn){
|
||||||
|
focusedInput.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
(isvalid === Asc.c_oAscError.ID.No) && callback.call(me);
|
||||||
|
};
|
||||||
|
var callback1 = function(isvalid) {
|
||||||
|
if (me.inputRangeMax.isVisible() && isvalid === Asc.c_oAscError.ID.No) {
|
||||||
|
isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.DataValidation, me.props.asc_getFormula2() ? me.props.asc_getFormula2().asc_getValue() : null, true, undefined, type);
|
||||||
|
if (isvalid !== Asc.c_oAscError.ID.No) {
|
||||||
|
focusedInput = me.inputRangeMax;
|
||||||
|
lblField = me.lblRangeMax;
|
||||||
|
}
|
||||||
|
if (isvalid===Asc.c_oAscError.ID.FormulaEvaluateError) {
|
||||||
|
Common.UI.warning({
|
||||||
|
msg: me.errorFormula,
|
||||||
|
maxwidth: 600,
|
||||||
|
buttons: ['yes', 'no'],
|
||||||
|
primary: 'yes',
|
||||||
|
callback: function(btn){
|
||||||
|
if (btn=='yes') {
|
||||||
|
callback2(Asc.c_oAscError.ID.No);
|
||||||
|
} else
|
||||||
|
focusedInput.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else
|
||||||
|
callback2(isvalid);
|
||||||
|
} else
|
||||||
|
callback2(isvalid);
|
||||||
|
};
|
||||||
isvalid = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.DataValidation, this.props.asc_getFormula1() ? this.props.asc_getFormula1().asc_getValue() : null, true, undefined, type);
|
isvalid = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.DataValidation, this.props.asc_getFormula1() ? this.props.asc_getFormula1().asc_getValue() : null, true, undefined, type);
|
||||||
if (isvalid !== Asc.c_oAscError.ID.No) {
|
if (isvalid !== Asc.c_oAscError.ID.No) {
|
||||||
focusedInput = minVisible ? this.inputRangeMin : this.inputRangeSource;
|
focusedInput = minVisible ? me.inputRangeMin : me.inputRangeSource;
|
||||||
lblField = minVisible ? this.lblRangeMin : this.lblRangeSource;
|
lblField = minVisible ? me.lblRangeMin : me.lblRangeSource;
|
||||||
}
|
}
|
||||||
if (this.inputRangeMax.isVisible() && isvalid === Asc.c_oAscError.ID.No) {
|
if (isvalid===Asc.c_oAscError.ID.FormulaEvaluateError) {
|
||||||
isvalid = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.DataValidation, this.props.asc_getFormula2() ? this.props.asc_getFormula2().asc_getValue() : null, true, undefined, type);
|
Common.UI.warning({
|
||||||
if (isvalid !== Asc.c_oAscError.ID.No) {
|
msg: this.errorFormula,
|
||||||
focusedInput = this.inputRangeMax;
|
maxwidth: 600,
|
||||||
lblField = this.lblRangeMax;
|
buttons: ['yes', 'no'],
|
||||||
}
|
primary: 'yes',
|
||||||
}
|
callback: function(btn){
|
||||||
if (isvalid === Asc.c_oAscError.ID.No) {
|
if (btn=='yes') {
|
||||||
isvalid = this.props.asc_checkValid();
|
callback1(Asc.c_oAscError.ID.No);
|
||||||
(isvalid !== Asc.c_oAscError.ID.No) && (focusedInput = minVisible ? this.inputRangeMin : this.inputRangeSource);
|
} else
|
||||||
}
|
focusedInput.focus();
|
||||||
|
}
|
||||||
switch (isvalid) {
|
});
|
||||||
case Asc.c_oAscError.ID.DataValidateNotNumeric:
|
} else
|
||||||
error = Common.Utils.String.format(this.errorNotNumeric, lblField.text());
|
callback1(isvalid);
|
||||||
break;
|
} else
|
||||||
case Asc.c_oAscError.ID.DataValidateNegativeTextLength:
|
callback.call(me);
|
||||||
error = Common.Utils.String.format(this.errorNegativeTextLength, this.cmbAllow.getDisplayValue(this.cmbAllow.getSelectedRecord()));
|
|
||||||
break;
|
|
||||||
case Asc.c_oAscError.ID.DataValidateMustEnterValue:
|
|
||||||
error = minVisible ? Common.Utils.String.format(this.errorMustEnterBothValues, this.lblRangeMin.text(), this.lblRangeMax.text()) :
|
|
||||||
Common.Utils.String.format(this.errorMustEnterValue, this.lblRangeSource.text());
|
|
||||||
break;
|
|
||||||
case Asc.c_oAscError.ID.DataValidateMinGreaterMax:
|
|
||||||
error = Common.Utils.String.format(this.errorMinGreaterMax, this.lblRangeMin.text(), this.lblRangeMax.text());
|
|
||||||
break;
|
|
||||||
case Asc.c_oAscError.ID.DataValidateInvalid:
|
|
||||||
error = Common.Utils.String.format((type==Asc.c_oAscEDataValidationType.Time) ? this.errorInvalidTime : ((type==Asc.c_oAscEDataValidationType.Date) ? this.errorInvalidDate : this.errorInvalid), lblField.text());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
error && Common.UI.warning({
|
|
||||||
msg: error,
|
|
||||||
maxwidth: 600,
|
|
||||||
callback: function(btn){
|
|
||||||
focusedInput.focus();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return (isvalid === Asc.c_oAscError.ID.No);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
strSettings: 'Settings',
|
strSettings: 'Settings',
|
||||||
|
@ -625,7 +667,10 @@ define([ 'text!spreadsheeteditor/main/app/template/DataValidationDialog.templ
|
||||||
errorInvalid: 'The value you entered for the field \"{0}\" is invalid.',
|
errorInvalid: 'The value you entered for the field \"{0}\" is invalid.',
|
||||||
errorNotNumeric: 'The field \"{0}\" must be a numeric value, numeric expression, or refer to a cell containing a numeric value.',
|
errorNotNumeric: 'The field \"{0}\" must be a numeric value, numeric expression, or refer to a cell containing a numeric value.',
|
||||||
errorNegativeTextLength: 'Negative values cannot be used in conditions \"{0}\".',
|
errorNegativeTextLength: 'Negative values cannot be used in conditions \"{0}\".',
|
||||||
errorMinGreaterMax: 'The \"{1}\" field must be greater than or equal to the \"{0}\" field.'
|
errorMinGreaterMax: 'The \"{1}\" field must be greater than or equal to the \"{0}\" field.',
|
||||||
|
errorFormula: 'The value currently evaluates to an error. Do you want to continue?',
|
||||||
|
errorNamedRange: 'A named range you specified cannot be found.',
|
||||||
|
errorInvalidList: 'The list source must be a delimited list, or a reference to single row or column.'
|
||||||
|
|
||||||
}, SSE.Views.DataValidationDialog || {}))
|
}, SSE.Views.DataValidationDialog || {}))
|
||||||
});
|
});
|
|
@ -1544,6 +1544,9 @@
|
||||||
"SSE.Views.DataValidationDialog.errorMustEnterValue": "You must enter a value in field \"{0}\".",
|
"SSE.Views.DataValidationDialog.errorMustEnterValue": "You must enter a value in field \"{0}\".",
|
||||||
"SSE.Views.DataValidationDialog.errorNegativeTextLength": "Negative values cannot be used in conditions \"{0}\".",
|
"SSE.Views.DataValidationDialog.errorNegativeTextLength": "Negative values cannot be used in conditions \"{0}\".",
|
||||||
"SSE.Views.DataValidationDialog.errorNotNumeric": "The field \"{0}\" must be a numeric value, numeric expression, or refer to a cell containing a numeric value.",
|
"SSE.Views.DataValidationDialog.errorNotNumeric": "The field \"{0}\" must be a numeric value, numeric expression, or refer to a cell containing a numeric value.",
|
||||||
|
"SSE.Views.DataValidationDialog.errorFormula": "The value currently evaluates to an error. Do you want to continue?",
|
||||||
|
"SSE.Views.DataValidationDialog.errorNamedRange": "A named range you specified cannot be found.",
|
||||||
|
"SSE.Views.DataValidationDialog.errorInvalidList": "The list source must be a delimited list, or a reference to single row or column.",
|
||||||
"SSE.Views.DataValidationDialog.strError": "Error Alert",
|
"SSE.Views.DataValidationDialog.strError": "Error Alert",
|
||||||
"SSE.Views.DataValidationDialog.strInput": "Input Message",
|
"SSE.Views.DataValidationDialog.strInput": "Input Message",
|
||||||
"SSE.Views.DataValidationDialog.strSettings": "Settings",
|
"SSE.Views.DataValidationDialog.strSettings": "Settings",
|
||||||
|
|
Loading…
Reference in a new issue