@steedos-widgets/amis-lib 1.2.25 → 1.2.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.
package/dist/index.esm.js CHANGED
@@ -336,7 +336,7 @@ const getSteedosAuth = () => {
336
336
  * @Author: baozhoutao@steedos.com
337
337
  * @Date: 2022-08-16 17:02:08
338
338
  * @LastEditors: baozhoutao@steedos.com
339
- * @LastEditTime: 2023-04-19 15:25:50
339
+ * @LastEditTime: 2023-06-20 13:50:15
340
340
  * @Description:
341
341
  */
342
342
 
@@ -347,14 +347,14 @@ const Router = {
347
347
  if(urlSearch.has('display')){
348
348
  return urlSearch.get('display')
349
349
  }
350
- // const key = `tab.${tab_id}.display`;
351
- const key = `page_display`;
350
+ const key = `tab_${tab_id}_display`;
351
+ // const key = `page_display`;
352
352
  const value = localStorage.getItem(key);
353
353
  return value ? value : 'grid'
354
354
  },
355
355
 
356
356
  setTabDisplayAs(tab_id, displayAs){
357
- const key = `tab.${tab_id}.display`;
357
+ const key = `tab_${tab_id}_display`;
358
358
  localStorage.setItem(key, displayAs);
359
359
  },
360
360
  getAppPath({formFactor, appId}){
@@ -368,15 +368,10 @@ const Router = {
368
368
  },
369
369
  getObjectDetailPath(props){
370
370
  const {formFactor, appId, objectName, recordId, listViewName, _templateType} = props;
371
- // var urlParams = new URLSearchParams(window.location.search);
372
- // if(objectName === 'instances'){
373
- // return `/workflow/space/\${context.tenantId}/\${listName}/${recordId}`;
374
- // }
375
- const displayAs = Router.getTabDisplayAs(objectName); //urlParams.get("display") ||
376
371
  if(_templateType === 'JavaScript'){
377
- return `/app/${appId}/${objectName}/view/${recordId}?display=${displayAs}&side_object=<%=item.objectName%>&side_listview_id=<%=item.listName%>`;
372
+ return `/app/${appId}/${objectName}/view/${recordId}?side_object=<%=item.objectName%>&side_listview_id=<%=item.listName%>`;
378
373
  }
379
- return `/app/${appId}/${objectName}/view/${recordId}?display=${displayAs}&side_object=\${objectName}&side_listview_id=\${listName}`;
374
+ return `/app/${appId}/${objectName}/view/${recordId}?side_object=\${objectName}&side_listview_id=\${listName}`;
380
375
  },
381
376
  getObjectRelatedViewPath({formFactor, appId, masterObjectName, masterRecordId, objectName, foreignKey}){
382
377
  return `/app/${appId}/${masterObjectName}/${masterRecordId}/${objectName}/grid?related_field_name=${foreignKey}`;
@@ -3126,7 +3121,10 @@ async function getObjectFieldsFilterFormSchema(ctx) {
3126
3121
  const formSchema = {
3127
3122
  "type": "service",
3128
3123
  "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
3129
- "className": ctx.formFactor === 'SMALL' ? "slds-filters__body p-0 mb-2" : "slds-filters__body p-0 sm:grid sm:gap-2 sm:grid-cols-4 mb-2",
3124
+ "className": ctx.formFactor === 'SMALL' ? "slds-filters__body p-0 mb-2 overflow-y-auto overflow-x-hidden" : "slds-filters__body p-0 sm:grid sm:gap-2 sm:grid-cols-4 mb-2",
3125
+ "style":{
3126
+ "max-height":ctx.formFactor === 'SMALL'?"30vh":"unset"
3127
+ },
3130
3128
  "schemaApi": {
3131
3129
  method: 'post',
3132
3130
  url: `\${context.rootUrl}/graphql?reload=\${filterFormSearchableFields|join}`,
@@ -5059,14 +5057,14 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
5059
5057
  {
5060
5058
  "type": "button",
5061
5059
  "label": i18next.t('frontend_display_type_is_table'),
5062
- "onClick": "let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
5060
+ "onClick": "const key = 'tab_"+objectName+"_display';localStorage.setItem(key, 'grid');let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
5063
5061
  "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
5064
5062
  "rightIconClassName": "m-l-sm"
5065
5063
  },
5066
5064
  {
5067
5065
  "type": "button",
5068
5066
  "label": i18next.t('frontend_display_type_is_split'),
5069
- "onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
5067
+ "onClick": "const key = 'tab_"+objectName+"_display';localStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
5070
5068
  "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
5071
5069
  "rightIconClassName": "m-l-sm"
5072
5070
  }
@@ -5228,7 +5226,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
5228
5226
  },
5229
5227
  // getExportExcelToolbarButtonSchema(),
5230
5228
  getSettingListviewToolbarButtonSchema(),
5231
- getDisplayAsButton(showDisplayAs),
5229
+ getDisplayAsButton(mainObject?.name),
5232
5230
  filterVisible ? {
5233
5231
  "label": i18next.t('frontend_button_search_tooltip'),
5234
5232
  "icon": "fa fa-search",
@@ -8059,13 +8057,13 @@ async function getTableApi(mainObject, fields, options){
8059
8057
  const masterRecord = self._master.record;
8060
8058
  const masterObjectName = self._master.objectName;
8061
8059
  let relatedValue = self._master.recordId;
8062
- if(refField.reference_to_field && refField.reference_to_field != '_id'){
8060
+ if(refField && refField.reference_to_field && refField.reference_to_field != '_id'){
8063
8061
  relatedValue = masterRecord[refField.reference_to_field]
8064
8062
  }
8065
8063
  let relatedFilters;
8066
8064
  if (
8067
- refField._reference_to ||
8068
- (refField.reference_to && !_.isString(refField.reference_to))
8065
+ refField && (refField._reference_to ||
8066
+ (refField.reference_to && !_.isString(refField.reference_to)))
8069
8067
  ) {
8070
8068
  relatedFilters = [
8071
8069
  [relatedKey + "/o", "=", masterObjectName],
@@ -8215,7 +8213,7 @@ function getRecordPermissionsApi(object, recordId, options){
8215
8213
 
8216
8214
  const API_CACHE = 100;
8217
8215
 
8218
- function getReadonlyFormAdaptor(object, fields){
8216
+ function getReadonlyFormAdaptor(object, fields, options){
8219
8217
  let scriptStr = '';
8220
8218
  const selectFields = _$1.filter(fields, function(field){return field.name.indexOf('.') < 0 && ((field.type == 'select' && field.options) || ((field.type == 'lookup' || field.type == 'master_detail') && !field.reference_to))});
8221
8219
  const gridAndObjectFieldsName = _$1.map(_$1.filter(fields, function(field){return field.name.indexOf('.') < 0 && (field.type === 'object' || field.type === 'grid')}), 'name');
@@ -8255,9 +8253,16 @@ function getReadonlyFormAdaptor(object, fields){
8255
8253
 
8256
8254
  return `
8257
8255
  if(payload.data.data.length === 0){
8258
- return {
8259
- status: 2,
8260
- msg: "无法找到记录"
8256
+ var isEditor = !!${options && options.isEditor};
8257
+ if(isEditor){
8258
+ // 设计器中始终显示表单,有记录则显示第一条记录,没记录时显示为空表单
8259
+ payload.data.data = [{}];
8260
+ }
8261
+ else{
8262
+ return {
8263
+ status: 2,
8264
+ msg: "无法找到记录"
8265
+ }
8261
8266
  }
8262
8267
  }
8263
8268
  if(payload.data.data){
@@ -8274,7 +8279,7 @@ function getReadonlyFormAdaptor(object, fields){
8274
8279
  var record = _.cloneDeep(data);
8275
8280
  try{
8276
8281
  _.each(gridAndObjectFieldsName, function(name){
8277
- data[name] = data._display[name];
8282
+ data[name] = data._display && data._display[name];
8278
8283
  })
8279
8284
  }catch(e){
8280
8285
  console.error(e)
@@ -8295,10 +8300,10 @@ function getReadonlyFormAdaptor(object, fields){
8295
8300
  async function getReadonlyFormInitApi(object, recordId, fields, options){
8296
8301
  return {
8297
8302
  method: "post",
8298
- url: getApi$2()+"&recordId=${recordId}",
8303
+ url: getApi$2() + '&objectName=${objectName}' + "&recordId=${recordId}",
8299
8304
  cache: API_CACHE,
8300
8305
  // requestAdaptor: "console.log('getReadonlyFormInitApi requestAdaptor', api);return api;",
8301
- adaptor: getReadonlyFormAdaptor(object, fields),
8306
+ adaptor: getReadonlyFormAdaptor(object, fields, options),
8302
8307
  data: await getFindOneQuery$1(object, recordId, fields, options),
8303
8308
  headers: {
8304
8309
  Authorization: "Bearer ${context.tenantId},${context.authToken}"
@@ -9730,8 +9735,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
9730
9735
  /*
9731
9736
  * @Author: baozhoutao@steedos.com
9732
9737
  * @Date: 2022-07-05 15:55:39
9733
- * @LastEditors: Please set LastEditors
9734
- * @LastEditTime: 2023-05-17 09:09:33
9738
+ * @LastEditors: liaodaxue
9739
+ * @LastEditTime: 2023-06-20 14:05:50
9735
9740
  * @Description:
9736
9741
  */
9737
9742
 
@@ -9774,10 +9779,11 @@ async function getObjectRelatedList(
9774
9779
  if(!isEmpty(relatedLists)){
9775
9780
  for (const relatedList of relatedLists) {
9776
9781
  const arr = relatedList.related_field_fullname.split(".");
9782
+ const foreign_key = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
9777
9783
  related.push({
9778
9784
  masterObjectName: objectName,
9779
9785
  object_name: arr[0],
9780
- foreign_key: arr[1],
9786
+ foreign_key,
9781
9787
  label: relatedList.label,
9782
9788
  columns: relatedList.field_names,
9783
9789
  sort: relatedList.sort,
@@ -9790,10 +9796,11 @@ async function getObjectRelatedList(
9790
9796
  const details = [].concat(uiSchema.details || []);
9791
9797
  for (const detail of details) {
9792
9798
  const arr = detail.split(".");
9799
+ const foreign_key = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
9793
9800
  related.push({
9794
9801
  masterObjectName: objectName,
9795
9802
  object_name: arr[0],
9796
- foreign_key: arr[1]
9803
+ foreign_key
9797
9804
  });
9798
9805
  }
9799
9806
  }
@@ -9825,14 +9832,16 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9825
9832
  if(!isEmpty(mainRelatedLists)){
9826
9833
  for (const relatedList of mainRelatedLists) {
9827
9834
  const arr = relatedList.related_field_fullname.split(".");
9828
- mainRelated[arr[0]] = arr[1];
9835
+ const foreign_key_value = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
9836
+ mainRelated[arr[0]] = foreign_key_value;
9829
9837
  }
9830
9838
  }else {
9831
9839
  const details = union(mainObjectUiSchema.details,mainObjectUiSchema.lookup_details) || [];
9832
9840
  for (const detail of details) {
9833
9841
  const arr = detail.split(".");
9842
+ const foreign_key_value = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
9834
9843
  if(!has(mainRelated,arr[0])){
9835
- mainRelated[arr[0]] = arr[1];
9844
+ mainRelated[arr[0]] = foreign_key_value;
9836
9845
  }
9837
9846
  }
9838
9847
  }