Merge pull request 'refactor: standardize frontend' (#5) from refactor/standardize-frontend into main
Reviewed-on: #5
This commit was merged in pull request #5.
This commit is contained in:
@@ -1,13 +1,10 @@
|
|||||||
/**
|
/**
|
||||||
* Chrono Manager Module Boot Script
|
* Chrono Manager Module Boot
|
||||||
*
|
|
||||||
* This script is executed when the chrono_manager module is loaded.
|
|
||||||
* It initializes the chronoStore which manages calendars, events, tasks, and journals state.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
console.log('[Chrono Manager] Booting Chrono Manager module...')
|
console.log('[Chrono Manager] Booting module...')
|
||||||
|
|
||||||
console.log('[Chrono Manager] Chrono Manager module booted successfully')
|
console.log('[Chrono Manager] Module booted successfully...')
|
||||||
|
|
||||||
// CSS will be injected by build process
|
// CSS will be injected by build process
|
||||||
//export const css = ['__CSS_FILENAME_PLACEHOLDER__']
|
//export const css = ['__CSS_FILENAME_PLACEHOLDER__']
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Class model for Collection Interface
|
* 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 {
|
export class CollectionObject implements CollectionInterface {
|
||||||
|
|
||||||
@@ -17,17 +17,7 @@ export class CollectionObject implements CollectionInterface {
|
|||||||
signature: null,
|
signature: null,
|
||||||
created: null,
|
created: null,
|
||||||
modified: null,
|
modified: null,
|
||||||
properties: {
|
properties: new CollectionPropertiesObject(),
|
||||||
'@type': 'chrono.collection',
|
|
||||||
version: 1,
|
|
||||||
total: 0,
|
|
||||||
contents: {},
|
|
||||||
label: '',
|
|
||||||
description: null,
|
|
||||||
rank: 0,
|
|
||||||
visibility: null,
|
|
||||||
color: null,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,8 +25,6 @@ export class CollectionObject implements CollectionInterface {
|
|||||||
this._data = data;
|
this._data = data;
|
||||||
if (data.properties) {
|
if (data.properties) {
|
||||||
this._data.properties = new CollectionPropertiesObject().fromJson(data.properties as CollectionPropertiesInterface);
|
this._data.properties = new CollectionPropertiesObject().fromJson(data.properties as CollectionPropertiesInterface);
|
||||||
} else {
|
|
||||||
this._data.properties = new CollectionPropertiesObject();
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -115,10 +103,9 @@ export class CollectionPropertiesObject implements CollectionPropertiesInterface
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._data = {
|
this._data = {
|
||||||
'@type': 'chrono.collection',
|
'@type': 'chrono:collection',
|
||||||
version: 1,
|
version: 1,
|
||||||
total: 0,
|
content: [],
|
||||||
contents: {},
|
|
||||||
label: '',
|
label: '',
|
||||||
description: null,
|
description: null,
|
||||||
rank: null,
|
rank: null,
|
||||||
@@ -129,20 +116,6 @@ export class CollectionPropertiesObject implements CollectionPropertiesInterface
|
|||||||
|
|
||||||
fromJson(data: CollectionPropertiesInterface): CollectionPropertiesObject {
|
fromJson(data: CollectionPropertiesInterface): CollectionPropertiesObject {
|
||||||
this._data = data;
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,30 +139,8 @@ export class CollectionPropertiesObject implements CollectionPropertiesInterface
|
|||||||
return this._data.version;
|
return this._data.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
get total(): number | undefined {
|
get content(): CollectionContentTypes[] {
|
||||||
return this._data.total;
|
return this._data.content || [];
|
||||||
}
|
|
||||||
|
|
||||||
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 {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Mutable Properties */
|
/** Mutable Properties */
|
||||||
|
|||||||
@@ -9,15 +9,9 @@ import { EventObject } from "./event";
|
|||||||
import { TaskObject } from "./task";
|
import { TaskObject } from "./task";
|
||||||
import { JournalObject } from "./journal";
|
import { JournalObject } from "./journal";
|
||||||
|
|
||||||
type EntityPropertiesData = EventInterface | TaskInterface | JournalInterface;
|
|
||||||
type EntityPropertiesObject = EventObject | TaskObject | JournalObject;
|
|
||||||
type EntityInternal = Omit<EntityInterface<EntityPropertiesData>, 'properties'> & {
|
|
||||||
properties: EntityPropertiesData | EntityPropertiesObject;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class EntityObject implements EntityInterface {
|
export class EntityObject implements EntityInterface {
|
||||||
|
|
||||||
_data!: EntityInternal;
|
_data!: EntityInterface;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._data = {
|
this._data = {
|
||||||
@@ -28,99 +22,85 @@ export class EntityObject implements EntityInterface {
|
|||||||
signature: null,
|
signature: null,
|
||||||
created: null,
|
created: null,
|
||||||
modified: null,
|
modified: null,
|
||||||
properties: new EventObject().toJson(),
|
properties: new EventObject(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fromJson(data: EntityInterface): EntityObject {
|
fromJson(data: EntityInterface): EntityObject {
|
||||||
this._data = data as EntityInternal;
|
this._data = data
|
||||||
if (data.properties) {
|
if (data.properties) {
|
||||||
this._data.properties = this.hydrateProperties(data.properties);
|
const type = data.properties.type
|
||||||
|
if (type === 'task') {
|
||||||
|
this._data.properties = new TaskObject().fromJson(data.properties as TaskInterface);
|
||||||
|
} else if (type === 'journal') {
|
||||||
|
this._data.properties = new JournalObject().fromJson(data.properties as JournalInterface);
|
||||||
} else {
|
} else {
|
||||||
this._data.properties = new EventObject();
|
this._data.properties = new EventObject().fromJson(data.properties as EventInterface);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
toJson(): EntityInterface {
|
toJson(): EntityInterface {
|
||||||
const json = { ...this._data };
|
const json = { ...this._data }
|
||||||
if (this._data.properties instanceof EventObject ||
|
if (this._data.properties instanceof EventObject ||
|
||||||
this._data.properties instanceof TaskObject ||
|
this._data.properties instanceof TaskObject ||
|
||||||
this._data.properties instanceof JournalObject) {
|
this._data.properties instanceof JournalObject) {
|
||||||
json.properties = this._data.properties.toJson();
|
json.properties = this._data.properties.toJson();
|
||||||
}
|
}
|
||||||
return json as EntityInterface;
|
return json as EntityInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
clone(): EntityObject {
|
clone(): EntityObject {
|
||||||
const cloned = new EntityObject();
|
const cloned = new EntityObject()
|
||||||
cloned._data = JSON.parse(JSON.stringify(this.toJson())) as EntityInternal;
|
cloned._data = { ...this._data }
|
||||||
return cloned;
|
return cloned
|
||||||
}
|
|
||||||
|
|
||||||
private hydrateProperties(properties: EntityPropertiesData): EntityPropertiesObject {
|
|
||||||
const type = properties.type;
|
|
||||||
if (type === 'task') {
|
|
||||||
return new TaskObject().fromJson(properties as TaskInterface);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type === 'journal') {
|
|
||||||
return new JournalObject().fromJson(properties as JournalInterface);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new EventObject().fromJson(properties as EventInterface);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Immutable Properties */
|
/** Immutable Properties */
|
||||||
|
|
||||||
get provider(): string {
|
get provider(): string {
|
||||||
return this._data.provider;
|
return this._data.provider
|
||||||
}
|
}
|
||||||
|
|
||||||
get service(): string {
|
get service(): string {
|
||||||
return this._data.service;
|
return this._data.service
|
||||||
}
|
}
|
||||||
|
|
||||||
get collection(): string | number {
|
get collection(): string | number {
|
||||||
return this._data.collection;
|
return this._data.collection
|
||||||
}
|
}
|
||||||
|
|
||||||
get identifier(): string | number {
|
get identifier(): string | number {
|
||||||
return this._data.identifier;
|
return this._data.identifier
|
||||||
}
|
}
|
||||||
|
|
||||||
get signature(): string | null {
|
get signature(): string | null {
|
||||||
return this._data.signature;
|
return this._data.signature
|
||||||
}
|
}
|
||||||
|
|
||||||
get created(): string | null {
|
get created(): string | null {
|
||||||
return this._data.created;
|
return this._data.created
|
||||||
}
|
}
|
||||||
|
|
||||||
get modified(): string | null {
|
get modified(): string | null {
|
||||||
return this._data.modified;
|
return this._data.modified
|
||||||
}
|
}
|
||||||
|
|
||||||
get properties(): EntityPropertiesObject {
|
get properties(): EventObject | TaskObject | JournalObject {
|
||||||
if (this._data.properties instanceof EventObject ||
|
if (this._data.properties instanceof EventObject ||
|
||||||
this._data.properties instanceof TaskObject ||
|
this._data.properties instanceof TaskObject ||
|
||||||
this._data.properties instanceof JournalObject) {
|
this._data.properties instanceof JournalObject) {
|
||||||
return this._data.properties;
|
return this._data.properties
|
||||||
}
|
|
||||||
|
|
||||||
if (this._data.properties) {
|
|
||||||
const hydrated = this.hydrateProperties(this._data.properties as EntityPropertiesData);
|
|
||||||
this._data.properties = hydrated;
|
|
||||||
return hydrated;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultProperties = new EventObject();
|
const defaultProperties = new EventObject();
|
||||||
this._data.properties = defaultProperties;
|
this._data.properties = defaultProperties;
|
||||||
return defaultProperties;
|
return defaultProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
set properties(value: EntityPropertiesObject) {
|
set properties(value: EventObject | TaskObject | JournalObject) {
|
||||||
this._data.properties = value;
|
this._data.properties = value
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
export { ProviderObject } from './provider';
|
||||||
|
export { ServiceObject } from './service';
|
||||||
export { CollectionObject } from './collection';
|
export { CollectionObject } from './collection';
|
||||||
export { EntityObject } from './entity';
|
export { EntityObject } from './entity';
|
||||||
export { EventObject } from './event';
|
export { EventObject } from './event';
|
||||||
export { TaskObject } from './task';
|
export { TaskObject } from './task';
|
||||||
export { JournalObject } from './journal';
|
export { JournalObject } from './journal';
|
||||||
export { ProviderObject } from './provider';
|
|
||||||
export { ServiceObject } from './service';
|
|
||||||
export {
|
export {
|
||||||
Identity,
|
Identity,
|
||||||
IdentityNone,
|
IdentityNone,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export class ProviderObject implements ProviderInterface {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._data = {
|
this._data = {
|
||||||
'@type': 'chrono.provider',
|
'@type': 'chrono:provider',
|
||||||
identifier: '',
|
identifier: '',
|
||||||
label: '',
|
label: '',
|
||||||
capabilities: {},
|
capabilities: {},
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import { CollectionObject, CollectionPropertiesObject } from '../models/collecti
|
|||||||
*/
|
*/
|
||||||
function createCollectionObject(data: CollectionInterface): CollectionObject {
|
function createCollectionObject(data: CollectionInterface): CollectionObject {
|
||||||
const integrationStore = useIntegrationStore();
|
const integrationStore = useIntegrationStore();
|
||||||
const factoryItem = integrationStore.getItemById('mail_collection_factory', data.provider) as any;
|
const factoryItem = integrationStore.getItemById('chrono_collection_factory', data.provider) as any;
|
||||||
const factory = factoryItem?.factory;
|
const factory = factoryItem?.factory;
|
||||||
|
|
||||||
// Use provider factory if available, otherwise base class
|
// Use provider factory if available, otherwise base class
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export { useCollectionsStore } from './collectionsStore';
|
|
||||||
export { useEntitiesStore } from './entitiesStore';
|
|
||||||
export { useProvidersStore } from './providersStore';
|
export { useProvidersStore } from './providersStore';
|
||||||
export { useServicesStore } from './servicesStore';
|
export { useServicesStore } from './servicesStore';
|
||||||
|
export { useCollectionsStore } from './collectionsStore';
|
||||||
|
export { useEntitiesStore } from './entitiesStore';
|
||||||
|
|||||||
@@ -6,12 +6,6 @@ import type { ListFilter, ListSort, SourceSelector } from './common';
|
|||||||
/**
|
/**
|
||||||
* Collection information
|
* Collection information
|
||||||
*/
|
*/
|
||||||
export interface CollectionContentsInterface {
|
|
||||||
event?: boolean;
|
|
||||||
task?: boolean;
|
|
||||||
journal?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CollectionInterface {
|
export interface CollectionInterface {
|
||||||
provider: string;
|
provider: string;
|
||||||
service: string | number;
|
service: string | number;
|
||||||
@@ -23,14 +17,15 @@ export interface CollectionInterface {
|
|||||||
properties: CollectionPropertiesInterface;
|
properties: CollectionPropertiesInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type CollectionContentTypes = 'event' | 'task' | 'journal';
|
||||||
|
|
||||||
export interface CollectionBaseProperties {
|
export interface CollectionBaseProperties {
|
||||||
'@type': string;
|
'@type': string;
|
||||||
version: number;
|
version: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CollectionImmutableProperties extends CollectionBaseProperties {
|
export interface CollectionImmutableProperties extends CollectionBaseProperties {
|
||||||
total?: number;
|
content: CollectionContentTypes[];
|
||||||
contents: CollectionContentsInterface;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CollectionMutableProperties extends CollectionBaseProperties {
|
export interface CollectionMutableProperties extends CollectionBaseProperties {
|
||||||
@@ -119,7 +114,6 @@ export interface CollectionDeleteRequest {
|
|||||||
identifier: string | number;
|
identifier: string | number;
|
||||||
options?: {
|
options?: {
|
||||||
force?: boolean; // Whether to force delete even if collection is not empty
|
force?: boolean; // Whether to force delete even if collection is not empty
|
||||||
recursive?: boolean; // Whether to delete child collections/items as well
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ export interface ServiceCapabilitiesInterface {
|
|||||||
EntityDelete?: boolean;
|
EntityDelete?: boolean;
|
||||||
EntityMove?: boolean;
|
EntityMove?: boolean;
|
||||||
EntityCopy?: boolean;
|
EntityCopy?: boolean;
|
||||||
// Send capability
|
|
||||||
EntityTransmit?: boolean;
|
|
||||||
[key: string]: boolean | object | string | string[] | undefined;
|
[key: string]: boolean | object | string | string[] | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +269,10 @@ export type ServiceListFilterCollection = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type ServiceListFilterEntity = {
|
export type ServiceListFilterEntity = {
|
||||||
'*'?: string;
|
'text'?: string;
|
||||||
|
'label'?: string;
|
||||||
|
'description'?: string;
|
||||||
|
'location'?: string;
|
||||||
'before'?: string;
|
'before'?: string;
|
||||||
'after'?: string;
|
'after'?: string;
|
||||||
[attribute: string]: string | undefined;
|
[attribute: string]: string | undefined;
|
||||||
@@ -281,7 +282,7 @@ export type ServiceListFilterEntity = {
|
|||||||
* Service list sort specification
|
* Service list sort specification
|
||||||
*/
|
*/
|
||||||
export type ServiceListSortCollection = ("label" | "rank" | string)[];
|
export type ServiceListSortCollection = ("label" | "rank" | string)[];
|
||||||
export type ServiceListSortEntity = ( "sent" | "size" | string)[];
|
export type ServiceListSortEntity = ( "label" | "start" | string)[];
|
||||||
|
|
||||||
export type ServiceListRange = {
|
export type ServiceListRange = {
|
||||||
'tally'?: string[];
|
'tally'?: string[];
|
||||||
|
|||||||
Reference in New Issue
Block a user