forked from Yadro/time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectModel.ts
More file actions
74 lines (64 loc) · 1.65 KB
/
Copy pathProjectModel.ts
File metadata and controls
74 lines (64 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import * as colors from '@ant-design/colors';
import { makeObservable, observable } from 'mobx';
import AbstractModel from '../../../base/AbstractModel';
import { ITreeItemWithParent } from '../../../types/ITreeItem';
export enum DEFAULT_PROJECT_ID {
MyDay = '0',
Inbox = '1',
}
export const DEFAULT_PROJECTS: IJsonProjectItem[] = [
// {
// key: DEFAULT_PROJECT_ID.MyDay,
// title: 'My Day',
// color: colors.yellow.primary || '',
// deletable: false,
// expanded: false,
// },
{
key: DEFAULT_PROJECT_ID.Inbox,
title: 'Inbox',
color: colors.blue.primary || '',
deletable: false,
expanded: false,
parent: undefined,
},
];
export interface IJsonProjectItem extends ITreeItemWithParent {
color: string;
expanded: boolean;
deletable: boolean;
children?: IJsonProjectItem[];
}
interface IProjectModel extends ITreeItemWithParent {
color: string;
expanded: boolean;
deletable: boolean;
children?: IProjectModel[];
}
export default class ProjectModel extends AbstractModel
implements IProjectModel {
key: string = '';
title: string = '';
color: string = '';
expanded: boolean = false;
deletable: boolean = true;
children?: ProjectModel[] = [];
parent: ProjectModel | undefined;
constructor(props: IJsonProjectItem) {
super();
const newProps = {
...props,
children: props.children?.map((json) => new ProjectModel(json)),
};
this.load(newProps);
makeObservable(this, {
key: observable,
title: observable,
color: observable,
expanded: observable,
deletable: observable,
children: observable,
// parent: none,
});
}
}