mirror of
https://github.com/ONLYOFFICE/sdkjs-forms.git
synced 2026-02-10 18:05:42 +08:00
[oform] Move UserMaster to separate module
Also refactor UserMaster
This commit is contained in:
1
api.js
1
api.js
@ -30,6 +30,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var AscOForm;
|
||||||
|
|
||||||
(function(window, document) {
|
(function(window, document) {
|
||||||
window['Asc']['Addons'] = window['Asc']['Addons'] || {};
|
window['Asc']['Addons'] = window['Asc']['Addons'] || {};
|
||||||
|
|||||||
@ -8,7 +8,8 @@
|
|||||||
"apiBuilder.js",
|
"apiBuilder.js",
|
||||||
"oform/Main.js",
|
"oform/Main.js",
|
||||||
"oform/Field.js",
|
"oform/Field.js",
|
||||||
"oform/User.js"
|
"oform/User.js",
|
||||||
|
"oform/UserMaster.js"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,100 +57,14 @@
|
|||||||
AscDFH.drawingContentChanges[AscDFH.historyitem_UserMasterUser] = function(oClass) {return oClass.Users;};
|
AscDFH.drawingContentChanges[AscDFH.historyitem_UserMasterUser] = function(oClass) {return oClass.Users;};
|
||||||
|
|
||||||
|
|
||||||
|
function CUser()
|
||||||
function CUserMaster() {
|
{
|
||||||
CBaseFormatObject.call(this);
|
AscFormat.CBaseFormatObject.call(this);
|
||||||
this.UserId = null;
|
this.UserMaster = null;
|
||||||
this.SignInfo = null;
|
|
||||||
this.CipherInfo = null;
|
|
||||||
this.Role = null;
|
|
||||||
|
|
||||||
this.Users = [];
|
|
||||||
}
|
|
||||||
InitClass(CUserMaster, CBaseFormatObject, AscDFH.historyitem_type_UserMaster);
|
|
||||||
CUserMaster.prototype.setUserId = function (sUserId) {
|
|
||||||
AscCommon.History.Add(new CChangesString(this, AscDFH.historyitem_UserMasterUserId, this.UserId, sUserId));
|
|
||||||
this.UserId = sUserId;
|
|
||||||
};
|
|
||||||
CUserMaster.prototype.setSignInfo = function (oSignInfo) {
|
|
||||||
AscCommon.History.Add(new CChangesObject(this, AscDFH.historyitem_UserMasterSignInfo, this.SignInfo, oSignInfo));
|
|
||||||
this.SignInfo = oSignInfo;
|
|
||||||
|
|
||||||
};
|
|
||||||
CUserMaster.prototype.setCipherInfo = function (oCipherInfo) {
|
|
||||||
AscCommon.History.Add(new CChangesObject(this, AscDFH.historyitem_UserMasterCipherInfo, this.CipherInfo, oCipherInfo));
|
|
||||||
this.CipherInfo = oCipherInfo;
|
|
||||||
};
|
|
||||||
CUserMaster.prototype.setRole = function (sRole) {
|
|
||||||
AscCommon.History.Add(new CChangesString(this, AscDFH.historyitem_UserMasterRole, this.Role, sRole));
|
|
||||||
this.Role = sRole;
|
|
||||||
};
|
|
||||||
CUserMaster.prototype.addUser = function (oUser) {
|
|
||||||
AscCommon.History.Add(new CChangesContent(this, AscDFH.historyitem_UserMasterUser, this.Users.length, [oUser], true));
|
|
||||||
this.Users.push(oUser);
|
|
||||||
};
|
|
||||||
CUserMaster.prototype.readChildXml = function (name, reader) {
|
|
||||||
let bRead = false;
|
|
||||||
switch (name) {
|
|
||||||
case "Id": {
|
|
||||||
let oNode = new CT_XmlNode();
|
|
||||||
oNode.fromXml(reader);
|
|
||||||
this.setUserId(oNode.text);
|
|
||||||
bRead = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "SignInfo": {
|
|
||||||
let oSignInfo = new CSignInfo();
|
|
||||||
oSignInfo.fromXml(reader);
|
|
||||||
this.setSignInfo(oSignInfo);
|
|
||||||
bRead = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "CipherInfo": {
|
|
||||||
let oCipherInfo = new CCipherInfo();
|
|
||||||
oCipherInfo.fromXml(reader);
|
|
||||||
this.setCipherInfo(oCipherInfo);
|
|
||||||
bRead = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "Role": {
|
|
||||||
let oNode = new CT_XmlNode();
|
|
||||||
oNode.fromXml(reader);
|
|
||||||
this.setRole(oNode.text);
|
|
||||||
bRead = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bRead;
|
|
||||||
};
|
|
||||||
CUserMaster.prototype.writeChildren = function(writer) {
|
|
||||||
let oIdNode = new CT_XmlNode();
|
|
||||||
oIdNode.text = this.UserId;
|
|
||||||
oIdNode.toXml(writer, "Id");
|
|
||||||
if(this.SignInfo) {
|
|
||||||
this.SignInfo.toXml(writer);
|
|
||||||
}
|
|
||||||
if(this.CipherInfo) {
|
|
||||||
this.CipherInfo.toXml(writer);
|
|
||||||
}
|
|
||||||
let oRoleNode = new CT_XmlNode();
|
|
||||||
oRoleNode.text = this.Role;
|
|
||||||
oRoleNode.toXml(writer, "Role");
|
|
||||||
}
|
|
||||||
CUserMaster.prototype.toXml = function (writer) {
|
|
||||||
writer.WriteXmlString(AscCommonWord.g_sXmlHeader);
|
|
||||||
writer.WriteXmlNodeStart("UserMaster");
|
|
||||||
writer.WriteXmlAttributesEnd();
|
|
||||||
this.writeChildren(writer);
|
|
||||||
writer.WriteXmlNodeEnd("UserMaster");
|
|
||||||
};
|
|
||||||
|
|
||||||
function CUser() {
|
|
||||||
CUserMaster.call(this);
|
|
||||||
this.Email = null;
|
this.Email = null;
|
||||||
this.Telephone = null;
|
this.Telephone = null;
|
||||||
}
|
}
|
||||||
InitClass(CUser, CUserMaster, AscDFH.historyitem_type_User);
|
InitClass(CUser, AscFormat.CBaseFormatObject, AscDFH.historyitem_type_User);
|
||||||
CUser.prototype.setEmail = function (sEmail) {
|
CUser.prototype.setEmail = function (sEmail) {
|
||||||
AscCommon.History.Add(new CChangesString(this, AscDFH.historyitem_UserEmail, this.Email, sEmail));
|
AscCommon.History.Add(new CChangesString(this, AscDFH.historyitem_UserEmail, this.Email, sEmail));
|
||||||
this.Email = sEmail;
|
this.Email = sEmail;
|
||||||
@ -299,7 +213,6 @@
|
|||||||
writer.WriteXmlNodeEnd("CipherInfo");
|
writer.WriteXmlNodeEnd("CipherInfo");
|
||||||
};
|
};
|
||||||
|
|
||||||
AscWord.CUserMaster = CUserMaster;
|
|
||||||
AscWord.CUser = CUser;
|
AscWord.CUser = CUser;
|
||||||
AscWord.CSignInfo = CSignInfo;
|
AscWord.CSignInfo = CSignInfo;
|
||||||
AscWord.CCipherInfo = CCipherInfo;
|
AscWord.CCipherInfo = CCipherInfo;
|
||||||
|
|||||||
115
oform/UserMaster.js
Normal file
115
oform/UserMaster.js
Normal file
@ -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)
|
||||||
|
{
|
||||||
|
const CChangesString = AscDFH.CChangesDrawingsString;
|
||||||
|
|
||||||
|
AscDFH.changesFactory[AscDFH.historyitem_UserMasterUserId] = CChangesString;
|
||||||
|
AscDFH.changesFactory[AscDFH.historyitem_UserMasterRole] = CChangesString;
|
||||||
|
|
||||||
|
AscDFH.drawingsChangesMap[AscDFH.historyitem_UserMasterUserId] = function(oClass, value) {oClass.UserId = value;};
|
||||||
|
AscDFH.drawingsChangesMap[AscDFH.historyitem_UserMasterRole] = function(oClass, value) {oClass.Role = value;};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function CUserMaster()
|
||||||
|
{
|
||||||
|
AscFormat.CBaseFormatObject.call(this);
|
||||||
|
|
||||||
|
this.UserId = null;
|
||||||
|
this.Role = null;
|
||||||
|
}
|
||||||
|
AscFormat.InitClass(CUserMaster, AscFormat.CBaseFormatObject, AscDFH.historyitem_type_UserMaster);
|
||||||
|
CUserMaster.prototype.setUserId = function (userId)
|
||||||
|
{
|
||||||
|
AscCommon.History.Add(new CChangesString(this, AscDFH.historyitem_UserMasterUserId, this.UserId, userId));
|
||||||
|
this.UserId = userId;
|
||||||
|
};
|
||||||
|
CUserMaster.prototype.setRole = function (role)
|
||||||
|
{
|
||||||
|
if (role !== this.Role)
|
||||||
|
{
|
||||||
|
AscCommon.History.Add(new CChangesString(this, AscDFH.historyitem_UserMasterRole, this.Role, sRole));
|
||||||
|
this.Role = sRole;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
CUserMaster.prototype.readChildXml = function(name, reader)
|
||||||
|
{
|
||||||
|
let bRead = false;
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "Id":
|
||||||
|
{
|
||||||
|
let oNode = new CT_XmlNode();
|
||||||
|
oNode.fromXml(reader);
|
||||||
|
this.setUserId(oNode.text);
|
||||||
|
bRead = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "Role":
|
||||||
|
{
|
||||||
|
let oNode = new CT_XmlNode();
|
||||||
|
oNode.fromXml(reader);
|
||||||
|
this.setRole(oNode.text);
|
||||||
|
bRead = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bRead;
|
||||||
|
};
|
||||||
|
CUserMaster.prototype.writeChildren = function(writer)
|
||||||
|
{
|
||||||
|
let oIdNode = new CT_XmlNode();
|
||||||
|
oIdNode.text = this.UserId;
|
||||||
|
oIdNode.toXml(writer, "Id");
|
||||||
|
|
||||||
|
let oRoleNode = new CT_XmlNode();
|
||||||
|
oRoleNode.text = this.Role;
|
||||||
|
oRoleNode.toXml(writer, "Role");
|
||||||
|
}
|
||||||
|
CUserMaster.prototype.toXml = function (writer)
|
||||||
|
{
|
||||||
|
writer.WriteXmlString(AscCommonWord.g_sXmlHeader);
|
||||||
|
writer.WriteXmlNodeStart("UserMaster");
|
||||||
|
writer.WriteXmlAttributesEnd();
|
||||||
|
this.writeChildren(writer);
|
||||||
|
writer.WriteXmlNodeEnd("UserMaster");
|
||||||
|
};
|
||||||
|
//--------------------------------------------------------export----------------------------------------------------
|
||||||
|
window['AscOForm'].CUserMaster = CUserMaster;
|
||||||
|
|
||||||
|
})(window);
|
||||||
Reference in New Issue
Block a user