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

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.
@@ -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}`;
@@ -790,8 +796,8 @@ actions:
790
796
  todo: !<tag:yaml.org,2002:js/function> |-
791
797
  function (object_name, record_id, fields, data) {
792
798
  var record = data && data.record;
793
- var userSession = Creator.USER_CONTEXT;
794
- var authorization = "Bearer " + userSession.spaceId + "," + userSession.user.authToken;
799
+ var userSession = Builder.settings.context.user;
800
+ var authorization = "Bearer " + userSession.spaceId + "," + userSession.authToken;
795
801
  var formId = _.isObject(record.form) ? record.form._id : record.form;
796
802
  window.$.ajax({
797
803
  type: "POST",
@@ -22,6 +22,21 @@ fields:
22
22
  readonly: true
23
23
  name: state
24
24
  filterable: true
25
+ style:
26
+ type: select
27
+ label: Style
28
+ options:
29
+ - label: Table
30
+ value: table
31
+ - label: Groups
32
+ value: groups
33
+ - label: Tabs
34
+ value: tabs
35
+ - label: Wizard
36
+ value: wizard
37
+ readonly: true
38
+ name: style
39
+ filterable: true
25
40
  description:
26
41
  type: textarea
27
42
  label: Description
@@ -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;
@@ -521,6 +524,9 @@ module.exports = {
521
524
  // 数据库更新操作:将forms表current的fields字段更新为最终数组
522
525
  form.current.fields = getFinalFormFields(inputFields);
523
526
  form.current.amis_schema = amis_schema;
527
+ form.current.style = formSchema.style;
528
+ form.style = formSchema.style;
529
+ form.description = formSchema.description;
524
530
 
525
531
  // 以下为将解析字段存储的功能,为将解析字段存储至数据库forms表的功能
526
532
  let updatedForms = [];
@@ -221,6 +221,7 @@ async function updateForm(formId, form, forms, flows, currentUserId) {
221
221
  current.fields = _formatFieldsID(form["current"]["fields"]);
222
222
  current.form_script = form["current"]["form_script"];
223
223
  current.name_forumla = form["current"]["name_forumla"];
224
+ current.style = form["current"]["style"];
224
225
 
225
226
  formUpdateObj.$set = {
226
227
  'current': current,
@@ -228,6 +229,7 @@ async function updateForm(formId, form, forms, flows, currentUserId) {
228
229
  'modified': now,
229
230
  'modified_by': currentUserId,
230
231
  'is_valid': form["is_valid"],
232
+ 'style': form["style"],
231
233
  'description': form["description"],
232
234
  'help_text': form["help_text"],
233
235
  'error_message': form["error_message"],
@@ -293,7 +295,7 @@ async function isSpaceAdmin(spaceId, userId, roles) {
293
295
  }
294
296
  }
295
297
 
296
- async function makeSteps(userId, fields = []) {
298
+ async function makeSteps(userId, fields = [], language) {
297
299
  let blank_ayy = [];
298
300
  let stepEnd = _makeNewID();
299
301
  let steps = [];
@@ -303,7 +305,7 @@ async function makeSteps(userId, fields = []) {
303
305
  start_step.approver_roles = blank_ayy;
304
306
  start_step.approver_users = blank_ayy;
305
307
  start_step.fields_modifiable = blank_ayy;
306
- start_step.name = '开始';
308
+ start_step.name = language === 'zh-CN' ? '开始' : 'Start';
307
309
  start_step.step_type = "start";
308
310
  start_step.posx = -1;
309
311
  start_step.posy = -1;
@@ -336,7 +338,7 @@ async function makeSteps(userId, fields = []) {
336
338
  end_step.approver_users = blank_ayy;
337
339
  end_step.fields_modifiable = blank_ayy;
338
340
  end_step.lines = blank_ayy;
339
- end_step.name = '结束';
341
+ end_step.name = language === 'zh-CN' ? '结束' : 'End';
340
342
  end_step.step_type = "end";
341
343
  end_step.posx = -1;
342
344
  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.16",
4
4
  "main": "package.service.js",
5
5
  "license": "MIT",
6
6
  "scripts": {