@steedos-widgets/amis-lib 1.2.2 → 1.2.3

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
@@ -334,14 +334,19 @@ const getSteedosAuth = () => {
334
334
  * @Author: baozhoutao@steedos.com
335
335
  * @Date: 2022-08-16 17:02:08
336
336
  * @LastEditors: baozhoutao@steedos.com
337
- * @LastEditTime: 2023-04-11 09:57:37
337
+ * @LastEditTime: 2023-04-17 15:24:21
338
338
  * @Description:
339
339
  */
340
340
 
341
341
 
342
342
  const Router = {
343
343
  getTabDisplayAs(tab_id){
344
- const key = `tab.${tab_id}.display`;
344
+ var urlSearch = new URLSearchParams(document.location.search);
345
+ if(urlSearch.has('display')){
346
+ return urlSearch.get('display')
347
+ }
348
+ // const key = `tab.${tab_id}.display`;
349
+ const key = `page.display`;
345
350
  const value = localStorage.getItem(key);
346
351
  return value ? value : 'grid'
347
352
  },
@@ -2828,7 +2833,6 @@ async function getObjectFieldsFilterBarSchema(objectSchema, fields, ctx) {
2828
2833
  function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
2829
2834
  const { icon, label } = objectSchema;
2830
2835
  const listViewButtonOptions = [];
2831
- // let currentListView;
2832
2836
  each(
2833
2837
  objectSchema.list_views,
2834
2838
  (listView, name) => {
@@ -2836,19 +2840,11 @@ function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
2836
2840
  type: "button",
2837
2841
  label: listView.label,
2838
2842
  actionType: "link",
2839
- // icon: "fa fa-plus",
2840
2843
  link: `/app/\${appId}/${objectSchema.name}/grid/${name}`
2841
2844
  });
2842
- // if(name === listViewName){
2843
- // currentListView = listView;
2844
- // }
2845
2845
  }
2846
2846
  );
2847
2847
 
2848
- // if(!currentListView){
2849
- // return {};
2850
- // }
2851
-
2852
2848
  const buttons = getListViewButtons(objectSchema, {});
2853
2849
  let amisButtonsSchema = map(buttons, (button) => {
2854
2850
  return {
@@ -2859,34 +2855,7 @@ function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
2859
2855
  className: `button_${button.name}`
2860
2856
  }
2861
2857
  });
2862
- // if(objectSchema.permissions?.allowDelete){
2863
- // const bulkDeleteScript = `
2864
- // const data = event.data;
2865
- // const listViewId = data.listViewId;
2866
- // const uiSchema = data.uiSchema;
2867
- // const scopeId = data.scopeId;
2868
- // BuilderAmisObject.AmisLib.standardButtonsTodo.standard_delete_many.call({
2869
- // listViewId,
2870
- // uiSchema,
2871
- // scopeId
2872
- // })
2873
- // `;
2874
- // amisButtonsSchema.push({
2875
- // type: 'button',
2876
- // label: "删除",
2877
- // className: `antd-Button antd-Button--default antd-Button--size-default`,
2878
- // "onEvent": {
2879
- // "click": {
2880
- // "actions": [
2881
- // {
2882
- // "actionType": "custom",
2883
- // "script": bulkDeleteScript
2884
- // }
2885
- // ]
2886
- // }
2887
- // }
2888
- // });
2889
- // }
2858
+
2890
2859
  const reg = new RegExp('_', 'g');
2891
2860
  const standardIcon = icon && icon.replace(reg, '-');
2892
2861
  return {
@@ -3076,27 +3045,14 @@ async function getObjectListHeaderFieldsFilterBar(objectSchema, listViewName, ct
3076
3045
  * @param {*} objectSchema 对象UISchema
3077
3046
  * @returns amisSchema
3078
3047
  */
3079
- async function getObjectListHeader$1(objectSchema, listViewName, ctx) {
3048
+ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
3080
3049
  let firstLineSchema = getObjectListHeaderFirstLine(objectSchema);
3081
- // let secordLineSchema = await getObjectListHeaderSecordLine(objectSchema, listViewName, ctx);
3082
- // let body = [firstLineSchema, secordLineSchema];
3083
3050
  let body = [firstLineSchema];
3084
- // let roundedCss = "";
3085
- // if (ctx.onlyFirstLine) {
3086
- // body = [firstLineSchema];
3087
- // }
3088
- // else if (ctx.onlySecordLine) {
3089
- // // 列表视图自定义amisSchema时不能加圆角
3090
- // roundedCss = "";
3091
- // // body = [secordLineSchema];
3092
- // }
3093
3051
  let headerSchema = [{
3094
3052
  "type": "wrapper",
3095
3053
  "body": body,
3096
3054
  "className": `bg-gray-100 sm:rounded-tl sm:rounded-tr p-4 -mb-4`
3097
3055
  }];
3098
- // const fieldsFilterBarSchema = await getObjectListHeaderFieldsFilterBar(objectSchema, listViewName, ctx);
3099
- // headerSchema.push(fieldsFilterBarSchema);
3100
3056
  return headerSchema;
3101
3057
  }
3102
3058
 
@@ -3350,6 +3306,7 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
3350
3306
  "icon": "fa fa-table-columns",
3351
3307
  "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
3352
3308
  "align": "right",
3309
+ "visibleOn": "${formFactor !== 'SMALL'}",
3353
3310
  "buttons": [
3354
3311
  {
3355
3312
  "label": "显示为",
@@ -3486,7 +3443,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3486
3443
  }
3487
3444
  }
3488
3445
  } : {},
3489
- showDisplayAs? getDisplayAsButton(mainObject?.name) : {}
3446
+ getDisplayAsButton(mainObject?.name)
3490
3447
  ]
3491
3448
  }else {
3492
3449
  return [
@@ -4079,7 +4036,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
4079
4036
  }
4080
4037
  ]
