mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-04-07 14:09:12 +08:00
fix/bug-79247 (#1804)
[all] Fix bug 79257 Co-authored-by: Angsar <ansar.aydarbek@onlyoffice.com> Co-committed-by: Angsar <ansar.aydarbek@onlyoffice.com>
This commit is contained in:
@ -19589,25 +19589,6 @@
|
||||
return ToXlValidationTypeFrom(validation.asc_getType());
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the validation type.
|
||||
* @memberof ApiValidation
|
||||
* @typeofeditors ["CSE"]
|
||||
* @param {ValidationType} Type - The validation type.
|
||||
* @see office-js-api/Examples/{Editor}/ApiValidation/Methods/SetType.js
|
||||
*/
|
||||
ApiValidation.prototype.SetType = function(Type) {
|
||||
const validation = getSingleValidation(this);
|
||||
if (!validation) {
|
||||
return;
|
||||
}
|
||||
// If there are multiple validations, we cannot set type
|
||||
let internalType = FromXlValidationTypeTo(Type);
|
||||
if (internalType !== -1) {
|
||||
validation.setType(internalType);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the validation alert style.
|
||||
* @memberof ApiValidation
|
||||
@ -19623,24 +19604,6 @@
|
||||
return ToXlValidationAlertStyleFrom(validation.getErrorStyle());
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the validation alert style.
|
||||
* @memberof ApiValidation
|
||||
* @typeofeditors ["CSE"]
|
||||
* @param {ValidationAlertStyle} AlertStyle - The validation alert style.
|
||||
* @see office-js-api/Examples/{Editor}/ApiValidation/Methods/SetAlertStyle.js
|
||||
*/
|
||||
ApiValidation.prototype.SetAlertStyle = function(AlertStyle) {
|
||||
const validation = getSingleValidation(this);
|
||||
if (!validation) {
|
||||
return;
|
||||
}
|
||||
let internalAlertStyle = FromXlValidationAlertStyleTo(AlertStyle);
|
||||
if (internalAlertStyle !== -1) {
|
||||
validation.setErrorStyle(internalAlertStyle);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns whether blank values are permitted by the range data validation.
|
||||
* @memberof ApiValidation
|
||||
@ -19903,22 +19866,6 @@
|
||||
return formula1 ? formula1.asc_getValue() : "";
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the first formula in the data validation.
|
||||
* @memberof ApiValidation
|
||||
* @typeofeditors ["CSE"]
|
||||
* @param {string} Formula1 - The first formula.
|
||||
* @see office-js-api/Examples/{Editor}/ApiValidation/Methods/SetFormula1.js
|
||||
*/
|
||||
ApiValidation.prototype.SetFormula1 = function(Formula1) {
|
||||
const validation = getSingleValidation(this);
|
||||
if (!validation) {
|
||||
return;
|
||||
}
|
||||
let formula = new window['Asc'].CDataFormula(Formula1);
|
||||
validation.setFormula1(formula);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the second formula in the data validation.
|
||||
* @memberof ApiValidation
|
||||
@ -19935,22 +19882,6 @@
|
||||
return formula2 ? formula2.asc_getValue() : "";
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the second formula in the data validation.
|
||||
* @memberof ApiValidation
|
||||
* @typeofeditors ["CSE"]
|
||||
* @param {string} Formula2 - The second formula.
|
||||
* @see office-js-api/Examples/{Editor}/ApiValidation/Methods/SetFormula2.js
|
||||
*/
|
||||
ApiValidation.prototype.SetFormula2 = function(Formula2) {
|
||||
const validation = getSingleValidation(this);
|
||||
if (!validation) {
|
||||
return;
|
||||
}
|
||||
let formula = new window['Asc'].CDataFormula(Formula2);
|
||||
validation.setFormula2(formula);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the data validation operator.
|
||||
* @memberof ApiValidation
|
||||
@ -19966,24 +19897,6 @@
|
||||
return ToXlValidationOperatorFrom(validation.getOperator());
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the data validation operator.
|
||||
* @memberof ApiValidation
|
||||
* @typeofeditors ["CSE"]
|
||||
* @param {ValidationOperator} Operator - The validation operator.
|
||||
* @see office-js-api/Examples/{Editor}/ApiValidation/Methods/SetOperator.js
|
||||
*/
|
||||
ApiValidation.prototype.SetOperator = function(Operator) {
|
||||
const validation = getSingleValidation(this);
|
||||
if (!validation) {
|
||||
return;
|
||||
}
|
||||
let internalOperator = FromXlValidationOperatorTo(Operator);
|
||||
if (internalOperator !== -1) {
|
||||
validation.setOperator(internalOperator);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the parent range object.
|
||||
* @memberof ApiValidation
|
||||
@ -19999,18 +19912,12 @@
|
||||
Object.defineProperty(ApiValidation.prototype, "Type", {
|
||||
get: function() {
|
||||
return this.GetType();
|
||||
},
|
||||
set: function(value) {
|
||||
this.SetType(value);
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(ApiValidation.prototype, "AlertStyle", {
|
||||
get: function() {
|
||||
return this.GetAlertStyle();
|
||||
},
|
||||
set: function(value) {
|
||||
this.SetAlertStyle(value);
|
||||
}
|
||||
});
|
||||
|
||||
@ -20090,27 +19997,18 @@
|
||||
get: function() {
|
||||
return this.GetFormula1();
|
||||
},
|
||||
set: function(value) {
|
||||
this.SetFormula1(value);
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(ApiValidation.prototype, "Formula2", {
|
||||
get: function() {
|
||||
return this.GetFormula2();
|
||||
},
|
||||
set: function(value) {
|
||||
this.SetFormula2(value);
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(ApiValidation.prototype, "Operator", {
|
||||
get: function() {
|
||||
return this.GetOperator();
|
||||
},
|
||||
set: function(value) {
|
||||
this.SetOperator(value);
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(ApiValidation.prototype, "Parent", {
|
||||
@ -20122,9 +20020,6 @@
|
||||
Object.defineProperty(ApiValidation.prototype, "Value", {
|
||||
get: function() {
|
||||
return this.GetFormula1();
|
||||
},
|
||||
set: function(value) {
|
||||
this.SetFormula1(value);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -200,12 +200,18 @@ $(function () {
|
||||
|
||||
// 1) 'Contains': try to add inside existing (D2:D4)
|
||||
const inside = ws.GetRange("D2:D4");
|
||||
const resInside = inside.GetValidation().Add('xlValidateWholeNumber', 'xlValidAlertStop', 'xlBetween', 5, 6);
|
||||
let resInside = null;
|
||||
try{
|
||||
resInside = inside.GetValidation().Add('xlValidateWholeNumber', 'xlValidAlertStop', 'xlBetween', 5, 6);
|
||||
}catch{}
|
||||
const afterInside = countValidations();
|
||||
|
||||
// 2) 'Intersects': try to add partially crossing (C4:E7 intersects D1:D5 on D4:D5)
|
||||
const inter = ws.GetRange("C4:E7");
|
||||
const resInter = inter.GetValidation().Add('xlValidateWholeNumber', 'xlValidAlertStop', 'xlBetween', 7, 8);
|
||||
let resInter = null;
|
||||
try{
|
||||
resInter = inter.GetValidation().Add('xlValidateWholeNumber', 'xlValidAlertStop', 'xlBetween', 7, 8);
|
||||
}catch{}
|
||||
const afterInter = countValidations();
|
||||
|
||||
// Implementation detail: Add() must return null and keep validation count unchanged
|
||||
@ -231,18 +237,12 @@ $(function () {
|
||||
const v = r.GetValidation();
|
||||
// Type
|
||||
assert.strictEqual(v.GetType(), 'xlValidateWholeNumber', "GetType matches");
|
||||
v.SetType('xlValidateDecimal');
|
||||
assert.strictEqual(v.GetType(), 'xlValidateDecimal', "SetType updated");
|
||||
|
||||
// Operator
|
||||
assert.strictEqual(v.GetOperator(), 'xlBetween', "Default operator between");
|
||||
v.SetOperator('xlGreater');
|
||||
assert.strictEqual(v.GetOperator(), 'xlGreater', "Operator updated");
|
||||
|
||||
// AlertStyle
|
||||
assert.strictEqual(v.GetAlertStyle(), 'xlValidAlertStop', "Default alert stop");
|
||||
v.SetAlertStyle('xlValidAlertWarning');
|
||||
assert.strictEqual(v.GetAlertStyle(), 'xlValidAlertWarning', "AlertStyle updated");
|
||||
|
||||
// Flags
|
||||
v.SetIgnoreBlank(false);
|
||||
@ -271,14 +271,6 @@ $(function () {
|
||||
assert.strictEqual(v.GetErrorTitle(), "Bad age", "ErrorTitle OK");
|
||||
assert.strictEqual(v.GetErrorMessage(), "Must be 1..100", "ErrorMessage OK");
|
||||
|
||||
// Formulas & Value property mapping
|
||||
v.SetFormula1("2");
|
||||
v.SetFormula2("99");
|
||||
assert.strictEqual(v.GetFormula1(), "2", "Formula1 OK");
|
||||
assert.strictEqual(v.GetFormula2(), "99", "Formula2 OK");
|
||||
v.Value = "10";
|
||||
assert.strictEqual(v.Value, "10", "Value <-> Formula1 mapping works");
|
||||
|
||||
// Parent
|
||||
assert.ok(v.GetParent(), "Parent exists");
|
||||
assert.ok(v.Parent, "Parent property getter exists");
|
||||
@ -402,8 +394,12 @@ $(function () {
|
||||
QUnit.test("Modify when there is no validation: returns null", function (assert) {
|
||||
initializeTest();
|
||||
const v = ws.GetRange("Y1:Y2").GetValidation();
|
||||
const res = v.Modify('xlValidateWholeNumber', 'xlValidAlertStop', 'xlBetween', 1, 2);
|
||||
assert.strictEqual(res, null, "Modify returns null when nothing to modify");
|
||||
try {
|
||||
const res = v.Modify('xlValidateWholeNumber', 'xlValidAlertStop', 'xlBetween', 1, 2);
|
||||
assert.strictEqual(res, null, "Modify returns null when nothing to modify");
|
||||
} catch {
|
||||
assert.ok(true, "Modify threw an exception, which is also acceptable");
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.module("Enum conversion helpers — sanity");
|
||||
|
||||
Reference in New Issue
Block a user