@steedos-widgets/amis-object 1.3.0 → 1.3.2-beta.2
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/dist/amis-object.cjs.js +95 -53
- package/dist/amis-object.cjs.js.map +1 -1
- package/dist/amis-object.esm.js +96 -54
- package/dist/amis-object.esm.js.map +1 -1
- package/dist/amis-object.umd.js +54 -52
- package/dist/amis-object.umd.js.map +1 -1
- package/dist/assets.json +16 -16
- package/dist/pages/PageRecordDetail.d.ts +8 -0
- package/package.json +3 -3
package/dist/amis-object.cjs.js
CHANGED
|
@@ -3551,11 +3551,26 @@ const Router$1 = {
|
|
|
3551
3551
|
/*
|
|
3552
3552
|
* @Author: baozhoutao@steedos.com
|
|
3553
3553
|
* @Date: 2022-07-20 16:29:22
|
|
3554
|
-
* @LastEditors:
|
|
3555
|
-
* @LastEditTime: 2023-09-
|
|
3554
|
+
* @LastEditors: liaodaxue
|
|
3555
|
+
* @LastEditTime: 2023-09-11 17:19:53
|
|
3556
3556
|
* @Description:
|
|
3557
3557
|
*/
|
|
3558
3558
|
|
|
3559
|
+
function getImageFieldUrl(url) {
|
|
3560
|
+
if (window.Meteor && window.Meteor.isCordova != true) {
|
|
3561
|
+
// '//'的位置
|
|
3562
|
+
const doubleSlashIndex = url.indexOf('//');
|
|
3563
|
+
const urlIndex = url.indexOf('/', doubleSlashIndex + 2);
|
|
3564
|
+
const rootUrl = url.substring(urlIndex);
|
|
3565
|
+
return rootUrl;
|
|
3566
|
+
}
|
|
3567
|
+
return url;
|
|
3568
|
+
}
|
|
3569
|
+
|
|
3570
|
+
if(typeof window != 'undefined'){
|
|
3571
|
+
window.getImageFieldUrl = getImageFieldUrl;
|
|
3572
|
+
}
|
|
3573
|
+
|
|
3559
3574
|
function getContrastColor(bgColor) {
|
|
3560
3575
|
var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
|
|
3561
3576
|
var r = parseInt(backgroundColor.substr(0, 2), 16);
|
|
@@ -3566,6 +3581,9 @@ function getContrastColor(bgColor) {
|
|
|
3566
3581
|
}
|
|
3567
3582
|
|
|
3568
3583
|
function getLookupListView(refObjectConfig) {
|
|
3584
|
+
if(!refObjectConfig){
|
|
3585
|
+
return null;
|
|
3586
|
+
}
|
|
3569
3587
|
const listNameAll = "all";
|
|
3570
3588
|
const listNameLookup = "lookup";
|
|
3571
3589
|
let listViewAll, listViewLookup;
|
|
@@ -11714,7 +11732,13 @@ async function getTableApi(mainObject, fields, options){
|
|
|
11714
11732
|
if(field.type === 'file'){
|
|
11715
11733
|
item[key] = value
|
|
11716
11734
|
}else{
|
|
11717
|
-
item[key] = _.map(value,
|
|
11735
|
+
item[key] = _.map(value, (item)=>{
|
|
11736
|
+
if(field.type === 'image'){
|
|
11737
|
+
const url = window.getImageFieldUrl(item.url);
|
|
11738
|
+
return url;
|
|
11739
|
+
}
|
|
11740
|
+
return item.url;
|
|
11741
|
+
})
|
|
11718
11742
|
}
|
|
11719
11743
|
}
|
|
11720
11744
|
})
|
|
@@ -11956,10 +11980,14 @@ function getScriptForAddUrlPrefixForImgFields(fields){
|
|
|
11956
11980
|
let fieldProps = imgFields[item];
|
|
11957
11981
|
if(fieldProps.multiple){
|
|
11958
11982
|
if(imgFieldDisplayValue instanceof Array){
|
|
11959
|
-
data[item] = imgFieldDisplayValue.map((i)=>{
|
|
11983
|
+
data[item] = imgFieldDisplayValue.map((i)=>{
|
|
11984
|
+
const url = window.getImageFieldUrl(i.url);
|
|
11985
|
+
return url;
|
|
11986
|
+
});
|
|
11960
11987
|
}
|
|
11961
11988
|
}else{
|
|
11962
|
-
|
|
11989
|
+
const url = imgFieldDisplayValue && window.getImageFieldUrl(imgFieldDisplayValue.url);
|
|
11990
|
+
data[item] = url;
|
|
11963
11991
|
}
|
|
11964
11992
|
}
|
|
11965
11993
|
})
|
|
@@ -14120,53 +14148,34 @@ async function getListSchema(
|
|
|
14120
14148
|
};
|
|
14121
14149
|
}
|
|
14122
14150
|
|
|
14123
|
-
|
|
14124
|
-
async function getTableSchema(
|
|
14125
|
-
appName,
|
|
14126
|
-
objectName,
|
|
14127
|
-
columns,
|
|
14128
|
-
ctx = {}
|
|
14129
|
-
) {
|
|
14130
|
-
// console.time('getTableSchema', columns);
|
|
14131
|
-
const uiSchema = await getUISchema(objectName);
|
|
14132
|
-
|
|
14133
|
-
let sort = ctx.sort;
|
|
14134
|
-
if(!sort){
|
|
14135
|
-
const sortField = ctx.sortField;
|
|
14136
|
-
const sortOrder = ctx.sortOrder;
|
|
14137
|
-
if(sortField){
|
|
14138
|
-
let sortStr = sortField + ' ' + sortOrder || 'asc';
|
|
14139
|
-
sort = sortStr;
|
|
14140
|
-
}
|
|
14141
|
-
}
|
|
14142
|
-
|
|
14151
|
+
async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
|
|
14143
14152
|
let fields = [];
|
|
14144
|
-
for(const column of columns){
|
|
14153
|
+
for (const column of columns) {
|
|
14145
14154
|
if (_$1.isString(column)) {
|
|
14146
|
-
if(column.indexOf('.') > 0){
|
|
14155
|
+
if (column.indexOf('.') > 0) {
|
|
14147
14156
|
const fieldName = column.split('.')[0];
|
|
14148
14157
|
const displayName = column.split('.')[1];
|
|
14149
14158
|
const filedInfo = uiSchema.fields[fieldName];
|
|
14150
|
-
if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && _$1.isString(filedInfo.reference_to)
|
|
14159
|
+
if (filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && _$1.isString(filedInfo.reference_to)) {
|
|
14151
14160
|
const rfUiSchema = await getUISchema(filedInfo.reference_to);
|
|
14152
14161
|
const rfFieldInfo = rfUiSchema.fields[displayName];
|
|
14153
|
-
fields.push(Object.assign({}, rfFieldInfo, {name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: {fieldName, displayName}}));
|
|
14162
|
+
fields.push(Object.assign({}, rfFieldInfo, { name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } }, ctx));
|
|
14154
14163
|
}
|
|
14155
|
-
}else {
|
|
14156
|
-
if(uiSchema.fields[column]){
|
|
14157
|
-
fields.push(uiSchema.fields[column]);
|
|
14164
|
+
} else {
|
|
14165
|
+
if (uiSchema.fields[column]) {
|
|
14166
|
+
fields.push(Object.assign({}, uiSchema.fields[column], ctx));
|
|
14158
14167
|
}
|
|
14159
14168
|
}
|
|
14160
14169
|
} else if (_$1.isObject(column)) {
|
|
14161
|
-
if(column.field.indexOf('.') > 0){
|
|
14170
|
+
if (column.field.indexOf('.') > 0) {
|
|
14162
14171
|
const fieldName = column.field.split('.')[0];
|
|
14163
14172
|
const displayName = column.field.split('.')[1];
|
|
14164
14173
|
const filedInfo = uiSchema.fields[fieldName];
|
|
14165
|
-
if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && _$1.isString(filedInfo.reference_to)
|
|
14174
|
+
if (filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && _$1.isString(filedInfo.reference_to)) {
|
|
14166
14175
|
const rfUiSchema = await getUISchema(filedInfo.reference_to);
|
|
14167
14176
|
const rfFieldInfo = rfUiSchema.fields[displayName];
|
|
14168
|
-
fields.push(Object.assign({}, rfFieldInfo,
|
|
14169
|
-
{name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: {fieldName, displayName}},
|
|
14177
|
+
fields.push(Object.assign({}, rfFieldInfo, ctx,
|
|
14178
|
+
{ name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } },
|
|
14170
14179
|
{
|
|
14171
14180
|
width: column.width,
|
|
14172
14181
|
wrap: column.wrap, // wrap = true 是没效果的
|
|
@@ -14174,10 +14183,10 @@ async function getTableSchema(
|
|
|
14174
14183
|
}
|
|
14175
14184
|
));
|
|
14176
14185
|
}
|
|
14177
|
-
}else {
|
|
14178
|
-
if(uiSchema.fields[column.field]){
|
|
14186
|
+
} else {
|
|
14187
|
+
if (uiSchema.fields[column.field]) {
|
|
14179
14188
|
fields.push(
|
|
14180
|
-
Object.assign({}, uiSchema.fields[column.field], {
|
|
14189
|
+
Object.assign({}, uiSchema.fields[column.field], ctx, {
|
|
14181
14190
|
width: column.width,
|
|
14182
14191
|
wrap: column.wrap, // wrap = true 是没效果的
|
|
14183
14192
|
amis: column.amis
|
|
@@ -14187,17 +14196,36 @@ async function getTableSchema(
|
|
|
14187
14196
|
}
|
|
14188
14197
|
}
|
|
14189
14198
|
}
|
|
14199
|
+
return fields;
|
|
14200
|
+
}
|
|
14201
|
+
|
|
14202
|
+
// 获取对象表格
|
|
14203
|
+
async function getTableSchema(
|
|
14204
|
+
appName,
|
|
14205
|
+
objectName,
|
|
14206
|
+
columns,
|
|
14207
|
+
ctx = {}
|
|
14208
|
+
) {
|
|
14209
|
+
// console.time('getTableSchema', columns);
|
|
14210
|
+
const uiSchema = await getUISchema(objectName);
|
|
14211
|
+
|
|
14212
|
+
let sort = ctx.sort;
|
|
14213
|
+
if(!sort){
|
|
14214
|
+
const sortField = ctx.sortField;
|
|
14215
|
+
const sortOrder = ctx.sortOrder;
|
|
14216
|
+
if(sortField){
|
|
14217
|
+
let sortStr = sortField + ' ' + sortOrder || 'asc';
|
|
14218
|
+
sort = sortStr;
|
|
14219
|
+
}
|
|
14220
|
+
}
|
|
14221
|
+
|
|
14222
|
+
let fields = await convertColumnsToTableFields(columns, uiSchema);
|
|
14190
14223
|
|
|
14191
14224
|
const extraColumns = ctx.extraColumns;
|
|
14192
14225
|
|
|
14193
14226
|
if (extraColumns) {
|
|
14194
|
-
|
|
14195
|
-
|
|
14196
|
-
fields.push({ extra: true, name: column });
|
|
14197
|
-
} else if (_$1.isObject(column)) {
|
|
14198
|
-
fields.push({ extra: true, name: column.field });
|
|
14199
|
-
}
|
|
14200
|
-
});
|
|
14227
|
+
let extraFields = await convertColumnsToTableFields(extraColumns, uiSchema, {extra: true});
|
|
14228
|
+
fields = fields.concat(extraFields);
|
|
14201
14229
|
}
|
|
14202
14230
|
|
|
14203
14231
|
const amisSchema = await getObjectCRUD(uiSchema, fields, {
|
|
@@ -17814,6 +17842,8 @@ var AmisObjectListView = function (props) { return __awaiter(void 0, void 0, voi
|
|
|
17814
17842
|
return __generator(this, function (_j) {
|
|
17815
17843
|
switch (_j.label) {
|
|
17816
17844
|
case 0:
|
|
17845
|
+
// console.time('AmisObjectListView')
|
|
17846
|
+
console.log("AmisObjectListView props", props);
|
|
17817
17847
|
$schema = props.$schema, top = props.top, perPage = props.perPage, _a = props.showHeader, showHeader = _a === void 0 ? true : _a, data = props.data, defaultData = props.defaultData, _b = props.crud, crud = _b === void 0 ? {} : _b, _c = props.className, className = _c === void 0 ? "" : _c, crudClassName = props.crudClassName, _d = props.showDisplayAs, showDisplayAs = _d === void 0 ? false : _d, sideSchema = props.sideSchema, props.columnsTogglable, _f = props.filterVisible, filterVisible = _f === void 0 ? true : _f, headerToolbarItems = props.headerToolbarItems, rowClassNameExpr = props.rowClassNameExpr, _g = props.hiddenColumnOperation, hiddenColumnOperation = _g === void 0 ? false : _g;
|
|
17818
17848
|
headerSchema = props.headerSchema;
|
|
17819
17849
|
ctx = props.ctx;
|
|
@@ -17946,7 +17976,7 @@ var AmisObjectListView = function (props) { return __awaiter(void 0, void 0, voi
|
|
|
17946
17976
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
17947
17977
|
},
|
|
17948
17978
|
"requestAdaptor": "api.data={query: '{spaces__findOne(id: \"none\"){_id,name}}'};return api;",
|
|
17949
|
-
"adaptor": "\n // console.log('service listview schemaApi adaptor....', api.body); \n let { appId, objectName, defaultListName: listName, display, formFactor: defaultFormFactor} = api.body;\n if(api.body.listName){\n listName = api.body.listName;\n }\n return new Promise((resolve)=>{\n const listViewSchemaProps = ".concat(JSON.stringify(listViewSchemaProps), ";\n const formFactor = ([\"split\"].indexOf(display) > -1) ? 'SMALL': defaultFormFactor;\n listViewSchemaProps.formFactor = formFactor;\n listViewSchemaProps.displayAs = display;\n
|
|
17979
|
+
"adaptor": "\n // console.log('service listview schemaApi adaptor....', api.body); \n let { appId, objectName, defaultListName: listName, display, formFactor: defaultFormFactor} = api.body;\n if(api.body.listName){\n listName = api.body.listName;\n }\n return new Promise((resolve)=>{\n const listViewSchemaProps = ".concat(JSON.stringify(listViewSchemaProps), ";\n const formFactor = ([\"split\"].indexOf(display) > -1) ? 'SMALL': defaultFormFactor;\n listViewSchemaProps.formFactor = formFactor;\n listViewSchemaProps.displayAs = display;\n \n window.getListSchema(appId, objectName, listName, listViewSchemaProps).then((schema)=>{\n try{\n const uiSchema = schema.uiSchema;\n const listView = _.find(\n uiSchema.list_views,\n (listView, name) => {\n // \u4F20\u5165listViewName\u7A7A\u503C\u5219\u53D6\u7B2C\u4E00\u4E2A\n if(!listName){\n listName = name;\n }\n return name === listName || listView._id === listName;\n }\n );\n if(listView){\n window.Steedos && window.Steedos.setDocumentTitle && window.Steedos.setDocumentTitle({pageName: listView.label || listView.name})\n }\n }catch(e){\n console.error(e)\n }\n payload.data = schema.amisSchema;\n // console.log(\"schema================>\", schema)\n resolve(payload)\n });\n });\n ")
|
|
17950
17980
|
},
|
|
17951
17981
|
// "body": body,
|
|
17952
17982
|
// "data": serviceData
|
|
@@ -18790,8 +18820,8 @@ var AmisGlobalFooter = function (props) { return __awaiter(void 0, void 0, void
|
|
|
18790
18820
|
/*
|
|
18791
18821
|
* @Author: baozhoutao@steedos.com
|
|
18792
18822
|
* @Date: 2022-09-01 14:44:57
|
|
18793
|
-
* @LastEditors:
|
|
18794
|
-
* @LastEditTime: 2023-08
|
|
18823
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
18824
|
+
* @LastEditTime: 2023-09-08 17:54:54
|
|
18795
18825
|
* @Description:
|
|
18796
18826
|
*/
|
|
18797
18827
|
var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -18811,7 +18841,7 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
|
|
|
18811
18841
|
"body": __spreadArray(__spreadArray([], __read(customButtons), false), [
|
|
18812
18842
|
{
|
|
18813
18843
|
"type": "button",
|
|
18814
|
-
"hiddenOn": "window
|
|
18844
|
+
"hiddenOn": "${window:innerWidth < 768 || (window:Meteor.settings.public && window:Meteor.settings.public.platform && window:Meteor.settings.public.platform.is_oem)}",
|
|
18815
18845
|
"id": "u:267a7e84a89d",
|
|
18816
18846
|
"onEvent": {
|
|
18817
18847
|
"click": {
|
|
@@ -19126,6 +19156,7 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
|
|
|
19126
19156
|
"type": "button",
|
|
19127
19157
|
"label": instance.t('frontend_about'),
|
|
19128
19158
|
"className": "flex",
|
|
19159
|
+
"hiddenOn": "${window:Meteor.settings.public && window:Meteor.settings.public.platform && window:Meteor.settings.public.platform.is_oem}",
|
|
19129
19160
|
"onEvent": {
|
|
19130
19161
|
"click": {
|
|
19131
19162
|
"actions": [
|
|
@@ -19487,7 +19518,7 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
|
|
|
19487
19518
|
* @Author: baozhoutao@steedos.com
|
|
19488
19519
|
* @Date: 2023-01-14 16:41:24
|
|
19489
19520
|
* @LastEditors: baozhoutao@steedos.com
|
|
19490
|
-
* @LastEditTime: 2023-09-
|
|
19521
|
+
* @LastEditTime: 2023-09-11 16:48:35
|
|
19491
19522
|
* @Description:
|
|
19492
19523
|
*/
|
|
19493
19524
|
var getSelectFlowSchema = function (id, props) {
|
|
@@ -19635,7 +19666,7 @@ var getSelectFlowSchema = function (id, props) {
|
|
|
19635
19666
|
method: "post",
|
|
19636
19667
|
url: "${context.rootUrl}/graphql?keywords=${keywords}",
|
|
19637
19668
|
requestAdaptor: "\n const keywords = api.body.keywords || '';\n const appId = '".concat(data.app_id || "", "';\n api.data = {\n query: `\n {\n options: flows__getList(action: \"").concat(action, "\", keywords: \"${keywords}\", appId: \"${appId}\", distributeInstanceId: \"").concat(distributeInstanceId, "\", distributeStepId: \"").concat(distributeStepId, "\"){\n value:_id\n label:name\n children: flows{\n value: _id,\n label: name\n }\n }\n }\n `\n }\n "),
|
|
19638
|
-
adaptor: "\n var options = payload.data.options;\n if(options){\n options.forEach(function(item,index) {\n if(item.value != 'startFlows' && (!item.children || item.children.length == 0)){\n payload.data.options.splice(index,1)\n }\n })\n }\n if(payload.data.options.length === 1 && payload.data.options[0].children.length === 1){\n
|
|
19669
|
+
adaptor: "\n var options = payload.data.options;\n if(options){\n options.forEach(function(item,index) {\n if(item.value != 'startFlows' && (!item.children || item.children.length == 0)){\n payload.data.options.splice(index,1)\n }\n })\n }\n // if(payload.data.options.length === 1 && payload.data.options[0].children.length === 1){\n // payload.data.value = payload.data.options[0].children[0].value\n // }\n return payload;\n ",
|
|
19639
19670
|
"headers": {
|
|
19640
19671
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
19641
19672
|
}
|
|
@@ -19801,7 +19832,17 @@ var PageRecordDetail = function (props) { return __awaiter(void 0, void 0, void
|
|
|
19801
19832
|
case 2: return [2 /*return*/, {
|
|
19802
19833
|
type: 'service',
|
|
19803
19834
|
"className": 'h-full',
|
|
19804
|
-
body: recordSchema
|
|
19835
|
+
body: recordSchema,
|
|
19836
|
+
"onEvent": {
|
|
19837
|
+
"recordLoaded": {
|
|
19838
|
+
"actions": [
|
|
19839
|
+
{
|
|
19840
|
+
"actionType": "custom",
|
|
19841
|
+
"script": "window.Steedos && window.Steedos.setDocumentTitle && Steedos.setDocumentTitle({pageName: event.data.record.name})"
|
|
19842
|
+
}
|
|
19843
|
+
]
|
|
19844
|
+
}
|
|
19845
|
+
}
|
|
19805
19846
|
}];
|
|
19806
19847
|
}
|
|
19807
19848
|
});
|
|
@@ -19817,6 +19858,7 @@ var PageObject = function (props) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
19817
19858
|
case 1:
|
|
19818
19859
|
uiSchema = _b.sent();
|
|
19819
19860
|
delete $schema.data.recordId;
|
|
19861
|
+
window.Steedos && window.Steedos.setDocumentTitle && window.Steedos.setDocumentTitle({ tabName: uiSchema.label || uiSchema.name });
|
|
19820
19862
|
// 最外层的data是render data, 会被updateProps data覆盖, 所以组件data需要单开一个数据域. 所以此处有2层service
|
|
19821
19863
|
return [2 /*return*/, {
|
|
19822
19864
|
type: "service",
|