@nocobase/plugin-workflow 0.7.2-alpha.1 → 0.7.2-alpha.2

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.
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export default function (props: any): JSX.Element;
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = _default;
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 _antd() {
19
+ const data = require("antd");
20
+
21
+ _antd = function _antd() {
22
+ return data;
23
+ };
24
+
25
+ return data;
26
+ }
27
+
28
+ function _reactI18next() {
29
+ const data = require("react-i18next");
30
+
31
+ _reactI18next = function _reactI18next() {
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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
49
+
50
+ function _default(props) {
51
+ const collection = props.collection,
52
+ value = props.value,
53
+ onChange = props.onChange;
54
+
55
+ const _useTranslation = (0, _reactI18next().useTranslation)(),
56
+ t = _useTranslation.t;
57
+
58
+ const compile = (0, _client().useCompile)();
59
+
60
+ const _useCollectionManager = (0, _client().useCollectionManager)(),
61
+ getCollectionFields = _useCollectionManager.getCollectionFields;
62
+
63
+ const fields = getCollectionFields(collection).filter(field => field.interface && (!field.target || field.type === 'belongsTo')).map(field => {
64
+ var _field$uiSchema, _field$uiSchema2;
65
+
66
+ return field.type === 'belongsTo' ? {
67
+ title: `${compile(((_field$uiSchema = field.uiSchema) === null || _field$uiSchema === void 0 ? void 0 : _field$uiSchema.title) || field.name)} ID`,
68
+ name: field.foreignKey
69
+ } : {
70
+ title: compile(((_field$uiSchema2 = field.uiSchema) === null || _field$uiSchema2 === void 0 ? void 0 : _field$uiSchema2.title) || field.name),
71
+ name: field.name
72
+ };
73
+ });
74
+ return _react().default.createElement(_antd().Select, {
75
+ placeholder: t('Fields'),
76
+ value: value,
77
+ onChange: onChange
78
+ }, fields.map(field => _react().default.createElement(_antd().Select.Option, {
79
+ key: field.name,
80
+ value: field.name
81
+ }, field.title)));
82
+ }
83
+
84
+ function SelectWithAssociations(props) {
85
+ const collection = props.collection,
86
+ value = props.value,
87
+ onChange = props.onChange;
88
+
89
+ const _useTranslation2 = (0, _reactI18next().useTranslation)(),
90
+ t = _useTranslation2.t;
91
+
92
+ const compile = (0, _client().useCompile)();
93
+ const fields = (0, _client().useCollectionFilterOptions)(collection);
94
+ return _react().default.createElement(_antd().Cascader, {
95
+ fieldNames: {
96
+ label: 'title',
97
+ value: 'name',
98
+ children: 'children'
99
+ },
100
+ changeOnSelect: false,
101
+ value: Array.isArray(value) ? value : value === null || value === void 0 ? void 0 : value.split('.'),
102
+ options: compile(fields),
103
+ onChange: onChange,
104
+ placeholder: t('Select Field')
105
+ });
106
+ }
@@ -37,10 +37,6 @@ declare const _default: {
37
37
  components: {
38
38
  CollectionFieldset: React.MemoExoticComponent<React.FunctionComponent<Pick<any, string | number | symbol>>>;
39
39
  };
40
- getter({ type, options, onChange }: {
41
- type: any;
42
- options: any;
43
- onChange: any;
44
- }): JSX.Element;
40
+ getter(props: any): JSX.Element;
45
41
  };
46
42
  export default _default;
@@ -5,16 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- function _antd() {
9
- const data = require("antd");
10
-
11
- _antd = function _antd() {
12
- return data;
13
- };
14
-
15
- return data;
16
- }
17
-
18
8
  function _react() {
19
9
  const data = _interopRequireDefault(require("react"));
20
10
 
@@ -25,16 +15,6 @@ function _react() {
25
15
  return data;
26
16
  }
27
17
 
28
- function _reactI18next() {
29
- const data = require("react-i18next");
30
-
31
- _reactI18next = function _reactI18next() {
32
- return data;
33
- };
34
-
35
- return data;
36
- }
37
-
38
18
  function _client() {
39
19
  const data = require("@nocobase/client");
40
20
 
@@ -51,6 +31,8 @@ var _collection = require("../schemas/collection");
51
31
 
52
32
  var _WorkflowCanvas = require("../WorkflowCanvas");
53
33
 
34
+ var _CollectionFieldSelect = _interopRequireDefault(require("../components/CollectionFieldSelect"));
35
+
54
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
55
37
 
56
38
  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; }
@@ -87,21 +69,10 @@ var _default = {
87
69
  CollectionFieldset: _calculators.CollectionFieldset
88
70
  },
89
71
 
90
- getter({
91
- type,
92
- options,
93
- onChange: _onChange
94
- }) {
95
- var _collections$find;
96
-
97
- const _useTranslation = (0, _reactI18next().useTranslation)(),
98
- t = _useTranslation.t;
99
-
100
- const compile = (0, _client().useCompile)();
101
-
102
- const _useCollectionManager = (0, _client().useCollectionManager)(),
103
- _useCollectionManager2 = _useCollectionManager.collections,
104
- collections = _useCollectionManager2 === void 0 ? [] : _useCollectionManager2;
72
+ getter(props) {
73
+ const type = props.type,
74
+ options = props.options,
75
+ _onChange = props.onChange;
105
76
 
106
77
  const _useFlowContext = (0, _WorkflowCanvas.useFlowContext)(),
107
78
  nodes = _useFlowContext.nodes;
@@ -109,12 +80,10 @@ var _default = {
109
80
  const _nodes$find = nodes.find(n => n.id == options.nodeId),
110
81
  config = _nodes$find.config;
111
82
 
112
- const collection = (_collections$find = collections.find(item => item.name === config.collection)) !== null && _collections$find !== void 0 ? _collections$find : {
113
- fields: []
114
- };
115
- return _react().default.createElement(_antd().Select, {
116
- value: options.path,
117
- placeholder: t('Fields'),
83
+ const value = options === null || options === void 0 ? void 0 : options.path;
84
+ return _react().default.createElement(_CollectionFieldSelect.default, {
85
+ collection: config.collection,
86
+ value: value,
118
87
  onChange: path => {
119
88
  _onChange({
120
89
  type,
@@ -123,10 +92,7 @@ var _default = {
123
92
  })
124
93
  });
125
94
  }
126
- }, collection.fields.filter(field => _calculators.BaseTypeSet.has(field.uiSchema.type)).map(field => _react().default.createElement(_antd().Select.Option, {
127
- key: field.name,
128
- value: field.name
129
- }, compile(field.uiSchema.title))));
95
+ });
130
96
  }
131
97
 
132
98
  };
@@ -61,10 +61,6 @@ declare const _default: {
61
61
  components: {
62
62
  VariableComponent: typeof VariableComponent;
63
63
  };
64
- getter({ type, options, onChange }: {
65
- type: any;
66
- options: any;
67
- onChange: any;
68
- }): JSX.Element;
64
+ getter(props: any): JSX.Element;
69
65
  };
70
66
  export default _default;
@@ -15,26 +15,6 @@ function _react() {
15
15
  return data;
16
16
  }
17
17
 
18
- function _antd() {
19
- const data = require("antd");
20
-
21
- _antd = function _antd() {
22
- return data;
23
- };
24
-
25
- return data;
26
- }
27
-
28
- function _reactI18next() {
29
- const data = require("react-i18next");
30
-
31
- _reactI18next = function _reactI18next() {
32
- return data;
33
- };
34
-
35
- return data;
36
- }
37
-
38
18
  function _client() {
39
19
  const data = require("@nocobase/client");
40
20
 
@@ -51,6 +31,8 @@ var _calculators = require("../calculators");
51
31
 
52
32
  var _collection = require("../schemas/collection");
53
33
 
34
+ var _CollectionFieldSelect = _interopRequireDefault(require("../components/CollectionFieldSelect"));
35
+
54
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
55
37
 
56
38
  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; }
@@ -93,21 +75,10 @@ var _default = {
93
75
  VariableComponent: _calculators.VariableComponent
94
76
  },
95
77
 
96
- getter({
97
- type,
98
- options,
99
- onChange: _onChange
100
- }) {
101
- var _collections$find;
102
-
103
- const _useTranslation = (0, _reactI18next().useTranslation)(),
104
- t = _useTranslation.t;
105
-
106
- const compile = (0, _client().useCompile)();
107
-
108
- const _useCollectionManager = (0, _client().useCollectionManager)(),
109
- _useCollectionManager2 = _useCollectionManager.collections,
110
- collections = _useCollectionManager2 === void 0 ? [] : _useCollectionManager2;
78
+ getter(props) {
79
+ const type = props.type,
80
+ options = props.options,
81
+ _onChange = props.onChange;
111
82
 
112
83
  const _useFlowContext = (0, _WorkflowCanvas.useFlowContext)(),
113
84
  nodes = _useFlowContext.nodes;
@@ -115,12 +86,10 @@ var _default = {
115
86
  const _nodes$find = nodes.find(n => n.id == options.nodeId),
116
87
  config = _nodes$find.config;
117
88
 
118
- const collection = (_collections$find = collections.find(item => item.name === config.collection)) !== null && _collections$find !== void 0 ? _collections$find : {
119
- fields: []
120
- };
121
- return _react().default.createElement(_antd().Select, {
122
- value: options.path,
123
- placeholder: t('Fields'),
89
+ const value = options === null || options === void 0 ? void 0 : options.path;
90
+ return _react().default.createElement(_CollectionFieldSelect.default, {
91
+ collection: config.collection,
92
+ value: value,
124
93
  onChange: path => {
125
94
  _onChange({
126
95
  type,
@@ -129,14 +98,7 @@ var _default = {
129
98
  })
130
99
  });
131
100
  }
132
- }, collection.fields.filter(field => {
133
- var _field$uiSchema;
134
-
135
- return _calculators.BaseTypeSet.has((_field$uiSchema = field.uiSchema) === null || _field$uiSchema === void 0 ? void 0 : _field$uiSchema.type);
136
- }).map(field => _react().default.createElement(_antd().Select.Option, {
137
- key: field.name,
138
- value: field.name
139
- }, compile(field.uiSchema.title))));
101
+ });
140
102
  }
141
103
 
142
104
  };
@@ -83,10 +83,6 @@ declare const _default: {
83
83
  components: {
84
84
  FieldsSelect: React.MemoExoticComponent<React.FunctionComponent<unknown>>;
85
85
  };
86
- getter({ type, options, onChange }: {
87
- type: any;
88
- options: any;
89
- onChange: any;
90
- }): JSX.Element;
86
+ getter(props: any): JSX.Element;
91
87
  };
92
88
  export default _default;
@@ -47,20 +47,8 @@ function _client() {
47
47
 
48
48
  var _WorkflowCanvas = require("../WorkflowCanvas");
49
49
 
50
- var _calculators = require("../calculators");
51
-
52
50
  var _collection = require("../schemas/collection");
53
51
 
54
- function _reactI18next() {
55
- const data = require("react-i18next");
56
-
57
- _reactI18next = function _reactI18next() {
58
- return data;
59
- };
60
-
61
- return data;
62
- }
63
-
64
52
  function _css() {
65
53
  const data = require("@emotion/css");
66
54
 
@@ -81,6 +69,8 @@ function _core() {
81
69
  return data;
82
70
  }
83
71
 
72
+ var _CollectionFieldSelect = _interopRequireDefault(require("../components/CollectionFieldSelect"));
73
+
84
74
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
85
75
 
86
76
  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; }
@@ -206,47 +196,29 @@ var _default = {
206
196
  FieldsSelect
207
197
  },
208
198
 
209
- getter({
210
- type,
211
- options,
212
- onChange: _onChange
213
- }) {
214
- var _collections$find, _options$path;
215
-
216
- const _useTranslation = (0, _reactI18next().useTranslation)(),
217
- t = _useTranslation.t;
199
+ getter(props) {
200
+ var _options$path;
218
201
 
219
- const compile = (0, _client().useCompile)();
220
-
221
- const _useCollectionManager2 = (0, _client().useCollectionManager)(),
222
- _useCollectionManager3 = _useCollectionManager2.collections,
223
- collections = _useCollectionManager3 === void 0 ? [] : _useCollectionManager3;
202
+ const type = props.type,
203
+ options = props.options,
204
+ _onChange = props.onChange;
224
205
 
225
206
  const _useFlowContext = (0, _WorkflowCanvas.useFlowContext)(),
226
207
  workflow = _useFlowContext.workflow;
227
208
 
228
- const collection = (_collections$find = collections.find(item => item.name === workflow.config.collection)) !== null && _collections$find !== void 0 ? _collections$find : {
229
- fields: []
230
- };
231
- return _react().default.createElement(_antd().Select, {
232
- placeholder: t('Fields'),
233
- value: options === null || options === void 0 ? void 0 : (_options$path = options.path) === null || _options$path === void 0 ? void 0 : _options$path.replace(/^data\./, ''),
234
- onChange: path => {
209
+ const value = options === null || options === void 0 ? void 0 : (_options$path = options.path) === null || _options$path === void 0 ? void 0 : _options$path.replace(/^data\./, '');
210
+ return _react().default.createElement(_CollectionFieldSelect.default, {
211
+ collection: workflow.config.collection,
212
+ value: value,
213
+ onChange: value => {
235
214
  _onChange({
236
215
  type,
237
216
  options: _objectSpread(_objectSpread({}, options), {}, {
238
- path: `data.${path}`
217
+ path: `data.${value}`
239
218
  })
240
219
  });
241
220
  }
242
- }, collection.fields.filter(field => {
243
- var _field$uiSchema2;
244
-
245
- return _calculators.BaseTypeSet.has(field === null || field === void 0 ? void 0 : (_field$uiSchema2 = field.uiSchema) === null || _field$uiSchema2 === void 0 ? void 0 : _field$uiSchema2.type);
246
- }).map(field => _react().default.createElement(_antd().Select.Option, {
247
- key: field.name,
248
- value: field.name
249
- }, compile(field.uiSchema.title))));
221
+ });
250
222
  }
251
223
 
252
224
  };
@@ -57,6 +57,16 @@ function migrateConfig(config, oldToNew) {
57
57
  function migrate(value) {
58
58
  switch (typeOf(value)) {
59
59
  case 'object':
60
+ if (value.type === '$jobsMapByNodeId') {
61
+ var _oldToNew$get, _value$options;
62
+
63
+ return _objectSpread(_objectSpread({}, value), {}, {
64
+ options: _objectSpread(_objectSpread({}, value.options), {}, {
65
+ nodeId: (_oldToNew$get = oldToNew.get((_value$options = value.options) === null || _value$options === void 0 ? void 0 : _value$options.nodeId)) === null || _oldToNew$get === void 0 ? void 0 : _oldToNew$get.id
66
+ })
67
+ });
68
+ }
69
+
60
70
  return Object.keys(value).reduce((result, key) => _objectSpread(_objectSpread({}, result), {}, {
61
71
  [key]: migrate(value[key])
62
72
  }), {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-workflow",
3
- "version": "0.7.2-alpha.1",
3
+ "version": "0.7.2-alpha.2",
4
4
  "main": "lib/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "licenses": [
@@ -10,17 +10,17 @@
10
10
  }
11
11
  ],
12
12
  "dependencies": {
13
- "@nocobase/actions": "0.7.2-alpha.1",
14
- "@nocobase/client": "0.7.2-alpha.1",
15
- "@nocobase/database": "0.7.2-alpha.1",
16
- "@nocobase/server": "0.7.2-alpha.1",
17
- "@nocobase/utils": "0.7.2-alpha.1",
13
+ "@nocobase/actions": "0.7.2-alpha.2",
14
+ "@nocobase/client": "0.7.2-alpha.2",
15
+ "@nocobase/database": "0.7.2-alpha.2",
16
+ "@nocobase/server": "0.7.2-alpha.2",
17
+ "@nocobase/utils": "0.7.2-alpha.2",
18
18
  "cron-parser": "4.4.0",
19
19
  "json-templates": "^4.2.0",
20
20
  "react-js-cron": "^1.4.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@nocobase/test": "0.7.2-alpha.1"
23
+ "@nocobase/test": "0.7.2-alpha.2"
24
24
  },
25
- "gitHead": "2e7958360628d6306845aabcb1e574a8e91d08ad"
25
+ "gitHead": "a0cc50154cc292248ef107c95a24bcc0c7a586fa"
26
26
  }