diff --git a/oform/Role.js b/oform/Role.js index 7c211ac..4e14762 100644 --- a/oform/Role.js +++ b/oform/Role.js @@ -84,8 +84,15 @@ }; CRole.prototype.setFilled = function(isFilled) { - if (this.FieldGroup) - this.FieldGroup.setFilled(isFilled); + if (!this.FieldGroup || isFilled === this.FieldGroup.isFilled()) + return; + + this.FieldGroup.setFilled(isFilled); + + if (isFilled) + this.FieldGroup.setDate(Date.now()); + else + this.FieldGroup.setDate(undefined); }; CRole.prototype.getFieldGroup = function() { diff --git a/oform/format/FieldGroup.js b/oform/format/FieldGroup.js index 9c6bb6d..3595a34 100644 --- a/oform/format/FieldGroup.js +++ b/oform/format/FieldGroup.js @@ -43,6 +43,7 @@ AscOForm.CBaseFormatObject.call(this); this.Filled = false; + this.Date = undefined; this.Weight = null; this.Fields = []; this.Users = []; @@ -84,6 +85,18 @@ { return this.Weight; }; + CFieldGroup.prototype.setDate = function(date) + { + if (date === this.Date) + return; + + AscCommon.History.Add(new AscDFH.CChangesOFormFieldGroupDate(this, this.Date, date)); + this.Date = date; + }; + CFieldGroup.prototype.getDate = function() + { + return this.Date; + }; CFieldGroup.prototype.addField = function(field) { if (!field || -1 !== this.Fields.indexOf(field)) @@ -230,6 +243,13 @@ writer.WriteXmlNullableAttributeInt("weight", this.getWeight()); if (this.isFilled()) writer.WriteXmlNullableAttributeBool("filled", true); + + if (this.Date) + { + let dateUtc = new Date(this.Date).toISOString().slice(0, 19) + 'Z'; + writer.WriteXmlNullableAttributeString("date", dateUtc); + } + writer.WriteXmlAttributesEnd(); for (let userIndex = 0, userCount = this.Users.length; userIndex < userCount; ++userIndex) @@ -265,8 +285,14 @@ let attrName = reader.GetNameNoNS(); if ("weight" === attrName) fG.setWeight(reader.GetValueInt()); - if ("filled" === attrName) + else if ("filled" === attrName) fG.setFilled(reader.GetValueBool()); + else if ("date" === attrName) + { + let date = AscCommon.getTimeISO8601(reader.GetValueDecodeXml()); + if (!isNaN(date)) + fG.setDate(date); + } } let xmlReaderContext = reader.GetOformContext(); diff --git a/oform/format/changes/FieldGroupChanges.js b/oform/format/changes/FieldGroupChanges.js index 13d8b52..de330a0 100644 --- a/oform/format/changes/FieldGroupChanges.js +++ b/oform/format/changes/FieldGroupChanges.js @@ -38,6 +38,7 @@ 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; + window['AscDFH'].historyitem_OForm_FieldGroup_Date = window['AscDFH'].historyitem_type_OForm_FieldGroup | 5; /** * @constructor @@ -143,4 +144,25 @@ ); window['AscDFH'].CChangesOFormFieldGroupFilled = CChangesOFormFieldGroupFilled; + /** + * @constructor + * @extends {window['AscDFH'].CChangesBaseStringProperty} + */ + function CChangesOFormFieldGroupDate(Class, Old, New) + { + window['AscDFH'].CChangesBaseStringProperty.call(this, Class, Old, New); + } + window['AscDFH'].InheritPropertyChange( + CChangesOFormFieldGroupDate, + window['AscDFH'].CChangesBaseStringProperty, + window['AscDFH'].historyitem_OForm_FieldGroup_Date, + function(value) + { + let v = parseInt(value); + this.Class.Date = isNaN(v) ? undefined : v; + }, + false + ); + window['AscDFH'].CChangesOFormFieldGroupDate = CChangesOFormFieldGroupDate; + })(window);