From c74119b351dd88d915342baeee0141389f353096 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Tue, 18 Feb 2025 19:41:14 +0300 Subject: [PATCH] [de] Add a parameter indicating that a group of fields (role) is filled --- oform/Role.js | 9 +++++++++ oform/format/FieldGroup.js | 21 +++++++++++++++++++- oform/format/changes/FieldGroupChanges.js | 24 ++++++++++++++++++++++- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/oform/Role.js b/oform/Role.js index 1ee7f6f..7c211ac 100644 --- a/oform/Role.js +++ b/oform/Role.js @@ -78,6 +78,15 @@ if (this.FieldGroup) this.FieldGroup.setWeight(weight); }; + CRole.prototype.isFilled = function() + { + return this.FieldGroup ? this.FieldGroup.isFilled() : true; + }; + CRole.prototype.setFilled = function(isFilled) + { + if (this.FieldGroup) + this.FieldGroup.setFilled(isFilled); + }; CRole.prototype.getFieldGroup = function() { return this.FieldGroup; diff --git a/oform/format/FieldGroup.js b/oform/format/FieldGroup.js index 0e7d5a8..92a62a0 100644 --- a/oform/format/FieldGroup.js +++ b/oform/format/FieldGroup.js @@ -42,6 +42,7 @@ { AscOForm.CBaseFormatObject.call(this); + this.Filled = false; this.Weight = null; this.Fields = []; this.Users = []; @@ -57,6 +58,19 @@ this.Parent = parent; this.onChange(); }; + CFieldGroup.prototype.isFilled = function() + { + return !!this.Filled; + }; + CFieldGroup.prototype.setFilled = function(isFilled) + { + if (this.Filled === isFilled) + return; + + AscCommon.History.Add(new AscDFH.CChangesOFormFieldGroupFilled(this, this.Filled, isFilled)); + this.Filled = isFilled; + this.onChange(); + }; CFieldGroup.prototype.setWeight = function(value) { if (this.Weight === value) @@ -207,6 +221,8 @@ writer.WriteXmlNodeStart("fieldGroup"); writer.WriteXmlNullableAttributeInt("weight", this.getWeight()); + if (this.isFilled()) + writer.WriteXmlNullableAttributeInt("filled", "1"); writer.WriteXmlAttributesEnd(); for (let userIndex = 0, userCount = this.Users.length; userIndex < userCount; ++userIndex) @@ -239,8 +255,11 @@ while (reader.MoveToNextAttribute()) { - if ("weight" === reader.GetNameNoNS()) + let attrName = reader.GetNameNoNS(); + if ("weight" === attrName) fG.setWeight(reader.GetValueInt()); + if ("filled" === attrName) + fG.setFilled(reader.GetValueBool()); } let xmlReaderContext = reader.GetOformContext(); diff --git a/oform/format/changes/FieldGroupChanges.js b/oform/format/changes/FieldGroupChanges.js index f83adce..c4f58ca 100644 --- a/oform/format/changes/FieldGroupChanges.js +++ b/oform/format/changes/FieldGroupChanges.js @@ -37,6 +37,7 @@ window['AscDFH'].historyitem_OForm_FieldGroup_Weight = window['AscDFH'].historyitem_type_OForm_FieldGroup | 1; window['AscDFH'].historyitem_OForm_FieldGroup_AddRemoveField = window['AscDFH'].historyitem_type_OForm_FieldGroup | 2; window['AscDFH'].historyitem_OForm_FieldGroup_AddRemoveUser = window['AscDFH'].historyitem_type_OForm_FieldGroup | 3; + window['AscDFH'].historyitem_OForm_FieldGroup_Filled = window['AscDFH'].historyitem_type_OForm_FieldGroup | 4; /** * @constructor @@ -120,5 +121,26 @@ } ); window['AscDFH'].CChangesOFormFieldGroupAddRemoveUser = CChangesOFormFieldGroupAddRemoveUser; - + + /** + * @constructor + * @extends {window['AscDFH'].CChangesBaseBoolProperty} + */ + function CChangesOFormFieldGroupFilled(Class, Old, New) + { + window['AscDFH'].CChangesBaseBoolProperty.call(this, Class, Old, New); + } + window['AscDFH'].InheritPropertyChange( + CChangesOFormFieldGroupFilled, + window['AscDFH'].CChangesBaseBoolProperty, + window['AscDFH'].historyitem_OForm_FieldGroup_Filled, + function(value) + { + this.Class.Filled = value; + this.Class.onChange(); + }, + false + ); + window['AscDFH'].CChangesOFormFieldGroupFilled = CChangesOFormFieldGroupFilled; + })(window);