@steedos-widgets/amis-object 1.3.1 → 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.
@@ -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: 殷亮辉 yinlianghui@hotoa.com
3555
- * @LastEditTime: 2023-09-08 14:09:48
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);
@@ -11717,7 +11732,13 @@ async function getTableApi(mainObject, fields, options){
11717
11732
  if(field.type === 'file'){
11718
11733
  item[key] = value
11719
11734
  }else{
11720
- item[key] = _.map(value, 'url')
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
+ })
11721
11742
  }
11722
11743
  }
11723
11744
  })
@@ -11959,10 +11980,14 @@ function getScriptForAddUrlPrefixForImgFields(fields){
11959
11980
  let fieldProps = imgFields[item];
11960
11981
  if(fieldProps.multiple){
11961
11982
  if(imgFieldDisplayValue instanceof Array){
11962
- data[item] = imgFieldDisplayValue.map((i)=>{ return i.url });
11983
+ data[item] = imgFieldDisplayValue.map((i)=>{
11984
+ const url = window.getImageFieldUrl(i.url);
11985
+ return url;
11986
+ });
11963
11987
  }
11964
11988
  }else{
11965
- data[item] = imgFieldDisplayValue && imgFieldDisplayValue.url;
11989
+ const url = imgFieldDisplayValue && window.getImageFieldUrl(imgFieldDisplayValue.url);
11990
+ data[item] = url;
11966
11991
  }
11967
11992
  }
11968
11993
  })
@@ -14123,53 +14148,34 @@ async function getListSchema(
14123
14148
  };
14124
14149
  }
14125
14150
 
