@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,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
Detail: '详情',
|
|
9
|
+
Snapshot: '快照',
|
|
10
|
+
'Add block': '创建区块',
|
|
11
|
+
'Snapshot to description': '用于创建表的快照,保存指向的表的当前数据,仅在其所属的记录创建时保存,后续不再更新。',
|
|
12
|
+
'View record': '查看数据',
|
|
13
|
+
'Allow linking to multiple records': '允许关联多条记录',
|
|
14
|
+
'Related collection': '关系表'
|
|
15
|
+
};
|
|
16
|
+
exports.default = _default;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './server';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _server.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _server = _interopRequireDefault(require("./server"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
name: 'collectionsHistory',
|
|
9
|
+
title: '数据表历史',
|
|
10
|
+
sortable: 'sort',
|
|
11
|
+
autoGenId: false,
|
|
12
|
+
model: 'CollectionModel',
|
|
13
|
+
repository: 'CollectionRepository',
|
|
14
|
+
timestamps: false,
|
|
15
|
+
filterTargetKey: 'name',
|
|
16
|
+
fields: [{
|
|
17
|
+
type: 'uid',
|
|
18
|
+
name: 'key',
|
|
19
|
+
primaryKey: true
|
|
20
|
+
}, {
|
|
21
|
+
type: 'uid',
|
|
22
|
+
name: 'name',
|
|
23
|
+
unique: true,
|
|
24
|
+
prefix: 't_'
|
|
25
|
+
}, {
|
|
26
|
+
type: 'string',
|
|
27
|
+
name: 'title',
|
|
28
|
+
required: true
|
|
29
|
+
}, {
|
|
30
|
+
type: 'boolean',
|
|
31
|
+
name: 'inherit',
|
|
32
|
+
defaultValue: false
|
|
33
|
+
}, {
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
name: 'hidden',
|
|
36
|
+
defaultValue: false
|
|
37
|
+
}, {
|
|
38
|
+
type: 'json',
|
|
39
|
+
name: 'options',
|
|
40
|
+
defaultValue: {}
|
|
41
|
+
}, {
|
|
42
|
+
type: 'hasMany',
|
|
43
|
+
name: 'fields',
|
|
44
|
+
target: 'fieldsHistory',
|
|
45
|
+
sourceKey: 'name',
|
|
46
|
+
targetKey: 'name',
|
|
47
|
+
foreignKey: 'collectionName',
|
|
48
|
+
onDelete: 'CASCADE',
|
|
49
|
+
sortBy: 'sort'
|
|
50
|
+
}]
|
|
51
|
+
};
|
|
52
|
+
exports.default = _default;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
name: 'fieldsHistory',
|
|
9
|
+
title: '{{t("Fields history")}}',
|
|
10
|
+
autoGenId: false,
|
|
11
|
+
model: 'FieldModel',
|
|
12
|
+
timestamps: false,
|
|
13
|
+
sortable: {
|
|
14
|
+
name: 'sort',
|
|
15
|
+
scopeKey: 'collectionName'
|
|
16
|
+
},
|
|
17
|
+
indexes: [{
|
|
18
|
+
type: 'UNIQUE',
|
|
19
|
+
fields: ['collectionName', 'name']
|
|
20
|
+
}],
|
|
21
|
+
fields: [{
|
|
22
|
+
type: 'uid',
|
|
23
|
+
name: 'key',
|
|
24
|
+
primaryKey: true
|
|
25
|
+
}, {
|
|
26
|
+
type: 'uid',
|
|
27
|
+
name: 'name',
|
|
28
|
+
prefix: 'f_'
|
|
29
|
+
}, {
|
|
30
|
+
type: 'string',
|
|
31
|
+
name: 'type'
|
|
32
|
+
}, {
|
|
33
|
+
type: 'string',
|
|
34
|
+
name: 'interface',
|
|
35
|
+
allowNull: true
|
|
36
|
+
}, {
|
|
37
|
+
type: 'belongsTo',
|
|
38
|
+
name: 'collection',
|
|
39
|
+
target: 'collectionsHistory',
|
|
40
|
+
foreignKey: 'collectionName',
|
|
41
|
+
targetKey: 'name',
|
|
42
|
+
onDelete: 'CASCADE'
|
|
43
|
+
}, {
|
|
44
|
+
type: 'hasMany',
|
|
45
|
+
name: 'children',
|
|
46
|
+
target: 'fieldsHistory',
|
|
47
|
+
sourceKey: 'key',
|
|
48
|
+
foreignKey: 'parentKey'
|
|
49
|
+
}, {
|
|
50
|
+
type: 'hasOne',
|
|
51
|
+
name: 'reverseField',
|
|
52
|
+
target: 'fieldsHistory',
|
|
53
|
+
sourceKey: 'key',
|
|
54
|
+
foreignKey: 'reverseKey'
|
|
55
|
+
}, {
|
|
56
|
+
type: 'belongsTo',
|
|
57
|
+
name: 'uiSchema',
|
|
58
|
+
target: 'uiSchemas',
|
|
59
|
+
foreignKey: 'uiSchemaUid'
|
|
60
|
+
}, {
|
|
61
|
+
type: 'json',
|
|
62
|
+
name: 'options',
|
|
63
|
+
defaultValue: {}
|
|
64
|
+
}]
|
|
65
|
+
};
|
|
66
|
+
exports.default = _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Field, BaseColumnFieldOptions } from '@nocobase/database';
|
|
2
|
+
import { DataTypes } from 'sequelize';
|
|
3
|
+
export declare class SnapshotField extends Field {
|
|
4
|
+
get dataType(): DataTypes.AbstractDataTypeConstructor;
|
|
5
|
+
}
|
|
6
|
+
export interface SnapshotFieldOptions extends BaseColumnFieldOptions {
|
|
7
|
+
type: 'snapshot';
|
|
8
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SnapshotField = void 0;
|
|
7
|
+
|
|
8
|
+
function _database() {
|
|
9
|
+
const data = require("@nocobase/database");
|
|
10
|
+
|
|
11
|
+
_database = function _database() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _sequelize() {
|
|
19
|
+
const data = require("sequelize");
|
|
20
|
+
|
|
21
|
+
_sequelize = function _sequelize() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
class SnapshotField extends _database().Field {
|
|
29
|
+
get dataType() {
|
|
30
|
+
return _sequelize().DataTypes.JSON;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.SnapshotField = SnapshotField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './plugin';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _plugin.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _plugin = _interopRequireDefault(require("./plugin"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InstallOptions, Plugin } from '@nocobase/server';
|
|
2
|
+
export declare class SnapshotFieldPlugin extends Plugin {
|
|
3
|
+
afterAdd(): void;
|
|
4
|
+
beforeLoad(): Promise<void>;
|
|
5
|
+
load(): Promise<void>;
|
|
6
|
+
install(options?: InstallOptions): Promise<void>;
|
|
7
|
+
afterEnable(): Promise<void>;
|
|
8
|
+
afterDisable(): Promise<void>;
|
|
9
|
+
remove(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export default SnapshotFieldPlugin;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.SnapshotFieldPlugin = void 0;
|
|
7
|
+
|
|
8
|
+
function _server() {
|
|
9
|
+
const data = require("@nocobase/server");
|
|
10
|
+
|
|
11
|
+
_server = function _server() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _path() {
|
|
19
|
+
const data = require("path");
|
|
20
|
+
|
|
21
|
+
_path = function _path() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var _snapshotField = require("./fields/snapshot-field");
|
|
29
|
+
|
|
30
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
31
|
+
|
|
32
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
33
|
+
|
|
34
|
+
class SnapshotFieldPlugin extends _server().Plugin {
|
|
35
|
+
afterAdd() {}
|
|
36
|
+
|
|
37
|
+
beforeLoad() {
|
|
38
|
+
var _this = this;
|
|
39
|
+
|
|
40
|
+
return _asyncToGenerator(function* () {
|
|
41
|
+
const collectionHandler = /*#__PURE__*/function () {
|
|
42
|
+
var _ref = _asyncToGenerator(function* (model, {
|
|
43
|
+
transaction
|
|
44
|
+
}) {
|
|
45
|
+
var _collectionDoc$fields;
|
|
46
|
+
|
|
47
|
+
const collectionDoc = model.toJSON();
|
|
48
|
+
|
|
49
|
+
const collectionsHistoryRepository = _this.app.db.getRepository('collectionsHistory');
|
|
50
|
+
|
|
51
|
+
const fieldsHistoryRepository = _this.app.db.getRepository('fieldsHistory');
|
|
52
|
+
|
|
53
|
+
const existCollection = yield collectionsHistoryRepository.findOne({
|
|
54
|
+
filter: {
|
|
55
|
+
name: collectionDoc.name
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (existCollection) {
|
|
60
|
+
// 删除表和其关联字段
|
|
61
|
+
yield existCollection.destroy({
|
|
62
|
+
transaction
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
yield collectionsHistoryRepository.create({
|
|
67
|
+
values: collectionDoc,
|
|
68
|
+
transaction
|
|
69
|
+
});
|
|
70
|
+
yield fieldsHistoryRepository.createMany({
|
|
71
|
+
records: (_collectionDoc$fields = collectionDoc.fields) !== null && _collectionDoc$fields !== void 0 ? _collectionDoc$fields : [],
|
|
72
|
+
transaction
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return function collectionHandler(_x, _x2) {
|
|
77
|
+
return _ref.apply(this, arguments);
|
|
78
|
+
};
|
|
79
|
+
}();
|
|
80
|
+
|
|
81
|
+
_this.app.db.on('collections.afterCreateWithAssociations', collectionHandler);
|
|
82
|
+
|
|
83
|
+
const fieldHandler = /*#__PURE__*/function () {
|
|
84
|
+
var _ref2 = _asyncToGenerator(function* (model, {
|
|
85
|
+
transaction
|
|
86
|
+
}) {
|
|
87
|
+
const fieldDoc = model.get();
|
|
88
|
+
|
|
89
|
+
const fieldsHistoryRepository = _this.app.db.getRepository('fieldsHistory');
|
|
90
|
+
|
|
91
|
+
const existField = yield fieldsHistoryRepository.findOne({
|
|
92
|
+
filter: {
|
|
93
|
+
name: fieldDoc.name
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
if (existField) {
|
|
98
|
+
yield existField.destroy({
|
|
99
|
+
transaction
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
yield fieldsHistoryRepository.create({
|
|
104
|
+
values: fieldDoc,
|
|
105
|
+
transaction
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return function fieldHandler(_x3, _x4) {
|
|
110
|
+
return _ref2.apply(this, arguments);
|
|
111
|
+
};
|
|
112
|
+
}();
|
|
113
|
+
|
|
114
|
+
_this.app.db.on('fields.afterCreateWithAssociations', fieldHandler);
|
|
115
|
+
})();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
load() {
|
|
119
|
+
var _this2 = this;
|
|
120
|
+
|
|
121
|
+
return _asyncToGenerator(function* () {
|
|
122
|
+
// 导入 collection
|
|
123
|
+
yield _this2.db.import({
|
|
124
|
+
directory: (0, _path().resolve)(__dirname, 'collections')
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
_this2.app.db.registerFieldTypes({
|
|
128
|
+
snapshot: _snapshotField.SnapshotField
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
_this2.app.acl.allow('collectionsHistory', 'list', 'loggedIn');
|
|
132
|
+
})();
|
|
133
|
+
} // 初始化安装的时候
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
install(options) {
|
|
137
|
+
var _this3 = this;
|
|
138
|
+
|
|
139
|
+
return _asyncToGenerator(function* () {
|
|
140
|
+
yield _this3.app.db.sequelize.transaction( /*#__PURE__*/function () {
|
|
141
|
+
var _ref3 = _asyncToGenerator(function* (transaction) {
|
|
142
|
+
const collectionsRepository = _this3.app.db.getRepository('collections');
|
|
143
|
+
|
|
144
|
+
const collectionsHistoryRepository = _this3.app.db.getRepository('collectionsHistory');
|
|
145
|
+
|
|
146
|
+
if ((yield collectionsHistoryRepository.find()).length === 0) {
|
|
147
|
+
const collectionsModels = yield collectionsRepository.find();
|
|
148
|
+
yield collectionsHistoryRepository.createMany({
|
|
149
|
+
records: collectionsModels.map(m => m.get()),
|
|
150
|
+
transaction
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const fieldsRepository = _this3.app.db.getRepository('fields');
|
|
155
|
+
|
|
156
|
+
const fieldsHistoryRepository = _this3.app.db.getRepository('fieldsHistory');
|
|
157
|
+
|
|
158
|
+
if ((yield fieldsHistoryRepository.find()).length === 0) {
|
|
159
|
+
const fieldsModels = yield fieldsRepository.find();
|
|
160
|
+
yield fieldsHistoryRepository.createMany({
|
|
161
|
+
records: fieldsModels.map(m => m.get()),
|
|
162
|
+
transaction
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
return function (_x5) {
|
|
168
|
+
return _ref3.apply(this, arguments);
|
|
169
|
+
};
|
|
170
|
+
}());
|
|
171
|
+
})();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
afterEnable() {
|
|
175
|
+
return _asyncToGenerator(function* () {})();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
afterDisable() {
|
|
179
|
+
return _asyncToGenerator(function* () {})();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
remove() {
|
|
183
|
+
return _asyncToGenerator(function* () {})();
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
exports.SnapshotFieldPlugin = SnapshotFieldPlugin;
|
|
189
|
+
var _default = SnapshotFieldPlugin;
|
|
190
|
+
exports.default = _default;
|
package/package.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nocobase/plugin-snapshot-field",
|
|
3
|
+
"version": "0.8.1-alpha.3",
|
|
4
|
+
"main": "lib/server/index.js",
|
|
5
|
+
"devDependencies": {
|
|
6
|
+
"@nocobase/server": "0.8.1-alpha.3",
|
|
7
|
+
"@nocobase/test": "0.8.1-alpha.3"
|
|
8
|
+
},
|
|
9
|
+
"gitHead": "e03df3df5962b99d9fbf5b6e33fbe2b23f14f3d3"
|
|
10
|
+
}
|
package/server.d.ts
ADDED
package/server.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
var _index = _interopRequireWildcard(require("./lib/server"));
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
var _exportNames = {};
|
|
13
|
+
Object.defineProperty(exports, "default", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _index.default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
Object.keys(_index).forEach(function (key) {
|
|
21
|
+
if (key === "default" || key === "__esModule") return;
|
|
22
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
23
|
+
if (key in exports && exports[key] === _index[key]) return;
|
|
24
|
+
Object.defineProperty(exports, key, {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _index[key];
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SchemaInitializer, gridRowColWrap } from '@nocobase/client';
|
|
3
|
+
import { useSnapshotTranslation } from '../../locale';
|
|
4
|
+
|
|
5
|
+
export const SnapshotBlockInitializers = (props: any) => {
|
|
6
|
+
const { t } = useSnapshotTranslation();
|
|
7
|
+
const { insertPosition, component } = props;
|
|
8
|
+
return (
|
|
9
|
+
<SchemaInitializer.Button
|
|
10
|
+
wrap={gridRowColWrap}
|
|
11
|
+
insertPosition={insertPosition}
|
|
12
|
+
component={component}
|
|
13
|
+
title={component ? null : t('Add block')}
|
|
14
|
+
icon={'PlusOutlined'}
|
|
15
|
+
items={[
|
|
16
|
+
{
|
|
17
|
+
type: 'itemGroup',
|
|
18
|
+
title: '{{t("Current record blocks")}}',
|
|
19
|
+
children: [
|
|
20
|
+
{
|
|
21
|
+
key: 'details',
|
|
22
|
+
type: 'item',
|
|
23
|
+
title: '{{t("Details")}}',
|
|
24
|
+
component: 'SnapshotBlockInitializersDetailItem',
|
|
25
|
+
actionInitializers: 'CalendarFormActionInitializers',
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: 'itemGroup',
|
|
31
|
+
title: '{{t("Other blocks")}}',
|
|
32
|
+
children: [
|
|
33
|
+
{
|
|
34
|
+
key: 'markdown',
|
|
35
|
+
type: 'item',
|
|
36
|
+
title: '{{t("Markdown")}}',
|
|
37
|
+
component: 'MarkdownBlockInitializer',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
]}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
// const { t } = useSnapshotTranslation();
|
|
46
|
+
// return (
|
|
47
|
+
// <SchemaInitializer.Button
|
|
48
|
+
// wrap={gridRowColWrap}
|
|
49
|
+
// title={t('Add block')}
|
|
50
|
+
// icon={'PlusOutlined'}
|
|
51
|
+
// items={[
|
|
52
|
+
// {
|
|
53
|
+
// type: 'itemGroup',
|
|
54
|
+
// title: '{{ t("Data blocks") }}',
|
|
55
|
+
// children: [
|
|
56
|
+
// {
|
|
57
|
+
// type: 'item',
|
|
58
|
+
// title: '{{t("Details")}}',
|
|
59
|
+
// component: 'SnapshotBlockInitializersDetailItem',
|
|
60
|
+
// actionInitializers: 'CalendarFormActionInitializers',
|
|
61
|
+
// },
|
|
62
|
+
// ],
|
|
63
|
+
// },
|
|
64
|
+
// {
|
|
65
|
+
// type: 'itemGroup',
|
|
66
|
+
// title: '{{t("Other blocks")}}',
|
|
67
|
+
// children: [
|
|
68
|
+
// {
|
|
69
|
+
// type: 'item',
|
|
70
|
+
// title: '{{t("Markdown")}}',
|
|
71
|
+
// component: 'MarkdownBlockInitializer',
|
|
72
|
+
// },
|
|
73
|
+
// ],
|
|
74
|
+
// },
|
|
75
|
+
// ]}
|
|
76
|
+
// />
|
|
77
|
+
// );
|
|
78
|
+
};
|