@steedos-widgets/amis-lib 1.2.10 → 1.2.12

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.umd.js CHANGED
@@ -429,7 +429,7 @@
429
429
  * @Author: baozhoutao@steedos.com
430
430
  * @Date: 2022-05-23 09:53:08
431
431
  * @LastEditors: Please set LastEditors
432
- * @LastEditTime: 2023-05-18 16:34:39
432
+ * @LastEditTime: 2023-05-22 15:13:18
433
433
  * @Description:
434
434
  */
435
435
 
@@ -486,8 +486,9 @@
486
486
  let map = {};
487
487
  _$1.forEach(selectOptions,(option)=>{
488
488
  const optionValue = option.value + '';
489
- if(option.color){
490
- const background = option.color.charAt(0) === '#' ? option.color : '#'+option.color;
489
+ const optionColor = option.color + '';
490
+ if(optionColor){
491
+ const background = optionColor.charAt(0) === '#' ? optionColor : '#'+optionColor;
491
492
  const color = getContrastColor(background);
492
493
  const optionColorStyle = 'background:'+background+';color:'+color;
493
494
  map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
@@ -1893,9 +1894,10 @@
1893
1894
  {
1894
1895
  name: "template_url",
1895
1896
  label: "导入模板",
1896
- type: "tpl",
1897
- // type: "markdown",
1898
- // html: true,
1897
+ type: "markdown",
1898
+ options: {
1899
+ html: true
1900
+ },
1899
1901
  className: "whitespace-nowrap",
1900
1902
  },
1901
1903
  null,
@@ -2440,7 +2442,14 @@
2440
2442
  className: `button_${button.name}`
2441
2443
  }
2442
2444
  });
2443
- let dropdownButtons = ___default["default"].map(moreButtons, (button) => {
2445
+ let moreButtonsVisibleOn = '';
2446
+ let dropdownButtons = ___default["default"].map(moreButtons, (button, index) => {
2447
+ if(index === 0){
2448
+ moreButtonsVisibleOn = getButtonVisibleOn$1(button);
2449
+ }else {
2450
+ moreButtonsVisibleOn = moreButtonsVisibleOn + ' || ' +getButtonVisibleOn$1(button);
2451
+ }
2452
+
2444
2453
  return {
2445
2454
  type: 'steedos-object-button',
2446
2455
  name: button.name,
@@ -2450,12 +2459,13 @@
2450
2459
  });
2451
2460
  return {
2452
2461
  buttons: amisButtonsSchema,
2453
- moreButtons: dropdownButtons
2462
+ moreButtons: dropdownButtons,
2463
+ moreButtonsVisibleOn
2454
2464
  };
2455
2465
  };
2456
2466
 
2457
2467
  const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
2458
- const { buttons, moreButtons } = getObjectDetailHeaderButtons(objectSchema, recordId);
2468
+ const { buttons, moreButtons, moreButtonsVisibleOn } = getObjectDetailHeaderButtons(objectSchema, recordId);
2459
2469
  if(ctx.formFactor === 'SMALL'){
2460
2470
  return {
2461
2471
  "type": "button",
@@ -2510,7 +2520,8 @@
2510
2520
  type: "steedos-dropdown-button",
2511
2521
  label: "",
2512
2522
  buttons: moreButtons,
2513
- className: 'slds-icon'
2523
+ className: 'slds-icon',
2524
+ visibleOn: moreButtonsVisibleOn
2514
2525
  };
2515
2526
  buttons.push(dropdownButtonsSchema);
2516
2527
  }
@@ -2742,6 +2753,7 @@
2742
2753
  if (!ctx) {
2743
2754
  ctx = {};
2744
2755
  }
2756
+ const btnSearchId = "btn_filter_form_search_" + new Date().getTime();
2745
2757
  const filterFormSchema = await getObjectFieldsFilterFormSchema(ctx);
2746
2758
  const onSearchScript = `
2747
2759
  const scope = event.context.scoped;
@@ -2758,7 +2770,7 @@
2758
2770
  // // 这会造成handleFilterSubmit时把移除掉的搜索项字段之前的值加到过滤条件中
2759
2771
  // for(var k in filterFormValues){
2760
2772
  // if(filterFormValues[k] === "" && !filterFormValues.hasOwnProperty(k)){
2761
- // removedValues[k] = "";
2773
+ // removedValues[k] = null;
2762
2774
  // }
2763
2775
  // }
2764
2776
  // listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
@@ -2797,7 +2809,7 @@
2797
2809
  const removedValues = {};
2798
2810
  for(var k in filterFormValues){
2799
2811
  if(/^__searchable__/.test(k)){
2800
- removedValues[k] = "";
2812
+ removedValues[k] = null;
2801
2813
  }
2802
2814
  }
2803
2815
  if(!event.data.isLookup){
@@ -2808,7 +2820,7 @@
2808
2820
  if(localListViewProps){
2809
2821
  localListViewProps = JSON.parse(localListViewProps);
2810
2822
  for(var k in localListViewProps){
2811
- removedValues[k] = "";
2823
+ removedValues[k] = null;
2812
2824
  }
2813
2825
  }
2814
2826
  }
@@ -2966,7 +2978,7 @@
2966
2978
  });
2967
2979
  const removedValues = {};
2968
2980
  removedKeys.forEach(function(key){
2969
- removedValues[key] = "";
2981
+ removedValues[key] = null;
2970
2982
  });
2971
2983
  filterForm.setValues(removedValues);//这里使用filterInnerForm也可以
2972
2984
 
@@ -2979,10 +2991,14 @@
2979
2991
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
2980
2992
  if(localListViewProps){
2981
2993
  localListViewProps = JSON.parse(localListViewProps);
2982
- // const removedValues = {};
2983
- removedKeys.forEach(function(key){
2984
- delete localListViewProps[key];
2985
- // removedValues[key] = "";
2994
+ _.each(localListViewProps, function(n,k){
2995
+ // __searchable__开头的不在searchableFields范围则清除其值
2996
+ let isRemoved = !!removedFields.find(function(fieldName){
2997
+ return new RegExp("__searchable__\.*" + fieldName + "$").test(k);
2998
+ });
2999
+ if(isRemoved){
3000
+ delete localListViewProps[k];
3001
+ }
2986
3002
  });
2987
3003
  sessionStorage.setItem(listViewPropsStoreKey, JSON.stringify(localListViewProps));
2988
3004
  }
@@ -3016,9 +3032,10 @@
3016
3032
  "body": [
3017
3033
  {
3018
3034
  "type": "button",
3035
+ "id": btnSearchId,
3019
3036
  "label": "搜索",
3020
3037
  "icon": "fa fa-search",
3021
- "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
3038
+ // "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
3022
3039
  "onEvent": {
3023
3040
  "click": {
3024
3041
  "actions": [
@@ -3034,7 +3051,7 @@
3034
3051
  "type": "button",
3035
3052
  "label": "取消",
3036
3053
  "name": "btn_filter_form_cancel",
3037
- "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
3054
+ // "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
3038
3055
  "onEvent": {
3039
3056
  "click": {
3040
3057
  "actions": [
@@ -3149,6 +3166,10 @@
3149
3166
  "actionType": "custom",
3150
3167
  "script": onSearchableFieldsChangeScript
3151
3168
  },
3169
+ {
3170
+ "actionType": "click",
3171
+ "componentId": btnSearchId
3172
+ },
3152
3173
  {
3153
3174
  "componentId": "",
3154
3175
  "args": {},
@@ -3503,7 +3524,7 @@
3503
3524
  // "tpl": "${(record && uiSchema && record[uiSchema.NAME_FIELD_KEY]) || name}",
3504
3525
  "inline": false,
3505
3526
  "wrapperComponent": "",
3506
- "className": "leading-5 text-xl font-bold"
3527
+ "className": "record-detail-header-name leading-5 text-xl font-bold"
3507
3528
  }
3508
3529
  ],
3509
3530
  "columnClassName": "p-l-xs"
@@ -3512,6 +3533,7 @@
3512
3533
  "className": "flex justify-between"
3513
3534
  }
3514
3535
  ],
3536
+ "columnClassName": "flex-initial",
3515
3537
  "md": "auto",
3516
3538
  });
3517
3539
  }
@@ -3532,7 +3554,7 @@
3532
3554
  {
3533
3555
  "type": "grid",
3534
3556
  "columns": gridBody,
3535
- "className": "flex justify-between"
3557
+ "className": "flex justify-between flex-nowrap"
3536
3558
  }
3537
3559
  ],
3538
3560
  "hiddenOn": "${recordLoaded != true}"
@@ -3749,12 +3771,13 @@
3749
3771
  "type": "dialog",
3750
3772
  "title": "新建 列表视图",
3751
3773
  "data": {
3752
- "&": "$$",
3774
+ //"&":"$$",2.7、2.9、3.0在此处失效
3753
3775
  "all": "${uiSchema.list_views.all}",
3754
3776
  "list_view": "${uiSchema.list_views[listName]}",
3755
3777
  "appId": "${appId}",
3756
3778
  "global": "${global}",
3757
3779
  "targetObjectName": "${objectName}",
3780
+ "context": "${context}"
3758
3781
  },
3759
3782
  "body": [
3760
3783
  {
@@ -3898,12 +3921,13 @@
3898
3921
  "type": "dialog",
3899
3922
  "title": "复制 列表视图",
3900
3923
  "data": {
3901
- "&": "$$",
3924
+ //"&":"$$",2.7、2.9、3.0在此处失效
3902
3925
  "listName": "${listName}",
3903
3926
  "targetObjectName": "${objectName}",
3904
3927
  "list_view": "${uiSchema.list_views[listName]}",
3905
3928
  "appId": "${appId}",
3906
- "global": "${global}"
3929
+ "global": "${global}",
3930
+ "context": "${context}"
3907
3931
  },
3908
3932
  "body": [
3909
3933
  {
@@ -4045,7 +4069,8 @@
4045
4069
  "data": {
4046
4070
  "targetObjectName": "${objectName}",
4047
4071
  "recordId": "${uiSchema.list_views[listName]._id}",
4048
- "appId": "${appId}"
4072
+ "appId": "${appId}",
4073
+ "context": "${context}"
4049
4074
  },
4050
4075
  "body": [
4051
4076
  {
@@ -4102,6 +4127,7 @@
4102
4127
  "title": "共享设置",
4103
4128
  "data": {
4104
4129
  "recordId": "${uiSchema.list_views[listName]._id}",
4130
+ "context": "${context}"
4105
4131
  },
4106
4132
  "body": [
4107
4133
  {
@@ -4147,7 +4173,8 @@
4147
4173
  "targetObjectName": "${objectName}",
4148
4174
  "recordId": "${uiSchema.list_views[listName]._id}",
4149
4175
  "listName": "${listName}",
4150
- "appId": "${appId}"
4176
+ "appId": "${appId}",
4177
+ "context": "${context}"
4151
4178
  },
4152
4179
  "body": [
4153
4180
  {
@@ -4291,11 +4318,12 @@
4291
4318
  "type": "dialog",
4292
4319
  "title": "显示的列",
4293
4320
  "data": {
4294
- "&": "$$",
4321
+ //"&":"$$",2.7、2.9、3.0在此处失效
4295
4322
  "targetObjectName": "${objectName}",
4296
4323
  "recordId": "${uiSchema.list_views[listName]._id}",
4297
4324
  "listName": "${listName}",
4298
- "appId": "${appId}"
4325
+ "appId": "${appId}",
4326
+ "context": "${context}"
4299
4327
  },
4300
4328
  "body": [
4301
4329
  {
@@ -4444,11 +4472,12 @@
4444
4472
  "type": "dialog",
4445
4473
  "title": "默认排序规则",
4446
4474
  "data": {
4447
- "&": "$$",
4475
+ //"&":"$$",2.7、2.9、3.0在此处失效
4448
4476
  "targetObjectName": "${objectName}",
4449
4477
  "recordId": "${uiSchema.list_views[listName]._id}",
4450
4478
  "listName": "${listName}",
4451
- "appId": "${appId}"
4479
+ "appId": "${appId}",
4480
+ "context": "${context}"
4452
4481
  },
4453
4482
  "body": [
4454
4483
  {
@@ -5138,24 +5167,13 @@ else{
5138
5167
  "actionType": "custom",
5139
5168
  "script": `
5140
5169
  const scope = event.context.scoped;
5141
- //TODO: 将form中的value一同加入筛选内
5142
- // var filterForm = scope.parent.parent.getComponents().find(function(n){
5143
- // return n.props.type === "form";
5144
- // });
5145
- // var filterFormValues = filterForm.getValues();
5146
- filterFormValues={
5170
+ var filterFormValues={
5147
5171
  "__searchable__organizations_parents":event.data.value.value
5148
5172
  }
5149
5173
  var listView = scope.parent.getComponents().find(function(n){
5150
5174
  return n.props.type === "crud";
5151
5175
  });
5152
- const removedValues = {};
5153
- // for(var k in filterFormValues){
5154
- // if(filterFormValues[k] === "" && !filterFormValues.hasOwnProperty(k)){
5155
- // removedValues[k] = "";
5156
- // }
5157
- // }
5158
- listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
5176
+ listView.handleFilterSubmit(Object.assign({}, filterFormValues));
5159
5177
  `
5160
5178
  }
5161
5179
  ]
@@ -5269,7 +5287,7 @@ else{
5269
5287
 
5270
5288
  const source = await getApi$1(refObjectConfig, null, fields, {expand: true, alias: 'rows', queryOptions: `filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"`});
5271
5289
 
5272
- if(source.url){
5290
+ if(source.url && !ctx.inFilterForm){
5273
5291
  const depend_on = [];
5274
5292
  const sendOn = [];
5275
5293
  ___namespace.each(field.depend_on, (fName)=>{
@@ -5333,9 +5351,10 @@ else{
5333
5351
  filters.push(fieldFilters);
5334
5352
  }
5335
5353
 
5354
+ const inFilterForm = ${ctx.inFilterForm};
5336
5355
  const filtersFunction = ${field.filtersFunction || field._filtersFunction};
5337
5356
 
5338
- if(filtersFunction){
5357
+ if(filtersFunction && !inFilterForm){
5339
5358
  const _filters = filtersFunction(filters, api.data.$self.__super.__super);
5340
5359
  if(_filters && _filters.length > 0){
5341
5360
  filters.push(_filters);
@@ -5555,7 +5574,8 @@ else{
5555
5574
  sort = getListViewSort(listView);
5556
5575
  }
5557
5576
 
5558
- if(apiInfo.url){
5577
+ // 列表视图搜索栏中,即inFilterForm=true时,不需要执行depend_on
5578
+ if(apiInfo.url && !ctx.inFilterForm){
5559
5579
  const depend_on = [];
5560
5580
  const sendOn = [];
5561
5581
  ___namespace.each(field.depend_on, (fName)=>{
@@ -5592,9 +5612,10 @@ else{
5592
5612
  filters.push(fieldFilters);
5593
5613
  }
5594
5614
 
5615
+ const inFilterForm = ${ctx.inFilterForm};
5595
5616
  const filtersFunction = ${field.filtersFunction || field._filtersFunction};
5596
5617
 
5597
- if(filtersFunction){
5618
+ if(filtersFunction && !inFilterForm){
5598
5619
  const _filters = filtersFunction(filters, api.data.$);
5599
5620
  if(_filters && _filters.length > 0){
5600
5621
  filters.push(_filters);
@@ -5620,7 +5641,14 @@ else{
5620
5641
  referenceTo ? referenceTo.valueField.name : '';
5621
5642
  if(field.optionsFunction || field._optionsFunction){
5622
5643
  apiInfo.adaptor = `
5623
- payload.data.options = eval(${field.optionsFunction || field._optionsFunction})(api.data.$);
5644
+ var options = eval(${field.optionsFunction || field._optionsFunction})(api.data.$);
5645
+ if(api.data.$term){
5646
+ options = _.filter(options, function(o) {
5647
+ var label = o.label;
5648
+ return label.toLowerCase().indexOf(api.data.$term.toLowerCase()) > -1;
5649
+ });
5650
+ }
5651
+ payload.data.options = options;
5624
5652
  return payload;
5625
5653
  `;
5626
5654
  }
@@ -5756,7 +5784,7 @@ else{
5756
5784
  source.data.$term = "$term";
5757
5785
  source.data.$self = "$$";
5758
5786
 
5759
- if(idsDependOn && source.url){
5787
+ if(idsDependOn && source.url && !ctx.inFilterForm){
5760
5788
  source.sendOn = `\${${idsDependOn} && ${idsDependOn}.length}`;
5761
5789
  source.url = `${source.url}&depend_on_${idsDependOn}=\${${idsDependOn}|join}`;
5762
5790
  }
@@ -6598,7 +6626,7 @@ else{
6598
6626
  convertData.className = fieldTypeClassName;
6599
6627
  }
6600
6628
 
6601
- if(field.visible_on){
6629
+ if(field.visible_on && !ctx.inFilterForm){
6602
6630
  // convertData.visibleOn = `\$${field.visible_on.substring(1, field.visible_on.length -1).replace(/formData./g, '')}`;
6603
6631
  if(field.visible_on.startsWith("{{")){
6604
6632
  convertData.visibleOn = `${field.visible_on.substring(2, field.visible_on.length -2).replace(/formData./g, 'data.')}`;
@@ -6691,7 +6719,7 @@ else{
6691
6719
  _field.multiple = true;
6692
6720
  _field.is_wide = false;
6693
6721
  _field.defaultValue = undefined;
6694
- const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true}));
6722
+ const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
6695
6723
  if(amisField){
6696
6724
  return amisField;
6697
6725
  }
@@ -7531,11 +7559,12 @@ else{
7531
7559
  "expression": "this.__deletedRecord != true"
7532
7560
  },
7533
7561
  {
7534
- "args": {
7535
- "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
7536
- "blank": false
7537
- },
7538
- "actionType": "link",
7562
+ // "args": {
7563
+ // "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
7564
+ // "blank": false
7565
+ // },
7566
+ "actionType": "custom",
7567
+ "script": "Steedos.goBack()",
7539
7568
  "expression": "this.__deletedRecord === true"
7540
7569
  }
7541
7570
  ]
@@ -7693,7 +7722,7 @@ else{
7693
7722
  tpl: tpl,
7694
7723
  toggled: field.toggled,
7695
7724
  className,
7696
- html: field.type === 'html' ? true : null
7725
+ options: field.type === 'html' ? {html: true} : null
7697
7726
  // toggled: true
7698
7727
  }, field.amis, {name: field.name}));
7699
7728
  }