@nocobase/plugin-multi-app-share-collection 0.11.1-alpha.5 → 0.12.0-alpha.1
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/client.d.ts +2 -3
- package/client.js +1 -1
- package/dist/client/index.js +510 -0
- package/{lib → dist}/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/locale/es-ES.js +16 -0
- package/dist/locale/pt-BR.js +16 -0
- package/dist/locale/zh-CN.js +16 -0
- package/dist/server/collections/applications.js +21 -0
- package/dist/server/collections/collections.js +21 -0
- package/dist/server/index.js +11 -0
- package/{src/server/migrations/20230319111111-update-apps-collections.ts → dist/server/migrations/20230319111111-update-apps-collections.js} +26 -33
- package/dist/server/plugin.js +278 -0
- package/package.json +16 -25
- package/server.d.ts +2 -3
- package/server.js +1 -1
- package/lib/client/MultiAppShareCollectionProvider.js +0 -122
- package/lib/client/TableTransfer.js +0 -487
- package/lib/client/index.js +0 -27
- package/lib/client/utils.js +0 -25
- package/lib/index.js +0 -13
- package/lib/locale/es-ES.js +0 -19
- package/lib/locale/pt-BR.js +0 -19
- package/lib/locale/zh-CN.js +0 -19
- package/lib/server/collections/applications.js +0 -27
- package/lib/server/collections/collections.js +0 -27
- package/lib/server/index.js +0 -13
- package/lib/server/migrations/20230319111111-update-apps-collections.js +0 -110
- package/lib/server/plugin.js +0 -408
- package/src/client/MultiAppShareCollectionProvider.tsx +0 -86
- package/src/client/TableTransfer.tsx +0 -398
- package/src/client/index.tsx +0 -10
- package/src/client/utils.tsx +0 -11
- package/src/index.ts +0 -1
- package/src/locale/es-ES.ts +0 -12
- package/src/locale/pt-BR.ts +0 -12
- package/src/locale/zh-CN.ts +0 -12
- package/src/server/__tests__/collection-sync.test.ts +0 -514
- package/src/server/__tests__/index.ts +0 -25
- package/src/server/collections/.gitkeep +0 -0
- package/src/server/collections/applications.ts +0 -17
- package/src/server/collections/collections.ts +0 -17
- package/src/server/index.ts +0 -1
- package/src/server/plugin.ts +0 -332
- /package/{lib → dist}/client/MultiAppShareCollectionProvider.d.ts +0 -0
- /package/{lib → dist}/client/TableTransfer.d.ts +0 -0
- /package/{lib → dist}/client/index.d.ts +0 -0
- /package/{lib → dist}/client/utils.d.ts +0 -0
- /package/{lib → dist}/locale/es-ES.d.ts +0 -0
- /package/{lib → dist}/locale/pt-BR.d.ts +0 -0
- /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
- /package/{lib → dist}/server/collections/applications.d.ts +0 -0
- /package/{lib → dist}/server/collections/collections.d.ts +0 -0
- /package/{lib → dist}/server/index.d.ts +0 -0
- /package/{lib → dist}/server/migrations/20230319111111-update-apps-collections.d.ts +0 -0
- /package/{lib → dist}/server/plugin.d.ts +0 -0
package/client.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export { default } from './
|
|
3
|
-
|
|
1
|
+
export * from './dist/client';
|
|
2
|
+
export { default } from './dist/client';
|
package/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('./
|
|
1
|
+
module.exports = require('./dist/client/index.js');
|
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@nocobase/client"), require("react"), require("@formily/react"), require("@nocobase/plugin-multi-app-manager/client"), require("antd"), require("@nocobase/utils/client"), require("react-i18next")) : typeof define === "function" && define.amd ? define(["exports", "@nocobase/client", "react", "@formily/react", "@nocobase/plugin-multi-app-manager/client", "antd", "@nocobase/utils/client", "react-i18next"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@nocobase/plugin-multi-app-share-collection"] = {}, global["@nocobase/client"], global.react, global["@formily/react"], global["@nocobase/plugin-multi-app-manager"], global.antd, global["@nocobase/utils"], global["react-i18next"]));
|
|
3
|
+
})(this, function(exports2, client, require$$0, react, client$2, antd, client$1, reactI18next) {
|
|
4
|
+
"use strict";
|
|
5
|
+
var jsxRuntime = { exports: {} };
|
|
6
|
+
var reactJsxRuntime_production_min = {};
|
|
7
|
+
/**
|
|
8
|
+
* @license React
|
|
9
|
+
* react-jsx-runtime.production.min.js
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the MIT license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
|
|
17
|
+
function q(c, a, g) {
|
|
18
|
+
var b, d = {}, e = null, h = null;
|
|
19
|
+
void 0 !== g && (e = "" + g);
|
|
20
|
+
void 0 !== a.key && (e = "" + a.key);
|
|
21
|
+
void 0 !== a.ref && (h = a.ref);
|
|
22
|
+
for (b in a)
|
|
23
|
+
m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
24
|
+
if (c && c.defaultProps)
|
|
25
|
+
for (b in a = c.defaultProps, a)
|
|
26
|
+
void 0 === d[b] && (d[b] = a[b]);
|
|
27
|
+
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
28
|
+
}
|
|
29
|
+
reactJsxRuntime_production_min.Fragment = l;
|
|
30
|
+
reactJsxRuntime_production_min.jsx = q;
|
|
31
|
+
reactJsxRuntime_production_min.jsxs = q;
|
|
32
|
+
{
|
|
33
|
+
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
34
|
+
}
|
|
35
|
+
var jsxRuntimeExports = jsxRuntime.exports;
|
|
36
|
+
const excludeCollections = ["users", "roles", "applications"];
|
|
37
|
+
const useCollectionsGraph = ({ removed = [] }) => {
|
|
38
|
+
const { collections } = client.useCollectionManager();
|
|
39
|
+
const findAddable = require$$0.useCallback(
|
|
40
|
+
(name) => {
|
|
41
|
+
return client$1.CollectionsGraph.connectedNodes({
|
|
42
|
+
collections,
|
|
43
|
+
nodes: [name],
|
|
44
|
+
excludes: excludeCollections
|
|
45
|
+
}).filter((name2) => removed.includes(name2));
|
|
46
|
+
},
|
|
47
|
+
[removed]
|
|
48
|
+
);
|
|
49
|
+
const findRemovable = require$$0.useCallback(
|
|
50
|
+
(name) => {
|
|
51
|
+
return client$1.CollectionsGraph.connectedNodes({
|
|
52
|
+
collections,
|
|
53
|
+
nodes: [name],
|
|
54
|
+
excludes: excludeCollections,
|
|
55
|
+
direction: "reverse"
|
|
56
|
+
}).filter((name2) => !removed.includes(name2));
|
|
57
|
+
},
|
|
58
|
+
[removed]
|
|
59
|
+
);
|
|
60
|
+
return {
|
|
61
|
+
findAddable,
|
|
62
|
+
findRemovable
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const useCollections = () => {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
const record = client.useRecord();
|
|
68
|
+
const [selected, setSelected] = require$$0.useState([]);
|
|
69
|
+
const res1 = client.useRequest(
|
|
70
|
+
{
|
|
71
|
+
url: `applications/${record.name}/collectionBlacklist:list`,
|
|
72
|
+
params: {
|
|
73
|
+
paginate: false,
|
|
74
|
+
params: {
|
|
75
|
+
fields: ["name"]
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
onSuccess(data) {
|
|
81
|
+
var _a2;
|
|
82
|
+
setSelected((_a2 = data.data) == null ? void 0 : _a2.map((data2) => data2.name));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
const res2 = client.useRequest({
|
|
87
|
+
url: `collections`,
|
|
88
|
+
params: {
|
|
89
|
+
fields: ["name", "title", "hidden", "category.name", "category.color", "category.sort"],
|
|
90
|
+
sort: "sort",
|
|
91
|
+
paginate: false
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const res3 = client.useRequest({
|
|
95
|
+
url: `collectionCategories`,
|
|
96
|
+
params: {
|
|
97
|
+
sort: "sort",
|
|
98
|
+
paginate: false
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
loading: res1.loading || res2.loading || res3.loading,
|
|
103
|
+
collections: (((_a = res2.data) == null ? void 0 : _a.data) || []).filter((item) => !item.hidden && !excludeCollections.includes(item.name)),
|
|
104
|
+
removed: selected,
|
|
105
|
+
setSelected,
|
|
106
|
+
categories: (((_b = res3.data) == null ? void 0 : _b.data) || []).map((cat) => ({ label: cat.name, value: cat.name }))
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
const includes = (text, s) => {
|
|
110
|
+
const values = Array.isArray(s) ? s : [s];
|
|
111
|
+
for (const val of values) {
|
|
112
|
+
if (text.toLowerCase().includes(val)) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
};
|
|
118
|
+
const useRemovedDataSource = ({ collections, removed }) => {
|
|
119
|
+
const [filter, setFilter] = require$$0.useState({ name: "", category: [] });
|
|
120
|
+
const dataSource = require$$0.useMemo(() => {
|
|
121
|
+
return collections.filter((collection) => {
|
|
122
|
+
const { name, title, category = [] } = collection;
|
|
123
|
+
const results = [removed.includes(collection.name)];
|
|
124
|
+
if (filter.name) {
|
|
125
|
+
results.push(includes(name, filter.name) || includes(title, filter.name));
|
|
126
|
+
}
|
|
127
|
+
if (filter.category.length > 0) {
|
|
128
|
+
results.push(category.some((item) => includes(item.name, filter.category)));
|
|
129
|
+
}
|
|
130
|
+
return !results.includes(false);
|
|
131
|
+
});
|
|
132
|
+
}, [collections, removed, filter]);
|
|
133
|
+
const setNameFilter = require$$0.useMemo(
|
|
134
|
+
() => client$1.lodash.debounce((name) => {
|
|
135
|
+
setFilter({
|
|
136
|
+
...filter,
|
|
137
|
+
name
|
|
138
|
+
});
|
|
139
|
+
}, 300),
|
|
140
|
+
[]
|
|
141
|
+
);
|
|
142
|
+
return {
|
|
143
|
+
dataSource,
|
|
144
|
+
setNameFilter,
|
|
145
|
+
setCategoryFilter: (category) => {
|
|
146
|
+
setFilter({
|
|
147
|
+
...filter,
|
|
148
|
+
category
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
const useAddedDataSource = ({ collections, removed }) => {
|
|
154
|
+
const [filter, setFilter] = require$$0.useState({ name: "", category: [] });
|
|
155
|
+
const dataSource = collections.filter((collection) => {
|
|
156
|
+
const { name, title, category = [] } = collection;
|
|
157
|
+
const results = [!removed.includes(collection.name)];
|
|
158
|
+
if (filter.name) {
|
|
159
|
+
results.push(includes(name, filter.name) || includes(title, filter.name));
|
|
160
|
+
}
|
|
161
|
+
if (filter.category.length > 0) {
|
|
162
|
+
results.push(category.some((item) => includes(item.name, filter.category)));
|
|
163
|
+
}
|
|
164
|
+
return !results.includes(false);
|
|
165
|
+
});
|
|
166
|
+
const setNameFilter = require$$0.useMemo(
|
|
167
|
+
() => client$1.lodash.debounce((name) => {
|
|
168
|
+
setFilter({
|
|
169
|
+
...filter,
|
|
170
|
+
name
|
|
171
|
+
});
|
|
172
|
+
}, 300),
|
|
173
|
+
[]
|
|
174
|
+
);
|
|
175
|
+
return {
|
|
176
|
+
dataSource,
|
|
177
|
+
setNameFilter,
|
|
178
|
+
setCategoryFilter: (category) => {
|
|
179
|
+
setFilter({
|
|
180
|
+
...filter,
|
|
181
|
+
category
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
const TableTransfer = react.connect((props) => {
|
|
187
|
+
const { onChange } = props;
|
|
188
|
+
const { loading, collections, categories, removed, setSelected } = useCollections();
|
|
189
|
+
const [selectedRowKeys1, setSelectedRowKeys1] = require$$0.useState([]);
|
|
190
|
+
const [selectedRowKeys2, setSelectedRowKeys2] = require$$0.useState([]);
|
|
191
|
+
const { findAddable, findRemovable } = useCollectionsGraph({ removed });
|
|
192
|
+
const addedDataSource = useAddedDataSource({ collections, removed });
|
|
193
|
+
const removedDataSource = useRemovedDataSource({ collections, removed });
|
|
194
|
+
const { t } = reactI18next.useTranslation("multi-app-share-collection");
|
|
195
|
+
const { modal } = antd.App.useApp();
|
|
196
|
+
const { token } = client.useToken();
|
|
197
|
+
const columns = require$$0.useMemo(
|
|
198
|
+
() => [
|
|
199
|
+
{
|
|
200
|
+
title: t("Collection display name"),
|
|
201
|
+
dataIndex: "title"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
title: t("Collection name"),
|
|
205
|
+
dataIndex: "name"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
title: t("Collection category"),
|
|
209
|
+
dataIndex: "category",
|
|
210
|
+
render: (categories2) => categories2.map((category) => /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Tag, { color: category.color, children: category.name }, category.name))
|
|
211
|
+
}
|
|
212
|
+
],
|
|
213
|
+
[]
|
|
214
|
+
);
|
|
215
|
+
if (loading) {
|
|
216
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Spin, {});
|
|
217
|
+
}
|
|
218
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
219
|
+
antd.Row,
|
|
220
|
+
{
|
|
221
|
+
gutter: 24,
|
|
222
|
+
className: client.css`
|
|
223
|
+
.ant-table-tbody > tr.ant-table-row:hover > td {
|
|
224
|
+
background: #e6f7ff;
|
|
225
|
+
cursor: pointer;
|
|
226
|
+
}
|
|
227
|
+
`,
|
|
228
|
+
children: [
|
|
229
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Col, { span: 12, children: [
|
|
230
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
231
|
+
"div",
|
|
232
|
+
{
|
|
233
|
+
className: client.css`
|
|
234
|
+
display: flex;
|
|
235
|
+
justify-content: space-between;
|
|
236
|
+
align-items: center;
|
|
237
|
+
width: 100%;
|
|
238
|
+
margin-bottom: 8px;
|
|
239
|
+
`,
|
|
240
|
+
children: [
|
|
241
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { style: { fontSize: token.fontSizeLG, color: token.colorText }, children: t("Unshared collections") }),
|
|
242
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Input.Group, { compact: true, style: { width: 360 }, children: [
|
|
243
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
244
|
+
antd.Select,
|
|
245
|
+
{
|
|
246
|
+
popupMatchSelectWidth: false,
|
|
247
|
+
onChange: (value) => {
|
|
248
|
+
removedDataSource.setCategoryFilter(value);
|
|
249
|
+
},
|
|
250
|
+
mode: "multiple",
|
|
251
|
+
style: { width: "35%" },
|
|
252
|
+
size: "middle",
|
|
253
|
+
placeholder: t("All categories"),
|
|
254
|
+
options: categories,
|
|
255
|
+
allowClear: true
|
|
256
|
+
}
|
|
257
|
+
),
|
|
258
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
259
|
+
antd.Input,
|
|
260
|
+
{
|
|
261
|
+
onChange: (e) => removedDataSource.setNameFilter(e.target.value),
|
|
262
|
+
style: { width: "65%" },
|
|
263
|
+
placeholder: t("Enter name or title..."),
|
|
264
|
+
allowClear: true
|
|
265
|
+
}
|
|
266
|
+
)
|
|
267
|
+
] })
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
),
|
|
271
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
272
|
+
antd.Table,
|
|
273
|
+
{
|
|
274
|
+
bordered: true,
|
|
275
|
+
rowKey: "name",
|
|
276
|
+
rowSelection: {
|
|
277
|
+
type: "checkbox",
|
|
278
|
+
selectedRowKeys: selectedRowKeys1,
|
|
279
|
+
onChange(selectedRowKeys) {
|
|
280
|
+
const values = removed.filter((s) => !selectedRowKeys.includes(s));
|
|
281
|
+
setSelected(values);
|
|
282
|
+
onChange(values);
|
|
283
|
+
setSelectedRowKeys1([]);
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
pagination: false,
|
|
287
|
+
size: "small",
|
|
288
|
+
columns,
|
|
289
|
+
dataSource: removedDataSource.dataSource,
|
|
290
|
+
scroll: { y: "calc(100vh - 260px)" },
|
|
291
|
+
onRow: ({ name, disabled }) => ({
|
|
292
|
+
onClick: () => {
|
|
293
|
+
if (disabled)
|
|
294
|
+
return;
|
|
295
|
+
const adding = findAddable(name);
|
|
296
|
+
const change = () => {
|
|
297
|
+
const values = removed.filter((s) => !adding.includes(s));
|
|
298
|
+
setSelected(values);
|
|
299
|
+
onChange(values);
|
|
300
|
+
};
|
|
301
|
+
if (adding.length === 1) {
|
|
302
|
+
return change();
|
|
303
|
+
}
|
|
304
|
+
modal.confirm({
|
|
305
|
+
title: t("Are you sure to add the following collections?"),
|
|
306
|
+
width: "60%",
|
|
307
|
+
content: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
308
|
+
antd.Table,
|
|
309
|
+
{
|
|
310
|
+
size: "small",
|
|
311
|
+
columns,
|
|
312
|
+
dataSource: collections.filter((collection) => adding.includes(collection.name)),
|
|
313
|
+
pagination: false,
|
|
314
|
+
scroll: { y: "60vh" }
|
|
315
|
+
}
|
|
316
|
+
) }),
|
|
317
|
+
onOk() {
|
|
318
|
+
change();
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
})
|
|
323
|
+
}
|
|
324
|
+
)
|
|
325
|
+
] }),
|
|
326
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Col, { span: 12, children: [
|
|
327
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
328
|
+
"div",
|
|
329
|
+
{
|
|
330
|
+
className: client.css`
|
|
331
|
+
display: flex;
|
|
332
|
+
justify-content: space-between;
|
|
333
|
+
align-items: center;
|
|
334
|
+
width: 100%;
|
|
335
|
+
margin-bottom: 8px;
|
|
336
|
+
`,
|
|
337
|
+
children: [
|
|
338
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { style: { fontSize: token.fontSizeLG, color: token.colorText }, children: t("Shared collections") }),
|
|
339
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Input.Group, { compact: true, style: { width: 360 }, children: [
|
|
340
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
341
|
+
antd.Select,
|
|
342
|
+
{
|
|
343
|
+
popupMatchSelectWidth: false,
|
|
344
|
+
onChange: (value) => {
|
|
345
|
+
addedDataSource.setCategoryFilter(value);
|
|
346
|
+
},
|
|
347
|
+
mode: "multiple",
|
|
348
|
+
style: { width: "35%" },
|
|
349
|
+
size: "middle",
|
|
350
|
+
placeholder: t("All categories"),
|
|
351
|
+
options: categories,
|
|
352
|
+
allowClear: true
|
|
353
|
+
}
|
|
354
|
+
),
|
|
355
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
356
|
+
antd.Input,
|
|
357
|
+
{
|
|
358
|
+
onChange: (e) => addedDataSource.setNameFilter(e.target.value),
|
|
359
|
+
style: { width: "65%" },
|
|
360
|
+
placeholder: t("Enter name or title..."),
|
|
361
|
+
allowClear: true
|
|
362
|
+
}
|
|
363
|
+
)
|
|
364
|
+
] })
|
|
365
|
+
]
|
|
366
|
+
}
|
|
367
|
+
),
|
|
368
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
369
|
+
antd.Table,
|
|
370
|
+
{
|
|
371
|
+
bordered: true,
|
|
372
|
+
rowKey: "name",
|
|
373
|
+
rowSelection: {
|
|
374
|
+
type: "checkbox",
|
|
375
|
+
selectedRowKeys: selectedRowKeys2,
|
|
376
|
+
onChange(selectedRowKeys) {
|
|
377
|
+
const values = client$1.lodash.uniq(removed.concat(selectedRowKeys));
|
|
378
|
+
setSelected(values);
|
|
379
|
+
onChange(values);
|
|
380
|
+
setSelectedRowKeys2([]);
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
pagination: false,
|
|
384
|
+
size: "small",
|
|
385
|
+
columns,
|
|
386
|
+
dataSource: addedDataSource.dataSource,
|
|
387
|
+
scroll: { y: "calc(100vh - 260px)" },
|
|
388
|
+
onRow: ({ name }) => ({
|
|
389
|
+
onClick: () => {
|
|
390
|
+
const removing = findRemovable(name);
|
|
391
|
+
const change = () => {
|
|
392
|
+
removed.push(...removing);
|
|
393
|
+
const values = client$1.lodash.uniq([...removed]);
|
|
394
|
+
setSelected(values);
|
|
395
|
+
onChange(values);
|
|
396
|
+
};
|
|
397
|
+
if (removing.length === 1) {
|
|
398
|
+
return change();
|
|
399
|
+
}
|
|
400
|
+
modal.confirm({
|
|
401
|
+
title: t("Are you sure to remove the following collections?"),
|
|
402
|
+
width: "60%",
|
|
403
|
+
content: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
404
|
+
antd.Table,
|
|
405
|
+
{
|
|
406
|
+
size: "small",
|
|
407
|
+
columns,
|
|
408
|
+
dataSource: collections.filter((collection) => removing.includes(collection.name)),
|
|
409
|
+
pagination: false,
|
|
410
|
+
scroll: { y: "60vh" }
|
|
411
|
+
}
|
|
412
|
+
) }),
|
|
413
|
+
onOk() {
|
|
414
|
+
change();
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
})
|
|
419
|
+
}
|
|
420
|
+
)
|
|
421
|
+
] })
|
|
422
|
+
]
|
|
423
|
+
}
|
|
424
|
+
) });
|
|
425
|
+
});
|
|
426
|
+
const i18nText = (text) => {
|
|
427
|
+
return `{{t("${text}", { ns: 'multi-app-share-collection' })}}`;
|
|
428
|
+
};
|
|
429
|
+
const useShareCollectionAction = () => {
|
|
430
|
+
const form = react.useForm();
|
|
431
|
+
const ctx = client.useActionContext();
|
|
432
|
+
const api = client.useAPIClient();
|
|
433
|
+
const record = client.useRecord();
|
|
434
|
+
return {
|
|
435
|
+
async run() {
|
|
436
|
+
console.log(form.values.names);
|
|
437
|
+
await api.request({
|
|
438
|
+
url: `applications/${record.name}/collectionBlacklist`,
|
|
439
|
+
data: form.values.names,
|
|
440
|
+
method: "post"
|
|
441
|
+
});
|
|
442
|
+
ctx.setVisible(false);
|
|
443
|
+
form.reset();
|
|
444
|
+
antd.message.success("Saved successfully");
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
};
|
|
448
|
+
const updateSchema = client$2.tableActionColumnSchema.properties.update;
|
|
449
|
+
const deleteSchema = client$2.tableActionColumnSchema.properties.delete;
|
|
450
|
+
delete client$2.tableActionColumnSchema.properties.update;
|
|
451
|
+
delete client$2.tableActionColumnSchema.properties.delete;
|
|
452
|
+
client$2.tableActionColumnSchema.properties["collection"] = {
|
|
453
|
+
type: "void",
|
|
454
|
+
title: i18nText("Share collections"),
|
|
455
|
+
"x-component": "Action.Link",
|
|
456
|
+
"x-component-props": {},
|
|
457
|
+
properties: {
|
|
458
|
+
drawer: {
|
|
459
|
+
type: "void",
|
|
460
|
+
"x-component": "Action.Drawer",
|
|
461
|
+
"x-component-props": {
|
|
462
|
+
width: "95vw"
|
|
463
|
+
},
|
|
464
|
+
"x-decorator": "Form",
|
|
465
|
+
title: i18nText("Share collections"),
|
|
466
|
+
properties: {
|
|
467
|
+
names: {
|
|
468
|
+
type: "array",
|
|
469
|
+
"x-component": TableTransfer,
|
|
470
|
+
"x-decorator": "FormItem"
|
|
471
|
+
},
|
|
472
|
+
footer: {
|
|
473
|
+
type: "void",
|
|
474
|
+
"x-component": "Action.Drawer.Footer",
|
|
475
|
+
properties: {
|
|
476
|
+
cancel: {
|
|
477
|
+
title: '{{t("Cancel")}}',
|
|
478
|
+
"x-component": "Action",
|
|
479
|
+
"x-component-props": {
|
|
480
|
+
useAction: "{{ cm.useCancelAction }}"
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
submit: {
|
|
484
|
+
title: '{{t("Submit")}}',
|
|
485
|
+
"x-component": "Action",
|
|
486
|
+
"x-component-props": {
|
|
487
|
+
type: "primary",
|
|
488
|
+
useAction: useShareCollectionAction
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
client$2.tableActionColumnSchema.properties.update = updateSchema;
|
|
498
|
+
client$2.tableActionColumnSchema.properties.delete = deleteSchema;
|
|
499
|
+
const MultiAppShareCollectionProvider = (props) => {
|
|
500
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: props.children });
|
|
501
|
+
};
|
|
502
|
+
class MultiAppShareCollectionPlugin extends client.Plugin {
|
|
503
|
+
async load() {
|
|
504
|
+
this.app.use(MultiAppShareCollectionProvider);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
exports2.MultiAppShareCollectionPlugin = MultiAppShareCollectionPlugin;
|
|
508
|
+
exports2.default = MultiAppShareCollectionPlugin;
|
|
509
|
+
Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
510
|
+
});
|
package/{lib → dist}/index.d.ts
RENAMED
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var server = require('./server');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, 'default', {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return server__namespace.default; }
|
|
12
|
+
});
|
|
13
|
+
Object.keys(server).forEach(function (k) {
|
|
14
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return server[k]; }
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var es_ES_default = {
|
|
4
|
+
"Share collections": "Tablas compartidas",
|
|
5
|
+
"Unshared collections": "Tablas no compartidas",
|
|
6
|
+
"Shared collections": "Tablas compartidas",
|
|
7
|
+
"All categories": "Todas las categor\xEDas",
|
|
8
|
+
"Enter name or title...": "Introducir nombre o t\xEDtulo...",
|
|
9
|
+
"Are you sure to add the following collections?": "\xBFEst\xE1 seguro de que desea a\xF1adir las siguientes tablas?",
|
|
10
|
+
"Are you sure to remove the following collections?": "\xBFEst\xE1 seguro de que desea eliminar las siguientes tablas?",
|
|
11
|
+
"Collection display name": "Mostrar nombre de la tabla",
|
|
12
|
+
"Collection name": "Nombre de la tabla",
|
|
13
|
+
"Collection category": "Categor\xEDa de tabla"
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = es_ES_default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var pt_BR_default = {
|
|
4
|
+
"Share collections": "Compartilhar tabelas",
|
|
5
|
+
"Unshared collections": "Tabelas n\xE3o compartilhadas",
|
|
6
|
+
"Shared collections": "Tabelas compartilhadas",
|
|
7
|
+
"All categories": "Todas as categorias",
|
|
8
|
+
"Enter name or title...": "Digite o nome ou t\xEDtulo...",
|
|
9
|
+
"Are you sure to add the following collections?": "Tem certeza de que deseja adicionar as seguintes tabelas?",
|
|
10
|
+
"Are you sure to remove the following collections?": "Tem certeza de que deseja remover as seguintes tabelas?",
|
|
11
|
+
"Collection display name": "Nome de exibi\xE7\xE3o da tabela",
|
|
12
|
+
"Collection name": "Nome da tabela",
|
|
13
|
+
"Collection category": "Categoria da tabela"
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = pt_BR_default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zh_CN_default = {
|
|
4
|
+
"Share collections": "\u5171\u4EAB\u6570\u636E\u8868",
|
|
5
|
+
"Unshared collections": "\u672A\u5171\u4EAB\u7684\u6570\u636E\u8868",
|
|
6
|
+
"Shared collections": "\u5DF2\u5171\u4EAB\u7684\u6570\u636E\u8868",
|
|
7
|
+
"All categories": "\u6240\u6709\u5206\u7C7B",
|
|
8
|
+
"Enter name or title...": "\u8F93\u5165\u6570\u636E\u8868\u6807\u9898\u6216\u6807\u8BC6",
|
|
9
|
+
"Are you sure to add the following collections?": "\u786E\u5B9A\u6DFB\u52A0\u4EE5\u4E0B\u6570\u636E\u8868\uFF1F",
|
|
10
|
+
"Are you sure to remove the following collections?": "\u786E\u5B9A\u79FB\u9664\u4EE5\u4E0B\u6570\u636E\u8868\uFF1F",
|
|
11
|
+
"Collection display name": "\u6807\u9898",
|
|
12
|
+
"Collection name": "\u6807\u8BC6",
|
|
13
|
+
"Collection category": "\u5206\u7C7B"
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = zh_CN_default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var database = require('@nocobase/database');
|
|
4
|
+
|
|
5
|
+
var applications_default = database.extendCollection({
|
|
6
|
+
name: "applications",
|
|
7
|
+
fields: [
|
|
8
|
+
{
|
|
9
|
+
type: "belongsToMany",
|
|
10
|
+
name: "collectionBlacklist",
|
|
11
|
+
through: "appCollectionBlacklist",
|
|
12
|
+
target: "collections",
|
|
13
|
+
targetKey: "name",
|
|
14
|
+
otherKey: "collectionName",
|
|
15
|
+
sourceKey: "name",
|
|
16
|
+
foreignKey: "applicationName"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
module.exports = applications_default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var database = require('@nocobase/database');
|
|
4
|
+
|
|
5
|
+
var collections_default = database.extendCollection({
|
|
6
|
+
name: "collections",
|
|
7
|
+
fields: [
|
|
8
|
+
{
|
|
9
|
+
type: "belongsToMany",
|
|
10
|
+
name: "collectionBlacklist",
|
|
11
|
+
through: "appCollectionBlacklist",
|
|
12
|
+
target: "applications",
|
|
13
|
+
targetKey: "name",
|
|
14
|
+
otherKey: "applicationName",
|
|
15
|
+
sourceKey: "name",
|
|
16
|
+
foreignKey: "collectionName"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
module.exports = collections_default;
|