Split RainLoop/Actions.php and use JsonSerializable

This commit is contained in:
djmaze 2020-10-19 22:09:25 +02:00
parent 8cd2bd46d8
commit 9844c1882c
24 changed files with 3205 additions and 3066 deletions

View file

@ -237,13 +237,6 @@ export function staticPrefix(path) {
return VERSION_PREFIX + 'static/' + path;
}
/**
* @returns {string}
*/
export function emptyContactPic() {
return staticPrefix('css/images/empty-contact.png');
}
/**
* @param {string} fileName
* @returns {string}

View file

@ -13,12 +13,10 @@ export class AbstractModel {
*/
constructor() {
/*
constructor(props) {
if (new.target === Parent) {
throw new Error("Can't instantiate abstract class!");
}
this.sModelName = new.target.name;
props && Object.entries(props).forEach(([key, value]) => '@' !== key[0] && (this[key] = value));
*/
}
@ -59,7 +57,8 @@ export class AbstractModel {
// Object/Folder
// Object/Message
// Object/Template
return this.validJson(json) ? new this(json) : null;
return this.validJson(json) ? new this() : null;
// json && Object.entries(json).forEach(([key, value]) => '@' !== key[0] && (this[key] = value));
}
}

View file

@ -2,7 +2,6 @@ import ko from 'ko';
import { ContactPropertyType } from 'Common/Enums';
import { pInt, pString } from 'Common/Utils';
import { emptyContactPic } from 'Common/Links';
import { AbstractModel } from 'Knoin/AbstractModel';
@ -10,7 +9,7 @@ class ContactModel extends AbstractModel {
constructor() {
super();
this.idContact = 0;
this.id = 0;
this.display = '';
this.properties = [];
this.readOnly = false;
@ -53,11 +52,11 @@ class ContactModel extends AbstractModel {
static reviveFromJson(json) {
const contact = super.reviveFromJson(json);
if (contact) {
contact.idContact = pInt(json.IdContact);
contact.display = pString(json.Display);
contact.readOnly = !!json.ReadOnly;
contact.id = pInt(json.id);
contact.display = pString(json.display);
contact.readOnly = !!json.readOnly;
if (Array.isNotEmpty(json.Properties)) {
if (Array.isNotEmpty(json.properties)) {
json.Properties.forEach(property => {
if (property && property.Type && null != property.Value && null != property.TypeStr) {
contact.properties.push([pInt(property.Type), pString(property.Value), pString(property.TypeStr)]);
@ -68,18 +67,11 @@ class ContactModel extends AbstractModel {
return contact;
}
/**
* @returns {string}
*/
srcAttr() {
return emptyContactPic();
}
/**
* @returns {string}
*/
generateUid() {
return pString(this.idContact);
return pString(this.id);
}
/**

View file

@ -155,7 +155,7 @@ class ContactsPopupView extends AbstractViewNext {
});
this.contactsCheckedOrSelectedUids = ko.computed(() =>
this.contactsCheckedOrSelected().map(contact => contact.idContact)
this.contactsCheckedOrSelected().map(contact => contact.id)
);
this.selector = new Selector(
@ -436,7 +436,7 @@ class ContactsPopupView extends AbstractViewNext {
if (contacts.length) {
contacts.forEach(contact => {
if (currentContact && currentContact.idContact === contact.idContact) {
if (currentContact && currentContact.id === contact.id) {
currentContact = null;
this.currentContact(null);
}
@ -500,7 +500,7 @@ class ContactsPopupView extends AbstractViewNext {
this.viewReadOnly(false);
if (contact) {
id = contact.idContact;
id = contact.id;
if (Array.isNotEmpty(contact.properties)) {
contact.properties.forEach(property => {
if (property && property[0]) {