@steedos/service-plugin-amis 3.0.0-beta.36 → 3.0.0-beta.40

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-plugin-amis",
3
- "version": "3.0.0-beta.36",
3
+ "version": "3.0.0-beta.40",
4
4
  "main": "package.service.js",
5
5
  "scripts": {
6
6
  "build": "yarn build:tailwind-base && yarn build:tailwind",
@@ -13,7 +13,7 @@
13
13
  "publishConfig": {
14
14
  "access": "public"
15
15
  },
16
- "gitHead": "469f7a791d1a304b53446dba2a64349d599be897",
16
+ "gitHead": "ec76285f37e717e2ac48077ea51665119dc5437a",
17
17
  "devDependencies": {
18
18
  "tailwindcss": "3.2.4"
19
19
  }
@@ -126,14 +126,14 @@
126
126
  margin-right: 1rem
127
127
  }
128
128
 
129
- .mb-2 {
130
- margin-bottom: 0.5rem
131
- }
132
-
133
129
  .-mt-3 {
134
130
  margin-top: -0.75rem
135
131
  }
136
132
 
133
+ .mb-2 {
134
+ margin-bottom: 0.5rem
135
+ }
136
+
137
137
  .block {
138
138
  display: block
139
139
  }
@@ -1,336 +0,0 @@
1
- {
2
- "type": "page",
3
- "title": "Welcome to Steedos",
4
- "body": [
5
- {
6
- "type": "steedos-object-form",
7
- "className": "sm:border sm:rounded sm:border-gray-300 bg-white p-4",
8
- "label": "对象表单",
9
- "objectApiName": "apps",
10
- "recordId": "${recordId}",
11
- "mode": "edit",
12
- "fieldsExtend": {
13
- "tab_items": {
14
- "amis": {
15
- "name": "tab_items",
16
- "type": "steedos-input-table",
17
- "label": "",
18
- "showIndex": true,
19
- "source": "${tab_items}",
20
- "strictMode": true,
21
- "affixHeader": false,
22
- "editable": true,
23
- "addable": false,
24
- "removable": true,
25
- "draggable": false,
26
- "fields": [
27
- {
28
- "label": "${'apps.apps_form.tab' | t}",
29
- "type": "lookup",
30
- "multiple": false,
31
- "is_wide": false,
32
- "required": true,
33
- "reference_to": "tabs",
34
- "reference_to_field": "name",
35
- "sort_no": 30,
36
- "name": "tab_name",
37
- "hidden": false,
38
- "readonly": false,
39
- "disabled": false,
40
- "_prefix": "tab_items."
41
- },
42
- {
43
- "label": "${'apps.apps_form.tab_grouping' | t}",
44
- "name": "group",
45
- "_prefix": "tab_items.",
46
- "type": "text",
47
- "amis": {
48
- "type": "select",
49
- "source": "${tab_groups|pick:group_name}",
50
- "onEvent": {
51
- "change": {
52
- "actions": [
53
- {
54
- "actionType": "custom",
55
- "script": "const tabGroupKey = \"group\";const getTabsSortFun = function (groupNames) { return function (m, n) { var tempM = !!m[tabGroupKey] ? 1 : 0; var tempN = !!n[tabGroupKey] ? 1 : 0; if (!m[tabGroupKey] || !n[tabGroupKey]) { return tempM - tempN; } return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]); };};const quickEidtSaveForTab = function (input, prop_name) { const currentPropValue = input.value; const rowValue = input.__super; const formValue = input.__super.__super; const tab_name = rowValue.tab_name; rowValue[prop_name] = currentPropValue; delete rowValue.index; let newTabs = formValue.tab_items.map(function (item) { if (item.tab_name == tab_name) { return Object.assign({}, item, rowValue); } else { return item; } }); const tabGroups = input.__super.__super.tab_groups; const groupNames = _.compact(_.map(tabGroups, \"group_name\")); if (groupNames && groupNames.length) { newTabs.sort(getTabsSortFun(groupNames)); } return { tab_items: newTabs }};const eventData = event.data;const newTabTtemsProp = quickEidtSaveForTab(eventData, \"group\");setTimeout(function () { doAction({ actionType: 'setValue', componentId: \"object_form\", args: { value: newTabTtemsProp } });},300);"
56
- }
57
- ]
58
- }
59
- },
60
- "placeholder": "-"
61
- },
62
- "className": "m-0",
63
- "checkAll": false,
64
- "selectFirst": false,
65
- "searchable": true,
66
- "clearable": true,
67
- "multiple": false,
68
- "mode": "inline"
69
- }
70
- ],
71
- "columns": [
72
- {
73
- "name": "tab_name",
74
- "inlineEditMode": false
75
- },
76
- "group"
77
- ],
78
- "headerToolbar": [
79
- {
80
- "type": "service",
81
- "id": "tabs-options-service",
82
- "className": "mb-2",
83
- "body": [
84
- {
85
- "type": "button",
86
- "id": "u:a35a2276145d",
87
- "label": "${'apps.apps_form.tab_generate' | t}",
88
- "onEvent": {
89
- "click": {
90
- "actions": [
91
- {
92
- "script": "const appId = null; const page = Steedos.Page.getPage('app', appId, null, null, 'generate_object_tabs'); if (page && page.schema) { const pageSchema = JSON.parse(page.schema); let formSchema = pageSchema.body[0]; formSchema.canAccessSuperData = false; formSchema.wrapWithPanel = false; formSchema.className = 'steedos-amis-form'; const title = t('apps.apps_form.tab_generate_title'); doAction({ 'actionType': 'dialog', 'dialog': { 'type': 'dialog', 'title': title, 'body': formSchema, 'size': 'lg' } }); }",
93
- "actionType": "custom"
94
- }
95
- ],
96
- "weight": 0
97
- }
98
- },
99
- "tpl": "内容"
100
- },
101
- {
102
- "type": "button",
103
- "label": "${'apps.apps_form.tab_set' | t}",
104
- "id": "u:853b890ab524",
105
- "actionType": "dialog",
106
- "dialog": {
107
- "type": "dialog",
108
- "title": "${'apps.apps_form.tab_set' | t}",
109
- "body": [
110
- {
111
- "type": "transfer",
112
- "name": "picked_tabs",
113
- "value": "${tab_items|pick:tab_name}",
114
- "sortable": true,
115
- "source": "${tabs_options}",
116
- "searchable": true,
117
- "itemHeight": 40,
118
- "id": "u:f2d36873abd1"
119
- }
120
- ],
121
- "onEvent": {
122
- "confirm": {
123
- "actions": [
124
- {
125
- "actionType": "custom",
126
- "script": "const tabGroupKey = 'group';const getTabsSortFun = function (groupNames) { return function (m, n) { var tempM = !!m[tabGroupKey] ? 1 : 0; var tempN = !!n[tabGroupKey] ? 1 : 0; if (!m[tabGroupKey] || !n[tabGroupKey]) { return tempM - tempN; } return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]); };};const clearTabs = function (input) { return { tab_items: [] }};const convertDataForTabs = function (input) { let pickedTabs = input.picked_tabs || []; const superTabs = _.keyBy(input.__super.tab_items, 'tab_name'); if (typeof pickedTabs === 'string') { pickedTabs = pickedTabs.split(','); } const tabOptions = _.keyBy(input.__super.tabs_options, 'value'); const convertedTabs = pickedTabs.map(function (tab_name) { const superTab = superTabs[tab_name]; if (superTab) { return superTab; } else { const tabOption = tabOptions[tab_name]; return { tab_name: tab_name, group: tabOption.group } } }); const tabGroups = input.__super.tab_groups; const groupNames = _.compact(_.map(tabGroups, 'group_name')); if (groupNames && groupNames.length) { convertedTabs.sort(getTabsSortFun(groupNames)); } return { tab_items: convertedTabs }};const eventData = event.data;doAction({ actionType: 'setValue', componentId: 'object_form', args: { value: convertDataForTabs(eventData) }});doAction({ actionType: 'setValue', componentId: 'tabs-options-service', args: { value: convertDataForTabs(eventData) }});"
127
- }
128
- ]
129
- }
130
- },
131
- "size": "lg",
132
- "id": "u:9c93896a73cf",
133
- "closeOnEsc": false,
134
- "closeOnOutside": false,
135
- "showCloseButton": true,
136
- "showErrorMsg": true,
137
- "showLoading": true,
138
- "dataMapSwitch": false
139
- }
140
- },
141
- {
142
- "type": "button",
143
- "label": "${'apps.apps_form.tab_grouping_set' | t}",
144
- "actionType": "dialog",
145
- "dialog": {
146
- "title": "${'apps.apps_form.tab_grouping_set' | t}",
147
- "body": [
148
- {
149
- "type": "input-table",
150
- "name": "setting_groups",
151
- "value": "${tab_groups}",
152
- "addable": true,
153
- "draggable": true,
154
- "editable": true,
155
- "needConfirm": false,
156
- "columns": [
157
- {
158
- "name": "group_name",
159
- "label": "${'apps.apps_form.tab_grouping_name' | t}",
160
- "id": "u:383c7744b499"
161
- },
162
- {
163
- "name": "default_open",
164
- "label": "${'apps.apps_form.tab_grouping_open' | t}",
165
- "id": "u:7a243c84ed66",
166
- "type": "checkbox",
167
- "value": true
168
- }
169
- ],
170
- "removable": true,
171
- "id": "setting_groups"
172
- }
173
- ],
174
- "onEvent": {
175
- "confirm": {
176
- "actions": [
177
- {
178
- "actionType": "custom",
179
- "script": "const tabGroupKey = 'group';\nconst getTabsSortFun = function (groupNames) {\n return function (m, n) {\n var tempM = !!m[tabGroupKey] ? 1 : 0;\n var tempN = !!n[tabGroupKey] ? 1 : 0;\n if (!m[tabGroupKey] || !n[tabGroupKey]) {\n return tempM - tempN;\n }\n return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]);\n };\n};\nconst clearTabs = function (input) { return { tab_items: [] } };\nconst convertDataForGroups = function (input) {\n \n const settingGroups = input.setting_groups || [];\n const convertedGroups = _.uniqBy(settingGroups.map(function (item) {\n return { group_name: item.group_name, default_open: item.default_open }\n }), 'group_name');\n const groupNames = _.compact(_.map(convertedGroups, 'group_name'));\n const tab_items = input.tab_items;\n tab_items?.sort(getTabsSortFun(groupNames));\n \n return { tab_groups: convertedGroups, tab_items: tab_items }\n};\nconst eventData = event.data;\ndoAction(\n {\n actionType: 'setValue',\n componentId: 'object_form',\n args: { value: convertDataForGroups(eventData) }\n }\n);"
180
- }
181
- ]
182
- }
183
- },
184
- "type": "dialog",
185
- "size": "lg",
186
- "id": "setting_groups",
187
- "closeOnEsc": false,
188
- "closeOnOutside": false,
189
- "showCloseButton": true,
190
- "showErrorMsg": true,
191
- "showLoading": true,
192
- "dataMapSwitch": false
193
- },
194
- "id": "u:111b043b193c"
195
- }
196
- ],
197
- "messages": {
198
- },
199
- "api": {
200
- "method": "post",
201
- "url": "${context.rootUrl}/graphql",
202
- "adaptor": "let data = payload.data;\ndata.tabs_options = [];\nif (data.options && data.options.length) {\n data.tabs_options = data.options.map(function (option) {\n option.label = option.label + '(' + option.value + ')';\n return option;\n });\n}\nif (!api.body.recordId) {\n const defaultValues = {\n is_creator: true,\n mobile: true,\n visible: true,\n sort: 9100\n };\n data = Object.assign({}, data, defaultValues);\n}\ndelete data.options;\npayload.data = data;\nreturn payload; ",
203
- "data": {
204
- "query": "{options:tabs{_id label:label value:name,type,object,desktop,mobile}}",
205
- "recordId": "${recordId}"
206
- },
207
- "headers": {
208
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
209
- },
210
- "messages": {
211
- },
212
- "requestAdaptor": ""
213
- }
214
- }
215
- ],
216
- "enableDialog": false,
217
- "id": "u:7949aecf0ca9"
218
- }
219
- },
220
- "objects": {
221
- "amis": {
222
- "name": "objects",
223
- "type": "select",
224
- "className": "m-0",
225
- "labelClassName": "text-left",
226
- "id": "u:4e5047e44905",
227
- "joinValues": false,
228
- "extractValue": true,
229
- "labelField": "label",
230
- "valueField": "value",
231
- "multiple": true,
232
- "checkAll": false,
233
- "searchable": true,
234
- "menuTpl": "",
235
- "source": {
236
- "method": "get",
237
- "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/options",
238
- "headers": {
239
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
240
- }
241
- },
242
- "autoComplete": ""
243
- }
244
- },
245
- "mobile_objects": {
246
- "amis": {
247
- "name": "mobile_objects",
248
- "type": "select",
249
- "className": "m-0",
250
- "labelClassName": "text-left",
251
- "id": "u:cfaeb2f857a8",
252
- "joinValues": false,
253
- "extractValue": true,
254
- "labelField": "label",
255
- "valueField": "value",
256
- "multiple": true,
257
- "checkAll": false,
258
- "searchable": true,
259
- "menuTpl": "",
260
- "source": {
261
- "method": "get",
262
- "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/options",
263
- "messages": {
264
- },
265
- "headers": {
266
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
267
- }
268
- },
269
- "autoComplete": ""
270
- }
271
- },
272
- "visible_on": {
273
- "amis": {
274
- "type": "control",
275
- "body": [
276
- {
277
- "type": "service",
278
- "id": "u:edcd865de7d8",
279
- "body": [
280
- {
281
- "type": "input-formula",
282
- "name": "visible_on",
283
- "evalMode": false,
284
- "variableMode": "tabs",
285
- "variables": "${visibleOnVariables}",
286
- "visibleOn": "${visibleOnVariables}",
287
- "id": "u:618105d5bfad",
288
- "labelClassName": "none"
289
- }
290
- ],
291
- "api": {
292
- "method": "get",
293
- "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/apps/fields/options",
294
- "cache": 30000,
295
- "adaptor": "const visibleOnVariables = SteedosUI.getFormulaVariables(payload.data.options);\nconst defaultValueVariables = [visibleOnVariables[1]];\npayload = {\n data: {\n visibleOnVariables,\n defaultValueVariables\n }\n};\nreturn payload;",
296
- "headers": {
297
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
298
- }
299
- },
300
- "dsType": "api"
301
- }
302
- ],
303
- "id": "u:996ef29c6851"
304
- }
305
- }
306
- },
307
- "enableTabs": true,
308
- "debug": false,
309
- "initApiRequestAdaptor": "",
310
- "initApiAdaptor": "var data = payload.data;\nif (data.tab_items && !_.isArray(data.tab_items)) {\n // 数据库中存储的是对象格式而不是数组,转换为数组用于界面显示\n let arrTabItems = [];\n _.each(data.tab_items, function (n, k) {\n n.tab_name = k;\n delete n.index;\n arrTabItems.push(n);\n });\n data.tab_items = arrTabItems;\n}\nif (data._id && !data.tab_items) {\n const tabOptions = data.tabs_options || [];\n const tabItems = [];\n // 把应用中原来tabs属性值添加到新的tab_items属性的默认值中\n if (data.tabs && data.tabs.length) {\n data.tabs.forEach(function (item) {\n tabItems.push({ tab_name: item });\n });\n }\n const pushObjectsToTabItems = function (objects) {\n objects.forEach(function (item) {\n // 已经有绑定到指定对象的选项卡就不添加\n let existObjectItem = !!tabItems.find(function (tabItem) {\n return !!tabOptions.find(function (option) {\n return tabItem.tab_name === tabItem.value && option.object === item;\n });\n });\n if (existObjectItem) {\n return;\n }\n // 找到指向指定对象的选项卡\n let tempOption = tabOptions.find(function (option) {\n return option.type === \"object\" && option.object === item;\n });\n if (!tempOption) {\n return;\n }\n // 选项卡名称如果重复了就不添加\n let existTabItem = !!tabItems.find(function (tabItem) {\n return tabItem.tab_name === tempOption.value;\n });\n if (existTabItem) {\n return;\n }\n if (tempOption) {\n tabItems.push({ tab_name: tempOption.value });\n }\n });\n }\n // 把应用中原来objects属性值添加到新的tab_items属性的默认值中\n if (data.objects && data.objects.length) {\n pushObjectsToTabItems(data.objects);\n }\n // 把应用中原来mobile_objects属性值添加到新的tab_items属性的默认值中\n if (data.mobile_objects && data.mobile_objects.length) {\n pushObjectsToTabItems(data.mobile_objects);\n }\n data.tab_items = tabItems;\n}\n\npayload.data = data;\ndelete payload.extensions;\nreturn payload;\n ",
311
- "apiRequestAdaptor": "delete formData.tabs_options;\nconst recordId = formData.recordId;\n\n// 新加字段tab_items,值同步回传到老字段tabs中兼容老UI界面\nformData.tabs = [];\nif (formData.tab_items && formData.tab_items.length) { \n formData.tabs = formData.tab_items.map(function (item) { return item.tab_name; });\n}\n\n/*\ntab_items存储为:\ntab_items: {\n test1:{\n group:\"xxx\"\n },\n test3:{\n group:\"yyy\"\n }\n}\n而不是:\ntab_items: [\n {\n \"index\":1,\n \"group\":\"xxx\"\n },\n {\n \"index\":2,\n \"group\":\"yyy\"\n }\n]\n*/\nif (formData.tab_items) { \n formData.tab_items = _.keyBy(formData.tab_items, \"tab_name\")\n let tempIndex = 0;\n _.each(formData.tab_items, function (n, k) {\n tempIndex++;\n n.index = tempIndex;\n delete n.tab_name;\n });\n}\n\nquery = `mutation{record: ${objectName}__insert(doc: {__saveData}){_id}}`;\nif(recordId){\n query = `mutation{record: ${objectName}__update(id: \"${recordId}\", doc: {__saveData}){_id}}`;\n};\n__saveData = JSON.stringify(JSON.stringify(formData));\n\napi.data = {query: query.replace('{__saveData}', __saveData)};\nreturn api;\n",
312
- "apiAdaptor": "",
313
- "form": {
314
- "id": "object_form"
315
- },
316
- "id": "u:e1c1a841d373",
317
- "tabsMode": "line"
318
- }
319
- ],
320
- "regions": [
321
- "body"
322
- ],
323
- "data": {
324
- "objectName": "apps",
325
- "initialValues": {},
326
- "appId": "builder",
327
- "title": "",
328
- "context": {
329
- "rootUrl": "http://127.0.0.1:5800",
330
- "tenantId": "64a4d6dd7fe9acaf8c330a37",
331
- "userId": "683e09cd-8482-4034-bd29-5a30643e6c0f",
332
- "authToken": "2906ff4353c25cfe291352f899ba3446aa5577f3de7ad60e1aa500c60dee7ca6fb446412f1c9693775b4cc"
333
- }
334
- },
335
- "id": "u:de840f3523f2"
336
- }
@@ -1,12 +0,0 @@
1
- name: apps_form
2
- is_active: true
3
- label: 应用程序表单
4
- object_name: apps
5
- pageAssignments:
6
- - desktop: true
7
- mobile: true
8
- page: apps_form
9
- type: orgDefault
10
- render_engine: amis
11
- type: form
12
- widgets: []