refactor: standardize frontend

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-02-24 17:38:27 -05:00
parent 27558d98d3
commit e7fc0e8a9a
9 changed files with 51 additions and 128 deletions
+6 -55
View File
@@ -2,7 +2,7 @@
* Class model for Collection Interface
*/
import type { CollectionContentsInterface, CollectionInterface, CollectionPropertiesInterface } from "@/types/collection";
import type { CollectionContentTypes, CollectionInterface, CollectionPropertiesInterface } from "@/types/collection";
export class CollectionObject implements CollectionInterface {
@@ -17,17 +17,7 @@ export class CollectionObject implements CollectionInterface {
signature: null,
created: null,
modified: null,
properties: {
'@type': 'chrono.collection',
version: 1,
total: 0,
contents: {},
label: '',
description: null,
rank: 0,
visibility: null,
color: null,
},
properties: new CollectionPropertiesObject(),
};
}
@@ -35,8 +25,6 @@ export class CollectionObject implements CollectionInterface {
this._data = data;
if (data.properties) {
this._data.properties = new CollectionPropertiesObject().fromJson(data.properties as CollectionPropertiesInterface);
} else {
this._data.properties = new CollectionPropertiesObject();
}
return this;
}
@@ -115,10 +103,9 @@ export class CollectionPropertiesObject implements CollectionPropertiesInterface
constructor() {
this._data = {
'@type': 'chrono.collection',
'@type': 'chrono:collection',
version: 1,
total: 0,
contents: {},
content: [],
label: '',
description: null,
rank: null,
@@ -129,20 +116,6 @@ export class CollectionPropertiesObject implements CollectionPropertiesInterface
fromJson(data: CollectionPropertiesInterface): CollectionPropertiesObject {
this._data = data;
const raw = this._data as any;
if ((!raw.contents || Object.keys(raw.contents).length === 0) && raw.content !== undefined && raw.content !== null) {
if (typeof raw.content === 'string') {
raw.contents = {
event: raw.content === 'event',
task: raw.content === 'task',
journal: raw.content === 'journal',
};
} else if (typeof raw.content === 'object') {
raw.contents = raw.content;
}
}
return this;
}
@@ -166,30 +139,8 @@ export class CollectionPropertiesObject implements CollectionPropertiesInterface
return this._data.version;
}
get total(): number | undefined {
return this._data.total;
}
get contents(): CollectionContentsInterface {
const raw = this._data as any;
if (raw.contents && Object.keys(raw.contents).length > 0) {
return raw.contents;
}
if (typeof raw.content === 'string') {
return {
event: raw.content === 'event',
task: raw.content === 'task',
journal: raw.content === 'journal',
};
}
if (raw.content && typeof raw.content === 'object') {
return raw.content;
}
return {};
get content(): CollectionContentTypes[] {
return this._data.content || [];
}
/** Mutable Properties */