[oform] Add event about changing user master

This commit is contained in:
KirillovIlya
2022-11-29 14:32:03 +03:00
parent 89e2cb15f9
commit f88a486b13
5 changed files with 47 additions and 6 deletions

View File

@ -315,6 +315,7 @@
AscCommon.History.Add(new AscDFH.CChangesOFormDocumentUserMaster(this, userMaster.GetId(), true));
this.UserMasters.push(userMaster);
userMaster.setParent(this);
};
CDocument.prototype.removeUserMaster = function(userMaster)
{
@ -322,6 +323,7 @@
if (-1 === index)
return;
userMaster.setParent(null);
AscCommon.History.Add(new AscDFH.CChangesOFormDocumentUserMaster(this, userMaster.GetId(), false));
this.UserMasters.splice(index, 1);
};
@ -399,6 +401,20 @@
this.OForm.onChangeRoles();
};
CDocument.prototype.onChangeFieldGroup = function(fieldGroup)
{
if (!this.OForm)
return;
this.OForm.onChangeRoles();
};
CDocument.prototype.onChangeUserMaster = function(userMaster)
{
if (!this.OForm)
return;
this.OForm.onChangeRoles();
};
//--------------------------------------------------------export----------------------------------------------------
AscOForm.CDocument = CDocument;

View File

@ -114,7 +114,7 @@
if (!this.Parent)
return;
this.Parent.onChangeFieldGroups();
this.Parent.onChangeFieldGroup(this);
};
CFieldGroup.prototype.getFirstUser = function()
{

View File

@ -50,8 +50,14 @@
if (true === generateId)
this.setUserId(AscCommon.CreateGUID());
this.Parent = null;
}
AscFormat.InitClass(CUserMaster, AscFormat.CBaseFormatObject, AscDFH.historyitem_type_OForm_UserMaster);
CUserMaster.prototype.setParent = function(parent)
{
this.Parent = parent;
};
CUserMaster.prototype.setUserId = function(userId)
{
if (userId === this.UserId)
@ -59,6 +65,7 @@
AscCommon.History.Add(new AscDFH.CChangesOFormUserMasterUserId(this, this.UserId, userId));
this.UserId = userId;
this.onChange();
};
CUserMaster.prototype.getUserId = function()
{
@ -73,6 +80,7 @@
AscCommon.History.Add(new AscDFH.CChangesOFormUserMasterRole(this, this.Role, role));
this.Role = role;
this.onChange();
};
CUserMaster.prototype.getRole = function()
{
@ -87,6 +95,7 @@
AscCommon.History.Add(new AscDFH.CChangesOFormUserMasterColor(this, oldColor, newColor));
this.Color = newColor;
this.onChange();
};
CUserMaster.prototype.getColor = function()
{
@ -135,6 +144,13 @@
return 0;
};
CUserMaster.prototype.onChange = function()
{
if (!this.Parent)
return;
this.Parent.onChangeUserMaster(this);
};
CUserMaster.prototype.readChildXml = function(name, reader)
{
let bRead = false;

View File

@ -252,16 +252,22 @@
window['AscDFH'].historyitem_OForm_Document_UserMaster,
function()
{
let user = AscCommon.g_oTableId.GetById(this.Key);
if (-1 === this.Class.UserMasters.indexOf(user))
this.Class.UserMasters.push(user);
let userMaster = AscCommon.g_oTableId.GetById(this.Key);
if (-1 === this.Class.UserMasters.indexOf(userMaster))
{
userMaster.setParent(this.Class);
this.Class.UserMasters.push(userMaster);
}
},
function()
{
let user = AscCommon.g_oTableId.GetById(this.Key);
let index = this.Class.UserMasters.indexOf(user);
let userMaster = AscCommon.g_oTableId.GetById(this.Key);
let index = this.Class.UserMasters.indexOf(userMaster);
if (-1 !== index)
{
userMaster.setParent(null);
this.Class.UserMasters.splice(index, 1);
}
}
);
window['AscDFH'].CChangesOFormDocumentUserMaster = CChangesOFormDocumentUserMaster;

View File

@ -53,6 +53,7 @@
function(Value)
{
this.Class.UserId = Value;
this.Class.onChange();
},
false
);
@ -73,6 +74,7 @@
function(Value)
{
this.Class.Role = Value;
this.Class.onChange();
},
false
);
@ -93,6 +95,7 @@
function(value)
{
this.Class.Color = value;
this.Class.onChange();
},
false
);