@steedos/service-plugin-amis 2.3.0-beta.24 → 2.3.0-beta.26
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.
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
return true;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
// 加载Amis SDK: 如果直接放到body中会导致meteor 编译后的 cordova.js 加载报错
|
|
50
|
+
// 加载Amis SDK: 如果直接放到body中会导致 meteor 编译后的 cordova.js 加载报错
|
|
51
51
|
let amisSDKScript = document.createElement("script");
|
|
52
52
|
amisSDKScript.setAttribute("src", Steedos.absoluteUrl('/unpkg.com/amis/sdk/sdk.js'));
|
|
53
53
|
document.getElementsByTagName("head")[0].appendChild(amisSDKScript);
|
|
@@ -73,6 +73,8 @@
|
|
|
73
73
|
waitForThing(window, 'assetsLoaded'),
|
|
74
74
|
waitForThing(window, 'amis'),
|
|
75
75
|
]).then(()=>{
|
|
76
|
+
window.React = window.__React;
|
|
77
|
+
window.ReactDOM = window.__ReactDOM;
|
|
76
78
|
const AmisRenderers = [];
|
|
77
79
|
|
|
78
80
|
const amisComps = lodash.filter(Builder.registry['meta-components'], function(item){ return item.componentName && item.amis?.render});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// 解决多个react 问题. 注册组件时, 使用 amis 自带的 react , 运行 steedos 相关组件时, 使用 全局 react
|
|
2
|
+
window.addEventListener('message', function (event) {
|
|
3
|
+
const { data } = event;
|
|
4
|
+
if (data.type === 'Builder.loaded') {
|
|
5
|
+
if(Meteor.settings.public.page && Meteor.settings.public.page.assetUrls){
|
|
6
|
+
const defaultAssetsUrls = Meteor.settings.public.page.assetUrls.split(',')
|
|
7
|
+
Promise.all([
|
|
8
|
+
waitForThing(window, 'amis'),
|
|
9
|
+
]).then(()=>{
|
|
10
|
+
window.__React = window.React;
|
|
11
|
+
window.__ReactDOM = window.ReactDOM;
|
|
12
|
+
window.React = amisRequire('react');
|
|
13
|
+
window.ReactDOM = amisRequire('react-dom');
|
|
14
|
+
window.ReactDom = window.ReactDOM;
|
|
15
|
+
Builder.registerRemoteAssets(defaultAssetsUrls);
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
})
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"modalName": "${modalName}",
|
|
19
19
|
"objectName": "${objectName}"
|
|
20
20
|
},
|
|
21
|
-
"requestAdaptor": "\nconst formData = api.data.$;\nfor (key in formData){\n // image、select等字段清空值后保存的空字符串转换为null。\n if(formData[key] === ''){\n formData[key] = null;\n }\n}\nconst objectName = api.data.objectName;\nconst fieldsName = Object.keys(formData);\ndelete formData.created;\ndelete formData.created_by;\ndelete formData.modified;\ndelete formData.modified_by;\ndelete formData._display;\ndelete formData.tabs_options;\ndelete formData.tab_groups_options;\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\nlet query = `mutation{record: ${objectName}__insert(doc: {__saveData}){_id}}`;\nif(formData.recordId){\n query = `mutation{record: ${objectName}__update(id: \"${formData.recordId}\", doc: {__saveData}){_id}}`;\n};\ndelete formData._id;\nlet __saveData = JSON.stringify(JSON.stringify(formData));\n\napi.data = {query: query.replace('{__saveData}', __saveData)};\nreturn api;\n",
|
|
21
|
+
"requestAdaptor": "\nconst formData = api.data.$;\nfor (key in formData){\n // image、select等字段清空值后保存的空字符串转换为null。\n if(formData[key] === ''){\n formData[key] = null;\n }\n}\nconst objectName = api.data.objectName;\nconst fieldsName = Object.keys(formData);\ndelete formData.created;\ndelete formData.created_by;\ndelete formData.modified;\ndelete formData.modified_by;\ndelete formData._display;\ndelete formData.tabs_options;\ndelete formData.tab_groups_options;\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\nlet query = `mutation{record: ${objectName}__insert(doc: {__saveData}){_id}}`;\nif(formData.recordId){\n query = `mutation{record: ${objectName}__update(id: \"${formData.recordId}\", doc: {__saveData}){_id}}`;\n};\ndelete formData._id;\nlet __saveData = JSON.stringify(JSON.stringify(formData));\n\napi.data = {query: query.replace('{__saveData}', __saveData)};\nreturn api;\n",
|
|
22
22
|
"responseData": {
|
|
23
23
|
"recordId": "${record._id}"
|
|
24
24
|
},
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"method": "post",
|
|
32
32
|
"url": "${context.rootUrl}/graphql",
|
|
33
33
|
"sendOn": "!!this.recordId",
|
|
34
|
-
"adaptor": "var data = payload.data.data[0];\nif(data){\n //初始化接口返回的字段移除字段值为null的字段\n for (key in data){\n if(data[key] === null){\n delete data[key];\n }\n }\n};\npayload.data = data;\ndelete payload.extensions;\nreturn payload;\n ",
|
|
34
|
+
"adaptor": "var data = payload.data.data[0];\nif(data){\n //初始化接口返回的字段移除字段值为null的字段\n for (key in data){\n if(data[key] === null){\n delete data[key];\n }\n }\n};\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}\npayload.data = data;\ndelete payload.extensions;\nreturn payload;\n ",
|
|
35
35
|
"data": {
|
|
36
36
|
"query": "{data:apps(filters:[\"_id\", \"=\", \"${recordId}\"]){_id,name,code,icon_slds,visible,description,tabs,tab_items,tab_groups,objects,mobile_objects,is_creator,mobile,sort,url,is_use_ie,is_use_iframe,is_new_window,on_click,auth_name,secret,is_system,from_code_id,instance_state,created,created_by:created_by__expand{_id,name},modified,modified_by:modified_by__expand{_id,name},_display{visible,is_creator,mobile,is_use_ie,is_use_iframe,is_new_window,is_system,instance_state,created,modified}}}"
|
|
37
37
|
},
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"api": {
|
|
50
50
|
"method": "post",
|
|
51
51
|
"url": "${context.rootUrl}/graphql",
|
|
52
|
-
"adaptor": "let data = payload.data;\ndata.tabs_options = data.options;\ndelete data.options\npayload.data = data;\nreturn payload;\n",
|
|
52
|
+
"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}\ndelete data.options\npayload.data = data;\nreturn payload;\n",
|
|
53
53
|
"data": {
|
|
54
54
|
"query": "{options:tabs{_id label:label value:name,type,object,desktop,mobile}}"
|
|
55
55
|
},
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"valueField": "symbol",
|
|
108
108
|
"multiple": false,
|
|
109
109
|
"source": "${sldsIconsOptions}",
|
|
110
|
-
"menuTpl": "<span class=\"flex
|
|
110
|
+
"menuTpl": "<span class=\"flex items-center mt-0.5\">\n <span role=\"img\" aria-label=\"smile\" class=\"anticon anticon-smile\">\n <span class=\"slds-icon_container slds-icon-standard-${symbol|split:_|join:-}\">\n <svg class=\"slds-icon slds-icon_x-small\" aria-hidden=\"true\">\n <use xlink:href=\"/unpkg.com/@salesforce-ux/design-system/assets/icons/standard-sprite/svg/symbols.svg#${symbol}\"></use>\n </svg>\n </span>\n </span>\n <span class=\"pl-1.5\">${symbol}</span>\n</span>"
|
|
111
111
|
}
|
|
112
112
|
],
|
|
113
113
|
"id": "u:420b0162ce2c",
|
|
@@ -262,7 +262,7 @@
|
|
|
262
262
|
"actions": [
|
|
263
263
|
{
|
|
264
264
|
"actionType": "custom",
|
|
265
|
-
"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 // 没有配置group属性的字段排在前面\n return tempM - tempN;\n }\n // 字段所属分组不在groupNames时排在前面,其他字段按其所属分组在groupNames中的排序先后顺序排序,所属分组相同的字段排在一起。\n return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]);\n };\n}\n\nconst clearTabs = function (input) {\n return {\n tab_items: []\n }\n}\n\n// 字段列表每一列数据变量时立即同步值到表单中\nconst quickEidtSaveForTab = function (input, prop_name) {\n const currentPropValue = input.value;\n const rowValue = input.__super;\n const formValue = input.__super.__super.__super;\n const tab_name = rowValue.tab_name;\n rowValue[prop_name] = currentPropValue;\n delete rowValue.index;\n let newTabs = formValue.tab_items.map(function (item) {\n if (item.tab_name == tab_name) {\n return Object.assign({}, item, rowValue);\n }\n else {\n return item;\n }\n });\n const tabGroups = input.__super.__super.tab_groups;\n const groupNames =
|
|
265
|
+
"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 // 没有配置group属性的字段排在前面\n return tempM - tempN;\n }\n // 字段所属分组不在groupNames时排在前面,其他字段按其所属分组在groupNames中的排序先后顺序排序,所属分组相同的字段排在一起。\n return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]);\n };\n}\n\nconst clearTabs = function (input) {\n return {\n tab_items: []\n }\n}\n\n// 字段列表每一列数据变量时立即同步值到表单中\nconst quickEidtSaveForTab = function (input, prop_name) {\n const currentPropValue = input.value;\n const rowValue = input.__super;\n const formValue = input.__super.__super.__super;\n const tab_name = rowValue.tab_name;\n rowValue[prop_name] = currentPropValue;\n delete rowValue.index;\n let newTabs = formValue.tab_items.map(function (item) {\n if (item.tab_name == tab_name) {\n return Object.assign({}, item, rowValue);\n }\n else {\n return item;\n }\n });\n const tabGroups = input.__super.__super.tab_groups;\n const groupNames = _.compact(_.map(tabGroups, \"group_name\"));\n if (groupNames && groupNames.length) {\n // tabs重新按分组排序\n newTabs.sort(getTabsSortFun(groupNames));\n }\n return {\n tab_items: newTabs\n }\n}\n\nconst eventData = event.data;\ndoAction({\n actionType: 'setValue',\n componentId: \"apps-form\",\n args: {\n value: clearTabs()\n }\n});\n\nconst newTabTtemsProp = quickEidtSaveForTab(eventData, \"group\");\n\nsetTimeout(function () { \n // 不加延时会显示异常\n doAction({\n actionType: 'setValue',\n componentId: \"apps-form\",\n args: {\n value: newTabTtemsProp\n }\n });\n},300);"
|
|
266
266
|
}
|
|
267
267
|
]
|
|
268
268
|
}
|
|
@@ -343,7 +343,7 @@
|
|
|
343
343
|
"actions": [
|
|
344
344
|
{
|
|
345
345
|
"actionType": "custom",
|
|
346
|
-
"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 // 没有配置group属性的字段排在前面\n return tempM - tempN;\n }\n // 字段所属分组不在groupNames时排在前面,其他字段按其所属分组在groupNames中的排序先后顺序排序,所属分组相同的字段排在一起。\n return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]);\n };\n}\n\nconst clearTabs = function (input) { \n return {\n tab_items: []\n }\n}\n\nconst convertDataForTabs = function (input) { \n let pickedTabs = input.picked_tabs || [];\n const superTabs = _.keyBy(input.__super.tab_items, 'tab_name');\n if (typeof pickedTabs === \"string\") {\n pickedTabs = pickedTabs.split(\",\");\n }\n const tabOptions =
|
|
346
|
+
"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 // 没有配置group属性的字段排在前面\n return tempM - tempN;\n }\n // 字段所属分组不在groupNames时排在前面,其他字段按其所属分组在groupNames中的排序先后顺序排序,所属分组相同的字段排在一起。\n return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]);\n };\n}\n\nconst clearTabs = function (input) { \n return {\n tab_items: []\n }\n}\n\nconst convertDataForTabs = function (input) { \n let pickedTabs = input.picked_tabs || [];\n const superTabs = _.keyBy(input.__super.tab_items, 'tab_name');\n if (typeof pickedTabs === \"string\") {\n pickedTabs = pickedTabs.split(\",\");\n }\n const tabOptions = _.keyBy(input.__super.__super.__super.__super.__super.tabs_options, \"value\");\n const convertedTabs = pickedTabs.map(function (tab_name) {\n const superTab = superTabs[tab_name];\n if (superTab) {\n return superTab;\n }\n else {\n const tabOption = tabOptions[tab_name];\n return {\n tab_name: tab_name,\n group: tabOption.group\n }\n }\n });\n const tabGroups = input.__super.__super.__super.__super.__super.tab_groups;\n const groupNames = _.compact(_.map(tabGroups, \"group_name\"));\n // tabs重新按分组排序\n if (groupNames && groupNames.length) { \n convertedTabs.sort(getTabsSortFun(groupNames));\n }\n return {\n tab_items: convertedTabs\n }\n}\n\nconst eventData = event.data;\ndoAction({\n actionType: 'setValue',\n componentId: \"apps-form\",\n args: {\n value: clearTabs()\n }\n});\n\ndoAction({\n actionType: 'setValue',\n componentId: \"apps-form\",\n args: {\n value: convertDataForTabs(eventData)\n }\n});\n\n"
|
|
347
347
|
}
|
|
348
348
|
]
|
|
349
349
|
}
|
|
@@ -386,7 +386,7 @@
|
|
|
386
386
|
"actions": [
|
|
387
387
|
{
|
|
388
388
|
"actionType": "custom",
|
|
389
|
-
"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 // 没有配置group属性的字段排在前面\n return tempM - tempN;\n }\n // 字段所属分组不在groupNames时排在前面,其他字段按其所属分组在groupNames中的排序先后顺序排序,所属分组相同的字段排在一起。\n return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]);\n };\n}\n\nconst clearTabs = function (input) {\n return {\n tab_items: []\n }\n}\n\n// 把”设置分组“弹出窗口中设置的分组转为主表单groups字段值格式\n// 同时根据新的groups排序重新设置tabs属性的字段先后次序\n// 因为直接设置tabs值有bug,即新值老值会串,所以需要先执行上面的clearTabs清除原来的值\nconst convertDataForGroups = function(input) {\n const settingGroups = input.setting_groups || [];\n const convertedGroups =
|
|
389
|
+
"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 // 没有配置group属性的字段排在前面\n return tempM - tempN;\n }\n // 字段所属分组不在groupNames时排在前面,其他字段按其所属分组在groupNames中的排序先后顺序排序,所属分组相同的字段排在一起。\n return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]);\n };\n}\n\nconst clearTabs = function (input) {\n return {\n tab_items: []\n }\n}\n\n// 把”设置分组“弹出窗口中设置的分组转为主表单groups字段值格式\n// 同时根据新的groups排序重新设置tabs属性的字段先后次序\n// 因为直接设置tabs值有bug,即新值老值会串,所以需要先执行上面的clearTabs清除原来的值\nconst convertDataForGroups = function(input) {\n const settingGroups = input.setting_groups || [];\n const convertedGroups = _.uniqBy(settingGroups.map(function (item) {\n return {\n group_name: item.group_name\n }\n }), \"group_name\");\n\n const groupNames = _.compact(_.map(convertedGroups, \"group_name\"));\n const tab_items = input.__super.__super.items;\n // tabs重新按分组排序\n tab_items.sort(getTabsSortFun(groupNames));\n\n return {\n tab_groups: convertedGroups,\n tab_items: tab_items\n }\n};\n\nconst eventData = event.data;\ndoAction({\n actionType: 'setValue',\n componentId: \"apps-form\",\n args: {\n value: clearTabs()\n }\n});\n\ndoAction({\n actionType: 'setValue',\n componentId: \"apps-form\",\n args: {\n value: convertDataForGroups(eventData)\n }\n});\n\n"
|
|
390
390
|
}
|
|
391
391
|
]
|
|
392
392
|
}
|
|
@@ -494,7 +494,8 @@
|
|
|
494
494
|
"className": "",
|
|
495
495
|
"contentClassName": ""
|
|
496
496
|
}
|
|
497
|
-
]
|
|
497
|
+
],
|
|
498
|
+
"messages": {}
|
|
498
499
|
}
|
|
499
500
|
],
|
|
500
501
|
"panelClassName": "m-0 -mt-3",
|
|
@@ -538,7 +539,10 @@
|
|
|
538
539
|
"data": {
|
|
539
540
|
"objectName": "apps",
|
|
540
541
|
"context": {
|
|
541
|
-
"rootUrl": "http://127.0.0.1:5800"
|
|
542
|
+
"rootUrl": "http://127.0.0.1:5800",
|
|
543
|
+
"tenantId": "hKdnwE55WcnWveYxS",
|
|
544
|
+
"userId": "62ede4f62161e377e35de58c",
|
|
545
|
+
"authToken": "dd5788a359e3435f46d35fdafc2ea9f82aef1e4e653f9813da81bb403916f1e9801902331c75dcc8cbd5c0"
|
|
542
546
|
}
|
|
543
547
|
},
|
|
544
548
|
"id": "u:953fda4052b6",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-plugin-amis",
|
|
3
|
-
"version": "2.3.0-beta.
|
|
3
|
+
"version": "2.3.0-beta.26",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "node .scripts/build.tailwind.js"
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
|
-
"gitHead": "
|
|
13
|
+
"gitHead": "38a77106857327c34de3145a9ea9aeeb47957b2c"
|
|
14
14
|
}
|