diff --git a/oform/FieldGroup.js b/oform/FieldGroup.js new file mode 100644 index 0000000..d3cc30c --- /dev/null +++ b/oform/FieldGroup.js @@ -0,0 +1,88 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +"use strict"; + +(function(window) +{ + /** + * @constructor + */ + function CFieldGroup() + { + AscFormat.CBaseFormatObject.call(this); + + this.Weight = null; + this.Fields = []; + } + AscFormat.InitClass(CUser, AscFormat.CBaseFormatObject, AscDFH.historyitem_type_OForm_FieldGroup); + CFieldGroup.prototype.setWeight = function(value) + { + if (this.Weight === value) + return; + + AscCommon.History.Add(new AscDFH.CChangesOFormFieldGroupWeight(this, this.Weight, value)); + this.Weight = value; + }; + CFieldGroup.prototype.addField = function(field) + { + if (!field || -1 !== this.Fields.indexOf(field)) + return; + + AscCommon.History.Add(new AscDFH.CChangesOFormFieldGroupAddField(this, field.GetId())); + this.Fields.push(field); + }; + CFieldGroup.prototype.removeField = function(field) + { + if (!field) + return; + + let index = this.Fields.indexOf(field); + if (-1 === index) + return; + + AscCommon.History.Add(new AscDFH.CChangesOFormFieldGroupRemoveField(this, field.GetId())); + this.Fields.splice(index, 1); + }; + CFieldGroup.prototype.readChildXml = function(name, reader) + { + // TODO: implement + return false; + }; + CFieldGroup.prototype.toXml = function(writer) + { + // TODO: implement + }; + //--------------------------------------------------------export---------------------------------------------------- + AscOForm.CFieldGroup = CFieldGroup; + +})(window); diff --git a/oform/FieldMaster.js b/oform/FieldMaster.js index 73a822d..c6631b6 100644 --- a/oform/FieldMaster.js +++ b/oform/FieldMaster.js @@ -69,7 +69,7 @@ if (-1 !== this.Users.indexOf(user)) return; - AscCommon.History.Add(new AscDFH.CChangesOFormFieldMasterAddUser(this, user)); + AscCommon.History.Add(new AscDFH.CChangesOFormFieldMasterAddUser(this, user.GetId())); this.Users.push(user); }; CFieldMaster.prototype.removeUser = function(user) @@ -78,7 +78,7 @@ if (-1 === index) return; - AscCommon.History.Add(new AscDFH.CChangesOFormFieldMasterRemoveUser(this, user)); + AscCommon.History.Add(new AscDFH.CChangesOFormFieldMasterRemoveUser(this, user.GetId())); this.Users.splice(index, 1); }; CFieldMaster.prototype.addSigner = function(user) @@ -86,7 +86,7 @@ if (-1 !== this.Signers.indexOf(user)) return; - AscCommon.History.Add(new AscDFH.CChangesOFormFieldMasterAddSigner(this, user)); + AscCommon.History.Add(new AscDFH.CChangesOFormFieldMasterAddSigner(this, user.GetId())); this.Signers.push(user); }; CFieldMaster.prototype.removeSigner = function(user) @@ -95,7 +95,7 @@ if (-1 === index) return; - AscCommon.History.Add(new AscDFH.CChangesOFormFieldMasterRemoveSigner(this, user)); + AscCommon.History.Add(new AscDFH.CChangesOFormFieldMasterRemoveSigner(this, user.GetId())); this.Signers.splice(index, 1); }; CFieldMaster.prototype.readAttrXml = function(name, reader) diff --git a/oform/changes/DictionaryBase.js b/oform/changes/DictionaryBase.js new file mode 100644 index 0000000..2886776 --- /dev/null +++ b/oform/changes/DictionaryBase.js @@ -0,0 +1,82 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +"use strict"; + +(function(window) +{ + /** + * Базовое изменение для работы с каким-либо контейнером, в который по ключу-key (string) + * добавляют/удаляют значение + * @constructor + * @extends {window['AscDFH'].CChangesBase} + */ + function CChangesDictionaryBase(Class, key, isAdd) + { + AscDFH.CChangesBase.call(this, Class); + this.Key = key; + } + CChangesDictionaryBase.prototype = Object.create(AscDFH.CChangesBase.prototype); + CChangesDictionaryBase.prototype.constructor = CChangesDictionaryBase; + CChangesDictionaryBase.prototype.Redo = function() + { + }; + CChangesDictionaryBase.prototype.Undo = function() + { + }; + CChangesDictionaryBase.prototype.WriteToBinary = function(writer) + { + writer.WriteString2(this.Key); + }; + CChangesDictionaryBase.prototype.ReadFromBinary = function(reader) + { + this.Key = reader.GetString2(); + }; + CChangesDictionaryBase.prototype.IsNeedRecalculate = function() + { + return false; + }; + window['AscDFH'].CChangesDictionaryBase = CChangesDictionaryBase; + + function InheritDictionaryChange(changeClass, type, redoFunction, undoFunction) + { + window['AscDFH'].changesFactory[type] = changeClass; + + changeClass.prototype = Object.create(CChangesDictionaryBase.prototype); + changeClass.prototype.constructor = changeClass; + changeClass.prototype.Type = type; + changeClass.prototype.Redo = redoFunction; + changeClass.prototype.Undo = undoFunction; + } + window['AscDFH'].InheritDictionaryChange = InheritDictionaryChange; + +})(window); diff --git a/oform/changes/FieldGroupChanges.js b/oform/changes/FieldGroupChanges.js new file mode 100644 index 0000000..24c2049 --- /dev/null +++ b/oform/changes/FieldGroupChanges.js @@ -0,0 +1,115 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +"use strict"; + +(function(window) +{ + window['AscDFH'].historyitem_OForm_FieldGroup_Weight = window['AscDFH'].historyitem_type_OForm_FieldGroup | 1; + window['AscDFH'].historyitem_OForm_FieldGroup_AddField = window['AscDFH'].historyitem_type_OForm_FieldGroup | 2; + window['AscDFH'].historyitem_OForm_FieldGroup_RemoveField = window['AscDFH'].historyitem_type_OForm_FieldGroup | 3; + + /** + * @constructor + * @extends {window['AscDFH'].CChangesBaseLongProperty} + */ + function CChangesOFormFieldGroupWeight(Class, Old, New) + { + window['AscDFH'].CChangesBaseLongProperty.call(this, Class, Old, New); + } + window['AscDFH'].InheritPropertyChange( + CChangesOFormFieldGroupWeight, + window['AscDFH'].CChangesBaseLongProperty, + window['AscDFH'].historyitem_OForm_FieldGroup_Weight, + function(value) + { + this.Class.Weight = value; + }, + false + ); + window['AscDFH'].CChangesOFormFieldGroupWeight = CChangesOFormFieldGroupWeight; + + /** + * @constructor + * @extends {window['AscDFH'].CChangesDictionaryBase} + */ + function CChangesOFormFieldGroupAddField(Class, fieldId) + { + window['AscDFH'].CChangesDictionaryBase.call(this, Class, fieldId); + } + InheritUserChange( + CChangesOFormFieldGroupAddField, + window['AscDFH'].historyitem_OForm_FieldGroup_AddField, + function() + { + let field = AscCommon.g_oTableId.GetById(this.Key); + if (-1 === this.Class.Fields.indexOf(field)) + this.Class.Fields.push(field); + }, + function() + { + let field = AscCommon.g_oTableId.GetById(this.Key); + let index = this.Class.Fields.indexOf(field); + if (-1 !== index) + this.Class.Fields.splice(index, 1); + } + ); + window['AscDFH'].CChangesOFormFieldGroupAddField = CChangesOFormFieldGroupAddField; + + /** + * @constructor + * @extends {window['AscDFH'].CChangesDictionaryBase} + */ + function CChangesOFormFieldGroupRemoveField(Class, fieldId) + { + window['AscDFH'].CChangesDictionaryBase.call(this, Class, fieldId); + } + InheritUserChange( + CChangesOFormFieldGroupRemoveField, + window['AscDFH'].historyitem_OForm_FieldGroup_RemoveField, + function() + { + let field = AscCommon.g_oTableId.GetById(this.Key); + let index = this.Class.Fields.indexOf(field); + if (-1 !== index) + this.Class.Fields.splice(index, 1); + }, + function() + { + let field = AscCommon.g_oTableId.GetById(this.Key); + if (-1 === this.Class.Fields.indexOf(field)) + this.Class.Fields.push(field); + } + ); + window['AscDFH'].CChangesOFormFieldGroupRemoveField = CChangesOFormFieldGroupRemoveField; + +})(window); diff --git a/oform/changes/FieldMasterChanges.js b/oform/changes/FieldMasterChanges.js index 99c698f..d519921 100644 --- a/oform/changes/FieldMasterChanges.js +++ b/oform/changes/FieldMasterChanges.js @@ -34,56 +34,11 @@ (function(window) { - window['AscDFH'].historyitem_FormFieldMaster_FieldId = window['AscDFH'].historyitem_type_OForm_FieldMaster | 1; - window['AscDFH'].historyitem_FormFieldMaster_AddUser = window['AscDFH'].historyitem_type_OForm_FieldMaster | 2; - window['AscDFH'].historyitem_FormFieldMaster_RemoveUser = window['AscDFH'].historyitem_type_OForm_FieldMaster | 3; - window['AscDFH'].historyitem_FormFieldMaster_AddSigner = window['AscDFH'].historyitem_type_OForm_FieldMaster | 4; - window['AscDFH'].historyitem_FormFieldMaster_RemoveSigner = window['AscDFH'].historyitem_type_OForm_FieldMaster | 5; - - - /** - * Базовое изменение для работы с FieldMaster.Users и FieldMaster.Signers - * @constructor - * @extends {window['AscDFH'].CChangesBase} - */ - function CChangeUserBase(Class, user) - { - AscDFH.CChangesBase.call(this, Class); - this.UserId = user.GetId(); - } - CChangeUserBase.prototype = Object.create(AscDFH.CChangesBase.prototype); - CChangeUserBase.prototype.constructor = CChangeUserBase; - CChangeUserBase.prototype.Redo = function() - { - }; - CChangeUserBase.prototype.Undo = function() - { - }; - CChangeUserBase.prototype.WriteToBinary = function(writer) - { - // String : Id комментария - writer.WriteString2(this.UserId); - }; - CChangeUserBase.prototype.ReadFromBinary = function(reader) - { - // String : Id комментария - this.UserId = reader.GetString2(); - }; - CChangeUserBase.prototype.IsNeedRecalculate = function() - { - return false; - }; - - function InheritUserChange(changeClass, type, redoFunction, undoFunction) - { - window['AscDFH'].changesFactory[type] = changeClass; - - changeClass.prototype = Object.create(CChangeUserBase.prototype); - changeClass.prototype.constructor = changeClass; - changeClass.prototype.Type = type; - changeClass.prototype.Redo = redoFunction; - changeClass.prototype.Undo = undoFunction; - } + window['AscDFH'].historyitem_OFormFieldMaster_FieldId = window['AscDFH'].historyitem_type_OForm_FieldMaster | 1; + window['AscDFH'].historyitem_OFormFieldMaster_AddUser = window['AscDFH'].historyitem_type_OForm_FieldMaster | 2; + window['AscDFH'].historyitem_OFormFieldMaster_RemoveUser = window['AscDFH'].historyitem_type_OForm_FieldMaster | 3; + window['AscDFH'].historyitem_OFormFieldMaster_AddSigner = window['AscDFH'].historyitem_type_OForm_FieldMaster | 4; + window['AscDFH'].historyitem_OFormFieldMaster_RemoveSigner = window['AscDFH'].historyitem_type_OForm_FieldMaster | 5; /** * @constructor @@ -96,7 +51,7 @@ window['AscDFH'].InheritPropertyChange( CChangesOFormFieldMasterFieldId, window['AscDFH'].CChangesBaseStringProperty, - window['AscDFH'].historyitem_FormFieldMaster_FieldId, + window['AscDFH'].historyitem_OFormFieldMaster_FieldId, function(value) { this.Class.FieldId = value; @@ -107,24 +62,24 @@ /** * @constructor - * @extends {CChangeUserBase} + * @extends {window['AscDFH'].CChangesDictionaryBase} */ - function CChangesOFormFieldMasterAddUser(Class, user) + function CChangesOFormFieldMasterAddUser(Class, userId) { - CChangeUserBase.call(this, Class, user); + window['AscDFH'].CChangesDictionaryBase.call(this, Class, userId); } - InheritUserChange( + window['AscDFH'].InheritDictionaryChange( CChangesOFormFieldMasterAddUser, - window['AscDFH'].historyitem_FormFieldMaster_AddUser, + window['AscDFH'].historyitem_OFormFieldMaster_AddUser, function() { - let user = AscCommon.g_oTableId.GetById(this.UserId); + let user = AscCommon.g_oTableId.GetById(this.Key); if (-1 === this.Class.Users.indexOf(user)) this.Class.Users.push(user); }, function() { - let user = AscCommon.g_oTableId.GetById(this.UserId); + let user = AscCommon.g_oTableId.GetById(this.Key); let index = this.Class.Users.indexOf(user); if (-1 !== index) this.Class.Users.splice(index, 1); @@ -134,25 +89,25 @@ /** * @constructor - * @extends {CChangeUserBase} + * @extends {window['AscDFH'].CChangesDictionaryBase} */ - function CChangesOFormFieldMasterRemoveUser(Class, user) + function CChangesOFormFieldMasterRemoveUser(Class, userId) { - CChangeUserBase.call(this, Class, user); + window['AscDFH'].CChangesDictionaryBase.call(this, Class, userId); } - InheritUserChange( + window['AscDFH'].InheritDictionaryChange( CChangesOFormFieldMasterRemoveUser, - window['AscDFH'].historyitem_FormFieldMaster_RemoveUser, + window['AscDFH'].historyitem_OFormFieldMaster_RemoveUser, function() { - let user = AscCommon.g_oTableId.GetById(this.UserId); + let user = AscCommon.g_oTableId.GetById(this.Key); let index = this.Class.Users.indexOf(user); if (-1 !== index) this.Class.Users.splice(index, 1); }, function() { - let user = AscCommon.g_oTableId.GetById(this.UserId); + let user = AscCommon.g_oTableId.GetById(this.Key); if (-1 === this.Class.Users.indexOf(user)) this.Class.Users.push(user); } @@ -161,24 +116,24 @@ /** * @constructor - * @extends {CChangeUserBase} + * @extends {window['AscDFH'].CChangesDictionaryBase} */ - function CChangesOFormFieldMasterAddSigner(Class, user) + function CChangesOFormFieldMasterAddSigner(Class, userId) { - CChangeUserBase.call(this, Class, user); + window['AscDFH'].CChangesDictionaryBase.call(this, Class, userId); } - InheritUserChange( + window['AscDFH'].InheritDictionaryChange( CChangesOFormFieldMasterAddSigner, - window['AscDFH'].historyitem_FormFieldMaster_AddSigner, + window['AscDFH'].historyitem_OFormFieldMaster_AddSigner, function() { - let user = AscCommon.g_oTableId.GetById(this.UserId); + let user = AscCommon.g_oTableId.GetById(this.Key); if (-1 === this.Class.Signers.indexOf(user)) this.Class.Signers.push(user); }, function() { - let user = AscCommon.g_oTableId.GetById(this.UserId); + let user = AscCommon.g_oTableId.GetById(this.Key); let index = this.Class.Signers.indexOf(user); if (-1 !== index) this.Class.Signers.splice(index, 1); @@ -188,25 +143,25 @@ /** * @constructor - * @extends {CChangeUserBase} + * @extends {window['AscDFH'].CChangesDictionaryBase} */ - function CChangesOFormFieldMasterRemoveSigner(Class, user) + function CChangesOFormFieldMasterRemoveSigner(Class, userId) { - CChangeUserBase.call(this, Class, user); + window['AscDFH'].CChangesDictionaryBase.call(this, Class, userId); } - InheritUserChange( + window['AscDFH'].InheritDictionaryChange( CChangesOFormFieldMasterRemoveSigner, - window['AscDFH'].historyitem_FormFieldMaster_RemoveSigner, + window['AscDFH'].historyitem_OFormFieldMaster_RemoveSigner, function() { - let user = AscCommon.g_oTableId.GetById(this.UserId); + let user = AscCommon.g_oTableId.GetById(this.Key); let index = this.Class.Signers.indexOf(user); if (-1 !== index) this.Class.Signers.splice(index, 1); }, function() { - let user = AscCommon.g_oTableId.GetById(this.UserId); + let user = AscCommon.g_oTableId.GetById(this.Key); if (-1 === this.Class.Signers.indexOf(user)) this.Class.Signers.push(user); }