@voplus/morpho-document 1.0.0-dev241 → 1.0.0-dev243
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +2 -0
- package/es/components/ActivityLog/state.js +50 -54
- package/es/components/ActivityLog/state.js.map +1 -1
- package/es/components/AddDocDropdown/state.js +93 -97
- package/es/components/AddDocDropdown/state.js.map +1 -1
- package/es/components/AvatarList/state.js +46 -50
- package/es/components/AvatarList/state.js.map +1 -1
- package/es/components/BreadCrumbsHeader/state.js +33 -37
- package/es/components/BreadCrumbsHeader/state.js.map +1 -1
- package/es/components/DocumentCard/index.d.ts +10 -0
- package/es/components/DocumentCard/index.js +36 -0
- package/es/components/DocumentCard/index.js.map +1 -0
- package/es/components/DocumentCard/index.less +109 -0
- package/es/components/DocumentCard/state.d.ts +15 -0
- package/es/components/DocumentCard/state.js +67 -0
- package/es/components/DocumentCard/state.js.map +1 -0
- package/es/components/DocumentHeader/index.d.ts +1 -0
- package/es/components/DocumentHeader/index.js +11 -5
- package/es/components/DocumentHeader/index.js.map +1 -1
- package/es/components/DocumentHeader/index.less +4 -4
- package/es/components/DocumentHeader/state.d.ts +2 -0
- package/es/components/DocumentHeader/state.js +63 -67
- package/es/components/DocumentHeader/state.js.map +1 -1
- package/es/components/DocumentItem/state.js +44 -48
- package/es/components/DocumentItem/state.js.map +1 -1
- package/es/components/DocumentList/state.js +212 -216
- package/es/components/DocumentList/state.js.map +1 -1
- package/es/components/DocumentListView/state.js +8 -12
- package/es/components/DocumentListView/state.js.map +1 -1
- package/es/components/DocumentMenu/state.js +74 -78
- package/es/components/DocumentMenu/state.js.map +1 -1
- package/es/components/DocumentSelectDialog/index.js +1 -1
- package/es/components/DocumentSelectDialog/index.js.map +1 -1
- package/es/components/DocumentSelectDialog/state.js +68 -72
- package/es/components/DocumentSelectDialog/state.js.map +1 -1
- package/es/components/DocumentSortableTree/index.js +2 -2
- package/es/components/DocumentSortableTree/index.js.map +1 -1
- package/es/components/DocumentSortableTree/state.js +171 -175
- package/es/components/DocumentSortableTree/state.js.map +1 -1
- package/es/components/DocumentSortableTree/themes/FileExplorerTheme/index.js.map +1 -0
- package/es/components/{FileExplorerTheme → DocumentSortableTree/themes/FileExplorerTheme}/node-content-renderer.js +3 -3
- package/es/components/DocumentSortableTree/themes/FileExplorerTheme/node-content-renderer.js.map +1 -0
- package/es/components/DocumentSortableTree/themes/FileExplorerTheme/tree-node-renderer.js.map +1 -0
- package/es/components/DocumentSortableTree/themes/SortableTreeDocumentTheme/index.js.map +1 -0
- package/es/components/{SortableTreeDocumentTheme → DocumentSortableTree/themes/SortableTreeDocumentTheme}/node-content-renderer.js +1 -1
- package/es/components/DocumentSortableTree/themes/SortableTreeDocumentTheme/node-content-renderer.js.map +1 -0
- package/es/components/DocumentSortableTree/themes/SortableTreeDocumentTheme/tree-node-renderer.js.map +1 -0
- package/es/components/DocumentTree/state.js +82 -86
- package/es/components/DocumentTree/state.js.map +1 -1
- package/es/components/FileViewer/ImageViewer.js +1 -1
- package/es/components/FileViewer/ImageViewer.js.map +1 -1
- package/es/components/Links/state.js +63 -67
- package/es/components/Links/state.js.map +1 -1
- package/es/components/NewDocumentForm/state.js +35 -39
- package/es/components/NewDocumentForm/state.js.map +1 -1
- package/es/components/PeopleAccess/PeopleAccessState.js +132 -136
- package/es/components/PeopleAccess/PeopleAccessState.js.map +1 -1
- package/es/components/PublishModal/state.js +10 -14
- package/es/components/PublishModal/state.js.map +1 -1
- package/es/components/QuickAccessSearch/state.js +59 -63
- package/es/components/QuickAccessSearch/state.js.map +1 -1
- package/es/components/QuickViewDialog/state.js +22 -26
- package/es/components/QuickViewDialog/state.js.map +1 -1
- package/es/components/TagView/state.js +59 -63
- package/es/components/TagView/state.js.map +1 -1
- package/es/components/VersionsModal/state.js +23 -27
- package/es/components/VersionsModal/state.js.map +1 -1
- package/es/controls/DocumentStatusLabel/index.js +3 -1
- package/es/controls/DocumentStatusLabel/index.js.map +1 -1
- package/es/controls/DocumentStatusLabel/index.less +7 -1
- package/es/controls/FlagIcon/index.js +1 -1
- package/es/controls/FlagIcon/index.js.map +1 -1
- package/es/controls/FlagIcon/index.less +4 -4
- package/es/controls/ToolBar/state.js +143 -147
- package/es/controls/ToolBar/state.js.map +1 -1
- package/es/controls/filters/CreateDateFilter/state.js +27 -31
- package/es/controls/filters/CreateDateFilter/state.js.map +1 -1
- package/es/controls/filters/DocumentStatusFilter/state.js +38 -42
- package/es/controls/filters/DocumentStatusFilter/state.js.map +1 -1
- package/es/controls/filters/DocumentTypeFilter/state.js +48 -52
- package/es/controls/filters/DocumentTypeFilter/state.js.map +1 -1
- package/es/controls/filters/FlagFilter/state.js +46 -50
- package/es/controls/filters/FlagFilter/state.js.map +1 -1
- package/es/data/DocumentMetaStore.js +34 -38
- package/es/data/DocumentMetaStore.js.map +1 -1
- package/es/data/DocumentStore/DocumentStore.js +228 -232
- package/es/data/DocumentStore/DocumentStore.js.map +1 -1
- package/es/data/contexts/DocumentListContext/index.js +30 -34
- package/es/data/contexts/DocumentListContext/index.js.map +1 -1
- package/es/data/metas/FileTypeMeta.js +21 -25
- package/es/data/metas/FileTypeMeta.js.map +1 -1
- package/es/data/metas/ShortcutMeta.js +22 -26
- package/es/data/metas/ShortcutMeta.js.map +1 -1
- package/es/modules/unit/components/ActivityLog/state.js +15 -19
- package/es/modules/unit/components/ActivityLog/state.js.map +1 -1
- package/es/modules/unit/components/AddUnitDropdown/state.js +75 -79
- package/es/modules/unit/components/AddUnitDropdown/state.js.map +1 -1
- package/es/modules/unit/components/BreadCrumbsHeader/state.js +14 -18
- package/es/modules/unit/components/BreadCrumbsHeader/state.js.map +1 -1
- package/es/modules/unit/components/Members/state.js +21 -25
- package/es/modules/unit/components/Members/state.js.map +1 -1
- package/es/modules/unit/components/NewUnitForm/state.js +43 -47
- package/es/modules/unit/components/NewUnitForm/state.js.map +1 -1
- package/es/modules/unit/components/SubUnitList/state.js +28 -32
- package/es/modules/unit/components/SubUnitList/state.js.map +1 -1
- package/es/modules/unit/components/UnitDetails/state.js +20 -24
- package/es/modules/unit/components/UnitDetails/state.js.map +1 -1
- package/es/modules/unit/components/UnitHead/state.js +5 -9
- package/es/modules/unit/components/UnitHead/state.js.map +1 -1
- package/es/modules/unit/components/UnitItem/state.js +16 -20
- package/es/modules/unit/components/UnitItem/state.js.map +1 -1
- package/es/modules/unit/components/UnitList/state.js +27 -31
- package/es/modules/unit/components/UnitList/state.js.map +1 -1
- package/es/modules/unit/components/UnitSortableTree/state.js +153 -157
- package/es/modules/unit/components/UnitSortableTree/state.js.map +1 -1
- package/es/modules/unit/controls/ContactSelect/state.js +36 -40
- package/es/modules/unit/controls/ContactSelect/state.js.map +1 -1
- package/es/modules/unit/controls/ToolBar/ContactMenu/state.js +64 -68
- package/es/modules/unit/controls/ToolBar/ContactMenu/state.js.map +1 -1
- package/es/modules/unit/controls/ToolBar/state.js +58 -62
- package/es/modules/unit/controls/ToolBar/state.js.map +1 -1
- package/es/modules/unit/controls/UnitTypeFilter/state.js +55 -59
- package/es/modules/unit/controls/UnitTypeFilter/state.js.map +1 -1
- package/es/modules/unit/data/UnitContext/index.js +20 -24
- package/es/modules/unit/data/UnitContext/index.js.map +1 -1
- package/es/modules/unit/data/UnitStore.js +198 -202
- package/es/modules/unit/data/UnitStore.js.map +1 -1
- package/es/modules/unit/pages/UnitTreeView/state.js +10 -14
- package/es/modules/unit/pages/UnitTreeView/state.js.map +1 -1
- package/es/pages/Library/LibraryDefaultView/Content.d.ts +6 -0
- package/es/pages/Library/LibraryDefaultView/Content.js +31 -0
- package/es/pages/Library/LibraryDefaultView/Content.js.map +1 -0
- package/es/pages/Library/LibraryDefaultView/index.d.ts +4 -0
- package/es/pages/Library/LibraryDefaultView/index.js +74 -0
- package/es/pages/Library/LibraryDefaultView/index.js.map +1 -0
- package/es/pages/Library/LibraryDefaultView/index.less +54 -0
- package/es/pages/Library/LibraryDefaultView/state.d.ts +14 -0
- package/es/pages/Library/LibraryDefaultView/state.js +31 -0
- package/es/pages/Library/LibraryDefaultView/state.js.map +1 -0
- package/es/pages/Library/data/LibraryStore.d.ts +10 -0
- package/es/pages/Library/data/LibraryStore.js +16 -0
- package/es/pages/Library/data/LibraryStore.js.map +1 -0
- package/es/pages/Library/data/hook.d.ts +2 -0
- package/es/pages/Library/data/hook.js +10 -0
- package/es/pages/Library/data/hook.js.map +1 -0
- package/es/pages/Library/data/index.d.ts +3 -0
- package/es/pages/Library/data/index.js +4 -0
- package/es/pages/Library/data/index.js.map +1 -0
- package/es/pages/Library/data/interfaces.d.ts +2 -0
- package/es/pages/Library/data/interfaces.js +1 -0
- package/es/pages/Library/data/interfaces.js.map +1 -0
- package/es/pages/Page/PageDefaultView/index.d.ts +12 -0
- package/es/pages/Page/PageDefaultView/index.js +97 -0
- package/es/pages/Page/PageDefaultView/index.js.map +1 -0
- package/es/pages/Page/PageDefaultView/index.less +49 -0
- package/es/pages/Page/PageDefaultView/state.d.ts +7 -0
- package/es/pages/Page/PageDefaultView/state.js +15 -0
- package/es/pages/Page/PageDefaultView/state.js.map +1 -0
- package/es/pages/Page/PageTextItem/index.d.ts +7 -0
- package/es/pages/Page/PageTextItem/index.js +39 -0
- package/es/pages/Page/PageTextItem/index.js.map +1 -0
- package/es/pages/Page/PageTextItem/index.less +31 -0
- package/es/pages/Page/PageTextItem/state.d.ts +9 -0
- package/es/pages/Page/PageTextItem/state.js +22 -0
- package/es/pages/Page/PageTextItem/state.js.map +1 -0
- package/es/pages/Page/PlusDropDown/index.d.ts +7 -0
- package/es/pages/Page/PlusDropDown/index.js +14 -0
- package/es/pages/Page/PlusDropDown/index.js.map +1 -0
- package/es/pages/Page/PlusDropDown/index.less +11 -0
- package/es/pages/Page/data/IPageItemState.d.ts +4 -0
- package/es/pages/Page/data/IPageItemState.js +1 -0
- package/es/pages/Page/data/IPageItemState.js.map +1 -0
- package/es/pages/Page/data/PageContext.d.ts +18 -0
- package/es/pages/Page/data/PageContext.js +48 -0
- package/es/pages/Page/data/PageContext.js.map +1 -0
- package/es/pages/Page/data/PageStore.d.ts +10 -0
- package/es/pages/Page/data/PageStore.js +16 -0
- package/es/pages/Page/data/PageStore.js.map +1 -0
- package/es/pages/Page/data/hook.d.ts +2 -0
- package/es/pages/Page/data/hook.js +10 -0
- package/es/pages/Page/data/hook.js.map +1 -0
- package/es/pages/Page/data/index.d.ts +3 -0
- package/es/pages/Page/data/index.js +4 -0
- package/es/pages/Page/data/index.js.map +1 -0
- package/es/pages/Page/data/interfaces.d.ts +2 -0
- package/es/pages/Page/data/interfaces.js +1 -0
- package/es/pages/Page/data/interfaces.js.map +1 -0
- package/es/pages/TreeViewPage/state.js +10 -14
- package/es/pages/TreeViewPage/state.js.map +1 -1
- package/es/routes.d.ts +20 -0
- package/es/routes.js +27 -1
- package/es/routes.js.map +1 -1
- package/package.json +7 -7
- package/es/components/FileExplorerTheme/index.js.map +0 -1
- package/es/components/FileExplorerTheme/node-content-renderer.js.map +0 -1
- package/es/components/FileExplorerTheme/tree-node-renderer.js.map +0 -1
- package/es/components/SortableTreeDocumentTheme/index.js.map +0 -1
- package/es/components/SortableTreeDocumentTheme/node-content-renderer.js.map +0 -1
- package/es/components/SortableTreeDocumentTheme/tree-node-renderer.js.map +0 -1
- package/es/controls/Panable/index.d.ts +0 -7
- package/es/controls/Panable/index.js +0 -65
- package/es/controls/Panable/index.js.map +0 -1
- package/es/controls/Panable/index.less +0 -15
- package/es/controls/Panable/state.d.ts +0 -9
- package/es/controls/Panable/state.js +0 -39
- package/es/controls/Panable/state.js.map +0 -1
- /package/es/components/{FileExplorerTheme → DocumentSortableTree/themes/FileExplorerTheme}/index.d.ts +0 -0
- /package/es/components/{FileExplorerTheme → DocumentSortableTree/themes/FileExplorerTheme}/index.js +0 -0
- /package/es/components/{FileExplorerTheme → DocumentSortableTree/themes/FileExplorerTheme}/node-content-renderer.d.ts +0 -0
- /package/es/components/{FileExplorerTheme → DocumentSortableTree/themes/FileExplorerTheme}/node-content-renderer.less +0 -0
- /package/es/components/{FileExplorerTheme → DocumentSortableTree/themes/FileExplorerTheme}/tree-node-renderer.d.ts +0 -0
- /package/es/components/{FileExplorerTheme → DocumentSortableTree/themes/FileExplorerTheme}/tree-node-renderer.js +0 -0
- /package/es/components/{FileExplorerTheme → DocumentSortableTree/themes/FileExplorerTheme}/tree-node-renderer.less +0 -0
- /package/es/components/{SortableTreeDocumentTheme → DocumentSortableTree/themes/SortableTreeDocumentTheme}/index.d.ts +0 -0
- /package/es/components/{SortableTreeDocumentTheme → DocumentSortableTree/themes/SortableTreeDocumentTheme}/index.js +0 -0
- /package/es/components/{SortableTreeDocumentTheme → DocumentSortableTree/themes/SortableTreeDocumentTheme}/node-content-renderer.d.ts +0 -0
- /package/es/components/{SortableTreeDocumentTheme → DocumentSortableTree/themes/SortableTreeDocumentTheme}/node-content-renderer.less +0 -0
- /package/es/components/{SortableTreeDocumentTheme → DocumentSortableTree/themes/SortableTreeDocumentTheme}/tree-node-renderer.d.ts +0 -0
- /package/es/components/{SortableTreeDocumentTheme → DocumentSortableTree/themes/SortableTreeDocumentTheme}/tree-node-renderer.js +0 -0
- /package/es/components/{SortableTreeDocumentTheme → DocumentSortableTree/themes/SortableTreeDocumentTheme}/tree-node-renderer.less +0 -0
|
@@ -7,209 +7,205 @@ import hash from "object-hash";
|
|
|
7
7
|
import invariant from "invariant";
|
|
8
8
|
import { setTimeout } from "timers";
|
|
9
9
|
const StoreName = "UnitStore";
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
return moved;
|
|
187
|
-
}
|
|
10
|
+
export class UnitStore extends Store {
|
|
11
|
+
constructor(_api) {
|
|
12
|
+
super();
|
|
13
|
+
this._api = _api;
|
|
14
|
+
this.name = StoreName;
|
|
15
|
+
/** Contac created event dispatcher */
|
|
16
|
+
this._created = new EventDispatcher();
|
|
17
|
+
this._deleted = new EventDispatcher();
|
|
18
|
+
this._memberCreated = new EventDispatcher();
|
|
19
|
+
this._memberDeleted = new EventDispatcher();
|
|
20
|
+
/** Id of documents to be moved. */
|
|
21
|
+
this.moveIds = [];
|
|
22
|
+
this.items = new CountedMap((key) => UnitStore.createDefaultContact({ id: key }), observable.map([], { deep: true }));
|
|
23
|
+
this._listCache = new Map();
|
|
24
|
+
invariant(_api, `API cannot be ${_api}.`);
|
|
25
|
+
}
|
|
26
|
+
/** Event fires when a new unit has been created. */
|
|
27
|
+
get UnitCreatedEvent() {
|
|
28
|
+
return this._created.asEvent();
|
|
29
|
+
}
|
|
30
|
+
/** Event fires when a delete contact has been deleted. */
|
|
31
|
+
get UnitDeletedEvent() {
|
|
32
|
+
return this._deleted.asEvent();
|
|
33
|
+
}
|
|
34
|
+
/** Event fires when a new member has been created. */
|
|
35
|
+
get MemberCreatedEvent() {
|
|
36
|
+
return this._memberCreated.asEvent();
|
|
37
|
+
}
|
|
38
|
+
/** Event fires when a delete member has been deleted. */
|
|
39
|
+
get MemberDeletedEvent() {
|
|
40
|
+
return this._memberDeleted.asEvent();
|
|
41
|
+
}
|
|
42
|
+
/** Create a default contact object with optional default values. */
|
|
43
|
+
static createDefaultContact(defaultValues) {
|
|
44
|
+
const v = { loaded: false, address: {}, primaryLegalIdentity: {} };
|
|
45
|
+
if (defaultValues)
|
|
46
|
+
Object.assign(v, defaultValues);
|
|
47
|
+
return v;
|
|
48
|
+
}
|
|
49
|
+
/** Create a new contact base on type. */
|
|
50
|
+
async createFromType(options) {
|
|
51
|
+
invariant(options.name, "Name cannot be empty.");
|
|
52
|
+
const r = await this._api.post(`api/groups/create`, new RequestBuilder().form(options));
|
|
53
|
+
const t = (await r.json());
|
|
54
|
+
this._created.dispatch(this, t);
|
|
55
|
+
console.log("createFromType", t);
|
|
56
|
+
return t;
|
|
57
|
+
}
|
|
58
|
+
/** 新增用戶至Group.
|
|
59
|
+
* pid是小組id type必须是Team
|
|
60
|
+
* id 是現有用戶id (必须是用户)
|
|
61
|
+
*/
|
|
62
|
+
async addUserFromGroup(options) {
|
|
63
|
+
// invariant(options.name, "Name cannot be empty.");
|
|
64
|
+
const r = await this._api.post(`/api/groups/${options.pid}/add/${options.id}`);
|
|
65
|
+
const t = (await r.json());
|
|
66
|
+
t.parentNodeId = options.pid;
|
|
67
|
+
this._memberCreated.dispatch(this, t);
|
|
68
|
+
console.log("addUserFromGroup", t);
|
|
69
|
+
return t;
|
|
70
|
+
}
|
|
71
|
+
/** Load a task from server.
|
|
72
|
+
* @param {string} id - id of the task.
|
|
73
|
+
* @param {LoadTaskOptions} options - Optional load options.
|
|
74
|
+
*/
|
|
75
|
+
async load(id, options) {
|
|
76
|
+
let query = "";
|
|
77
|
+
if (options.includes)
|
|
78
|
+
query = query.concat(`includes=${options.includes}`);
|
|
79
|
+
if (query)
|
|
80
|
+
query = "?".concat(query);
|
|
81
|
+
const r = await this._api.get(`/units/${id}${query}`);
|
|
82
|
+
return (await r.json());
|
|
83
|
+
}
|
|
84
|
+
/** Refresh a loaded unit. */
|
|
85
|
+
async refresh(id, options) {
|
|
86
|
+
if (!this.items.has(id))
|
|
87
|
+
return;
|
|
88
|
+
const c = await this.load(id, options);
|
|
89
|
+
this.items.overwrite(id, c);
|
|
90
|
+
}
|
|
91
|
+
/** Load a list of contacts from server.
|
|
92
|
+
* @param {LoadTaskListOptions}
|
|
93
|
+
*/
|
|
94
|
+
async loadList(options) {
|
|
95
|
+
options = options !== null && options !== void 0 ? options : { Filters: [] };
|
|
96
|
+
// skip local cache with paging.
|
|
97
|
+
if (options === null || options === void 0 ? void 0 : options.Page)
|
|
98
|
+
return await this.loadUnitsFromServer(options);
|
|
99
|
+
// const reload = options.reload;
|
|
100
|
+
delete options["reload"];
|
|
101
|
+
// Calculate hash code for load options.
|
|
102
|
+
const hc = hash(options);
|
|
103
|
+
// load from server if not cached
|
|
104
|
+
if (!this._listCache.has(hc)) {
|
|
105
|
+
const result = await this.loadUnitsFromServer(options);
|
|
106
|
+
// Save cache and clear time out.
|
|
107
|
+
this._listCache.set(hc, result);
|
|
108
|
+
setTimeout(() => {
|
|
109
|
+
this._listCache.delete(hc);
|
|
110
|
+
}, 5 * 60 * 1000);
|
|
111
|
+
}
|
|
112
|
+
return this._listCache.get(hc);
|
|
113
|
+
}
|
|
114
|
+
async loadUnitsFromServer(options) {
|
|
115
|
+
const urlPostFix = options.parent ? `/${options.parent}/units` : "";
|
|
116
|
+
const r = await this._api.post(`/units${urlPostFix}`, new RequestBuilder().json(options));
|
|
117
|
+
const result = await r.json();
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
/** Load a list of team of a contact from server.
|
|
121
|
+
* @param id - id of the contact.
|
|
122
|
+
* @param {LoadUnitListOptions}
|
|
123
|
+
*/
|
|
124
|
+
async loadTeamList(id, options) {
|
|
125
|
+
invariant(id, "id cannot be empty");
|
|
126
|
+
const r = await this._api.post(`/api/groups/${id}/members`, new RequestBuilder().json(options ? options : {}));
|
|
127
|
+
return (await r.json());
|
|
128
|
+
}
|
|
129
|
+
/** Load a list of activities of a contact from server.
|
|
130
|
+
* @param id - id of the contact.
|
|
131
|
+
* @param {LoadUnitListOptions}
|
|
132
|
+
*/
|
|
133
|
+
async loadActivityList(id, options) {
|
|
134
|
+
invariant(id, "id cannot be empty");
|
|
135
|
+
let query = "";
|
|
136
|
+
if (options === null || options === void 0 ? void 0 : options.Includes) {
|
|
137
|
+
query = query.concat(`includes=${options.Includes}`);
|
|
138
|
+
}
|
|
139
|
+
if (query)
|
|
140
|
+
query = "?".concat(query);
|
|
141
|
+
const r = await this._api.post(`/units/${id}/activities${query}`, new RequestBuilder().json(options ? options : { Filters: [] }));
|
|
142
|
+
return (await r.json());
|
|
143
|
+
}
|
|
144
|
+
/** Edit an existing item on server. */
|
|
145
|
+
async edit(id, options) {
|
|
146
|
+
const r = await this._api.post(`api/units/${id}/info`, new RequestBuilder().json(options));
|
|
147
|
+
const t = await r.json();
|
|
148
|
+
this.items.overwrite(t.id, t);
|
|
149
|
+
}
|
|
150
|
+
async delete(id) {
|
|
151
|
+
await this._api.delete(`api/groups/${id}`);
|
|
152
|
+
const item = this.items.peek(id);
|
|
153
|
+
this._deleted.dispatch(this, item);
|
|
154
|
+
return item;
|
|
155
|
+
}
|
|
156
|
+
/** 把用戶從Group移除
|
|
157
|
+
* pid是小組id
|
|
158
|
+
* id 是現有用戶id (必须是用户)
|
|
159
|
+
*/
|
|
160
|
+
async deleteUser(options) {
|
|
161
|
+
await this._api.delete(`api/groups/${options.pid}/remove/${options.id}`);
|
|
162
|
+
const item = this.items.peek(options.id);
|
|
163
|
+
item.parentNodeId = options.pid;
|
|
164
|
+
this._memberDeleted.dispatch(this, item);
|
|
165
|
+
return item;
|
|
166
|
+
}
|
|
167
|
+
async moveAfter(id, afterId) {
|
|
168
|
+
await this._api.post(`api/units/${id}/move?afterId=${afterId}`);
|
|
169
|
+
}
|
|
170
|
+
cut(ids) {
|
|
171
|
+
invariant(ids, "Ids cannot be empty.");
|
|
172
|
+
this.moveIds = ids;
|
|
173
|
+
}
|
|
174
|
+
paste(target) {
|
|
175
|
+
this.move(toJS(this.moveIds), target);
|
|
176
|
+
this.moveIds = [];
|
|
177
|
+
}
|
|
178
|
+
async move(ids, targetId) {
|
|
179
|
+
const result = await this._api.post(`api/units/move`, new RequestBuilder().json({ Ids: ids, TargetId: targetId }));
|
|
180
|
+
const moved = await result.json();
|
|
181
|
+
for (const item of moved) {
|
|
182
|
+
this._created.dispatch(this, item);
|
|
183
|
+
}
|
|
184
|
+
this._deleted.dispatch(this, moved);
|
|
185
|
+
return moved;
|
|
188
186
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
})();
|
|
212
|
-
export { UnitStore };
|
|
187
|
+
}
|
|
188
|
+
__decorate([
|
|
189
|
+
observable
|
|
190
|
+
], UnitStore.prototype, "moveIds", void 0);
|
|
191
|
+
__decorate([
|
|
192
|
+
observable
|
|
193
|
+
], UnitStore.prototype, "items", void 0);
|
|
194
|
+
__decorate([
|
|
195
|
+
action
|
|
196
|
+
], UnitStore.prototype, "delete", null);
|
|
197
|
+
__decorate([
|
|
198
|
+
action
|
|
199
|
+
], UnitStore.prototype, "moveAfter", null);
|
|
200
|
+
__decorate([
|
|
201
|
+
action
|
|
202
|
+
], UnitStore.prototype, "cut", null);
|
|
203
|
+
__decorate([
|
|
204
|
+
action
|
|
205
|
+
], UnitStore.prototype, "paste", null);
|
|
206
|
+
__decorate([
|
|
207
|
+
action
|
|
208
|
+
], UnitStore.prototype, "move", null);
|
|
213
209
|
/** React hook to retrieve ContactStore */
|
|
214
210
|
export const useUnitStore = () => {
|
|
215
211
|
const context = useApplicationContext();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitStore.js","sourceRoot":"","sources":["../../../../src/modules/unit/data/UnitStore.ts"],"names":[],"mappings":";AAAA,OAAO,EAAe,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAe,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAG5F,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,SAAS,GAAG,WAAW,CAAC;AAqD9B
|
|
1
|
+
{"version":3,"file":"UnitStore.js","sourceRoot":"","sources":["../../../../src/modules/unit/data/UnitStore.ts"],"names":[],"mappings":";AAAA,OAAO,EAAe,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAe,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAG5F,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,SAAS,GAAG,WAAW,CA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AM,MAAM,CAAC,IAAI,EAAE,CAAC;QAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACzB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACnC;QACD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACpC,OAAO,KAAK,CAAC;IACd,CAAC;CACD;AAhOY;IAAX,UAAU;0CAA+B;AAwB1C;IAFC,UAAU;wCAKT;AA0IF;IAFC,MAAM;uCAON;AAmBD;IALC,MAAM;0CAON;AAID;IAFC,MAAM;oCAKN;AAID;IAFC,MAAM;sCAKN;AAOD;IALC,MAAM;qCAgBN;AAGF,0CAA0C;AAC1C,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE;IAChC,MAAM,OAAO,GAAG,qBAAqB,EAAE,CAAC;IACxC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;KAC7D;IACD,OAAO,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe,CAAC;AAClD,CAAC,CAAC"}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { observable } from "mobx";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
this.types = [];
|
|
7
|
-
}
|
|
3
|
+
export class State {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.types = [];
|
|
8
6
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
})();
|
|
17
|
-
export { State };
|
|
7
|
+
}
|
|
8
|
+
__decorate([
|
|
9
|
+
observable
|
|
10
|
+
], State.prototype, "types", void 0);
|
|
11
|
+
__decorate([
|
|
12
|
+
observable
|
|
13
|
+
], State.prototype, "filterType", void 0);
|
|
18
14
|
//# sourceMappingURL=state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../../../../src/modules/unit/pages/UnitTreeView/state.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../../../../src/modules/unit/pages/UnitTreeView/state.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,MAAM,OAAO,KAAK;IAAlB;QACoB,UAAK,GAAa,EAAE,CAAC;IAEzC,CAAC;CAAA;AAFY;IAAX,UAAU;oCAA6B;AAC5B;IAAX,UAAU;yCAA6C"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useDocument, useDocumentStore } from "../../../data";
|
|
2
|
+
import DocumentHeader from "../../../components/DocumentHeader";
|
|
3
|
+
import DocumentList from "../../../components/DocumentList";
|
|
4
|
+
import { FontAwesomeIcon as FAIcon } from "@fortawesome/react-fontawesome";
|
|
5
|
+
import PageDefaultView from "../../Page/PageDefaultView";
|
|
6
|
+
import React from "react";
|
|
7
|
+
import RichTextEditor from "@voplus/morpho-ui/es/controls/RichTextEditor";
|
|
8
|
+
import { Skeleton } from "@voplus/antd";
|
|
9
|
+
import TextEditor from "@voplus/morpho-text/es/components/TextEditor";
|
|
10
|
+
import { faEdit } from "@fortawesome/pro-light-svg-icons";
|
|
11
|
+
import { useObserver } from "mobx-react-lite";
|
|
12
|
+
const Content = (props) => {
|
|
13
|
+
const store = useDocumentStore();
|
|
14
|
+
const doc = useDocument(props.contentId, { reload: i => !i.path, includes: "tags,path" });
|
|
15
|
+
return useObserver(() => (React.createElement("div", { className: "library-default-view_content" }, !doc || !doc.loaded ? (React.createElement(Skeleton, null)) : doc.type === "Text" && doc.parentNodeId === props.id ? (
|
|
16
|
+
/* Type 为 Text且 parentNode的 type 不为Page */
|
|
17
|
+
React.createElement(React.Fragment, null,
|
|
18
|
+
React.createElement(DocumentHeader, { id: props.contentId, size: "h2" }),
|
|
19
|
+
React.createElement(TextEditor, { id: props.contentId, textOnly: doc.readonly, className: "library-padding" }))) : doc.type === "Library" ? (
|
|
20
|
+
/* Type 为 Library */
|
|
21
|
+
React.createElement(React.Fragment, null,
|
|
22
|
+
React.createElement(DocumentHeader, { id: props.contentId, size: "h2" }),
|
|
23
|
+
React.createElement("div", { className: "library-padding" }, doc.loading ? (React.createElement(Skeleton, { active: true })) : (React.createElement(RichTextEditor, { editable: false, readOnly: doc.status === "Readonly", placeholder: doc.status === "Readonly" ? ("No description") : (React.createElement("span", null,
|
|
24
|
+
React.createElement(FAIcon, { icon: faEdit }),
|
|
25
|
+
"Add Description")), content: doc.description || "", onSave: v => store.edit(props.id, { Description: v }) }))),
|
|
26
|
+
React.createElement(DocumentList, { id: props.id, multiple: true }))) : (
|
|
27
|
+
/* Type 为 Page or Type 为 Text且parentNode type为Page */
|
|
28
|
+
React.createElement(PageDefaultView, { id: props.contentId, expand: false })))));
|
|
29
|
+
};
|
|
30
|
+
export default Content;
|
|
31
|
+
//# sourceMappingURL=Content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Content.js","sourceRoot":"","sources":["../../../../src/pages/Library/LibraryDefaultView/Content.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,cAAc,MAAM,oCAAoC,CAAC;AAChE,OAAO,YAAY,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,eAAe,IAAI,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,eAAe,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,cAAc,MAAM,8CAA8C,CAAC;AAC1E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EAAC,iBAAiB,IAC9B,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CACd,oBAAC,QAAQ,IAAC,MAAM,SAAG,CACnB,CAAC,CAAC,CAAC,CACH,oBAAC,cAAc,IACd,QAAQ,EAAE,KAAK,EACf,QAAQ,EAAE,GAAG,CAAC,MAAM,KAAK,UAAU,EACnC,WAAW,EACV,GAAG,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,CAC3B,gBAAgB,CAChB,CAAC,CAAC,CAAC,CACH;gBACC,oBAAC,MAAM,IAAC,IAAI,EAAE,MAAM,GAAI;kCAElB,CACP,EAEF,OAAO,EAAE,GAAG,CAAC,WAAW,IAAI,EAAE,EAC9B,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,GACpD,CACF,CACI;QACN,oBAAC,YAAY,IAAC,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,QAAQ,SAAG,CACvB,CACjB,CAAC,CAAC,CAAC;IACH,sDAAsD;IACtD,oBAAC,eAAe,IAAC,EAAE,EAAE,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,GAAI,CACvD,CACI,CACN,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import "./index.less";
|
|
2
|
+
import { DownSquareOutlined, UpSquareOutlined } from "@ant-design/icons";
|
|
3
|
+
import { Menu, Tooltip } from "@voplus/antd";
|
|
4
|
+
import React, { useEffect, useState } from "react";
|
|
5
|
+
import { useDocumentStore } from "../../../data";
|
|
6
|
+
import Content from "./Content";
|
|
7
|
+
import DocumentSortableTree from "../../../components/DocumentSortableTree";
|
|
8
|
+
import FileExplorerTheme from "../../../components/DocumentSortableTree/themes/FileExplorerTheme";
|
|
9
|
+
import MainContent from "@voplus/morpho-ui/es/components/layout/MainContent";
|
|
10
|
+
import NewDocumentForm from "../../../components/NewDocumentForm";
|
|
11
|
+
import PlusDropDown from "../../../pages/Page/PlusDropDown";
|
|
12
|
+
import { SearchOutlined } from "@ant-design/icons";
|
|
13
|
+
import { State } from "./state";
|
|
14
|
+
import TimeoutInput from "@voplus/morpho-ui/es/controls/TimeoutInput";
|
|
15
|
+
import { useLibrary } from "../data";
|
|
16
|
+
import { useObserver } from "mobx-react-lite";
|
|
17
|
+
import { useRenderOnChange } from "@voplus/morpho-ui";
|
|
18
|
+
import { useRouteMatch } from "react-router";
|
|
19
|
+
import { useTabItem } from "@voplus/morpho-data";
|
|
20
|
+
const LibraryDefaultView = () => {
|
|
21
|
+
const match = useRouteMatch();
|
|
22
|
+
const id = match.params.id;
|
|
23
|
+
const library = useLibrary(id, { reload: true, includes: "tags" });
|
|
24
|
+
const store = useDocumentStore();
|
|
25
|
+
const tab = useTabItem();
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
tab.title = library.name;
|
|
28
|
+
}, []);
|
|
29
|
+
const [state] = useState(new State(id));
|
|
30
|
+
useRenderOnChange(() => state.filterType);
|
|
31
|
+
return useObserver(() => (React.createElement(MainContent, { className: "library-default-view" },
|
|
32
|
+
React.createElement("nav", null,
|
|
33
|
+
React.createElement("div", { className: "toc-tree-header" },
|
|
34
|
+
React.createElement("div", null,
|
|
35
|
+
React.createElement(TimeoutInput, { suffix: React.createElement(SearchOutlined, null), allowClear: true, onIdle: e => (state.filterType = { c: "Name", o: "contains", v1: e, l: "And" }) }),
|
|
36
|
+
React.createElement(Tooltip, { title: state.collapse ? "Expand All" : "Collapse All" },
|
|
37
|
+
React.createElement("span", { className: "collapse-icon", onClick: () => {
|
|
38
|
+
state.collapse = !state.collapse;
|
|
39
|
+
} }, state.collapse ? React.createElement(DownSquareOutlined, null) : React.createElement(UpSquareOutlined, null))),
|
|
40
|
+
React.createElement(PlusDropDown, { menu: React.createElement(Menu, { onClick: selectType },
|
|
41
|
+
React.createElement(Menu.Item, { key: "document" }, "Folder"),
|
|
42
|
+
React.createElement(Menu.Item, { key: "page" }, "Page"),
|
|
43
|
+
React.createElement(Menu.Item, { key: "text" }, "Text")) }))),
|
|
44
|
+
React.createElement(DocumentSortableTree, { id: id, canDrag: false, filterType: state.filterType, theme: FileExplorerTheme, onDocumentSelected: onClickDoc }),
|
|
45
|
+
state.addAble && (React.createElement(NewDocumentForm, { parentId: id, type: state.type, onCancel: () => (state.addAble = false) }))),
|
|
46
|
+
React.createElement(Content, { id: id, contentId: state.contentId }))));
|
|
47
|
+
/** Selected Library document type */
|
|
48
|
+
function selectType({ key }) {
|
|
49
|
+
state.type = key;
|
|
50
|
+
state.addAble = true;
|
|
51
|
+
}
|
|
52
|
+
function onClickDoc(id) {
|
|
53
|
+
const document = store.items.peek(id);
|
|
54
|
+
if (document.type === "Document")
|
|
55
|
+
return;
|
|
56
|
+
state.contentId =
|
|
57
|
+
document.parentNodeId !== library.id && document.type === "Text"
|
|
58
|
+
? document.parentNodeId || ""
|
|
59
|
+
: id;
|
|
60
|
+
scrollToAnchor(id);
|
|
61
|
+
}
|
|
62
|
+
function scrollToAnchor(anchorName) {
|
|
63
|
+
if (anchorName) {
|
|
64
|
+
// 查找锚点
|
|
65
|
+
const anchorElement = document.getElementById(anchorName);
|
|
66
|
+
// 如果对应id的锚点存在,跳转到锚点
|
|
67
|
+
if (anchorElement) {
|
|
68
|
+
anchorElement.scrollIntoView({ block: "end", behavior: "smooth" });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
export default LibraryDefaultView;
|
|
74
|
+
//# sourceMappingURL=index.js.map
|