14126
- // 获取对象表格
14127
- async function getTableSchema(
14128
- appName,
14129
- objectName,
14130
- columns,
14131
- ctx = {}
14132
- ) {
14133
- // console.time('getTableSchema', columns);
14134
- const uiSchema = await getUISchema(objectName);
14135
-
14136
- let sort = ctx.sort;
14137
- if(!sort){
14138
- const sortField = ctx.sortField;
14139
- const sortOrder = ctx.sortOrder;
14140
- if(sortField){
14141
- let sortStr = sortField + ' ' + sortOrder || 'asc';
14142
- sort = sortStr;
14143
- }
14144
- }
14145
-
14151
+ async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
14146
14152
  let fields = [];
14147
- for(const column of columns){
14153
+ for (const column of columns) {
14148
14154
  if (_$1.isString(column)) {
14149
- if(column.indexOf('.') > 0){
14155
+ if (column.indexOf('.') > 0) {
14150
14156
  const fieldName = column.split('.')[0];
14151
14157
  const displayName = column.split('.')[1];
14152
14158
  const filedInfo = uiSchema.fields[fieldName];
14153
- 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)) {
14154
14160
  const rfUiSchema = await getUISchema(filedInfo.reference_to);
14155
14161
  const rfFieldInfo = rfUiSchema.fields[displayName];
14156
- 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));
14157
14163
  }
14158
- }else {
14159
- if(uiSchema.fields[column]){
14160
- fields.push(uiSchema.fields[column]);
14164
+ } else {
14165
+ if (uiSchema.fields[column]) {
14166
+ fields.push(Object.assign({}, uiSchema.fields[column], ctx));
14161
14167
  }
14162
14168
  }
14163
14169
  } else if (_$1.isObject(column)) {
14164
- if(column.field.indexOf('.') > 0){
14170
+ if (column.field.indexOf('.') > 0) {
14165
14171
  const fieldName = column.field.split('.')[0];
14166
14172
  const displayName = column.field.split('.')[1];
14167
14173
  const filedInfo = uiSchema.fields[fieldName];
14168
- 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)) {
14169
14175
  const rfUiSchema = await getUISchema(filedInfo.reference_to);
14170
14176
  const rfFieldInfo = rfUiSchema.fields[displayName];
14171
- fields.push(Object.assign({}, rfFieldInfo,
14172
- {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 } },
14173
14179
  {
14174
14180
  width: column.width,
14175
14181
  wrap: column.wrap, // wrap = true 是没效果的
@@ -14177,10 +14183,10 @@ async function getTableSchema(
14177
14183
  }
14178
14184
  ));
14179
14185
  }
14180
- }else {
14181
- if(uiSchema.fields[column.field]){
14186
+ } else {
14187
+ if (uiSchema.fields[column.field]) {
14182
14188
  fields.push(
14183
- Object.assign({}, uiSchema.fields[column.field], {
14189
+ Object.assign({}, uiSchema.fields[column.field], ctx, {
14184
14190
  width: column.width,
14185
14191
  wrap: column.wrap, // wrap = true 是没效果的
14186
14192
  amis: column.amis
@@ -14190,17 +14196,36 @@ async function getTableSchema(
14190
14196
  }
14191
14197
  }
14192
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);
14193
14223
 
14194
14224
  const extraColumns = ctx.extraColumns;
14195
14225
 
14196
14226
  if (extraColumns) {
14197
- _$1.each(extraColumns, function (column) {
14198
- if (_$1.isString(column)) {
14199
- fields.push({ extra: true, name: column });
14200
- } else if (_$1.isObject(column)) {
14201
- fields.push({ extra: true, name: column.field });
14202
- }
14203
- });
14227
+ let extraFields = await convertColumnsToTableFields(extraColumns, uiSchema, {extra: true});
14228
+ fields = fields.concat(extraFields);
14204
14229
  }
14205
14230
 
14206
14231
  const amisSchema = await getObjectCRUD(uiSchema, fields, {
@@ -17817,6 +17842,8 @@ var AmisObjectListView = function (props) { return __awaiter(void 0, void 0, voi
17817
17842
  return __generator(this, function (_j) {
17818
17843
  switch (_j.label) {
17819
17844
  case 0:
17845
+ // console.time('AmisObjectListView')
17846
+ console.log("AmisObjectListView props", props);
17820
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;
17821
17848
  headerSchema = props.headerSchema;
17822
17849
  ctx = props.ctx;
@@ -17949,7 +17976,7 @@ var AmisObjectListView = function (props) { return __awaiter(void 0, void 0, voi
17949
17976
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
17950
17977
  },
17951
17978
  "requestAdaptor": "api.data={query: '{spaces__findOne(id: \"none\"){_id,name}}'};return api;",
17952
- "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 // console.log(\"====listViewSchemaProps===>\", listName, display, listViewSchemaProps)\n window.getListSchema(appId, objectName, listName, listViewSchemaProps).then((schema)=>{\n payload.data = schema.amisSchema;\n // console.log(\"payload================>\", payload)\n resolve(payload)\n });\n });\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 ")
17953
17980
  },
17954
17981
  // "body": body,
17955
17982
  // "data": serviceData
@@ -18793,8 +18820,8 @@ var AmisGlobalFooter = function (props) { return __awaiter(void 0, void 0, void
18793
18820
  /*
18794
18821
  * @Author: baozhoutao@steedos.com
18795
18822
  * @Date: 2022-09-01 14:44:57
18796
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
18797
- * @LastEditTime: 2023-08-28 15:04:28
18823
+ * @LastEditors: baozhoutao@steedos.com
18824
+ * @LastEditTime: 2023-09-08 17:54:54
18798
18825
  * @Description:
18799
18826
  */
18800
18827
  var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0, void 0, function () {
@@ -18814,7 +18841,7 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
18814
18841
  "body": __spreadArray(__spreadArray([], __read(customButtons), false), [
18815
18842
  {
18816
18843
  "type": "button",
18817
- "hiddenOn": "window.innerWidth < 768",
18844
+ "hiddenOn": "${window:innerWidth < 768 || (window:Meteor.settings.public && window:Meteor.settings.public.platform && window:Meteor.settings.public.platform.is_oem)}",
18818
18845
  "id": "u:267a7e84a89d",
18819
18846
  "onEvent": {
18820
18847
  "click": {
@@ -19129,6 +19156,7 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
19129
19156
  "type": "button",
19130
19157
  "label": instance.t('frontend_about'),
19131
19158
  "className": "flex",
19159
+ "hiddenOn": "${window:Meteor.settings.public && window:Meteor.settings.public.platform && window:Meteor.settings.public.platform.is_oem}",
19132
19160
  "onEvent": {
19133
19161
  "click": {
19134
19162
  "actions": [
@@ -19490,7 +19518,7 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
19490
19518
  * @Author: baozhoutao@steedos.com
19491
19519
  * @Date: 2023-01-14 16:41:24
19492
19520
  * @LastEditors: baozhoutao@steedos.com
19493
- * @LastEditTime: 2023-09-05 17:06:44
19521
+ * @LastEditTime: 2023-09-11 16:48:35
19494
19522
  * @Description:
19495
19523
  */
19496
19524
  var getSelectFlowSchema = function (id, props) {
@@ -19638,7 +19666,7 @@ var getSelectFlowSchema = function (id, props) {
19638
19666
  method: "post",
19639
19667
  url: "${context.rootUrl}/graphql?keywords=${keywords}",
19640
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 "),
19641
- 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 ",
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 ",
19642
19670
  "headers": {
19643
19671
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
19644
19672
  }
@@ -19804,7 +19832,17 @@ var PageRecordDetail = function (props) { return __awaiter(void 0, void 0, void
19804
19832
  case 2: return [2 /*return*/, {
19805
19833
  type: 'service',
19806
19834
  "className": 'h-full',
19807
- 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
+ }
19808
19846
  }];
19809
19847
  }
19810
19848
  });
@@ -19820,6 +19858,7 @@ var PageObject = function (props) { return __awaiter(void 0, void 0, void 0, fun
19820
19858
  case 1:
19821
19859
  uiSchema = _b.sent();
19822
19860
  delete $schema.data.recordId;
19861
+ window.Steedos && window.Steedos.setDocumentTitle && window.Steedos.setDocumentTitle({ tabName: uiSchema.label || uiSchema.name });
19823
19862
  // 最外层的data是render data, 会被updateProps data覆盖, 所以组件data需要单开一个数据域. 所以此处有2层service
19824
19863
  return [2 /*return*/, {
19825
19864
  type: "service",