Merge branch hotfix/v9.0.3 into master

This commit is contained in:
papacarlo
2025-07-08 11:41:41 +00:00
8 changed files with 257 additions and 12 deletions

View File

@ -621,6 +621,43 @@
this.Roles[roleIndex].setFilled(false);
}
};
OForm.prototype.setAllRolesFilled = function(userPr)
{
let name = userPr ? userPr.name : null;
let id = userPr ? userPr.id : null;
let email = userPr ? userPr.email : null;
for (let roleIndex = 0, roleCount = this.Roles.length; roleIndex < roleCount; ++roleIndex)
{
let role = this.Roles[roleIndex];
if (role.isFilled())
continue;
role.setFilled(true);
let userMaster = role.getUserMaster();
if (!userMaster)
continue;
if (name)
userMaster.setUserName(name);
if (id)
userMaster.setUserId(id);
if (email)
userMaster.setEmail(email);
}
};
OForm.prototype.isAllRolesFilled = function()
{
for (let roleIndex = 0, roleCount = this.Roles.length; roleIndex < roleCount; ++roleIndex)
{
if (!this.Roles[roleIndex].isFilled())
return false;
}
return true;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Private area
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -84,8 +84,22 @@
};
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.UserMaster.setUserId(AscCommon.CreateGUID());
this.UserMaster.setUserName(undefined);
this.UserMaster.setUserEmail(undefined);
this.FieldGroup.setDate(undefined);
}
};
CRole.prototype.getFieldGroup = function()
{

View File

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

View File

@ -97,9 +97,28 @@
};
CUser.fromXml = function(reader)
{
if (!reader.ReadNextNode())
return null;
let name = reader.GetNameNoNS();
if ("user" !== reader.GetNameNoNS())
return null;
let user = new CUser();
let depth = reader.GetDepth();
while (reader.ReadNextSiblingNode(depth))
{
name = reader.GetNameNoNS();
switch(reader.GetNameNoNS())
{
case "email":
user.setEmail(reader.GetTextDecodeXml());
break;
case "telephone":
user.setTelephone(reader.GetTextDecodeXml());
break;
}
}
return user;
};

View File

@ -59,10 +59,12 @@
function CUserMaster(generateId)
{
AscOForm.CBaseFormatObject.call(this);
this.UserId = undefined;
this.Role = undefined;
this.Color = undefined;
this.UserId = undefined;
this.UserName = undefined;
this.UserEmail = undefined;
this.Role = undefined;
this.Color = undefined;
if (true === generateId)
this.setUserId(AscCommon.CreateGUID());
@ -91,6 +93,32 @@
{
return this.UserId;
};
CUserMaster.prototype.setUserName = function(userName)
{
if (userName === this.UserName)
return;
AscCommon.History.Add(new AscDFH.CChangesOFormUserMasterUserName(this, this.UserName, userName));
this.UserName = userName;
this.onChange();
};
CUserMaster.prototype.getUserName = function()
{
return this.UserName;
};
CUserMaster.prototype.setUserEmail = function(userEmail)
{
if (userEmail === this.UserEmail)
return;
AscCommon.History.Add(new AscDFH.CChangesOFormUserMasterUserEmail(this, this.UserEmail, userEmail));
this.UserEmail = userEmail;
this.onChange();
};
CUserMaster.prototype.getUserEmail = function()
{
return this.UserEmail;
};
CUserMaster.prototype.setRole = function(role)
{
if (role === this.Role)
@ -192,6 +220,12 @@
if (this.UserId)
writer.WriteXmlNodeWithText("id", this.UserId);
if (this.UserName)
writer.WriteXmlNodeWithText("name", this.UserName);
if (this.UserEmail)
writer.WriteXmlNodeWithText("email", this.UserEmail);
if (this.Role)
writer.WriteXmlNodeWithText("role", this.Role);
@ -223,6 +257,12 @@
case "id":
um.setUserId(reader.GetTextDecodeXml());
break;
case "name":
um.setUserName(reader.GetTextDecodeXml());
break;
case "email":
um.setUserEmail(reader.GetTextDecodeXml());
break;
case "role":
um.setRole(reader.GetTextDecodeXml());
break;

View File

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

View File

@ -34,9 +34,11 @@
(function(window)
{
window['AscDFH'].historyitem_OForm_UserMaster_UserId = window['AscDFH'].historyitem_type_OForm_UserMaster | 1;
window['AscDFH'].historyitem_OForm_UserMaster_Role = window['AscDFH'].historyitem_type_OForm_UserMaster | 2;
window['AscDFH'].historyitem_OForm_UserMaster_Color = window['AscDFH'].historyitem_type_OForm_UserMaster | 3;
window['AscDFH'].historyitem_OForm_UserMaster_UserId = window['AscDFH'].historyitem_type_OForm_UserMaster | 1;
window['AscDFH'].historyitem_OForm_UserMaster_Role = window['AscDFH'].historyitem_type_OForm_UserMaster | 2;
window['AscDFH'].historyitem_OForm_UserMaster_Color = window['AscDFH'].historyitem_type_OForm_UserMaster | 3;
window['AscDFH'].historyitem_OForm_UserMaster_UserName = window['AscDFH'].historyitem_type_OForm_UserMaster | 4;
window['AscDFH'].historyitem_OForm_UserMaster_UserEmail = window['AscDFH'].historyitem_type_OForm_UserMaster | 5;
/**
* @constructor
@ -104,5 +106,47 @@
return new AscWord.CDocumentColor(0, 0, 0);
};
window['AscDFH'].CChangesOFormUserMasterColor = CChangesOFormUserMasterColor;
/**
* @constructor
* @extends {window['AscDFH'].CChangesBaseStringProperty}
*/
function CChangesOFormUserMasterUserName(Class, Old, New)
{
window['AscDFH'].CChangesBaseStringProperty.call(this, Class, Old, New);
}
window['AscDFH'].InheritPropertyChange(
CChangesOFormUserMasterUserName,
window['AscDFH'].CChangesBaseStringProperty,
window['AscDFH'].historyitem_OForm_UserMaster_UserName,
function(Value)
{
this.Class.UserName = Value;
this.Class.onChange();
},
false
);
window['AscDFH'].CChangesOFormUserMasterUserName = CChangesOFormUserMasterUserName;
/**
* @constructor
* @extends {window['AscDFH'].CChangesBaseStringProperty}
*/
function CChangesOFormUserMasterUserEmail(Class, Old, New)
{
window['AscDFH'].CChangesBaseStringProperty.call(this, Class, Old, New);
}
window['AscDFH'].InheritPropertyChange(
CChangesOFormUserMasterUserEmail,
window['AscDFH'].CChangesBaseStringProperty,
window['AscDFH'].historyitem_OForm_UserMaster_UserEmail,
function(Value)
{
this.Class.UserEmail = Value;
this.Class.onChange();
},
false
);
window['AscDFH'].CChangesOFormUserMasterUserEmail = CChangesOFormUserMasterUserEmail;
})(window);

43
plugin-events.js Normal file
View File

@ -0,0 +1,43 @@
/*
* (c) Copyright Ascensio System SIA 2010-2024
*
* 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-6 Ernesta Birznieka-Upish
* 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
*
*/
/**
* Event: onSubmitForm
* @event Plugin#onSubmitForm
* @memberof Plugin
* @typeofeditors ["CDE", "CFE"]
* @alias onSubmitForm
* @description The function called when the user clicks the "Complete & Submit" button.
* @see office-js-api/Examples/Plugins/{Editor}/Plugin/Events/onSubmitForm.js
*/
"use strict";