Initial commit
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* Class model for Collection Interface
|
||||
*/
|
||||
|
||||
import type {
|
||||
CollectionInterface,
|
||||
CollectionContentsInterface,
|
||||
CollectionPermissionsInterface,
|
||||
CollectionRolesInterface
|
||||
} from "@/types/collection";
|
||||
|
||||
export class CollectionObject implements CollectionInterface {
|
||||
|
||||
_data!: CollectionInterface;
|
||||
|
||||
constructor() {
|
||||
this._data = {
|
||||
'@type': 'people:collection',
|
||||
provider: null,
|
||||
service: null,
|
||||
in: null,
|
||||
id: null,
|
||||
label: null,
|
||||
description: null,
|
||||
priority: null,
|
||||
visibility: null,
|
||||
color: null,
|
||||
enabled: false,
|
||||
signature: null,
|
||||
permissions: {},
|
||||
roles: {},
|
||||
contents: {},
|
||||
};
|
||||
}
|
||||
|
||||
fromJson(data: CollectionInterface) : CollectionObject {
|
||||
this._data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
toJson(): CollectionInterface {
|
||||
return this._data;
|
||||
}
|
||||
|
||||
clone(): CollectionObject {
|
||||
const cloned = new CollectionObject()
|
||||
cloned._data = JSON.parse(JSON.stringify(this._data))
|
||||
return cloned
|
||||
}
|
||||
|
||||
/** Immutable Properties */
|
||||
|
||||
get '@type'(): string {
|
||||
return this._data['@type'];
|
||||
}
|
||||
|
||||
get provider(): string | null {
|
||||
return this._data.provider
|
||||
}
|
||||
|
||||
get service(): string | null {
|
||||
return this._data.service
|
||||
}
|
||||
|
||||
get in(): number | string | null {
|
||||
return this._data.in
|
||||
}
|
||||
|
||||
get id(): number | string | null {
|
||||
return this._data.id
|
||||
}
|
||||
|
||||
get signature(): string | null {
|
||||
return this._data.signature
|
||||
}
|
||||
|
||||
get permissions(): CollectionPermissionsInterface {
|
||||
return this._data.permissions
|
||||
}
|
||||
|
||||
get roles(): CollectionRolesInterface {
|
||||
return this._data.roles
|
||||
}
|
||||
|
||||
get contents(): CollectionContentsInterface {
|
||||
return this._data.contents
|
||||
}
|
||||
|
||||
/** Mutable Properties */
|
||||
|
||||
get label(): string | null {
|
||||
return this._data.label
|
||||
}
|
||||
|
||||
set label(value: string ) {
|
||||
this._data.label = value
|
||||
}
|
||||
|
||||
get description(): string | null {
|
||||
return this._data.description
|
||||
}
|
||||
|
||||
set description(value: string ) {
|
||||
this._data.description = value
|
||||
}
|
||||
|
||||
get priority(): number | null {
|
||||
return this._data.priority
|
||||
}
|
||||
|
||||
set priority(value: number ) {
|
||||
this._data.priority = value
|
||||
}
|
||||
|
||||
get visibility(): string | null {
|
||||
return this._data.visibility
|
||||
}
|
||||
|
||||
set visibility(value: string ) {
|
||||
this._data.visibility = value
|
||||
}
|
||||
|
||||
get color(): string | null {
|
||||
return this._data.color
|
||||
}
|
||||
|
||||
set color(value: string ) {
|
||||
this._data.color = value
|
||||
}
|
||||
|
||||
get enabled(): boolean {
|
||||
return this._data.enabled
|
||||
}
|
||||
|
||||
set enabled(value: boolean ) {
|
||||
this._data.enabled = value
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user