4081
4038
  },
4082
- showDisplayAs ? getDisplayAsButton(showDisplayAs) : {}
4039
+ getDisplayAsButton(showDisplayAs)
4083
4040
  // {
4084
4041
  // "type": "search-box",
4085
4042
  // "align": "right",
@@ -8344,8 +8301,8 @@ async function getRelatedListSchema(
8344
8301
  /*
8345
8302
  * @Author: baozhoutao@steedos.com
8346
8303
  * @Date: 2022-07-05 15:55:39
8347
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
8348
- * @LastEditTime: 2023-04-14 11:10:07
8304
+ * @LastEditors: baozhoutao@steedos.com
8305
+ * @LastEditTime: 2023-04-17 15:26:17
8349
8306
  * @Description:
8350
8307
  */
8351
8308
 
@@ -8558,6 +8515,7 @@ async function getListSchema(
8558
8515
  return { uiSchema };
8559
8516
  }
8560
8517
 
8518
+ // 直接返回自定义的列表视图schema
8561
8519
  if(listView.enable_amis_schema && listView.amis_schema){
8562
8520
  const amisSchema = isString(listView.amis_schema) ? JSON.parse(listView.amis_schema) : listView.amis_schema;
8563
8521
  return {
@@ -8571,6 +8529,7 @@ async function getListSchema(
8571
8529
  let sort = getListViewSort(listView);
8572
8530
  let listviewFilter = getListViewFilter(listView);
8573
8531
  let listview_filters = listView && listView._filters;
8532
+ // 返回 calendar 组件
8574
8533
  if(listView.type === "calendar"){
8575
8534
  const amisSchema = {
8576
8535
  "type": "steedos-object-calendar",
@@ -8589,14 +8548,21 @@ async function getListSchema(
8589
8548
 
8590
8549
  const defaults = ctx.defaults || {};
8591
8550
 
8592
- if(!defaults.headerSchema && ctx.showHeader){
8593
- defaults.headerSchema = await getObjectListHeader$1(uiSchema);
8594
- }
8551
+ // // 未自定义header 且显示header的时候, 使用系统header
8552
+ // if(!defaults.headerSchema && ctx.showHeader){
8553
+ // defaults.headerSchema = getObjectListHeader(uiSchema, listViewName);
8554
+ // }
8555
+
8556
+ // // 如果不显示header,则清理掉
8557
+ // if(!ctx.showHeader){
8558
+ // defaults.headerSchema = null;
8559
+ // }
8595
8560
 
8596
- if(!ctx.showHeader){
8597
- defaults.headerSchema = null;
8598
- }
8561
+ defaults.headerSchema = null;
8599
8562
 
8563
+ /**
8564
+ * 本次存储代码段
8565
+ */
8600
8566
  try {
8601
8567
  const listViewPropsStoreKey = location.pathname + "/crud/" + ctx.listViewId;
8602
8568
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
@@ -8711,7 +8677,7 @@ async function getTableSchema(
8711
8677
  headerToolbarItems: ctx.headerToolbarItems,
8712
8678
  buttons: await getListViewItemButtons(uiSchema, ctx)
8713
8679
  });
8714
- // console.log('getTableSchema====>amisSchema', amisSchema)
8680
+ console.log('getTableSchema====>amisSchema', amisSchema);
8715
8681
  // console.timeEnd('getTableSchema');
8716
8682
  return {
8717
8683
  uiSchema,
@@ -8909,6 +8875,7 @@ async function getObjectRelated(
8909
8875
  if(typeof window != 'undefined'){
8910
8876
  window.getUISchema = getUISchema;
8911
8877
  window.getUISchemaSync = getUISchemaSync;
8878
+ window.getListSchema = getListSchema;
8912
8879
  }
8913
8880
 
8914
8881
  // import { getListSchema } from './objects';