[oform] Implement reading a default user master

This commit is contained in:
KirillovIlya
2022-12-22 03:10:38 +03:00
parent 0720f6cce0
commit e412f3095d
4 changed files with 52 additions and 2 deletions

View File

@ -42,7 +42,6 @@
function OForm(document)
{
this.Format = new AscOForm.CDocument(this);
this.DefaultUser = this.Format.getDefaultUserMaster();
this.Document = document;
this.CurrentUser = null;

View File

@ -71,6 +71,14 @@
this.clearUserMasters();
this.clearFieldGroups();
};
CDocument.prototype.setDefaultUser = function(userMaster)
{
if (!userMaster || userMaster === this.DefaultUser)
return;
AscCommon.History.Add(new AscDFH.CChangesOFormDocumentDefaultUser(this, this.DefaultUser.GetId(), userMaster.GetId()));
this.DefaultUser = userMaster;
};
CDocument.prototype.setAuthor = function(author)
{
if (this.Author === author)
@ -227,6 +235,22 @@
case "fieldGroup":
this.addFieldGroup(AscOForm.CFieldGroup.fromXml(reader));
break;
case "defaultUser":
{
while (reader.MoveToNextAttribute())
{
if ("r:id" === reader.GetName())
{
let xmlContext = reader.GetContext();
let rId = reader.GetValueDecodeXml();
let rel = reader.rels.getRelationship(rId);
let userMaster = xmlContext.getUserMaster(rel.getFullPath());
if (userMaster)
this.setDefaultUser(userMaster);
}
}
break;
}
}
}

View File

@ -44,6 +44,7 @@
window['AscDFH'].historyitem_OForm_Document_User = window['AscDFH'].historyitem_type_OForm_Document | 8;
window['AscDFH'].historyitem_OForm_Document_UserMaster = window['AscDFH'].historyitem_type_OForm_Document | 9;
window['AscDFH'].historyitem_OForm_Document_FieldMaster = window['AscDFH'].historyitem_type_OForm_Document | 10;
window['AscDFH'].historyitem_OForm_Document_DefaultUser = window['AscDFH'].historyitem_type_OForm_Document | 11;
/**
* @constructor
@ -299,4 +300,30 @@
);
window['AscDFH'].CChangesOFormDocumentFieldMaster = CChangesOFormDocumentFieldMaster;
/**
* @constructor
* @extends {window['AscDFH'].CChangesBaseStringProperty}
*/
function CChangesOFormDocumentDefaultUser(Class, Old, New)
{
window['AscDFH'].CChangesBaseStringProperty.call(this, Class, Old, New);
}
window['AscDFH'].InheritPropertyChange(
CChangesOFormDocumentDefaultUser,
window['AscDFH'].CChangesBaseStringProperty,
window['AscDFH'].historyitem_OForm_Document_DefaultUser,
function(value)
{
let document = this.Class;
let userMaster = AscCommon.g_oTableId.GetById(value);
if (userMaster)
{
userMaster.setParent(document);
document.DefaultUser = userMaster;
}
},
false
);
window['AscDFH'].CChangesOFormDocumentDefaultUser = CChangesOFormDocumentDefaultUser;
})(window);

File diff suppressed because one or more lines are too long