@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.
Files changed (220) hide show
  1. package/changelog.md +2 -0
  2. package/es/components/ActivityLog/state.js +50 -54
  3. package/es/components/ActivityLog/state.js.map +1 -1
  4. package/es/components/AddDocDropdown/state.js +93 -97
  5. package/es/components/AddDocDropdown/state.js.map +1 -1
  6. package/es/components/AvatarList/state.js +46 -50
  7. package/es/components/AvatarList/state.js.map +1 -1
  8. package/es/components/BreadCrumbsHeader/state.js +33 -37
  9. package/es/components/BreadCrumbsHeader/state.js.map +1 -1
  10. package/es/components/DocumentCard/index.d.ts +10 -0
  11. package/es/components/DocumentCard/index.js +36 -0
  12. package/es/components/DocumentCard/index.js.map +1 -0
  13. package/es/components/DocumentCard/index.less +109 -0
  14. package/es/components/DocumentCard/state.d.ts +15 -0
  15. package/es/components/DocumentCard/state.js +67 -0
  16. package/es/components/DocumentCard/state.js.map +1 -0
  17. package/es/components/DocumentHeader/index.d.ts +1 -0
  18. package/es/components/DocumentHeader/index.js +11 -5
  19. package/es/components/DocumentHeader/index.js.map +1 -1
  20. package/es/components/DocumentHeader/index.less +4 -4
  21. package/es/components/DocumentHeader/state.d.ts +2 -0
  22. package/es/components/DocumentHeader/state.js +63 -67
  23. package/es/components/DocumentHeader/state.js.map +1 -1
  24. package/es/components/DocumentItem/state.js +44 -48
  25. package/es/components/DocumentItem/state.js.map +1 -1
  26. package/es/components/DocumentList/state.js +212 -216
  27. package/es/components/DocumentList/state.js.map +1 -1
  28. package/es/components/DocumentListView/state.js +8 -12
  29. package/es/components/DocumentListView/state.js.map +1 -1
  30. package/es/components/DocumentMenu/state.js +74 -78
  31. package/es/components/DocumentMenu/state.js.map +1 -1
  32. package/es/components/DocumentSelectDialog/index.js +1 -1
  33. package/es/components/DocumentSelectDialog/index.js.map +1 -1
  34. package/es/components/DocumentSelectDialog/state.js +68 -72
  35. package/es/components/DocumentSelectDialog/state.js.map +1 -1
  36. package/es/components/DocumentSortableTree/index.js +2 -2
  37. package/es/components/DocumentSortableTree/index.js.map +1 -1
  38. package/es/components/DocumentSortableTree/state.js +171 -175
  39. package/es/components/DocumentSortableTree/state.js.map +1 -1
  40. package/es/components/DocumentSortableTree/themes/FileExplorerTheme/index.js.map +1 -0
  41. package/es/components/{FileExplorerTheme → DocumentSortableTree/themes/FileExplorerTheme}/node-content-renderer.js +3 -3
  42. package/es/components/DocumentSortableTree/themes/FileExplorerTheme/node-content-renderer.js.map +1 -0
  43. package/es/components/DocumentSortableTree/themes/FileExplorerTheme/tree-node-renderer.js.map +1 -0
  44. package/es/components/DocumentSortableTree/themes/SortableTreeDocumentTheme/index.js.map +1 -0
  45. package/es/components/{SortableTreeDocumentTheme → DocumentSortableTree/themes/SortableTreeDocumentTheme}/node-content-renderer.js +1 -1
  46. package/es/components/DocumentSortableTree/themes/SortableTreeDocumentTheme/node-content-renderer.js.map +1 -0
  47. package/es/components/DocumentSortableTree/themes/SortableTreeDocumentTheme/tree-node-renderer.js.map +1 -0
  48. package/es/components/DocumentTree/state.js +82 -86
  49. package/es/components/DocumentTree/state.js.map +1 -1
  50. package/es/components/FileViewer/ImageViewer.js +1 -1
  51. package/es/components/FileViewer/ImageViewer.js.map +1 -1
  52. package/es/components/Links/state.js +63 -67
  53. package/es/components/Links/state.js.map +1 -1
  54. package/es/components/NewDocumentForm/state.js +35 -39
  55. package/es/components/NewDocumentForm/state.js.map +1 -1
  56. package/es/components/PeopleAccess/PeopleAccessState.js +132 -136
  57. package/es/components/PeopleAccess/PeopleAccessState.js.map +1 -1
  58. package/es/components/PublishModal/state.js +10 -14
  59. package/es/components/PublishModal/state.js.map +1 -1
  60. package/es/components/QuickAccessSearch/state.js +59 -63
  61. package/es/components/QuickAccessSearch/state.js.map +1 -1
  62. package/es/components/QuickViewDialog/state.js +22 -26
  63. package/es/components/QuickViewDialog/state.js.map +1 -1
  64. package/es/components/TagView/state.js +59 -63
  65. package/es/components/TagView/state.js.map +1 -1
  66. package/es/components/VersionsModal/state.js +23 -27
  67. package/es/components/VersionsModal/state.js.map +1 -1
  68. package/es/controls/DocumentStatusLabel/index.js +3 -1
  69. package/es/controls/DocumentStatusLabel/index.js.map +1 -1
  70. package/es/controls/DocumentStatusLabel/index.less +7 -1
  71. package/es/controls/FlagIcon/index.js +1 -1
  72. package/es/controls/FlagIcon/index.js.map +1 -1
  73. package/es/controls/FlagIcon/index.less +4 -4
  74. package/es/controls/ToolBar/state.js +143 -147
  75. package/es/controls/ToolBar/state.js.map +1 -1
  76. package/es/controls/filters/CreateDateFilter/state.js +27 -31
  77. package/es/controls/filters/CreateDateFilter/state.js.map +1 -1
  78. package/es/controls/filters/DocumentStatusFilter/state.js +38 -42
  79. package/es/controls/filters/DocumentStatusFilter/state.js.map +1 -1
  80. package/es/controls/filters/DocumentTypeFilter/state.js +48 -52
  81. package/es/controls/filters/DocumentTypeFilter/state.js.map +1 -1
  82. package/es/controls/filters/FlagFilter/state.js +46 -50
  83. package/es/controls/filters/FlagFilter/state.js.map +1 -1
  84. package/es/data/DocumentMetaStore.js +34 -38
  85. package/es/data/DocumentMetaStore.js.map +1 -1
  86. package/es/data/DocumentStore/DocumentStore.js +228 -232
  87. package/es/data/DocumentStore/DocumentStore.js.map +1 -1
  88. package/es/data/contexts/DocumentListContext/index.js +30 -34
  89. package/es/data/contexts/DocumentListContext/index.js.map +1 -1
  90. package/es/data/metas/FileTypeMeta.js +21 -25
  91. package/es/data/metas/FileTypeMeta.js.map +1 -1
  92. package/es/data/metas/ShortcutMeta.js +22 -26
  93. package/es/data/metas/ShortcutMeta.js.map +1 -1
  94. package/es/modules/unit/components/ActivityLog/state.js +15 -19
  95. package/es/modules/unit/components/ActivityLog/state.js.map +1 -1
  96. package/es/modules/unit/components/AddUnitDropdown/state.js +75 -79
  97. package/es/modules/unit/components/AddUnitDropdown/state.js.map +1 -1
  98. package/es/modules/unit/components/BreadCrumbsHeader/state.js +14 -18
  99. package/es/modules/unit/components/BreadCrumbsHeader/state.js.map +1 -1
  100. package/es/modules/unit/components/Members/state.js +21 -25
  101. package/es/modules/unit/components/Members/state.js.map +1 -1
  102. package/es/modules/unit/components/NewUnitForm/state.js +43 -47
  103. package/es/modules/unit/components/NewUnitForm/state.js.map +1 -1
  104. package/es/modules/unit/components/SubUnitList/state.js +28 -32
  105. package/es/modules/unit/components/SubUnitList/state.js.map +1 -1
  106. package/es/modules/unit/components/UnitDetails/state.js +20 -24
  107. package/es/modules/unit/components/UnitDetails/state.js.map +1 -1
  108. package/es/modules/unit/components/UnitHead/state.js +5 -9
  109. package/es/modules/unit/components/UnitHead/state.js.map +1 -1
  110. package/es/modules/unit/components/UnitItem/state.js +16 -20
  111. package/es/modules/unit/components/UnitItem/state.js.map +1 -1
  112. package/es/modules/unit/components/UnitList/state.js +27 -31
  113. package/es/modules/unit/components/UnitList/state.js.map +1 -1
  114. package/es/modules/unit/components/UnitSortableTree/state.js +153 -157
  115. package/es/modules/unit/components/UnitSortableTree/state.js.map +1 -1
  116. package/es/modules/unit/controls/ContactSelect/state.js +36 -40
  117. package/es/modules/unit/controls/ContactSelect/state.js.map +1 -1
  118. package/es/modules/unit/controls/ToolBar/ContactMenu/state.js +64 -68
  119. package/es/modules/unit/controls/ToolBar/ContactMenu/state.js.map +1 -1
  120. package/es/modules/unit/controls/ToolBar/state.js +58 -62
  121. package/es/modules/unit/controls/ToolBar/state.js.map +1 -1
  122. package/es/modules/unit/controls/UnitTypeFilter/state.js +55 -59
  123. package/es/modules/unit/controls/UnitTypeFilter/state.js.map +1 -1
  124. package/es/modules/unit/data/UnitContext/index.js +20 -24
  125. package/es/modules/unit/data/UnitContext/index.js.map +1 -1
  126. package/es/modules/unit/data/UnitStore.js +198 -202
  127. package/es/modules/unit/data/UnitStore.js.map +1 -1
  128. package/es/modules/unit/pages/UnitTreeView/state.js +10 -14
  129. package/es/modules/unit/pages/UnitTreeView/state.js.map +1 -1
  130. package/es/pages/Library/LibraryDefaultView/Content.d.ts +6 -0
  131. package/es/pages/Library/LibraryDefaultView/Content.js +31 -0
  132. package/es/pages/Library/LibraryDefaultView/Content.js.map +1 -0
  133. package/es/pages/Library/LibraryDefaultView/index.d.ts +4 -0
  134. package/es/pages/Library/LibraryDefaultView/index.js +74 -0
  135. package/es/pages/Library/LibraryDefaultView/index.js.map +1 -0
  136. package/es/pages/Library/LibraryDefaultView/index.less +54 -0
  137. package/es/pages/Library/LibraryDefaultView/state.d.ts +14 -0
  138. package/es/pages/Library/LibraryDefaultView/state.js +31 -0
  139. package/es/pages/Library/LibraryDefaultView/state.js.map +1 -0
  140. package/es/pages/Library/data/LibraryStore.d.ts +10 -0
  141. package/es/pages/Library/data/LibraryStore.js +16 -0
  142. package/es/pages/Library/data/LibraryStore.js.map +1 -0
  143. package/es/pages/Library/data/hook.d.ts +2 -0
  144. package/es/pages/Library/data/hook.js +10 -0
  145. package/es/pages/Library/data/hook.js.map +1 -0
  146. package/es/pages/Library/data/index.d.ts +3 -0
  147. package/es/pages/Library/data/index.js +4 -0
  148. package/es/pages/Library/data/index.js.map +1 -0
  149. package/es/pages/Library/data/interfaces.d.ts +2 -0
  150. package/es/pages/Library/data/interfaces.js +1 -0
  151. package/es/pages/Library/data/interfaces.js.map +1 -0
  152. package/es/pages/Page/PageDefaultView/index.d.ts +12 -0
  153. package/es/pages/Page/PageDefaultView/index.js +97 -0
  154. package/es/pages/Page/PageDefaultView/index.js.map +1 -0
  155. package/es/pages/Page/PageDefaultView/index.less +49 -0
  156. package/es/pages/Page/PageDefaultView/state.d.ts +7 -0
  157. package/es/pages/Page/PageDefaultView/state.js +15 -0
  158. package/es/pages/Page/PageDefaultView/state.js.map +1 -0
  159. package/es/pages/Page/PageTextItem/index.d.ts +7 -0
  160. package/es/pages/Page/PageTextItem/index.js +39 -0
  161. package/es/pages/Page/PageTextItem/index.js.map +1 -0
  162. package/es/pages/Page/PageTextItem/index.less +31 -0
  163. package/es/pages/Page/PageTextItem/state.d.ts +9 -0
  164. package/es/pages/Page/PageTextItem/state.js +22 -0
  165. package/es/pages/Page/PageTextItem/state.js.map +1 -0
  166. package/es/pages/Page/PlusDropDown/index.d.ts +7 -0
  167. package/es/pages/Page/PlusDropDown/index.js +14 -0
  168. package/es/pages/Page/PlusDropDown/index.js.map +1 -0
  169. package/es/pages/Page/PlusDropDown/index.less +11 -0
  170. package/es/pages/Page/data/IPageItemState.d.ts +4 -0
  171. package/es/pages/Page/data/IPageItemState.js +1 -0
  172. package/es/pages/Page/data/IPageItemState.js.map +1 -0
  173. package/es/pages/Page/data/PageContext.d.ts +18 -0
  174. package/es/pages/Page/data/PageContext.js +48 -0
  175. package/es/pages/Page/data/PageContext.js.map +1 -0
  176. package/es/pages/Page/data/PageStore.d.ts +10 -0
  177. package/es/pages/Page/data/PageStore.js +16 -0
  178. package/es/pages/Page/data/PageStore.js.map +1 -0
  179. package/es/pages/Page/data/hook.d.ts +2 -0
  180. package/es/pages/Page/data/hook.js +10 -0
  181. package/es/pages/Page/data/hook.js.map +1 -0
  182. package/es/pages/Page/data/index.d.ts +3 -0
  183. package/es/pages/Page/data/index.js +4 -0
  184. package/es/pages/Page/data/index.js.map +1 -0
  185. package/es/pages/Page/data/interfaces.d.ts +2 -0
  186. package/es/pages/Page/data/interfaces.js +1 -0
  187. package/es/pages/Page/data/interfaces.js.map +1 -0
  188. package/es/pages/TreeViewPage/state.js +10 -14
  189. package/es/pages/TreeViewPage/state.js.map +1 -1
  190. package/es/routes.d.ts +20 -0
  191. package/es/routes.js +27 -1
  192. package/es/routes.js.map +1 -1
  193. package/package.json +7 -7
  194. package/es/components/FileExplorerTheme/index.js.map +0 -1
  195. package/es/components/FileExplorerTheme/node-content-renderer.js.map +0 -1
  196. package/es/components/FileExplorerTheme/tree-node-renderer.js.map +0 -1
  197. package/es/components/SortableTreeDocumentTheme/index.js.map +0 -1
  198. package/es/components/SortableTreeDocumentTheme/node-content-renderer.js.map +0 -1
  199. package/es/components/SortableTreeDocumentTheme/tree-node-renderer.js.map +0 -1
  200. package/es/controls/Panable/index.d.ts +0 -7
  201. package/es/controls/Panable/index.js +0 -65
  202. package/es/controls/Panable/index.js.map +0 -1
  203. package/es/controls/Panable/index.less +0 -15
  204. package/es/controls/Panable/state.d.ts +0 -9
  205. package/es/controls/Panable/state.js +0 -39
  206. package/es/controls/Panable/state.js.map +0 -1
  207. /package/es/components/{FileExplorerTheme → DocumentSortableTree/themes/FileExplorerTheme}/index.d.ts +0 -0
  208. /package/es/components/{FileExplorerTheme → DocumentSortableTree/themes/FileExplorerTheme}/index.js +0 -0
  209. /package/es/components/{FileExplorerTheme → DocumentSortableTree/themes/FileExplorerTheme}/node-content-renderer.d.ts +0 -0
  210. /package/es/components/{FileExplorerTheme → DocumentSortableTree/themes/FileExplorerTheme}/node-content-renderer.less +0 -0
  211. /package/es/components/{FileExplorerTheme → DocumentSortableTree/themes/FileExplorerTheme}/tree-node-renderer.d.ts +0 -0
  212. /package/es/components/{FileExplorerTheme → DocumentSortableTree/themes/FileExplorerTheme}/tree-node-renderer.js +0 -0
  213. /package/es/components/{FileExplorerTheme → DocumentSortableTree/themes/FileExplorerTheme}/tree-node-renderer.less +0 -0
  214. /package/es/components/{SortableTreeDocumentTheme → DocumentSortableTree/themes/SortableTreeDocumentTheme}/index.d.ts +0 -0
  215. /package/es/components/{SortableTreeDocumentTheme → DocumentSortableTree/themes/SortableTreeDocumentTheme}/index.js +0 -0
  216. /package/es/components/{SortableTreeDocumentTheme → DocumentSortableTree/themes/SortableTreeDocumentTheme}/node-content-renderer.d.ts +0 -0
  217. /package/es/components/{SortableTreeDocumentTheme → DocumentSortableTree/themes/SortableTreeDocumentTheme}/node-content-renderer.less +0 -0
  218. /package/es/components/{SortableTreeDocumentTheme → DocumentSortableTree/themes/SortableTreeDocumentTheme}/tree-node-renderer.d.ts +0 -0
  219. /package/es/components/{SortableTreeDocumentTheme → DocumentSortableTree/themes/SortableTreeDocumentTheme}/tree-node-renderer.js +0 -0
  220. /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
