mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
merge all Model JSON @Object parsers into a reviveFromJson()
This commit is contained in:
parent
76648f04ae
commit
15e07a73e9
18 changed files with 378 additions and 411 deletions
|
|
@ -46,28 +46,26 @@ class ContactModel extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {Object} oItem
|
||||
* @returns {boolean}
|
||||
* @static
|
||||
* @param {FetchJsonContact} json
|
||||
* @returns {?ContactModel}
|
||||
*/
|
||||
parse(json) {
|
||||
let result = false;
|
||||
if (json && 'Object/Contact' === json['@Object']) {
|
||||
this.idContact = pInt(json.IdContact);
|
||||
this.display = pString(json.Display);
|
||||
this.readOnly = !!json.ReadOnly;
|
||||
static reviveFromJson(json) {
|
||||
const contact = super.reviveFromJson(json);
|
||||
if (contact) {
|
||||
contact.idContact = pInt(json.IdContact);
|
||||
contact.display = pString(json.Display);
|
||||
contact.readOnly = !!json.ReadOnly;
|
||||
|
||||
if (Array.isNotEmpty(json.Properties)) {
|
||||
json.Properties.forEach(property => {
|
||||
if (property && property.Type && null != property.Value && null != property.TypeStr) {
|
||||
this.properties.push([pInt(property.Type), pString(property.Value), pString(property.TypeStr)]);
|
||||
contact.properties.push([pInt(property.Type), pString(property.Value), pString(property.TypeStr)]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
return contact;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue