[de] Add a parameter indicating that a group of fields (role) is filled

This commit is contained in:
Ilya Kirillov
2025-02-18 19:41:14 +03:00
parent 87e1f3d133
commit c74119b351
3 changed files with 52 additions and 2 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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);