[oform] Rework changes for User/UserMaster classes

This commit is contained in:
KirillovIlya
2022-11-19 13:48:33 +03:00
committed by Ilya Kirillov
parent 7fa69ca7a1
commit 314bfc08f7
5 changed files with 141 additions and 38 deletions

2
api.js
View File

@ -30,7 +30,7 @@
*
*/
var AscOForm;
var AscOForm = {};
(function(window, document) {
window['Asc']['Addons'] = window['Asc']['Addons'] || {};

View File

@ -42,17 +42,31 @@
{
AscFormat.CBaseFormatObject.call(this);
this.Email = null;
this.Telephone = null;
this.UserMaster = userMaster;
this.Email = undefined;
this.Telephone = undefined;
this.UserMaster = undefined;
if (userMaster)
this.setUserMaster(userMaster);
}
AscFormat.InitClass(CUser, AscFormat.CBaseFormatObject, AscDFH.historyitem_type_OForm_User);
CUser.prototype.setUserMaster = function(userMaster)
{
if (this.UserMaster === userMaster)
return;
let oldValue = this.UserMaster ? this.UserMaster.GetId() : undefined;
let newValue = userMaster ? userMaster.GetId() : undefined;
AscCommon.History.Add(new AscDFH.CChangesOFormUserUserMaster(this, oldValue, newValue));
this.UserMaster = userMaster;
};
CUser.prototype.setEmail = function(email)
{
if (email === this.Email)
return;
AscCommon.History.Add(new CChangesString(this, AscDFH.historyitem_OForm_User_Email, this.Email, email));
AscCommon.History.Add(new AscDFH.CChangesOFormUserEmail(this, this.Email, email));
this.Email = email;
};
CUser.prototype.setTelephone = function(telephone)
@ -60,7 +74,7 @@
if (telephone === this.Telephone)
return;
AscCommon.History.Add(new CChangesString(this, AscDFH.historyitem_OForm_User_Telephone, this.Telephone, telephone));
AscCommon.History.Add(new AscDFH.CChangesOFormUserTelephone(this, this.Telephone, telephone));
this.Telephone = telephone;
};
CUser.prototype.getUserMaster = function()
@ -101,6 +115,6 @@
writer.WriteXmlNodeEnd("User");
};
//--------------------------------------------------------export----------------------------------------------------
window['AscOForm'].CUser = CUser;
AscOForm.CUser = CUser;
})(window);

View File

@ -42,22 +42,25 @@
{
AscFormat.CBaseFormatObject.call(this);
this.UserId = null;
this.Role = null;
this.UserId = undefined;
this.Role = undefined;
}
AscFormat.InitClass(CUserMaster, AscFormat.CBaseFormatObject, AscDFH.historyitem_type_OForm_UserMaster);
CUserMaster.prototype.setUserId = function (userId)
CUserMaster.prototype.setUserId = function(userId)
{
AscCommon.History.Add(new CChangesString(this, AscDFH.historyitem_OForm_UserMaster_UserId, this.UserId, userId));
if (userId === this.UserId)
return;
AscCommon.History.Add(new AscDFH.CChangesOFormUserMasterUserId(this, this.UserId, userId));
this.UserId = userId;
};
CUserMaster.prototype.setRole = function (role)
CUserMaster.prototype.setRole = function(role)
{
if (role !== this.Role)
{
AscCommon.History.Add(new CChangesString(this, AscDFH.historyitem_OForm_UserMaster_Role, this.Role, sRole));
this.Role = sRole;
}
if (role === this.Role)
return;
AscCommon.History.Add(new AscDFH.CChangesOFormUserMasterRole(this, this.Role, role));
this.Role = role;
};
CUserMaster.prototype.readChildXml = function(name, reader)
{
@ -83,7 +86,7 @@
}
return bRead;
};
CUserMaster.prototype.toXml = function (writer)
CUserMaster.prototype.toXml = function(writer)
{
writer.WriteXmlString(AscCommonWord.g_sXmlHeader);
writer.WriteXmlNodeStart("UserMaster");
@ -93,6 +96,6 @@
writer.WriteXmlNodeEnd("UserMaster");
};
//--------------------------------------------------------export----------------------------------------------------
window['AscOForm'].CUserMaster = CUserMaster;
AscOForm.CUserMaster = CUserMaster;
})(window);

View File

