@nocobase/plugin-snapshot-field 0.8.1-alpha.3
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/LICENSE +201 -0
- package/client.d.ts +4 -0
- package/client.js +30 -0
- package/lib/client/SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializers.d.ts +1 -0
- package/lib/client/SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializers.js +99 -0
- package/lib/client/SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializersDetailItem.d.ts +57 -0
- package/lib/client/SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializersDetailItem.js +190 -0
- package/lib/client/SnapshotBlock/SnapshotBlockProvider.d.ts +1 -0
- package/lib/client/SnapshotBlock/SnapshotBlockProvider.js +160 -0
- package/lib/client/SnapshotHistoryCollectionProvider.d.ts +4 -0
- package/lib/client/SnapshotHistoryCollectionProvider.js +72 -0
- package/lib/client/SnapshotRecordPicker.d.ts +1 -0
- package/lib/client/SnapshotRecordPicker.js +99 -0
- package/lib/client/index.d.ts +3 -0
- package/lib/client/index.js +71 -0
- package/lib/client/interface.d.ts +2 -0
- package/lib/client/interface.js +148 -0
- package/lib/client/locale/en-US.d.ts +10 -0
- package/lib/client/locale/en-US.js +16 -0
- package/lib/client/locale/index.d.ts +3 -0
- package/lib/client/locale/index.js +63 -0
- package/lib/client/locale/ja-JP.d.ts +2 -0
- package/lib/client/locale/ja-JP.js +8 -0
- package/lib/client/locale/ru-RU.d.ts +2 -0
- package/lib/client/locale/ru-RU.js +8 -0
- package/lib/client/locale/tr-TR.d.ts +2 -0
- package/lib/client/locale/tr-TR.js +8 -0
- package/lib/client/locale/zh-CN.d.ts +10 -0
- package/lib/client/locale/zh-CN.js +16 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +15 -0
- package/lib/server/collections/collectionsHistory.d.ts +3 -0
- package/lib/server/collections/collectionsHistory.js +52 -0
- package/lib/server/collections/fieldsHistory.d.ts +3 -0
- package/lib/server/collections/fieldsHistory.js +66 -0
- package/lib/server/fields/snapshot-field.d.ts +8 -0
- package/lib/server/fields/snapshot-field.js +35 -0
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +15 -0
- package/lib/server/plugin.d.ts +11 -0
- package/lib/server/plugin.js +190 -0
- package/package.json +10 -0
- package/server.d.ts +4 -0
- package/server.js +30 -0
- package/src/client/SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializers.tsx +78 -0
- package/src/client/SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializersDetailItem.tsx +121 -0
- package/src/client/SnapshotBlock/SnapshotBlockProvider.tsx +105 -0
- package/src/client/SnapshotHistoryCollectionProvider.tsx +42 -0
- package/src/client/SnapshotRecordPicker.tsx +52 -0
- package/src/client/index.tsx +50 -0
- package/src/client/interface.ts +102 -0
- package/src/client/locale/en-US.ts +10 -0
- package/src/client/locale/index.ts +24 -0
- package/src/client/locale/ja-JP.ts +1 -0
- package/src/client/locale/ru-RU.ts +1 -0
- package/src/client/locale/tr-TR.ts +1 -0
- package/src/client/locale/zh-CN.ts +9 -0
- package/src/index.ts +1 -0
- package/src/server/collections/.gitkeep +0 -0
- package/src/server/collections/collectionsHistory.ts +55 -0
- package/src/server/collections/fieldsHistory.ts +73 -0
- package/src/server/fields/snapshot-field.ts +12 -0
- package/src/server/index.ts +1 -0
- package/src/server/plugin.ts +110 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SnapshotBlockProvider = void 0;
|
|
7
|
+
|
|
8
|
+
function _react() {
|
|
9
|
+
const data = _interopRequireWildcard(require("react"));
|
|
10
|
+
|
|
11
|
+
_react = function _react() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _core() {
|
|
19
|
+
const data = require("@formily/core");
|
|
20
|
+
|
|
21
|
+
_core = function _core() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _react2() {
|
|
29
|
+
const data = require("@formily/react");
|
|
30
|
+
|
|
31
|
+
_react2 = function _react2() {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function _client() {
|
|
39
|
+
const data = require("@nocobase/client");
|
|
40
|
+
|
|
41
|
+
_client = function _client() {
|
|
42
|
+
return data;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function _antd() {
|
|
49
|
+
const data = require("antd");
|
|
50
|
+
|
|
51
|
+
_antd = function _antd() {
|
|
52
|
+
return data;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
59
|
+
|
|
60
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
61
|
+
|
|
62
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
63
|
+
|
|
64
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
65
|
+
|
|
66
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
67
|
+
|
|
68
|
+
const InternalFormBlockProvider = props => {
|
|
69
|
+
var _service$data;
|
|
70
|
+
|
|
71
|
+
const action = props.action,
|
|
72
|
+
readPretty = props.readPretty;
|
|
73
|
+
const field = (0, _react2().useField)();
|
|
74
|
+
const form = (0, _react().useMemo)(() => (0, _core().createForm)({
|
|
75
|
+
readPretty
|
|
76
|
+
}), []);
|
|
77
|
+
|
|
78
|
+
const _useBlockRequestConte = (0, _client().useBlockRequestContext)(),
|
|
79
|
+
resource = _useBlockRequestConte.resource,
|
|
80
|
+
service = _useBlockRequestConte.service;
|
|
81
|
+
|
|
82
|
+
const formBlockRef = (0, _react().useRef)();
|
|
83
|
+
|
|
84
|
+
if (service.loading) {
|
|
85
|
+
return _react().default.createElement(_antd().Spin, null);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return _react().default.createElement(_client().FormBlockContext.Provider, {
|
|
89
|
+
value: {
|
|
90
|
+
action,
|
|
91
|
+
form,
|
|
92
|
+
field,
|
|
93
|
+
service,
|
|
94
|
+
resource,
|
|
95
|
+
updateAssociationValues: [],
|
|
96
|
+
formBlockRef
|
|
97
|
+
}
|
|
98
|
+
}, readPretty ? _react().default.createElement(_client().RecordProvider, {
|
|
99
|
+
record: service === null || service === void 0 ? void 0 : (_service$data = service.data) === null || _service$data === void 0 ? void 0 : _service$data.data
|
|
100
|
+
}, _react().default.createElement("div", {
|
|
101
|
+
ref: formBlockRef
|
|
102
|
+
}, props.children)) : _react().default.createElement("div", {
|
|
103
|
+
ref: formBlockRef
|
|
104
|
+
}, props.children));
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const BlockRequestProvider = props => {
|
|
108
|
+
const field = (0, _react2().useField)();
|
|
109
|
+
const resource = (0, _client().useBlockResource)();
|
|
110
|
+
const service = {
|
|
111
|
+
loading: false,
|
|
112
|
+
data: {
|
|
113
|
+
data: (0, _client().useRecord)()
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const __parent = (0, _react().useContext)(_client().BlockRequestContext);
|
|
118
|
+
|
|
119
|
+
return _react().default.createElement(_client().BlockRequestContext.Provider, {
|
|
120
|
+
value: {
|
|
121
|
+
block: props.block,
|
|
122
|
+
props,
|
|
123
|
+
field,
|
|
124
|
+
service,
|
|
125
|
+
resource,
|
|
126
|
+
__parent
|
|
127
|
+
}
|
|
128
|
+
}, props.children);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const BlockProvider = props => {
|
|
132
|
+
const collection = props.collection,
|
|
133
|
+
association = props.association;
|
|
134
|
+
const resource = (0, _client().useResource)(props);
|
|
135
|
+
return _react().default.createElement(_client().MaybeCollectionProvider, {
|
|
136
|
+
collection: collection
|
|
137
|
+
}, _react().default.createElement(_client().BlockAssociationContext.Provider, {
|
|
138
|
+
value: association
|
|
139
|
+
}, _react().default.createElement(_client().BlockResourceContext.Provider, {
|
|
140
|
+
value: resource
|
|
141
|
+
}, _react().default.createElement(BlockRequestProvider, _objectSpread({}, props), props.children))));
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const SnapshotBlockProvider = props => {
|
|
145
|
+
const record = (0, _client().useRecord)();
|
|
146
|
+
const __tableName = record.__tableName;
|
|
147
|
+
|
|
148
|
+
const _useCollectionManager = (0, _client().useCollectionManager)(),
|
|
149
|
+
getInheritCollections = _useCollectionManager.getInheritCollections;
|
|
150
|
+
|
|
151
|
+
const inheritCollections = getInheritCollections(__tableName);
|
|
152
|
+
|
|
153
|
+
const _useDesignable = (0, _client().useDesignable)(),
|
|
154
|
+
designable = _useDesignable.designable;
|
|
155
|
+
|
|
156
|
+
const flag = !designable && __tableName && !inheritCollections.includes(props.collection) && __tableName !== props.collection;
|
|
157
|
+
return !flag && _react().default.createElement(BlockProvider, _objectSpread({}, props), _react().default.createElement(InternalFormBlockProvider, _objectSpread({}, props)));
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
exports.SnapshotBlockProvider = SnapshotBlockProvider;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SnapshotHistoryCollectionProvider = void 0;
|
|
7
|
+
|
|
8
|
+
function _client() {
|
|
9
|
+
const data = require("@nocobase/client");
|
|
10
|
+
|
|
11
|
+
_client = function _client() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _react() {
|
|
19
|
+
const data = _interopRequireWildcard(require("react"));
|
|
20
|
+
|
|
21
|
+
_react = function _react() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const _excluded = ["collections"];
|
|
29
|
+
|
|
30
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
+
|
|
32
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
+
|
|
34
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
35
|
+
|
|
36
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
37
|
+
|
|
38
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
39
|
+
|
|
40
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
41
|
+
|
|
42
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
43
|
+
|
|
44
|
+
const SnapshotHistoryCollectionProvider = props => {
|
|
45
|
+
var _useHistoryCollection, _snapshotTargetCollec, _snapshotTargetCollec2;
|
|
46
|
+
|
|
47
|
+
const collectionName = props.collectionName;
|
|
48
|
+
|
|
49
|
+
const _useContext = (0, _react().useContext)(_client().CollectionManagerContext),
|
|
50
|
+
allCollections = _useContext.collections,
|
|
51
|
+
rest = _objectWithoutProperties(_useContext, _excluded); // 目标表
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
const snapshotTargetCollection = (_useHistoryCollection = (0, _client().useHistoryCollectionsByNames)([collectionName])) === null || _useHistoryCollection === void 0 ? void 0 : _useHistoryCollection[0]; // 目标如果是继承表则获取继承表
|
|
55
|
+
|
|
56
|
+
const inheritCollections = (0, _client().useHistoryCollectionsByNames)((_snapshotTargetCollec = snapshotTargetCollection === null || snapshotTargetCollection === void 0 ? void 0 : snapshotTargetCollection.inherits) !== null && _snapshotTargetCollec !== void 0 ? _snapshotTargetCollec : []); // 目标表内关联字段的表
|
|
57
|
+
|
|
58
|
+
const associationFieldTargetCollections = (0, _client().useHistoryCollectionsByNames)((_snapshotTargetCollec2 = snapshotTargetCollection === null || snapshotTargetCollection === void 0 ? void 0 : snapshotTargetCollection.fields.filter(i => i.interface !== 'snapshot').map(i => i.target)) !== null && _snapshotTargetCollec2 !== void 0 ? _snapshotTargetCollec2 : []); // 替换表的集合
|
|
59
|
+
|
|
60
|
+
const finallyHistoryCollecionts = [snapshotTargetCollection, ...associationFieldTargetCollections, ...inheritCollections].filter(i => i); // 过滤出不需要替换的表
|
|
61
|
+
|
|
62
|
+
const filterdAllCollection = allCollections.filter(c => !finallyHistoryCollecionts.map(i => i.name).includes(c.name)); // 最终替换后的表
|
|
63
|
+
|
|
64
|
+
const overridedCollections = [...filterdAllCollection, ...finallyHistoryCollecionts];
|
|
65
|
+
return _react().default.createElement(_client().CollectionManagerContext.Provider, {
|
|
66
|
+
value: _objectSpread(_objectSpread({}, rest), {}, {
|
|
67
|
+
collections: overridedCollections
|
|
68
|
+
})
|
|
69
|
+
}, props.children);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
exports.SnapshotHistoryCollectionProvider = SnapshotHistoryCollectionProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SnapshotRecordPicker: (props: any) => JSX.Element;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SnapshotRecordPicker = void 0;
|
|
7
|
+
|
|
8
|
+
function _react() {
|
|
9
|
+
const data = _interopRequireDefault(require("react"));
|
|
10
|
+
|
|
11
|
+
_react = function _react() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _react2() {
|
|
19
|
+
const data = require("@formily/react");
|
|
20
|
+
|
|
21
|
+
_react2 = function _react2() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _client() {
|
|
29
|
+
const data = require("@nocobase/client");
|
|
30
|
+
|
|
31
|
+
_client = function _client() {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var _SnapshotHistoryCollectionProvider = require("./SnapshotHistoryCollectionProvider");
|
|
39
|
+
|
|
40
|
+
const _excluded = ["value", "onChange"];
|
|
41
|
+
|
|
42
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
43
|
+
|
|
44
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
45
|
+
|
|
46
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
47
|
+
|
|
48
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
49
|
+
|
|
50
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
51
|
+
|
|
52
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
53
|
+
|
|
54
|
+
const useSnapshotFieldTargetCollectionName = () => {
|
|
55
|
+
var _historyCollections$f;
|
|
56
|
+
|
|
57
|
+
const fieldSchema = (0, _react2().useFieldSchema)();
|
|
58
|
+
|
|
59
|
+
const _useCollection = (0, _client().useCollection)(),
|
|
60
|
+
getField = _useCollection.getField;
|
|
61
|
+
|
|
62
|
+
const collectionField = getField(fieldSchema.name);
|
|
63
|
+
|
|
64
|
+
const _useCollectionHistory = (0, _client().useCollectionHistory)(),
|
|
65
|
+
historyCollections = _useCollectionHistory.historyCollections;
|
|
66
|
+
|
|
67
|
+
return (_historyCollections$f = historyCollections.find(i => i.name === collectionField.target)) === null || _historyCollections$f === void 0 ? void 0 : _historyCollections$f.name;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const ReadPrettyRecordPickerWrapper = props => {
|
|
71
|
+
const collectionName = useSnapshotFieldTargetCollectionName();
|
|
72
|
+
return _react().default.createElement(_SnapshotHistoryCollectionProvider.SnapshotHistoryCollectionProvider, {
|
|
73
|
+
collectionName: collectionName
|
|
74
|
+
}, _react().default.createElement(_client().ReadPrettyRecordPicker, _objectSpread({}, props)));
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const SnapshotRecordPickerInner = (0, _react2().connect)(props => {
|
|
78
|
+
const actionCtx = (0, _client().useActionContext)();
|
|
79
|
+
const isUpdateAction = actionCtx.fieldSchema['x-action'] === 'update';
|
|
80
|
+
return isUpdateAction ? _react().default.createElement(ReadPrettyRecordPickerWrapper, _objectSpread({}, props)) : _react().default.createElement(_client().InputRecordPicker, _objectSpread({}, props));
|
|
81
|
+
}, // mapProps(mapSuffixProps),
|
|
82
|
+
(0, _react2().mapReadPretty)(ReadPrettyRecordPickerWrapper));
|
|
83
|
+
|
|
84
|
+
const SnapshotRecordPicker = props => {
|
|
85
|
+
const value = props.value,
|
|
86
|
+
_onChange = props.onChange,
|
|
87
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
88
|
+
|
|
89
|
+
const newProps = _objectSpread(_objectSpread({}, restProps), {}, {
|
|
90
|
+
value: value === null || value === void 0 ? void 0 : value.data,
|
|
91
|
+
onChange: value => _onChange({
|
|
92
|
+
data: value
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
return _react().default.createElement(SnapshotRecordPickerInner, _objectSpread({}, newProps));
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
exports.SnapshotRecordPicker = SnapshotRecordPicker;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _client() {
|
|
9
|
+
const data = require("@nocobase/client");
|
|
10
|
+
|
|
11
|
+
_client = function _client() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _react() {
|
|
19
|
+
const data = _interopRequireWildcard(require("react"));
|
|
20
|
+
|
|
21
|
+
_react = function _react() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var _interface = require("./interface");
|
|
29
|
+
|
|
30
|
+
var _SnapshotRecordPicker = require("./SnapshotRecordPicker");
|
|
31
|
+
|
|
32
|
+
var _SnapshotBlockInitializers = require("./SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializers");
|
|
33
|
+
|
|
34
|
+
var _SnapshotBlockInitializersDetailItem = require("./SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializersDetailItem");
|
|
35
|
+
|
|
36
|
+
var _SnapshotBlockProvider = require("./SnapshotBlock/SnapshotBlockProvider");
|
|
37
|
+
|
|
38
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
39
|
+
|
|
40
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
41
|
+
|
|
42
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
43
|
+
|
|
44
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
45
|
+
|
|
46
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
47
|
+
|
|
48
|
+
var _default = _react().default.memo(props => {
|
|
49
|
+
const initializers = (0, _react().useContext)(_client().SchemaInitializerContext);
|
|
50
|
+
const snapshot = (0, _interface.useSnapshotInterface)();
|
|
51
|
+
(0, _react().useEffect)(() => {
|
|
52
|
+
(0, _client().registerField)(snapshot.group, snapshot.name, snapshot);
|
|
53
|
+
}, []);
|
|
54
|
+
return _react().default.createElement(_client().CollectionManagerProvider, {
|
|
55
|
+
interfaces: {
|
|
56
|
+
snapshot
|
|
57
|
+
}
|
|
58
|
+
}, _react().default.createElement(_client().CollectionHistoryProvider, null, _react().default.createElement(_client().SchemaInitializerProvider, {
|
|
59
|
+
initializers: _objectSpread(_objectSpread({}, initializers), {}, {
|
|
60
|
+
SnapshotBlockInitializers: _SnapshotBlockInitializers.SnapshotBlockInitializers
|
|
61
|
+
})
|
|
62
|
+
}, _react().default.createElement(_client().SchemaComponentOptions, {
|
|
63
|
+
components: {
|
|
64
|
+
SnapshotRecordPicker: _SnapshotRecordPicker.SnapshotRecordPicker,
|
|
65
|
+
SnapshotBlockProvider: _SnapshotBlockProvider.SnapshotBlockProvider,
|
|
66
|
+
SnapshotBlockInitializersDetailItem: _SnapshotBlockInitializersDetailItem.SnapshotBlockInitializersDetailItem
|
|
67
|
+
}
|
|
68
|
+
}, props.children))));
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
exports.default = _default;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSnapshotInterface = void 0;
|
|
7
|
+
|
|
8
|
+
function _lodash() {
|
|
9
|
+
const data = require("lodash");
|
|
10
|
+
|
|
11
|
+
_lodash = function _lodash() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _client() {
|
|
19
|
+
const data = require("@nocobase/client");
|
|
20
|
+
|
|
21
|
+
_client = function _client() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var _locale = require("./locale");
|
|
29
|
+
|
|
30
|
+
function _react() {
|
|
31
|
+
const data = require("react");
|
|
32
|
+
|
|
33
|
+
_react = function _react() {
|
|
34
|
+
return data;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
41
|
+
|
|
42
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
43
|
+
|
|
44
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
45
|
+
|
|
46
|
+
const defaultProps = _client().interfacesProperties.defaultProps,
|
|
47
|
+
recordPickerSelector = _client().interfacesProperties.recordPickerSelector;
|
|
48
|
+
|
|
49
|
+
const useSnapshotInterface = () => {
|
|
50
|
+
const _useSnapshotTranslati = (0, _locale.useSnapshotTranslation)(),
|
|
51
|
+
t = _useSnapshotTranslati.t;
|
|
52
|
+
|
|
53
|
+
const recordPickerViewer = {
|
|
54
|
+
type: 'void',
|
|
55
|
+
title: t('View record'),
|
|
56
|
+
'x-component': 'RecordPicker.Viewer',
|
|
57
|
+
'x-component-props': {
|
|
58
|
+
className: 'nb-action-popup'
|
|
59
|
+
},
|
|
60
|
+
properties: {
|
|
61
|
+
tabs: {
|
|
62
|
+
type: 'void',
|
|
63
|
+
'x-component': 'Tabs',
|
|
64
|
+
'x-component-props': {},
|
|
65
|
+
// 'x-initializer': 'TabPaneInitializers',
|
|
66
|
+
properties: {
|
|
67
|
+
tab1: {
|
|
68
|
+
type: 'void',
|
|
69
|
+
title: t('Detail'),
|
|
70
|
+
'x-component': 'Tabs.TabPane',
|
|
71
|
+
'x-designer': 'Tabs.Designer',
|
|
72
|
+
'x-component-props': {},
|
|
73
|
+
properties: {
|
|
74
|
+
grid: {
|
|
75
|
+
type: 'void',
|
|
76
|
+
'x-component': 'Grid',
|
|
77
|
+
'x-initializer': 'SnapshotBlockInitializers',
|
|
78
|
+
properties: {}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const snapshot = {
|
|
87
|
+
name: 'snapshot',
|
|
88
|
+
type: 'object',
|
|
89
|
+
group: 'advanced',
|
|
90
|
+
title: t('Snapshot'),
|
|
91
|
+
description: t('Snapshot to description'),
|
|
92
|
+
default: {
|
|
93
|
+
type: 'snapshot',
|
|
94
|
+
// name,
|
|
95
|
+
uiSchema: {
|
|
96
|
+
// title,
|
|
97
|
+
'x-component': 'SnapshotRecordPicker',
|
|
98
|
+
'x-component-props': {
|
|
99
|
+
// mode: 'tags',
|
|
100
|
+
multiple: true,
|
|
101
|
+
fieldNames: {
|
|
102
|
+
label: 'id',
|
|
103
|
+
value: 'id'
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
schemaInitialize(schema, {
|
|
110
|
+
field,
|
|
111
|
+
readPretty,
|
|
112
|
+
action,
|
|
113
|
+
block
|
|
114
|
+
}) {
|
|
115
|
+
if (readPretty || action === 'update') {
|
|
116
|
+
schema['properties'] = {
|
|
117
|
+
viewer: (0, _lodash().cloneDeep)(recordPickerViewer)
|
|
118
|
+
};
|
|
119
|
+
} else {
|
|
120
|
+
schema['properties'] = {
|
|
121
|
+
selector: (0, _lodash().cloneDeep)(recordPickerSelector)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
initialize: values => {},
|
|
127
|
+
properties: _objectSpread(_objectSpread({}, defaultProps), {}, {
|
|
128
|
+
target: {
|
|
129
|
+
type: 'string',
|
|
130
|
+
title: t('Related collection'),
|
|
131
|
+
required: true,
|
|
132
|
+
'x-reactions': ['{{useAsyncDataSource(loadCollections)}}'],
|
|
133
|
+
'x-decorator': 'FormItem',
|
|
134
|
+
'x-component': 'Select',
|
|
135
|
+
'x-disabled': '{{ !createOnly }}'
|
|
136
|
+
},
|
|
137
|
+
'uiSchema.x-component-props.multiple': {
|
|
138
|
+
type: 'boolean',
|
|
139
|
+
'x-content': t('Allow linking to multiple records'),
|
|
140
|
+
'x-decorator': 'FormItem',
|
|
141
|
+
'x-component': 'Checkbox'
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
};
|
|
145
|
+
return (0, _react().useMemo)(() => snapshot, [t]);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
exports.useSnapshotInterface = useSnapshotInterface;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
Detail: 'Detail',
|
|
9
|
+
Snapshot: 'Snapshot',
|
|
10
|
+
'View record': 'View record',
|
|
11
|
+
'Add block': 'Add block',
|
|
12
|
+
'Allow linking to multiple records': 'Allow linking to multiple records',
|
|
13
|
+
'Snapshot to description': 'It is used to create a snapshot of the table, save the current data of the pointed table, and save it only when the record to which it belongs is created, and will not be updated later.',
|
|
14
|
+
'Related collection': 'Related collection'
|
|
15
|
+
};
|
|
16
|
+
exports.default = _default;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NAMESPACE = void 0;
|
|
7
|
+
exports.lang = lang;
|
|
8
|
+
exports.useSnapshotTranslation = useSnapshotTranslation;
|
|
9
|
+
|
|
10
|
+
function _client() {
|
|
11
|
+
const data = require("@nocobase/client");
|
|
12
|
+
|
|
13
|
+
_client = function _client() {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function _reactI18next() {
|
|
21
|
+
const data = require("react-i18next");
|
|
22
|
+
|
|
23
|
+
_reactI18next = function _reactI18next() {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var _enUS = _interopRequireDefault(require("./en-US"));
|
|
31
|
+
|
|
32
|
+
var _jaJP = _interopRequireDefault(require("./ja-JP"));
|
|
33
|
+
|
|
34
|
+
var _ruRU = _interopRequireDefault(require("./ru-RU"));
|
|
35
|
+
|
|
36
|
+
var _trTR = _interopRequireDefault(require("./tr-TR"));
|
|
37
|
+
|
|
38
|
+
var _zhCN = _interopRequireDefault(require("./zh-CN"));
|
|
39
|
+
|
|
40
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
41
|
+
|
|
42
|
+
const NAMESPACE = 'snapshot-field';
|
|
43
|
+
exports.NAMESPACE = NAMESPACE;
|
|
44
|
+
|
|
45
|
+
_client().i18n.addResources('zh-CN', NAMESPACE, _zhCN.default);
|
|
46
|
+
|
|
47
|
+
_client().i18n.addResources('en-US', NAMESPACE, _enUS.default);
|
|
48
|
+
|
|
49
|
+
_client().i18n.addResources('ja-JP', NAMESPACE, _jaJP.default);
|
|
50
|
+
|
|
51
|
+
_client().i18n.addResources('ru-RU', NAMESPACE, _ruRU.default);
|
|
52
|
+
|
|
53
|
+
_client().i18n.addResources('tr-TR', NAMESPACE, _trTR.default);
|
|
54
|
+
|
|
55
|
+
function lang(key) {
|
|
56
|
+
return _client().i18n.t(key, {
|
|
57
|
+
ns: NAMESPACE
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function useSnapshotTranslation() {
|
|
62
|
+
return (0, _reactI18next().useTranslation)(NAMESPACE);
|
|
63
|
+
}
|