@steedos-widgets/amis-lib 1.3.18 → 1.3.19
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/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs.js +7 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +7 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +4 -4
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -321,7 +321,7 @@ var buttons=getButtons(uiSchema,ctx);var listButtons=___namespace.filter(buttons
|
|
|
321
321
|
},// "id": `service_listview_filter_form_${objectSchema.name}`,
|
|
322
322
|
"dataProvider":{"inited":dataProviderInited},"body":{"type":"wrapper","body":{"type":"wrapper","body":[filterFormSchema,{"type":"wrapper","body":{"type":"wrapper","body":[{"type":"button","id":btnSearchId,"label":i18next__default["default"].t('frontend_fields_filter_button_search'),"icon":"fa fa-search",// "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
323
323
|
"onEvent":{"click":{"actions":[{"actionType":"custom","script":onSearchScript}]}}},{"type":"button","label":i18next__default["default"].t('frontend_form_cancel'),"name":"btn_filter_form_cancel",// "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
324
|
-
"onEvent":{"click":{"actions":[{"actionType":"custom","script":onCancelScript}]}}},{"type":"button","label":i18next__default["default"].t('frontend_fields_filter_button_settings'),"onEvent":{"click":{"actions":[{"actionType":"dialog","dialog":{"type":"dialog","size":"md","title":i18next__default["default"].t('frontend_fields_filter_button_settings'),"body":[{"type":"form","title":"","body":[{"label":"","type":"transfer","name":"fields","id":"u:92c0b3cccca0","source":{"method":"get","url":"${context.rootUrl}/service/api/amis-metadata-objects/objects/${objectName}/fields/options","dataType":"json","headers":{"Authorization":"Bearer ${context.tenantId},${context.authToken}"},"data":{"$self":"$$"},"requestAdaptor":"","adaptor":"\n if(payload.errors){\n payload.status = 2;\n payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;\n }\n const selfData = api.body.$self;\n const uiSchema = selfData.uiSchema;\n const fields = uiSchema.fields;\n const options = ((payload.data && payload.data.options) || []).filter(function(item){\n let field = fields[item.value];\n // TODO: \u6682\u65F6\u7981\u7528location\u7C7B\u578B\u5B57\u6BB5\u7684\u5217\u8868\u641C\u7D22\n return !!field && window.isFieldTypeSearchable(field.type) && field.type !== 'location'\n });\n payload.data = {\n \"options\": options\n };\n return payload;\n "},"options":[],"required":true,"placeholder":"-","className":"col-span-2 m-0","checkAll":false,"searchable":true,"sortable":true,"joinValues":false,"extractValue":true,"multiple":true}],"id":"u:e5ac506d5683","mode":"normal","persistData":false,"promptPageLeave":true,"name":"form","debug":false,"actions":[],"panelClassName":"m-0","bodyClassName":"p-4","className":"steedos-amis-form"}],"id":"u:ca99fa9fe1b1","actions":[{"type":"button","label":i18next__default["default"].t('frontend_form_cancel'),"onEvent":{"click":{"actions":[{"componentId":"","args":{},"actionType":"closeDialog"}]}},"id":"u:4e447b5ca72a"},{"type":"button","label":i18next__default["default"].t('frontend_form_confirm'),"onEvent":{"click":{"actions":[{"actionType":"custom","script":onSearchableFieldsChangeScript},{"actionType":"click","componentId":btnSearchId,"args":{"__from_fields_filter_settings_confirm":true}},{"componentId":"","args":{},"actionType":"closeDrawer"}]}},"id":"u:14e7388fecd3","level":"primary"}],"closeOnEsc":false,"closeOnOutside":false,"showCloseButton":true,"data":{"&":"$$","objectName":"${objectName}","listName":"${listName}","listViewId":"${listViewId}","uiSchema":"${uiSchema}","isLookup":"${isLookup}","context":"${context}","fields":"${filterFormSearchableFields}"}}}]}},"id":"u:b96d84868a5a","level":"link"}],"size":"xs","className":"space-x-4"},"size":"xs","className":"slds-filters__footer slds-grid slds-shrink-none flex justify-between p-0"}],"size":"xs","className":"slds-filters"},"size":"xs","className":"border-gray-300 border-y slds-grid slds-grid_vertical slds-nowrap ".concat(!ctx.isLookup&&"mt-2"),"visibleOn":"this.showFieldsFilter"},"className":"bg-white"});case 11:case"end":return _context73.stop();}}},_callee73);}));return _getObjectFieldsFilterBarSchema.apply(this,arguments);}function getObjectListHeaderFirstLine(objectSchema,listViewName,ctx){var icon=objectSchema.icon,label=objectSchema.label;var listViewButtonOptions=[];_$1.each(objectSchema.list_views,function(listView,name){if(name==="lookup"){// 内置lookup
|
|
324
|
+
"onEvent":{"click":{"actions":[{"actionType":"custom","script":onCancelScript}]}}},{"type":"button","label":i18next__default["default"].t('frontend_fields_filter_button_settings'),"onEvent":{"click":{"actions":[{"actionType":"dialog","dialog":{"type":"dialog","size":"md","title":i18next__default["default"].t('frontend_fields_filter_button_settings'),"body":[{"type":"form","title":"","body":[{"label":"","type":"transfer","name":"fields","id":"u:92c0b3cccca0","source":{"method":"get","url":"${context.rootUrl}/service/api/amis-metadata-objects/objects/${objectName}/fields/options","dataType":"json","headers":{"Authorization":"Bearer ${context.tenantId},${context.authToken}"},"data":{"$self":"$$"},"requestAdaptor":"","adaptor":"\n if(payload.errors){\n payload.status = 2;\n payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;\n }\n const selfData = api.body.$self;\n const uiSchema = selfData.uiSchema;\n const fields = uiSchema.fields;\n const options = ((payload.data && payload.data.options) || []).filter(function(item){\n let field = fields[item.value];\n // TODO: \u6682\u65F6\u7981\u7528location\u7C7B\u578B\u5B57\u6BB5\u7684\u5217\u8868\u641C\u7D22\n return !!field && window.isFieldTypeSearchable(field.type) && field.type !== 'location'\n });\n payload.data = {\n \"options\": options\n };\n return payload;\n "},"options":[],"required":true,"placeholder":"-","className":"col-span-2 m-0","checkAll":false,"searchable":true,"sortable":true,"joinValues":false,"extractValue":true,"multiple":true}],"id":"u:e5ac506d5683","mode":"normal","persistData":false,"promptPageLeave":true,"name":"form","debug":false,"actions":[],"panelClassName":"m-0","bodyClassName":"p-4","className":"steedos-amis-form"}],"id":"u:ca99fa9fe1b1","actions":[{"type":"button","label":i18next__default["default"].t('frontend_form_cancel'),"onEvent":{"click":{"actions":[{"componentId":"","args":{},"actionType":"closeDialog"}]}},"id":"u:4e447b5ca72a"},{"type":"button","label":i18next__default["default"].t('frontend_form_confirm'),"onEvent":{"click":{"actions":[{"actionType":"custom","script":onSearchableFieldsChangeScript},{"actionType":"click","componentId":btnSearchId,"args":{"__from_fields_filter_settings_confirm":true}},{"componentId":"","args":{},"actionType":"closeDrawer"}]}},"id":"u:14e7388fecd3","level":"primary"}],"closeOnEsc":false,"closeOnOutside":false,"showCloseButton":true,"data":{"&":"$$","objectName":"${objectName}","listName":"${listName}","listViewId":"${listViewId}","uiSchema":"${uiSchema}","isLookup":"${isLookup}","context":"${context}","fields":"${filterFormSearchableFields}"}}}]}},"id":"u:b96d84868a5a","level":"link"}],"size":"xs","className":"space-x-4"},"size":"xs","className":"slds-filters__footer slds-grid slds-shrink-none flex justify-between p-0"}],"size":"xs","className":"slds-filters"},"size":"xs","className":"border-gray-300 border-y slds-grid slds-grid_vertical slds-nowrap ".concat(!ctx.isLookup&&"mt-2"),"visibleOn":"this.showFieldsFilter"},"className":"bg-white"});case 11:case"end":return _context73.stop();}}},_callee73);}));return _getObjectFieldsFilterBarSchema.apply(this,arguments);}function getObjectListHeaderFirstLine(objectSchema,listViewName,ctx){var icon=objectSchema.icon,label=objectSchema.label;var disabled_list_views=objectSchema.permissions.disabled_list_views;var listViewButtonOptions=[];_$1.each(objectSchema.list_views,function(listView,name){if(name==="lookup"||disabled_list_views&&disabled_list_views.indexOf(listView._id)>-1){// 内置lookup为弹出选择专用视图,根据用户权限被禁用的视图,不显示在列表切换区域
|
|
325
325
|
return;}listViewButtonOptions.push({type:"button",label:listView.label,actionType:"link",link:"/app/${appId}/".concat(objectSchema.name,"/grid/").concat(name)});});var amisButtonsSchema=getObjectListViewButtonsSchemas(objectSchema,{formFactor:ctx.formFactor});var reg=new RegExp('_','g');var standardIcon=icon&&icon.replace(reg,'-');var standardNewButton=_.find(amisButtonsSchema,{name:"standard_new"});var buttonSchema=[{"type":"flex","items":amisButtonsSchema,"visibleOn":"${display == 'split'?false:true}"}];if(ctx.formFactor!=='SMALL'){var restButtons=Array.isArray(amisButtonsSchema)?amisButtonsSchema.filter(function(obj){return obj.name!=="standard_new";}):[];buttonSchema.push({"type":"flex","items":[standardNewButton,restButtons.length>0&&{"type":"dropdown-button","buttons":restButtons,"className":" ml-1","menuClassName":"p-none split-dropdown-buttons","align":"right","size":"sm"}],"visibleOn":"${display == 'split'?true:false}"});}return{"type":"grid","columns":[{"body":[{"type":"grid","columns":[{"body":{"type":"tpl","className":"block","tpl":"<svg class=\"slds-icon slds-icon_container slds-icon-standard-".concat(standardIcon," slds-page-header__icon\" aria-hidden=\"true\"><use xlink:href=\"/assets/icons/standard-sprite/svg/symbols.svg#").concat(icon,"\"></use></svg>")},"md":"auto","className":"","columnClassName":"flex justify-center items-center","valign":"middle"},{"body":[{"type":"tpl","tpl":"".concat(label),"inline":false,"wrapperComponent":"","className":"text-md leading-none text-black"},{"type":"dropdown-button","className":"","label":"\${listName ? uiSchema.list_views[listName].label : uiSchema.list_views[defaultListName].label}","rightIcon":"fa fa-caret-down","size":"sm","hideCaret":true,"closeOnClick":true,"btnClassName":"!bg-transparent !border-none !hover:border-none text-lg h-5 font-bold p-0 text-black leading-none","buttons":listViewButtonOptions}],"md":"","columnClassName":"p-l-xs"}],"className":"flex justify-between"}],"md":"auto"},{"body":buttonSchema,"md":"auto","valign":"middle"}],"className":"flex justify-between"};}/**
|
|
326
326
|
* 列表视图顶部第二行amisSchema
|
|
327
327
|
* @param {*} objectSchema 对象UISchema
|
|
@@ -498,13 +498,13 @@ options.queryCount=true;if(nonpaged||isTreeObject){options.top=5000;bodyProps.fo
|
|
|
498
498
|
}else if(top){bodyProps.footerToolbar=[];if(options.isRelated){options.queryCount=true;}else{options.queryCount=false;}}// console.log(`getObjectHeaderToolbar====2===>`, options.filterVisible)
|
|
499
499
|
bodyProps.headerToolbar=getObjectHeaderToolbar(objectSchema,fields,options.formFactor,{showDisplayAs:showDisplayAs,hiddenCount:options.queryCount===false,headerToolbarItems:options.headerToolbarItems,filterVisible:options.filterVisible});options.amisData=createObject(options.amisData,{objectName:objectSchema.name,// _id: null,
|
|
500
500
|
recordPermissions:objectSchema.permissions,uiSchema:objectSchema// loaded: false //crud接收适配器中设置为true,否则就是刷新浏览器第一次加载
|
|
501
|
-
});body=null;id="listview_".concat(objectSchema.name);if(!(options.formFactor==='SMALL'&&false)){_context81.next=42;break;}delete bodyProps.bulkActions;delete bodyProps.headerToolbar;delete bodyProps.footerToolbar;_context81.next=27;return getCardSchema(fields,Object.assign({idFieldName:objectSchema.idFieldName,labelFieldName:objectSchema.NAME_FIELD_KEY||'name'},options,{actions:false}));case 27:card=_context81.sent;_context81.t3=Object;_context81.t4={};_context81.t5=card;_context81.t6=id;_context81.t7=id;_context81.next=35;return getTableApi(objectSchema,fields,options);case 35:_context81.t8=_context81.sent;_context81.t9=options.tableHiddenOn;_context81.t10={type:'crud',primaryField:'_id',id:_context81.t6,name:_context81.t7,keepItemSelectionOnPageChange:false,api:_context81.t8,hiddenOn:_context81.t9};_context81.t11=bodyProps;body=_context81.t3.assign.call(_context81.t3,_context81.t4,_context81.t5,_context81.t10,_context81.t11);_context81.next=
|
|
501
|
+
});body=null;id="listview_".concat(objectSchema.name);if(!(options.formFactor==='SMALL'&&false)){_context81.next=42;break;}delete bodyProps.bulkActions;delete bodyProps.headerToolbar;delete bodyProps.footerToolbar;_context81.next=27;return getCardSchema(fields,Object.assign({idFieldName:objectSchema.idFieldName,labelFieldName:objectSchema.NAME_FIELD_KEY||'name'},options,{actions:false}));case 27:card=_context81.sent;_context81.t3=Object;_context81.t4={};_context81.t5=card;_context81.t6=id;_context81.t7=id;_context81.next=35;return getTableApi(objectSchema,fields,options);case 35:_context81.t8=_context81.sent;_context81.t9=options.tableHiddenOn;_context81.t10={type:'crud',primaryField:'_id',id:_context81.t6,name:_context81.t7,keepItemSelectionOnPageChange:false,api:_context81.t8,hiddenOn:_context81.t9};_context81.t11=bodyProps;body=_context81.t3.assign.call(_context81.t3,_context81.t4,_context81.t5,_context81.t10,_context81.t11);_context81.next=71;break;case 42:labelFieldName=objectSchema.NAME_FIELD_KEY||'name';// organizations 对象的历史遗留问题, fullname 被标记为了 名称字段. 在此处特殊处理.
|
|
502
502
|
if(objectSchema.name==='organizations'){labelFieldName='name';}tableOptions=Object.assign({idFieldName:objectSchema.idFieldName,labelFieldName:labelFieldName,permissions:objectSchema.permissions,enable_inline_edit:objectSchema.enable_inline_edit,crudId:listSchema.id||id},options);tableOptions.amisData=createObject(options.amisData||{},{});_context81.next=48;return getTableSchema$1(fields,tableOptions);case 48:table=_context81.sent;// delete table.mode;
|
|
503
503
|
//image与avatar需要在提交修改时特别处理
|
|
504
|
-
imageNames=___default["default"].compact(___default["default"].map(___default["default"].filter(fields,function(field){return["image","avatar"].includes(field.type);}),'name'));quickSaveApiRequestAdaptor="\n var graphqlOrder = \"\";\n var imageNames = ".concat(JSON.stringify(imageNames),";\n const rowsDiff = _.cloneDeep(api.data.rowsDiff);\n rowsDiff.forEach(function (item, index) {\n for(key in item){\n if(_.includes(imageNames, key)){\n if(typeof item[key] == \"string\"){\n const match = item[key].match(/\\/([^\\/]+)$/);\n item[key] = match && match.length > 1?match[1]:\"\";\n }else{\n item[key] = _.map(item[key], function(ele){\n const match = ele.match(/\\/([^\\/]+)$/);\n return match && match.length > 1?match[1]:\"\";\n })\n }\n }\n }\n item = _.omit(item, '_display');\n const itemOrder = 'update' + index + ':' + api.data.objectName + '__update(id:\"' + item._id + '\", doc:' + JSON.stringify(JSON.stringify(_.omit(item, '_id'))) + ') {_id}';\n graphqlOrder += itemOrder;\n })\n graphqlOrder = 'mutation {' + graphqlOrder + '}';\n return {\n ...api,\n data: {\n query: graphqlOrder\n }\n }\n ");autoFillHeight=true;if(options.isRelated||window.innerWidth<768){autoFillHeight=false;}_context81.t12=Object;_context81.t13={};_context81.t14=table;_context81.t15=id;_context81.t16=id;_context81.next=60;return getTableApi(objectSchema,fields,options);case 60:_context81.t17=_context81.sent;_context81.t18=options.tableHiddenOn;_context81.t19=autoFillHeight;_context81.t20="flex-auto ".concat(crudClassName||"");_context81.t21=
|
|
504
|
+
imageNames=___default["default"].compact(___default["default"].map(___default["default"].filter(fields,function(field){return["image","avatar"].includes(field.type);}),'name'));quickSaveApiRequestAdaptor="\n var graphqlOrder = \"\";\n var imageNames = ".concat(JSON.stringify(imageNames),";\n const rowsDiff = _.cloneDeep(api.data.rowsDiff);\n rowsDiff.forEach(function (item, index) {\n for(key in item){\n if(_.includes(imageNames, key)){\n if(typeof item[key] == \"string\"){\n const match = item[key].match(/\\/([^\\/]+)$/);\n item[key] = match && match.length > 1?match[1]:\"\";\n }else{\n item[key] = _.map(item[key], function(ele){\n const match = ele.match(/\\/([^\\/]+)$/);\n return match && match.length > 1?match[1]:\"\";\n })\n }\n }\n }\n item = _.omit(item, '_display');\n const itemOrder = 'update' + index + ':' + api.data.objectName + '__update(id:\"' + item._id + '\", doc:' + JSON.stringify(JSON.stringify(_.omit(item, '_id'))) + ') {_id}';\n graphqlOrder += itemOrder;\n })\n graphqlOrder = 'mutation {' + graphqlOrder + '}';\n return {\n ...api,\n data: {\n query: graphqlOrder\n }\n }\n ");autoFillHeight=true;if(options.isRelated||window.innerWidth<768){autoFillHeight=false;}_context81.t12=Object;_context81.t13={};_context81.t14=table;_context81.t15=id;_context81.t16=id;_context81.next=60;return getTableApi(objectSchema,fields,options);case 60:_context81.t17=_context81.sent;_context81.t18=options.tableHiddenOn;_context81.t19=autoFillHeight;_context81.t20="flex-auto ".concat(crudClassName||"");_context81.t21={"bg-white":"true","is-steedos-crud-data-empty":"${!items || COUNT(items) == 0}"};_context81.t22=crudClassName;_context81.t23={url:"${context.rootUrl}/graphql",method:"post",dataType:"json",headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"},requestAdaptor:quickSaveApiRequestAdaptor,adaptor:"\n if(payload.errors){\n payload.status = 2;\n payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;\n }\n return payload;\n "};_context81.t24=options.rowClassNameExpr;_context81.t25={type:'crud',primaryField:'_id',affixHeader:false,id:_context81.t15,name:_context81.t16,keepItemSelectionOnPageChange:true,api:_context81.t17,hiddenOn:_context81.t18,autoFillHeight:_context81.t19,className:_context81.t20,bodyClassName:_context81.t21,crudClassName:_context81.t22,quickSaveApi:_context81.t23,rowClassNameExpr:_context81.t24};_context81.t26=bodyProps;body=_context81.t12.assign.call(_context81.t12,_context81.t13,_context81.t14,_context81.t25,_context81.t26);case 71:body=defaultsDeep({},listSchema,body);_context81.next=74;return getCrudSchemaWithDataFilter(body,{crudDataFilter:crudDataFilter,onCrudDataFilter:onCrudDataFilter,amisData:amisData,env:env});case 74:body=_context81.sent;crudModeClassName="";if(body.mode){crudModeClassName="steedos-crud-mode-".concat(body.mode);}if(defaults){headerSchema=defaults.headerSchema;footerSchema=defaults.footerSchema;if(headerSchema||footerSchema){wrappedBody=[body];if(headerSchema){if(___default["default"].isArray(headerSchema)){wrappedBody=___default["default"].union(headerSchema,wrappedBody);}else{wrappedBody.unshift(headerSchema);}}if(footerSchema){if(___default["default"].isArray(footerSchema)){wrappedBody=___default["default"].union(wrappedBody,footerSchema);}else{wrappedBody.push(footerSchema);}}body=wrappedBody;}}// console.timeEnd('getObjectCRUD');
|
|
505
505
|
// TODO: data应该只留loaded,其他属性都改为从上层传递下来
|
|
506
506
|
return _context81.abrupt("return",{type:'service',className:crudModeClassName,//目前crud的service层id不认用户自定义id,只支持默认规则id,许多地方的格式都写死了service_listview_${objectname}
|
|
507
|
-
id:"service_".concat(id),name:"page",data:options.amisData,body:body});case
|
|
507
|
+
id:"service_".concat(id),name:"page",data:options.amisData,body:body});case 79:case"end":return _context81.stop();}}},_callee81);}));return _getObjectCRUD.apply(this,arguments);}var getGlobalData=function getGlobalData(mode){var user=getSteedosAuth();return{mode:mode,user:user,spaceId:user.spaceId,userId:user.userId};};var getFormFields$1=function getFormFields$1(objectSchema,formProps){/**
|
|
508
508
|
* fieldsExtend: 重写字段定义
|
|
509
509
|
* fields: 包含的字段
|
|
510
510
|
* excludedFields: 排除的字段
|