@steedos-labs/plugin-workflow 3.0.0-beta.10 → 3.0.0-beta.12

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.
@@ -437,7 +437,7 @@ pushManager.get_badge = async function (send_from, user_id) {
437
437
  if (((ref4 = appKeyValue.value) != null ? ref4[appName] : void 0) !== categoryBadge) {
438
438
  _set = {};
439
439
  _set['value.' + appName] = categoryBadge;
440
- await getObject('steedos_keyvalues').update(appKeyValue._id, set)
440
+ await getObject('steedos_keyvalues').update(appKeyValue._id, _set)
441
441
  continue;
442
442
  }
443
443
  } else {
@@ -4,6 +4,7 @@ label: Workflow Category
4
4
  hidden: true
5
5
  version: 2
6
6
  enable_dataloader: false
7
+ enable_enhanced_lookup: true
7
8
  fields:
8
9
  name:
9
10
  type: text
@@ -573,6 +573,7 @@ actions:
573
573
  "name": "category",
574
574
  "deleted_lookup_record_behavior": "clear",
575
575
  "reference_to": "categories",
576
+ "required": true,
576
577
  "multiple": false
577
578
  },
578
579
  "id": "u:36461e5ef6f92"
@@ -3,6 +3,7 @@ const objectql = require("@steedos/objectql");
3
3
  const _ = require('underscore');
4
4
  const bodyParser = require('body-parser');
5
5
  const steedosI18n = require("@steedos/i18n");
6
+ const lodash = require('lodash');
6
7
  const { _makeNewID, getCollection } = require('../utils/collection');
7
8
 
8
9
  const designerManager = require('../utils/designerManager');
@@ -151,11 +152,52 @@ router.post('/am/forms', async function (req, res) {
151
152
  modified_by: userId,
152
153
  fields: form["current"]["fields"]
153
154
  };
155
+ let amis_schema = null;
154
156
  if (objectName) {
155
157
  current.fields = Object.values(formFields).concat(tables);
158
+ amis_schema = {
159
+ type: "form",
160
+ id: "instanceForm",
161
+ name: "instanceForm",
162
+ body: [],
163
+ "actions": [],
164
+ "wrapWithPanel": false
165
+ }
166
+
167
+ const getFieldEditTpl = async (field) => {
168
+ if(field.steedos_field){
169
+ const config = field.steedos_field;
170
+ if(config.type === 'formula' || config.type === 'summary'){
171
+ if(config.data_type == 'boolean'){
172
+ config.type = "checkbox"
173
+ }else if(config.data_type == 'number' || config.data_type == 'currency' ){
174
+ config.type = 'number'
175
+ }else if(config.data_type == 'percent'){
176
+ config.type = "number"
177
+ }else {
178
+ config.type = config.data_type
179
+ }
180
+ }
181
+ return {
182
+ type: `sfield-${lodash.toLower(lodash.camelCase(field.steedos_field.type))}`,
183
+ config: config
184
+ }
185
+ }
186
+ }
187
+
188
+ if (current.fields) {
189
+ for (let i = 0; i < current.fields.length; i++) {
190
+ const temp = await getFieldEditTpl(current.fields[i]);
191
+ if (temp) {
192
+ amis_schema.body.push(temp);
193
+ }
194
+ }
195
+ }
156
196
  }
157
197
  newForm.current = current;
158
198
  newForm.historys = [];
199
+ newForm.amis_schema = amis_schema ? JSON.stringify(amis_schema) : amis_schema
200
+ newForm.current.amis_schema = newForm.amis_schema;
159
201
  await objectql.getObject('forms').insert(newForm);
160
202
  const insertedForm = await formCollection.findOne({_id: newForm._id})
161
203
  insertedForms.push(insertedForm);
@@ -181,7 +223,7 @@ router.post('/am/forms', async function (req, res) {
181
223
  name: form["name"],
182
224
  app: form["app"],
183
225
  category: form["category"],
184
- enable_amisform: true
226
+ enable_amisform: false
185
227
  }
186
228
  if (companyId) {
187
229
  flow.company_id = companyId;
@@ -520,6 +520,7 @@ module.exports = {
520
520
 
521
521
  // 数据库更新操作:将forms表current的fields字段更新为最终数组
522
522
  form.current.fields = getFinalFormFields(inputFields);
523
+ form.current.amis_schema = amis_schema;
523
524
 
524
525
  // 以下为将解析字段存储的功能,为将解析字段存储至数据库forms表的功能
525
526
  let updatedForms = [];
@@ -134,7 +134,7 @@ async function updateForm(formId, form, forms, flows, currentUserId) {
134
134
  let insCount = await instancesCollection.countDocuments({
135
135
  space: spaceId,
136
136
  form: formId,
137
- 'form_version': form['current']['id']
137
+ form_version: form['current']['id'] || form['current']['_id']
138
138
  });
139
139
  if (insCount > 0) {
140
140
  pass = true;
@@ -144,7 +144,7 @@ async function updateForm(formId, form, forms, flows, currentUserId) {
144
144
  let recordsCount = await recordsCollection.countDocuments({
145
145
  space: spaceId,
146
146
  form: formId,
147
- 'form_version': form['current']['id']
147
+ form_version: form['current']['id'] || form['current']['_id']
148
148
  });
149
149
  if (recordsCount > 0) {
150
150
  pass = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos-labs/plugin-workflow",
3
- "version": "3.0.0-beta.10",
3
+ "version": "3.0.0-beta.12",
4
4
  "main": "package.service.js",
5
5
  "license": "MIT",
6
6
  "scripts": {