@steedos-labs/plugin-workflow 3.0.0-beta.14 → 3.0.0-beta.15

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.
@@ -631,7 +631,7 @@ actions:
631
631
  "requestAdaptor": "\n var filters = [];\n var top = 1000;\n if(api.data.$term){\n filters = [[\"label\", \"contains\", api.data.$term]];\n }\n // else if(api.data.$value){\n // filters = [[\"_id\", \"=\", api.data.$value]];\n // }\n\n var fieldFilters = [\"enable_workflow\",\"=\",true];\n if(fieldFilters && fieldFilters.length){\n filters.push(fieldFilters);\n }\n\n const filtersFunction = undefined;\n\n if(filtersFunction){\n const _filters = filtersFunction(filters, api.data.$);\n if(_filters && _filters.length > 0){\n filters.push(_filters);\n }\n }\n var sort = \"\";\n api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', top).replace('{__sort}', sort.trim());\n\n var defaultValue = api.data.$value;\n var optionsFiltersOp = \"=\";\n var optionsFilters = [[\"name\", optionsFiltersOp, []]];\n if (defaultValue && !api.data.$term) { \n // 字段值单独请求,没值的时候在请求中返回空\n optionsFilters = [[\"name\", optionsFiltersOp, defaultValue]];\n }\n api.data.query = api.data.query.replace(/{__options_filters}/g, JSON.stringify(optionsFilters));\n return api;\n "
632
632
  },
633
633
  "multiple": false
634
- }
634
+ },{"type": "checkbox","option": "","name": "enable_amisform","id": "u:f581950a606a","label": "${'flows.standard_new.enable_amis_forms' | t}"}
635
635
  ],
636
636
  "api": {
637
637
  "method": "post",
@@ -640,7 +640,7 @@ actions:
640
640
  "&": "$$",
641
641
  "space": "${spaceId}"
642
642
  },
643
- "requestAdaptor": "const {id, name, space} = api.body;var form = {\n id,\n name,\n space,\n is_valid: true,\n app: 'workflow',\n current: {\n id\n }\n\n};\nvar body = api.body;\nif (body.category) {\n form.category = body.category\n}\n\nlet companyId = body.company_id\nif (companyId) {\n form.company_id = companyId\n}\n\nif (body.object_name2) {\n form.object_name = body.object_name2\n}\n\napi.data = {\n Forms: [form]\n};\n\nconsole.log(`api`, api)\nreturn api;"
643
+ "requestAdaptor": "const {id, name, space, enable_amisform} = api.body;var form = {\n id,\n name,\n space, enable_amisform, \n is_valid: true,\n app: 'workflow',\n current: {\n id\n }\n\n};\nvar body = api.body;\nif (body.category) {\n form.category = body.category\n}\n\nlet companyId = body.company_id\nif (companyId) {\n form.company_id = companyId\n}\n\nif (body.object_name2) {\n form.object_name = body.object_name2\n}\n\napi.data = {\n Forms: [form]\n};\n\nconsole.log(`api`, api)\nreturn api;"
644
644
  },
