@steedos-widgets/amis-lib 1.2.9 → 1.2.11

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
@@ -1,5 +1,5 @@
1
1
  import * as _$1 from 'lodash';
2
- import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, includes, get, toArray, mergeWith, map, forEach, isBoolean, omitBy, isNil, isString, union, has, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, filter, startsWith } from 'lodash';
2
+ import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, forEach, includes, get, toArray, mergeWith, map, isBoolean, omitBy, isNil, isString, union, has, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, filter, startsWith } from 'lodash';
3
3
  import { Router as Router$1, getSteedosAuth as getSteedosAuth$1, lookupToAmis as lookupToAmis$1, fetchAPI as fetchAPI$1 } from '@steedos-widgets/amis-lib';
4
4
  import isPlainObject from 'lodash/isPlainObject';
5
5
 
@@ -382,11 +382,28 @@ const Router = {
382
382
 
383
383
  };
384
384
 
385
+ /*
386
+ * @Author: baozhoutao@steedos.com
387
+ * @Date: 2022-07-20 16:29:22
388
+ * @LastEditors: Please set LastEditors
389
+ * @LastEditTime: 2023-05-18 15:22:51
390
+ * @Description:
391
+ */
392
+
393
+ function getContrastColor(bgColor) {
394
+ var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
395
+ var r = parseInt(backgroundColor.substr(0, 2), 16);
396
+ var g = parseInt(backgroundColor.substr(2, 2), 16);
397
+ var b = parseInt(backgroundColor.substr(4, 2), 16);
398
+ var brightness = (r * 299 + g * 587 + b * 114) / 1000;
399
+ return brightness < 128 ? "#ffffff" : "#000000";
400
+ }
401
+
385
402
  /*
386
403
  * @Author: baozhoutao@steedos.com
387
404
  * @Date: 2022-05-23 09:53:08
388
- * @LastEditors: baozhoutao@steedos.com
389
- * @LastEditTime: 2023-04-10 11:22:54
405
+ * @LastEditors: Please set LastEditors
406
+ * @LastEditTime: 2023-05-22 15:13:18
390
407
  * @Description:
391
408
  */
392
409
 