- let UnitStore = /** @class */ (() => {
11
- class UnitStore extends Store {
12
- constructor(_api) {
13
- super();
14
- this._api = _api;
15
- this.name = StoreName;
16
- /** Contac created event dispatcher */
17
- this._created = new EventDispatcher();
18
- this._deleted = new EventDispatcher();
19
- this._memberCreated = new EventDispatcher();
20
- this._memberDeleted = new EventDispatcher();
21
- /** Id of documents to be moved. */
22
- this.moveIds = [];
23
- this.items = new CountedMap((key) => UnitStore.createDefaultContact({ id: key }), observable.map([], { deep: true }));
24
- this._listCache = new Map();
25
- invariant(_api, `API cannot be ${_api}.`);
26
- }
27
- /** Event fires when a new unit has been created. */
28
- get UnitCreatedEvent() {
29
- return this._created.asEvent();
30
- }
31
- /** Event fires when a delete contact has been deleted. */
32
- get UnitDeletedEvent() {
33
- return this._deleted.asEvent();
34
- }
35
- /** Event fires when a new member has been created. */
36
- get MemberCreatedEvent() {
37
- return this._memberCreated.asEvent();
38
- }
39
- /** Event fires when a delete member has been deleted. */
40
- get MemberDeletedEvent() {
41
- return this._memberDeleted.asEvent();
42
- }
43
- /** Create a default contact object with optional default values. */
44
- static createDefaultContact(defaultValues) {
45
- const v = { loaded: false, address: {}, primaryLegalIdentity: {} };
46
- if (defaultValues)
47
- Object.assign(v, defaultValues);
48
- return v;
49
- }
50
- /** Create a new contact base on type. */
51
- async createFromType(options) {
52
- invariant(options.name, "Name cannot be empty.");
53
- const r = await this._api.post(`api/groups/create`, new RequestBuilder().form(options));
54
- const t = (await r.json());
55
- this._created.dispatch(this, t);
56
- console.log("createFromType", t);
57
- return t;
58
- }
59
- /** 新增用戶至Group.
60
- * pid是小組id type必须是Team
61
- * id 是現有用戶id (必须是用户)
62
- */
63
- async addUserFromGroup(options) {
64
- // invariant(options.name, "Name cannot be empty.");
65
- const r = await this._api.post(`/api/groups/${options.pid}/add/${options.id}`);
66
- const t = (await r.json());
67
- t.parentNodeId = options.pid;
68
- this._memberCreated.dispatch(this, t);
69
- console.log("addUserFromGroup", t);
70
- return t;
71
- }
72
- /** Load a task from server.
73
- * @param {string} id - id of the task.
74
- * @param {LoadTaskOptions} options - Optional load options.
75
- */
76
- async load(id, options) {
77
- let query = "";
78
- if (options.includes)
79
- query = query.concat(`includes=${options.includes}`);
80
- if (query)
81
- query = "?".concat(query);
82
- const r = await this._api.get(`/units/${id}${query}`);
83
- return (await r.json());
84
- }
85
- /** Refresh a loaded unit. */
86
- async refresh(id, options) {
87
- if (!this.items.has(id))
88
- return;
89
- const c = await this.load(id, options);
90
- this.items.overwrite(id, c);
91
- }
92
- /** Load a list of contacts from server.
93
- * @param {LoadTaskListOptions}
94
- */
95
- async loadList(options) {
96
- options = options !== null && options !== void 0 ? options : { Filters: [] };
97
- // skip local cache with paging.
98
- if (options === null || options === void 0 ? void 0 : options.Page)
99
- return await this.loadUnitsFromServer(options);
100
- // const reload = options.reload;
101
- delete options["reload"];
102
- // Calculate hash code for load options.
103
- const hc = hash(options);
104
- // load from server if not cached
105
- if (!this._listCache.has(hc)) {
106
- const result = await this.loadUnitsFromServer(options);
107
- // Save cache and clear time out.
108
- this._listCache.set(hc, result);
109
- setTimeout(() => {
110
- this._listCache.delete(hc);
111
- }, 5 * 60 * 1000);
112
- }
113
- return this._listCache.get(hc);
114
- }
115
- async loadUnitsFromServer(options) {
116
- const urlPostFix = options.parent ? `/${options.parent}/units` : "";
117
- const r = await this._api.post(`/units${urlPostFix}`, new RequestBuilder().json(options));
118
- const result = await r.json();
119
- return result;
120
- }
121
- /** Load a list of team of a contact from server.
122
- * @param id - id of the contact.
123
- * @param {LoadUnitListOptions}
124
- */
125
- async loadTeamList(id, options) {
126
- invariant(id, "id cannot be empty");
127
- const r = await this._api.post(`/api/groups/${id}/members`, new RequestBuilder().json(options ? options : {}));
128
- return (await r.json());
129
- }
130
- /** Load a list of activities of a contact from server.
131
- * @param id - id of the contact.
132
- * @param {LoadUnitListOptions}
133
- */
134
- async loadActivityList(id, options) {
135
- invariant(id, "id cannot be empty");
136
- let query = "";
137
- if (options === null || options === void 0 ? void 0 : options.Includes) {
138
- query = query.concat(`includes=${options.Includes}`);
139
- }
140
- if (query)
141
- query = "?".concat(query);
142
- const r = await this._api.post(`/units/${id}/activities${query}`, new RequestBuilder().json(options ? options : { Filters: [] }));
143
- return (await r.json());
144
- }
145
- /** Edit an existing item on server. */
146
- async edit(id, options) {
147
- const r = await this._api.post(`api/units/${id}/info`, new RequestBuilder().json(options));
148
- const t = await r.json();
149
- this.items.overwrite(t.id, t);
150
- }
151
- async delete(id) {
152
- await this._api.delete(`api/groups/${id}`);
153
- const item = this.items.peek(id);
154
- this._deleted.dispatch(this, item);
155
- return item;
156
- }
157
- /** 把用戶從Group移除
158
- * pid是小組id
159
- * id 是現有用戶id (必须是用户)
160
- */
161
- async deleteUser(options) {
162
- await this._api.delete(`api/groups/${options.pid}/remove/${options.id}`);
163
- const item = this.items.peek(options.id);
164
- item.parentNodeId = options.pid;
165
- this._memberDeleted.dispatch(this, item);
166
- return item;
167
- }
168
- async moveAfter(id, afterId) {
169
- await this._api.post(`api/units/${id}/move?afterId=${afterId}`);
170
- }
171
- cut(ids) {
172
- invariant(ids, "Ids cannot be empty.");
173
- this.moveIds = ids;
174
- }
175
- paste(target) {
176
- this.move(toJS(this.moveIds), target);
177
- this.moveIds = [];
178
- }
179
- async move(ids, targetId) {
180
- const result = await this._api.post(`api/units/move`, new RequestBuilder().json({ Ids: ids, TargetId: targetId }));
181
- const moved = await result.json();
182
- for (const item of moved) {
183
- this._created.dispatch(this, item);
184
- }
185
- this._deleted.dispatch(this, moved);
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
- __decorate([
190
- observable
191
- ], UnitStore.prototype, "moveIds", void 0);
192
- __decorate([
193
- observable
194
- ], UnitStore.prototype, "items", void 0);
195
- __decorate([
196
- action
197
- ], UnitStore.prototype, "delete", null);
198
- __decorate([
199
- action
200
- ], UnitStore.prototype, "moveAfter", null);
201
- __decorate([
202
- action
203
- ], UnitStore.prototype, "cut", null);
204
- __decorate([
205
- action
206
- ], UnitStore.prototype, "paste", null);
207
- __decorate([
208
- action
209
- ], UnitStore.prototype, "move", null);
210
- return UnitStore;
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;IAAA,MAAa,SAAU,SAAQ,KAAK;QAQnC,YAAoC,IAAiB;YACpD,KAAK,EAAE,CAAC;YAD2B,SAAI,GAAJ,IAAI,CAAa;YAPrC,SAAI,GAAW,SAAS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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
- let State = /** @class */ (() => {
4
- class State {
5
- constructor() {
6
- this.types = [];
7
- }
3
+ export class State {
4
+ constructor() {
5
+ this.types = [];
8
6
  }
9
- __decorate([
10
- observable
11
- ], State.prototype, "types", void 0);
12
- __decorate([
13
- observable
14
- ], State.prototype, "filterType", void 0);
15
- return State;
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;IAAA,MAAa,KAAK;QAAlB;YACoB,UAAK,GAAa,EAAE,CAAC;QAEzC,CAAC;KAAA;IAFY;QAAX,UAAU;wCAA6B;IAC5B;QAAX,UAAU;6CAA6C;IACzD,YAAC;KAAA;SAHY,KAAK"}
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,6 @@
1
+ /// <reference types="react" />
2
+ declare const Content: (props: {
3
+ id: string;
4
+ contentId: string;
5
+ }) => JSX.Element;
6
+ export default Content;
@@ -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,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,UAAU,MAAM,8CAA8C,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,WAAW,E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,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,4 @@
1
+ /// <reference types="react" />
2
+ import "./index.less";
3
+ declare const LibraryDefaultView: () => JSX.Element;
4
+ export default LibraryDefaultView;
@@ -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