645
645
  "onEvent": {
646
646
  "submitSucc": {
@@ -687,7 +687,10 @@ actions:
687
687
  'on': list
688
688
  todo: !<tag:yaml.org,2002:js/function> |-
689
689
  function (object_name, record_id, fields) {
690
- const locale = 'ZH-CN';
690
+ let locale = 'ZH-CN';
691
+ if(Builder.settings.context.user.language != 'zh-CN'){
692
+ locale = 'en-us'
693
+ }
691
694
  const space = Builder.settings.context.user.spaceId;
692
695
  const flow = null;
693
696
  const companyId = Builder.settings.context.user.company_id;
@@ -721,7 +724,10 @@ actions:
721
724
  todo: !<tag:yaml.org,2002:js/function> |-
722
725
  function (object_name, record_id, record_permissions, data) {
723
726
  const flow = data && data.record;
724
- const locale = 'ZH-CN';
727
+ let locale = 'ZH-CN';
728
+ if(Builder.settings.context.user.language != 'zh-CN'){
729
+ locale = 'en-us'
730
+ }
725
731
  const space = Builder.settings.context.user.spaceId;
726
732
  const companyId = Builder.settings.context.user.company_id;
727
733
  let url = `/applications/designer/current/${locale.toLocaleLowerCase()}/?spaceId=${space}` + `&flowId=${flow._id}`;
@@ -84,6 +84,7 @@ router.get('/am/designer/startup', async function (req, res) {
84
84
  router.post('/am/forms', async function (req, res) {
85
85
  try {
86
86
  let userId = req.user.userId;
87
+ let language = req.user.language;
87
88
  let data = req.body;
88
89
  let formCollection = await getCollection('forms');
89
90
  let flowCollection = await getCollection('flows');
@@ -156,12 +157,13 @@ router.post('/am/forms', async function (req, res) {
156
157
  if (objectName) {
157
158
  current.fields = Object.values(formFields).concat(tables);
158
159
  amis_schema = {
159
- type: "form",
160
+ type: 'steedos-flow-form',
160
161
  id: "instanceForm",
161
- name: "instanceForm",
162
- body: [],
163
- "actions": [],
164
- "wrapWithPanel": false
162
+ name: newForm.name,
163
+ label: newForm.name,
164
+ description: newForm.description,
165
+ className: "steedos-flow-form steedos-flow-layout-page",
166
+ body: []
165
167
  }
166
168
 
167
169
  const getFieldEditTpl = async (field) => {
@@ -250,7 +252,7 @@ router.post('/am/forms', async function (req, res) {
250
252
  flow.perms = flowPerms;
251
253
  let flow_current = {
252
254
  _id: _makeNewID(),
253
- steps: await designerManager.makeSteps(userId, newForm.current.fields),
255
+ steps: await designerManager.makeSteps(userId, newForm.current.fields, language),
254
256
  _rev: 1,
255
257
  flow: flow._id,
256
258
  form_version: form["current"]["id"],
@@ -115,6 +115,12 @@
115
115
  tenantId,
116
116
  authToken,
117
117
  },
118
+ global: {
119
+ userId: userId,
120
+ spaceId: tenantId,
121
+ user: <%- JSON.stringify(userSession) %>,
122
+ now: new Date(),
123
+ }
118
124
  },
119
125
  };
120
126
 
@@ -144,14 +150,14 @@
144
150
 
145
151
  if (!schema) {
146
152
  //进if说明schema字段为空 说明为旧表单 对schema重新赋值
147
- schema =
148
- {
149
- type: "form",
153
+ schema = {
154
+ type: 'steedos-flow-form',
150
155
  id: "instanceForm",
151
- name: "instanceForm",
152
- body: [],
153
- "actions": [],
154
- "wrapWithPanel": false
156
+ name: result.data.data.record.name,
157
+ label: result.data.data.record.name,
158
+ description: result.data.data.record.description,
159
+ className: "steedos-flow-form steedos-flow-layout-page",
160
+ body: []
155
161
  }
156
162
  if (result.data.data.record.current.fields) {
157
163
  for (let i = 0; i < result.data.data.record.current.fields.length; i++) {
@@ -190,6 +196,14 @@
190
196
  schema.data.context.tenantId = tenantId;
191
197
  schema.data.context.userId = userId;
192
198
  schema.data.context.authToken = authToken;
199
+
200
+ schema.data.global = {
201
+ userId: userId,
202
+ spaceId: tenantId,
203
+ user: <%- JSON.stringify(userSession) %>,
204
+ now: new Date(),
205
+ }
206
+
193
207
  return schema || initialContent
194
208
  }
195
209
  } else {
@@ -462,6 +476,7 @@
462
476
  );
463
477
  if (schema.data && typeof schema.data.context === 'object') {
464
478
  delete schema.data.context
479
+ delete schema.data.global
465
480
  }
466
481
 
467
482
  return await axios.post(
@@ -56,6 +56,9 @@ const AmisInputTypes = [
56
56
 
57
57
  // getInstanceFormSchema() 在用户创建的表单中获取到type为form name为instanceForm的表单,其他的表单不要
58
58
  function getInstanceFormSchema(amis_schema) {
59
+ if(!amis_schema){
60
+ return ;
61
+ }
59
62
 
60
63
  if (amis_schema.type === 'form' && amis_schema.name === 'instanceForm' || amis_schema.type === 'steedos-flow-form') {
61
64
  const proper_schema = amis_schema;
@@ -293,7 +293,7 @@ async function isSpaceAdmin(spaceId, userId, roles) {
293
293
  }
294
294
  }
295
295
 
296
- async function makeSteps(userId, fields = []) {
296
+ async function makeSteps(userId, fields = [], language) {
297
297
  let blank_ayy = [];
298
298
  let stepEnd = _makeNewID();
299
299
  let steps = [];
@@ -303,7 +303,7 @@ async function makeSteps(userId, fields = []) {
303
303
  start_step.approver_roles = blank_ayy;
304
304
  start_step.approver_users = blank_ayy;
305
305
  start_step.fields_modifiable = blank_ayy;
306
- start_step.name = '开始';
306
+ start_step.name = language === 'zh-CN' ? '开始' : 'Start';
307
307
  start_step.step_type = "start";
308
308
  start_step.posx = -1;
309
309
  start_step.posy = -1;
@@ -336,7 +336,7 @@ async function makeSteps(userId, fields = []) {
336
336
  end_step.approver_users = blank_ayy;
337
337
  end_step.fields_modifiable = blank_ayy;
338
338
  end_step.lines = blank_ayy;
339
- end_step.name = '结束';
339
+ end_step.name = language === 'zh-CN' ? '结束' : 'End';
340
340
  end_step.step_type = "end";
341
341
  end_step.posx = -1;
342
342
  end_step.posy = -1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos-labs/plugin-workflow",
3
- "version": "3.0.0-beta.14",
3
+ "version": "3.0.0-beta.15",
4
4
  "main": "package.service.js",
5
5
  "license": "MIT",
6
6
  "scripts": {