@@ -439,6 +456,22 @@ async function getRefObjectNameFieldName(field){
439
456
  function getSelectTpl(field){
440
457
  return `<div>\${_display.${field.name}}</div>`
441
458
  }
459
+ function getSelectMap(selectOptions){
460
+ let map = {};
461
+ forEach(selectOptions,(option)=>{
462
+ const optionValue = option.value + '';
463
+ const optionColor = option.color + '';
464
+ if(optionColor){
465
+ const background = optionColor.charAt(0) === '#' ? optionColor : '#'+optionColor;
466
+ const color = getContrastColor(background);
467
+ const optionColorStyle = 'background:'+background+';color:'+color;
468
+ map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
469
+ }else {
470
+ map[optionValue] = option.label;
471
+ }
472
+ });
473
+ return map;
474
+ }
442
475
 
443
476
  function getNameTplUrl(field, ctx){
444
477
  if(ctx.objectName === 'cms_files'){
@@ -1835,9 +1868,10 @@ const getSchema$1 = (uiSchema) => {
1835
1868
  {
1836
1869
  name: "template_url",
1837
1870
  label: "导入模板",
1838
- type: "tpl",
1839
- // type: "markdown",
1840
- // html: true,
1871
+ type: "markdown",
1872
+ options: {
1873
+ html: true
1874
+ },
1841
1875
  className: "whitespace-nowrap",
1842
1876
  },
1843
1877
  null,
@@ -2684,6 +2718,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2684
2718
  if (!ctx) {
2685
2719
  ctx = {};
2686
2720
  }
2721
+ const btnSearchId = "btn_filter_form_search_" + new Date().getTime();
2687
2722
  const filterFormSchema = await getObjectFieldsFilterFormSchema(ctx);
2688
2723
  const onSearchScript = `
2689
2724
  const scope = event.context.scoped;
@@ -2700,7 +2735,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2700
2735
  // // 这会造成handleFilterSubmit时把移除掉的搜索项字段之前的值加到过滤条件中
2701
2736
  // for(var k in filterFormValues){
2702
2737
  // if(filterFormValues[k] === "" && !filterFormValues.hasOwnProperty(k)){
2703
- // removedValues[k] = "";
2738
+ // removedValues[k] = null;
2704
2739
  // }
2705
2740
  // }
2706
2741
  // listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
@@ -2739,7 +2774,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2739
2774
  const removedValues = {};
2740
2775
  for(var k in filterFormValues){
2741
2776
  if(/^__searchable__/.test(k)){
2742
- removedValues[k] = "";
2777
+ removedValues[k] = null;
2743
2778
  }
2744
2779
  }
2745
2780
  if(!event.data.isLookup){
@@ -2750,7 +2785,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2750
2785
  if(localListViewProps){
2751
2786
  localListViewProps = JSON.parse(localListViewProps);
2752
2787
  for(var k in localListViewProps){
2753
- removedValues[k] = "";
2788
+ removedValues[k] = null;
2754
2789
  }
2755
2790
  }
2756
2791
  }
@@ -2908,7 +2943,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2908
2943
  });
2909
2944
  const removedValues = {};
2910
2945
  removedKeys.forEach(function(key){
2911
- removedValues[key] = "";
2946
+ removedValues[key] = null;
2912
2947
  });
2913
2948
  filterForm.setValues(removedValues);//这里使用filterInnerForm也可以
2914
2949
 
@@ -2921,10 +2956,14 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2921
2956
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
2922
2957
  if(localListViewProps){
2923
2958
  localListViewProps = JSON.parse(localListViewProps);
2924
- // const removedValues = {};
2925
- removedKeys.forEach(function(key){
2926
- delete localListViewProps[key];
2927
- // removedValues[key] = "";
2959
+ _.each(localListViewProps, function(n,k){
2960
+ // __searchable__开头的不在searchableFields范围则清除其值
2961
+ let isRemoved = !!removedFields.find(function(fieldName){
2962
+ return new RegExp("__searchable__\.*" + fieldName + "$").test(k);
2963
+ });
2964
+ if(isRemoved){
2965
+ delete localListViewProps[k];
2966
+ }
2928
2967
  });
2929
2968
  sessionStorage.setItem(listViewPropsStoreKey, JSON.stringify(localListViewProps));
2930
2969
  }
@@ -2958,9 +2997,10 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2958
2997
  "body": [
2959
2998
  {
2960
2999
  "type": "button",
3000
+ "id": btnSearchId,
2961
3001
  "label": "搜索",
2962
3002
  "icon": "fa fa-search",
2963
- "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
3003
+ // "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
2964
3004
  "onEvent": {
2965
3005
  "click": {
2966
3006
  "actions": [
@@ -2976,7 +3016,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2976
3016
  "type": "button",
2977
3017
  "label": "取消",
2978
3018
  "name": "btn_filter_form_cancel",
2979
- "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
3019
+ // "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
2980
3020
  "onEvent": {
2981
3021
  "click": {
2982
3022
  "actions": [
@@ -3091,6 +3131,10 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3091
3131
  "actionType": "custom",
3092
3132
  "script": onSearchableFieldsChangeScript
3093
3133
  },
3134
+ {
3135
+ "actionType": "click",
3136
+ "componentId": btnSearchId
3137
+ },
3094
3138
  {
3095
3139
  "componentId": "",
3096
3140
  "args": {},
@@ -3398,8 +3442,8 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
3398
3442
  },
3399
3443
  "body":[{
3400
3444
  "type": "button",
3401
- "visibleOn": "${window:innerWidth > 768 && window:historyPaths.length > 1}",
3402
- "className":"flex mr-2",
3445
+ "visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
3446
+ "className":"flex mr-4",
3403
3447
  "onEvent": {
3404
3448
  "click": {
3405
3449
  "actions": [
@@ -3416,7 +3460,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
3416
3460
  "category": "utility",
3417
3461
  "name": "back",
3418
3462
  "colorVariant": "default",
3419
- "className": "slds-button_icon slds-global-header__icon"
3463
+ "className": "slds-button_icon slds-global-header__icon w-4"
3420
3464
  }
3421
3465
  ]
3422
3466
  }]
@@ -3445,7 +3489,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
3445
3489
  // "tpl": "${(record && uiSchema && record[uiSchema.NAME_FIELD_KEY]) || name}",
3446
3490
  "inline": false,
3447
3491
  "wrapperComponent": "",
3448
- "className": "leading-5 text-xl font-bold"
3492
+ "className": "record-detail-header-name leading-5 text-xl font-bold"
3449
3493
  }
3450
3494
  ],
3451
3495
  "columnClassName": "p-l-xs"
@@ -3454,6 +3498,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
3454
3498
  "className": "flex justify-between"
3455
3499
  }
3456
3500
  ],
3501
+ "columnClassName": "flex-initial",
3457
3502
  "md": "auto",
3458
3503
  });
3459
3504
  }
@@ -3474,7 +3519,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
3474
3519
  {
3475
3520
  "type": "grid",
3476
3521
  "columns": gridBody,
3477
- "className": "flex justify-between"
3522
+ "className": "flex justify-between flex-nowrap"
3478
3523
  }
3479
3524
  ],
3480
3525
  "hiddenOn": "${recordLoaded != true}"
@@ -3691,12 +3736,13 @@ const getNewListviewButtonSchema = ()=>{
3691
3736
  "type": "dialog",
3692
3737
  "title": "新建 列表视图",
3693
3738
  "data": {
3694
- "&": "$$",
3739
+ //"&":"$$",2.7、2.9、3.0在此处失效
3695
3740
  "all": "${uiSchema.list_views.all}",
3696
3741
  "list_view": "${uiSchema.list_views[listName]}",
3697
3742
  "appId": "${appId}",
3698
3743
  "global": "${global}",
3699
3744
  "targetObjectName": "${objectName}",
3745
+ "context": "${context}"
3700
3746
  },
3701
3747
  "body": [
3702
3748
  {
@@ -3840,12 +3886,13 @@ const getCopyListviewButtonSchema = ()=>{
3840
3886
  "type": "dialog",
3841
3887
  "title": "复制 列表视图",
3842
3888
  "data": {
3843
- "&": "$$",
3889
+ //"&":"$$",2.7、2.9、3.0在此处失效
3844
3890
  "listName": "${listName}",
3845
3891
  "targetObjectName": "${objectName}",
3846
3892
  "list_view": "${uiSchema.list_views[listName]}",
3847
3893
  "appId": "${appId}",
3848
- "global": "${global}"
3894
+ "global": "${global}",
3895
+ "context": "${context}"
3849
3896
  },
3850
3897
  "body": [
3851
3898
  {
@@ -3987,7 +4034,8 @@ const getRenameListviewButtonSchema = ()=>{
3987
4034
  "data": {
3988
4035
  "targetObjectName": "${objectName}",
3989
4036
  "recordId": "${uiSchema.list_views[listName]._id}",
3990
- "appId": "${appId}"
4037
+ "appId": "${appId}",
4038
+ "context": "${context}"
3991
4039
  },
3992
4040
  "body": [
3993
4041
  {
@@ -4044,6 +4092,7 @@ const getSetListviewShareButtonSchema = ()=>{
4044
4092
  "title": "共享设置",
4045
4093
  "data": {
4046
4094
  "recordId": "${uiSchema.list_views[listName]._id}",
4095
+ "context": "${context}"
4047
4096
  },
4048
4097
  "body": [
4049
4098
  {
@@ -4089,7 +4138,8 @@ const getSetListviewFiltersButtonSchema = ()=>{
4089
4138
  "targetObjectName": "${objectName}",
4090
4139
  "recordId": "${uiSchema.list_views[listName]._id}",
4091
4140
  "listName": "${listName}",
4092
- "appId": "${appId}"
4141
+ "appId": "${appId}",
4142
+ "context": "${context}"
4093
4143
  },
4094
4144
  "body": [
4095
4145
  {
@@ -4233,11 +4283,12 @@ const getSetListviewColumnsButtonSchema = ()=>{
4233
4283
  "type": "dialog",
4234
4284
  "title": "显示的列",
4235
4285
  "data": {
4236
- "&": "$$",
4286
+ //"&":"$$",2.7、2.9、3.0在此处失效
4237
4287
  "targetObjectName": "${objectName}",
4238
4288
  "recordId": "${uiSchema.list_views[listName]._id}",
4239
4289
  "listName": "${listName}",
4240
- "appId": "${appId}"
4290
+ "appId": "${appId}",
4291
+ "context": "${context}"
4241
4292
  },
4242
4293
  "body": [
4243
4294
  {
@@ -4384,13 +4435,14 @@ const getSetListviewSortButtonSchema = ()=>{
4384
4435
  {
4385
4436
  "dialog": {
4386
4437
  "type": "dialog",
4387
- "title": "弹框标题",
4438
+ "title": "默认排序规则",
4388
4439
  "data": {
4389
- "&": "$$",
4440
+ //"&":"$$",2.7、2.9、3.0在此处失效
4390
4441
  "targetObjectName": "${objectName}",
4391
4442
  "recordId": "${uiSchema.list_views[listName]._id}",
4392
4443
  "listName": "${listName}",
4393
- "appId": "${appId}"
4444
+ "appId": "${appId}",
4445
+ "context": "${context}"
4394
4446
  },
4395
4447
  "body": [
4396
4448
  {
@@ -5080,24 +5132,13 @@ function getLookupSapceUserTreeSchema(){
5080
5132
  "actionType": "custom",
5081
5133
  "script": `
5082
5134
  const scope = event.context.scoped;
5083
- //TODO: 将form中的value一同加入筛选内
5084
- // var filterForm = scope.parent.parent.getComponents().find(function(n){
5085
- // return n.props.type === "form";
5086
- // });
5087
- // var filterFormValues = filterForm.getValues();
5088
- filterFormValues={
5135
+ var filterFormValues={
5089
5136
  "__searchable__organizations_parents":event.data.value.value
5090
5137
  }
5091
5138
  var listView = scope.parent.getComponents().find(function(n){
5092
5139
  return n.props.type === "crud";
5093
5140
  });
5094
- const removedValues = {};
5095
- // for(var k in filterFormValues){
5096
- // if(filterFormValues[k] === "" && !filterFormValues.hasOwnProperty(k)){
5097
- // removedValues[k] = "";
5098
- // }
5099
- // }
5100
- listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
5141
+ listView.handleFilterSubmit(Object.assign({}, filterFormValues));
5101
5142
  `
5102
5143
  }
5103
5144
  ]
@@ -5211,7 +5252,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
5211
5252
 
5212
5253
  const source = await getApi$1(refObjectConfig, null, fields, {expand: true, alias: 'rows', queryOptions: `filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"`});
5213
5254
 
5214
- if(source.url){
5255
+ if(source.url && !ctx.inFilterForm){
5215
5256
  const depend_on = [];
5216
5257
  const sendOn = [];
5217
5258
  _$1.each(field.depend_on, (fName)=>{
@@ -5275,9 +5316,10 @@ async function lookupToAmisPicker(field, readonly, ctx){
5275
5316
  filters.push(fieldFilters);
5276
5317
  }
5277
5318
 
5319
+ const inFilterForm = ${ctx.inFilterForm};
5278
5320
  const filtersFunction = ${field.filtersFunction || field._filtersFunction};
5279
5321
 
5280
- if(filtersFunction){
5322
+ if(filtersFunction && !inFilterForm){
5281
5323
  const _filters = filtersFunction(filters, api.data.$self.__super.__super);
5282
5324
  if(_filters && _filters.length > 0){
5283
5325
  filters.push(_filters);
@@ -5497,7 +5539,8 @@ async function lookupToAmisSelect(field, readonly, ctx){
5497
5539
  sort = getListViewSort(listView);
5498
5540
  }
5499
5541
 
5500
- if(apiInfo.url){
5542
+ // 列表视图搜索栏中,即inFilterForm=true时,不需要执行depend_on
5543
+ if(apiInfo.url && !ctx.inFilterForm){
5501
5544
  const depend_on = [];
5502
5545
  const sendOn = [];
5503
5546
  _$1.each(field.depend_on, (fName)=>{
@@ -5534,9 +5577,10 @@ async function lookupToAmisSelect(field, readonly, ctx){
5534
5577
  filters.push(fieldFilters);
5535
5578
  }
5536
5579
 
5580
+ const inFilterForm = ${ctx.inFilterForm};
5537
5581
  const filtersFunction = ${field.filtersFunction || field._filtersFunction};
5538
5582
 
5539
- if(filtersFunction){
5583
+ if(filtersFunction && !inFilterForm){
5540
5584
  const _filters = filtersFunction(filters, api.data.$);
5541
5585
  if(_filters && _filters.length > 0){
5542
5586
  filters.push(_filters);
@@ -5562,7 +5606,14 @@ async function lookupToAmisSelect(field, readonly, ctx){
5562
5606
  referenceTo ? referenceTo.valueField.name : '';
5563
5607
  if(field.optionsFunction || field._optionsFunction){
5564
5608
  apiInfo.adaptor = `
5565
- payload.data.options = eval(${field.optionsFunction || field._optionsFunction})(api.data.$);
5609
+ var options = eval(${field.optionsFunction || field._optionsFunction})(api.data.$);
5610
+ if(api.data.$term){
5611
+ options = _.filter(options, function(o) {
5612
+ var label = o.label;
5613
+ return label.toLowerCase().indexOf(api.data.$term.toLowerCase()) > -1;
5614
+ });
5615
+ }
5616
+ payload.data.options = options;
5566
5617
  return payload;
5567
5618
  `;
5568
5619
  }
@@ -5698,7 +5749,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
5698
5749
  source.data.$term = "$term";
5699
5750
  source.data.$self = "$$";
5700
5751
 
5701
- if(idsDependOn && source.url){
5752
+ if(idsDependOn && source.url && !ctx.inFilterForm){
5702
5753
  source.sendOn = `\${${idsDependOn} && ${idsDependOn}.length}`;
5703
5754
  source.url = `${source.url}&depend_on_${idsDependOn}=\${${idsDependOn}|join}`;
5704
5755
  }
@@ -5984,23 +6035,6 @@ const getAmisFileSchema = (steedosField, readonly)=>{
5984
6035
  return readonly ? getAmisFileReadonlySchema(steedosField) : getAmisFileEditSchema(steedosField);
5985
6036
  };
5986
6037
 
5987
- /*
5988
- * @Author: baozhoutao@steedos.com
5989
- * @Date: 2022-07-20 16:29:22
5990
- * @LastEditors: Please set LastEditors
5991
- * @LastEditTime: 2023-05-11 11:19:54
5992
- * @Description:
5993
- */
5994
-
5995
- function getContrastColor(bgColor) {
5996
- var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
5997
- var r = parseInt(backgroundColor.substr(0, 2), 16);
5998
- var g = parseInt(backgroundColor.substr(2, 2), 16);
5999
- var b = parseInt(backgroundColor.substr(4, 2), 16);
6000
- var brightness = (r * 299 + g * 587 + b * 114) / 1000;
6001
- return brightness >= 128 ? "#000000" : "#ffffff";
6002
- }
6003
-
6004
6038
  const OMIT_FIELDS = ['created', 'created_by', 'modified', 'modified_by'];
6005
6039
  // const Lookup = require('./lookup');
6006
6040
 
@@ -6191,19 +6225,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
6191
6225
  // break;
6192
6226
  case 'select':
6193
6227
  if(readonly){
6194
- const selectOptions = field.options;
6195
- let map = {};
6196
- _$1.forEach(selectOptions,(option)=>{
6197
- const optionValue = option.value + '';
6198
- if(option.color){
6199
- const background = '#'+option.color;
6200
- const color = getContrastColor(background);
6201
- const optionColorStyle = 'background:'+background+';color:'+color;
6202
- map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
6203
- }else {
6204
- map[optionValue] = option.label;
6205
- }
6206
- });
6228
+ const map = getSelectMap(field.options);
6207
6229
  convertData = {
6208
6230
  type: "static-mapping",
6209
6231
  name: field.name,
@@ -6569,7 +6591,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
6569
6591
  convertData.className = fieldTypeClassName;
6570
6592
  }
6571
6593
 
6572
- if(field.visible_on){
6594
+ if(field.visible_on && !ctx.inFilterForm){
6573
6595
  // convertData.visibleOn = `\$${field.visible_on.substring(1, field.visible_on.length -1).replace(/formData./g, '')}`;
6574
6596
  if(field.visible_on.startsWith("{{")){
6575
6597
  convertData.visibleOn = `${field.visible_on.substring(2, field.visible_on.length -2).replace(/formData./g, 'data.')}`;
@@ -6662,7 +6684,7 @@ async function getFieldSearchable(perField, permissionFields, ctx){
6662
6684
  _field.multiple = true;
6663
6685
  _field.is_wide = false;
6664
6686
  _field.defaultValue = undefined;
6665
- const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true}));
6687
+ const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
6666
6688
  if(amisField){
6667
6689
  return amisField;
6668
6690
  }
@@ -6902,7 +6924,8 @@ async function getEditFormInitApi(object, recordId, fields, options){
6902
6924
  data.global = "${global}";
6903
6925
  data.context = "${context}";
6904
6926
  data.defaultData = "${defaultData}";
6905
-
6927
+ data._master = "${_master}";
6928
+
6906
6929
  return {
6907
6930
  method: "post",
6908
6931
  url: getApi$2() + '&objectName=${objectName}' ,
@@ -6968,7 +6991,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
6968
6991
  formInitialValuesFun = new Function("return " + formInitialValuesFun)();
6969
6992
  }
6970
6993
  if(typeof formInitialValuesFun === "function"){
6971
- initialValues = formInitialValuesFun.apply({doc: defaultValues || {} , global: api.body.global})
6994
+ initialValues = formInitialValuesFun.apply({doc: defaultValues || {} , global: api.body.global, master: api.body._master })
6972
6995
  }
6973
6996
  }
6974
6997
  catch(ex){
@@ -7624,19 +7647,7 @@ async function getTableColumns(fields, options){
7624
7647
  }, field.amis, {name: field.name}));
7625
7648
  }
7626
7649
  else if(field.type === 'select'){
7627
- const selectOptions = field.options;
7628
- let map = {};
7629
- forEach(selectOptions,(option)=>{
7630
- const optionValue = option.value + '';
7631
- if(option.color){
7632
- const background = '#'+option.color;
7633
- const color = getContrastColor(background);
7634
- const optionColorStyle = 'background:'+background+';color:'+color;
7635
- map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
7636
- }else {
7637
- map[optionValue] = option.label;
7638
- }
7639
- });
7650
+ const map = getSelectMap(field.options);
7640
7651
  columns.push(Object.assign({}, {
7641
7652
  type: "mapping",
7642
7653
  name: field.name,
@@ -7675,7 +7686,7 @@ async function getTableColumns(fields, options){
7675
7686
  tpl: tpl,
7676
7687
  toggled: field.toggled,
7677
7688
  className,
7678
- html: field.type === 'html' ? true : null
7689
+ options: field.type === 'html' ? {html: true} : null
7679
7690
  // toggled: true
7680
7691
  }, field.amis, {name: field.name}));
7681
7692
  }
@@ -8189,11 +8200,10 @@ async function getTableApi(mainObject, fields, options){
8189
8200
  if(api.data.$self._isRelated){
8190
8201
  const self = api.data.$self;
8191
8202
  const relatedKey = self.relatedKey;
8192
- const recordId = self.recordId;
8193
8203
  const refField = self.uiSchema.fields[relatedKey];
8194
8204
  const masterRecord = self._master.record;
8195
8205
  const masterObjectName = self._master.objectName;
8196
- let relatedValue = recordId;
8206
+ let relatedValue = self._master.recordId;
8197
8207
  if(refField.reference_to_field && refField.reference_to_field != '_id'){
8198
8208
  relatedValue = masterRecord[refField.reference_to_field]
8199
8209
  }