@ -34,19 +34,77 @@
(function(window)
{
window['AscDFH'].historyitem_OForm_User_Email = window['AscDFH'].historyitem_type_OForm_User | 1;
window['AscDFH'].historyitem_OForm_User_Telephone = window['AscDFH'].historyitem_type_OForm_User | 2;
window['AscDFH'].historyitem_OForm_User_UserMaster = window['AscDFH'].historyitem_type_OForm_User | 1;
window['AscDFH'].historyitem_OForm_User_Email = window['AscDFH'].historyitem_type_OForm_User | 2;
window['AscDFH'].historyitem_OForm_User_Telephone = window['AscDFH'].historyitem_type_OForm_User | 3;
window['AscDFH'].changesFactory[AscDFH.historyitem_OForm_User_Email] = window['AscDFH'].CChangesDrawingsString;
window['AscDFH'].changesFactory[AscDFH.historyitem_OForm_User_Telephone] = window['AscDFH'].CChangesDrawingsString;
/**
* @constructor
* @extends {window['AscDFH'].CChangesBaseStringProperty}
*/
function CChangesOFormUserUserMaster(Class, Old, New)
{
window['AscDFH'].CChangesBaseStringProperty.call(this, Class, Old, New);
}
window['AscDFH'].InheritChange(
CChangesOFormUserUserMaster,
window['AscDFH'].CChangesBaseStringProperty,
window['AscDFH'].historyitem_OForm_User_UserMaster,
function(value)
{
if (!value)
{
this.Class.UserMaster = undefined;
}
else
{
let userMaster = AscCommon.g_oTableId.Get_ById(value);
if (userMaster)
this.Class.UserMaster = userMaster;
}
},
false
);
window['AscDFH'].CChangesOFormUserUserMaster = CChangesOFormUserUserMaster;
window['AscDFH'].drawingsChangesMap[AscDFH.historyitem_OForm_User_Email] = function(oClass, value)
/**
* @constructor
* @extends {window['AscDFH'].CChangesBaseStringProperty}
*/
function CChangesOFormUserEmail(Class, Old, New)
{
oClass.Email = value;
};
window['AscDFH'].drawingsChangesMap[AscDFH.historyitem_OForm_User_Telephone] = function(oClass, value)
window['AscDFH'].CChangesBaseStringProperty.call(this, Class, Old, New);
}
window['AscDFH'].InheritChange(
CChangesOFormUserEmail,
window['AscDFH'].CChangesBaseStringProperty,
window['AscDFH'].historyitem_OForm_User_Email,
function(value)
{
this.Class.Email = value;
},
false
);
window['AscDFH'].CChangesOFormUserEmail = CChangesOFormUserEmail;
/**
* @constructor
* @extends {window['AscDFH'].CChangesBaseStringProperty}
*/
function CChangesOFormUserTelephone(Class, Old, New)
{
oClass.Telephone = value;
};
window['AscDFH'].CChangesBaseStringProperty.call(this, Class, Old, New);
}
window['AscDFH'].InheritChange(
CChangesOFormUserTelephone,
window['AscDFH'].CChangesBaseStringProperty,
window['AscDFH'].historyitem_OForm_User_Telephone,
function(value)
{
this.Class.Telephone = value;
},
false
);
window['AscDFH'].CChangesOFormUserTelephone = CChangesOFormUserTelephone;
})(window);

View File

@ -37,16 +37,44 @@
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'].changesFactory[AscDFH.historyitem_OForm_UserMaster_UserId] = window['AscDFH'].CChangesDrawingsString;
window['AscDFH'].changesFactory[AscDFH.historyitem_OForm_UserMaster_Role] = window['AscDFH'].CChangesDrawingsString;
/**
* @constructor
* @extends {window['AscDFH'].CChangesBaseStringProperty}
*/
function CChangesOFormUserMasterUserId(Class, Old, New)
{
window['AscDFH'].CChangesBaseStringProperty.call(this, Class, Old, New);
}
window['AscDFH'].InheritChange(
CChangesOFormUserMasterUserId,
window['AscDFH'].CChangesBaseStringProperty,
window['AscDFH'].historyitem_OForm_UserMaster_UserId,
function(Value)
{
this.Class.UserId = Value;
},
false
);
window['AscDFH'].CChangesOFormUserMasterUserId = CChangesOFormUserMasterUserId;
window['AscDFH'].drawingsChangesMap[AscDFH.historyitem_OForm_UserMaster_UserId] = function(object, value)
/**
* @constructor
* @extends {window['AscDFH'].CChangesBaseStringProperty}
*/
function CChangesOFormUserMasterRole(Class, Old, New)
{
object.UserId = value;
};
window['AscDFH'].drawingsChangesMap[AscDFH.historyitem_OForm_UserMaster_Role] = function(object, value)
{
object.Role = value;
};
window['AscDFH'].CChangesBaseStringProperty.call(this, Class, Old, New);
}
window['AscDFH'].InheritChange(
CChangesOFormUserMasterRole,
window['AscDFH'].CChangesBaseStringProperty,
window['AscDFH'].historyitem_OForm_UserMaster_Role,
function(Value)
{
this.Class.Role = Value;
},
false
);
window['AscDFH'].CChangesOFormUserMasterRole = CChangesOFormUserMasterRole;
})(window);