@steedos-widgets/amis-object 1.2.35 → 1.2.37

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.
@@ -3568,8 +3568,8 @@ function getContrastColor(bgColor) {
3568
3568
  /*
3569
3569
  * @Author: baozhoutao@steedos.com
3570
3570
  * @Date: 2022-05-23 09:53:08
3571
- * @LastEditors: liaodaxue
3572
- * @LastEditTime: 2023-07-28 16:26:31
3571
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
3572
+ * @LastEditTime: 2023-08-03 18:07:54
3573
3573
  * @Description:
3574
3574
  */
3575
3575
 
@@ -3651,7 +3651,11 @@ function getNameTplUrl(field, ctx){
3651
3651
 
3652
3652
  function getNameTpl(field, ctx){
3653
3653
  const href = getNameTplUrl(field, ctx);
3654
- return `<a href="${href}">\${${field.name}}</a>`
3654
+ let linkTarget = "";
3655
+ if(ctx && ctx.isLookup){
3656
+ linkTarget = "target='_blank'";
3657
+ }
3658
+ return `<a href="${href}" ${linkTarget}>\${${field.name}}</a>`
3655
3659
  }
3656
3660
 
3657
3661
  function getRelatedFieldTpl(field, ctx){
@@ -3664,6 +3668,11 @@ function getRelatedFieldTpl(field, ctx){
3664
3668
  }
3665
3669
  }
3666
3670
 
3671
+ let linkTarget = "";
3672
+ if(ctx && ctx.isLookup){
3673
+ linkTarget = "target='_blank'";
3674
+ }
3675
+
3667
3676
  const onlyDisplayLabel = ctx.onlyDisplayLabel;
3668
3677
 
3669
3678
  let fieldDataStrTpl = `data._display.${field.name}`;
@@ -3679,7 +3688,7 @@ function getRelatedFieldTpl(field, ctx){
3679
3688
  const href = Router$1.getObjectDetailPath({
3680
3689
  formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
3681
3690
  });
3682
- labelTpl = `<a href="${href}"><%=item.label%></a>`;
3691
+ labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
3683
3692
  }
3684
3693
  tpl = `
3685
3694
  <% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item,index) { %> <% if(index>0 && index<${fieldDataStrTpl}.length){ %> , <% } %> ${labelTpl} <% }); %><% } %>
@@ -3697,7 +3706,7 @@ function getRelatedFieldTpl(field, ctx){
3697
3706
  const href = Router$1.getObjectDetailPath({
3698
3707
  formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
3699
3708
  });
3700
- labelTpl = `<a href="${href}">${labelTpl}</a>`;
3709
+ labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
3701
3710
  }
3702
3711
  tpl = labelTpl;
3703
3712
  }
@@ -3709,7 +3718,7 @@ function getRelatedFieldTpl(field, ctx){
3709
3718
  const href = Router$1.getObjectDetailPath({
3710
3719
  formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
3711
3720
  });
3712
- labelTpl = `<a href="${href}"><%=item.label%></a>`;
3721
+ labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
3713
3722
  }
3714
3723
  tpl = `
3715
3724
  <% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item) { %> ${labelTpl} <% }); %><% } %>
@@ -3845,7 +3854,7 @@ async function getFieldsTemplate(fields, display){
3845
3854
  if(displayFields.length > 0){
3846
3855
  return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
3847
3856
  }
3848
- return `${fieldsName.join(' ')},${expandFieldsQuery}`
3857
+ return ___default.trimEnd(`${fieldsName.join(' ')},${expandFieldsQuery}`, ",")
3849
3858
  }
3850
3859
 
3851
3860
  function getRecordPermissionsTemplate(){
@@ -6420,12 +6429,6 @@ async function getObjectFieldsFilterFormSchema(ctx) {
6420
6429
  if (
6421
6430
  field && window.isFieldTypeSearchable(field.type)
6422
6431
  ) {
6423
- delete field.defaultValue;
6424
- delete field.required;
6425
- delete field.is_wide;
6426
- delete field.readonly;
6427
- delete field.hidden;
6428
- delete field.omit;
6429
6432
  var ctx = ${JSON.stringify(ctx)};
6430
6433
  const amisField = window.getFieldSearchable(field, fields, ctx);
6431
6434
  return amisField;
@@ -6520,8 +6523,8 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6520
6523
  }
6521
6524
  if(!event.data.isLookup){
6522
6525
  // 刷新浏览器后,filterFormValues值是空的,只能从本地存储中取出并重置为空值
6523
- const listViewId = event.data.listViewId;
6524
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
6526
+ const listName = event.data.listName;
6527
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
6525
6528
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
6526
6529
  if(localListViewProps){
6527
6530
  localListViewProps = JSON.parse(localListViewProps);
@@ -6547,13 +6550,13 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6547
6550
  const dataProviderInited = `
6548
6551
  const objectName = data.objectName;
6549
6552
  const isLookup = data.isLookup;
6550
- const listViewId = data.listViewId;
6553
+ const listName = data.listName;
6551
6554
  let searchableFieldsStoreKey = location.pathname + "/searchable_fields/";
6552
6555
  if(isLookup){
6553
6556
  searchableFieldsStoreKey += "lookup/" + objectName;
6554
6557
  }
6555
6558
  else{
6556
- searchableFieldsStoreKey += (listViewId || "");
6559
+ searchableFieldsStoreKey += (listName || "");
6557
6560
  }
6558
6561
  let defaultSearchableFields = sessionStorage.getItem(searchableFieldsStoreKey);
6559
6562
  if(defaultSearchableFields){
@@ -6580,9 +6583,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6580
6583
  setData({ showFieldsFilter: false });
6581
6584
  }
6582
6585
  else{
6583
- console.log("===listViewPropsStoreKey=data==", data);
6584
- const listViewPropsStoreKey = location.pathname + "/crud/" + (data.listViewId || "");
6585
- console.log("===listViewPropsStoreKey=122==", listViewPropsStoreKey);
6586
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
6586
6587
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
6587
6588
  if(localListViewProps){
6588
6589
  localListViewProps = JSON.parse(localListViewProps);
@@ -6612,7 +6613,6 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6612
6613
  const listName = data.listName;
6613
6614
  const objectName = data.objectName;
6614
6615
  const isLookup = data.isLookup;
6615
- const listViewId = data.listViewId;
6616
6616
  const value = data.fields;
6617
6617
  const scope = event.context.scoped;
6618
6618
  // 这里的filterForm不是name为"listview-filter-form"的内部form,而是crud自带的filter form
@@ -6628,7 +6628,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6628
6628
  searchableFieldsStoreKey += "lookup/" + objectName;
6629
6629
  }
6630
6630
  else{
6631
- searchableFieldsStoreKey += (listViewId || "");
6631
+ searchableFieldsStoreKey += (listName || "");
6632
6632
  }
6633
6633
  sessionStorage.setItem(searchableFieldsStoreKey, value);
6634
6634
 
@@ -6686,7 +6686,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6686
6686
  }
6687
6687
 
6688
6688
  // 列表视图crud支持本地缓存,所以需要进一步清除浏览器本地缓存里面用户在可搜索项中移除的字段值
6689
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
6689
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
6690
6690
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
6691
6691
  if(localListViewProps){
6692
6692
  localListViewProps = JSON.parse(localListViewProps);
@@ -8905,6 +8905,10 @@ async function lookupToAmisPicker(field, readonly, ctx){
8905
8905
  return ;
8906
8906
  }
8907
8907
  const refObjectConfig = await getUISchema(referenceTo.objectName);
8908
+
8909
+ ctx.idFieldName = refObjectConfig.idFieldName;
8910
+ ctx.objectName = refObjectConfig.name;
8911
+
8908
8912
  const tableFields = [];
8909
8913
  let i = 0;
8910
8914
  const searchableFields = [];
@@ -9272,7 +9276,6 @@ async function lookupToAmisPicker(field, readonly, ctx){
9272
9276
  if(readonly){
9273
9277
  data.tpl = await getLookupTpl(field, ctx);
9274
9278
  }
9275
-
9276
9279
  return data;
9277
9280
  }
9278
9281
 
@@ -10602,6 +10605,24 @@ async function getFieldSearchable(perField, permissionFields, ctx){
10602
10605
  _field.multiple = true;
10603
10606
  _field.is_wide = false;
10604
10607
  _field.defaultValue = undefined;
10608
+ _field.required = false;
10609
+ _field.hidden = false;
10610
+ _field.omit = false;
10611
+
10612
+ if(_field.amis){
10613
+ delete _field.amis.static;
10614
+ delete _field.amis.staticOn;
10615
+ delete _field.amis.disabled;
10616
+ delete _field.amis.disabledOn;
10617
+ delete _field.amis.required;
10618
+ delete _field.amis.requiredOn;
10619
+ delete _field.amis.visible;
10620
+ delete _field.amis.visibleOn;
10621
+ delete _field.amis.hidden;
10622
+ delete _field.amis.hiddenOn;
10623
+ delete _field.amis.autoFill;
10624
+ }
10625
+
10605
10626
  const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
10606
10627
  if(amisField){
10607
10628
  return amisField;
@@ -10879,6 +10900,7 @@ async function getTableColumns$1(fields, options){
10879
10900
  if(field.wrap != true){
10880
10901
  className += " whitespace-nowrap";
10881
10902
  }
10903
+ let columnItem;
10882
10904
  if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
10883
10905
  const previewFileScript = `
10884
10906
  var data = event.data;
@@ -10886,12 +10908,11 @@ async function getTableColumns$1(fields, options){
10886
10908
  var file_id = data._id;
10887
10909
  SteedosUI.previewFile && SteedosUI.previewFile({file_name, file_id});
10888
10910
  `;
10889
- columns.push({
10911
+ columnItem = {
10890
10912
  "type": "button",
10891
10913
  "label": `<%=data.versions ? data.name : "${field.label}"%>`,
10892
10914
  className,
10893
10915
  "level": "link",
10894
- "quickEdit": quickEditSchema,
10895
10916
  "onEvent": {
10896
10917
  "click": {
10897
10918
  "actions": [
@@ -10917,9 +10938,9 @@ async function getTableColumns$1(fields, options){
10917
10938
  ]
10918
10939
  }
10919
10940
  }
10920
- });
10941
+ };
10921
10942
  }else if(field.type === 'toggle'){
10922
- columns.push(Object.assign({}, {
10943
+ columnItem = Object.assign({}, {
10923
10944
  type: "switch",
10924
10945
  name: field.name,
10925
10946
  label: field.label,
@@ -10927,24 +10948,22 @@ async function getTableColumns$1(fields, options){
10927
10948
  toggled: field.toggled,
10928
10949
  static: true,
10929
10950
  className,
10930
- quickEdit: quickEditSchema
10931
- }, field.amis, {name: field.name}));
10951
+ }, field.amis, {name: field.name});
10932
10952
  }else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
10933
- columns.push(Object.assign({}, {
10953
+ columnItem = Object.assign({}, {
10934
10954
  type: "switch",
10935
10955
  name: field.name,
10936
10956
  label: field.label,
10937
10957
  width: getFieldWidth(field.width),
10938
10958
  toggled: field.toggled,
10939
- quickEdit: quickEditSchema,
10940
10959
  static: true,
10941
10960
  className,
10942
10961
  ...getAmisFileReadonlySchema(field)
10943
- }, field.amis, {name: field.name}));
10962
+ }, field.amis, {name: field.name});
10944
10963
  }
10945
10964
  else if(field.type === 'select'){
10946
10965
  const map = getSelectMap(field.options);
10947
- columns.push(Object.assign({}, {
10966
+ columnItem = Object.assign({}, {
10948
10967
  type: "mapping",
10949
10968
  name: field.name,
10950
10969
  label: field.label,
@@ -10954,8 +10973,7 @@ async function getTableColumns$1(fields, options){
10954
10973
  toggled: field.toggled,
10955
10974
  className,
10956
10975
  static: true,
10957
- quickEdit: quickEditSchema
10958
- }, field.amis, {name: field.name}));
10976
+ }, field.amis, {name: field.name});
10959
10977
  }
10960
10978
  else {
10961
10979
  const tpl = await getFieldTpl(field, options);
@@ -10975,7 +10993,7 @@ async function getTableColumns$1(fields, options){
10975
10993
  className += 'min-w-56';
10976
10994
  }
10977
10995
  if(!field.hidden && !field.extra){
10978
- columns.push(Object.assign({}, {
10996
+ columnItem = Object.assign({}, {
10979
10997
  name: field.name,
10980
10998
  label: field.label,
10981
10999
  sortable: field.sortable,
@@ -10986,13 +11004,18 @@ async function getTableColumns$1(fields, options){
10986
11004
  toggled: field.toggled,
10987
11005
  className,
10988
11006
  static: true,
10989
- quickEdit: quickEditSchema,
10990
11007
  options: field.type === 'html' ? {html: true} : null
10991
11008
  // toggled: true
10992
- }, field.amis, {name: field.name}));
11009
+ }, field.amis, {name: field.name});
10993
11010
  }
10994
11011
  }
10995
-
11012
+ if(columnItem){
11013
+ if(quickEditSchema){
11014
+ columnItem.quickEdit = quickEditSchema;
11015
+ columnItem.quickEditEnabledOn = "${is_system !== true}";
11016
+ }
11017
+ columns.push(columnItem);
11018
+ }
10996
11019
  }
10997
11020
  // columns.push(getOperation(fields));
10998
11021
  if(!___default__namespace.some(columns, { name: options.labelFieldName })){
@@ -11298,6 +11321,7 @@ async function getTableOperation(ctx){
11298
11321
  }
11299
11322
 
11300
11323
  async function getTableSchema$1(fields, options){
11324
+ let isLookup = options && options.isLookup;
11301
11325
  if(!options){
11302
11326
  options = {};
11303
11327
  }
@@ -11307,7 +11331,9 @@ async function getTableSchema$1(fields, options){
11307
11331
  }
11308
11332
  else {
11309
11333
  columns = await getTableColumns$1(fields, options);
11310
- columns.push(await getTableOperation(options));
11334
+ if(!isLookup){
11335
+ columns.push(await getTableOperation(options));
11336
+ }
11311
11337
  }
11312
11338
  return {
11313
11339
  mode: "table",
@@ -11402,8 +11428,8 @@ async function getTableApi(mainObject, fields, options){
11402
11428
  const data = _.cloneDeep(api.data);
11403
11429
  try{
11404
11430
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
11405
- const listViewId = api.data.listViewId;
11406
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
11431
+ const listName = api.data.listName;
11432
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
11407
11433
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
11408
11434
  if(localListViewProps){
11409
11435
  localListViewProps = JSON.parse(localListViewProps);
@@ -11603,8 +11629,8 @@ async function getTableApi(mainObject, fields, options){
11603
11629
 
11604
11630
  try{
11605
11631
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
11606
- const listViewId = api.body.listViewId;
11607
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
11632
+ const listName = api.body.listName;
11633
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
11608
11634
  /**
11609
11635
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。
11610
11636
  * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
@@ -13573,7 +13599,7 @@ async function getRelatedListSchema(
13573
13599
  * @Author: baozhoutao@steedos.com
13574
13600
  * @Date: 2022-07-05 15:55:39
13575
13601
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
13576
- * @LastEditTime: 2023-08-01 14:50:23
13602
+ * @LastEditTime: 2023-08-04 12:27:48
13577
13603
  * @Description:
13578
13604
  */
13579
13605
 
@@ -13838,7 +13864,7 @@ async function getListSchema(
13838
13864
  * 本次存储代码段
13839
13865
  */
13840
13866
  try {
13841
- const listViewPropsStoreKey = location.pathname + "/crud/" + (ctx.listViewId || "");
13867
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewName || "");
13842
13868
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
13843
13869
  /**
13844
13870
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。
@@ -19279,14 +19305,16 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
19279
19305
  /*
19280
19306
  * @Author: baozhoutao@steedos.com
19281
19307
  * @Date: 2023-01-14 16:41:24
19282
- * @LastEditors: baozhoutao@steedos.com
19283
- * @LastEditTime: 2023-07-31 10:22:56
19308
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
19309
+ * @LastEditTime: 2023-08-03 13:32:08
19284
19310
  * @Description:
19285
19311
  */
19286
19312
  var getSelectFlowSchema = function (id, props) {
19287
19313
  var label = props.label, data = props.data, name = props.name, required = props.required, _a = props.action, action = _a === void 0 ? "query" : _a, _b = props.distributeInstanceId, distributeInstanceId = _b === void 0 ? "" : _b, _c = props.distributeStepId, distributeStepId = _c === void 0 ? "" : _c, _d = props.mode, mode = _d === void 0 ? "input-tree" : _d, className = props.className, onEvent = props.onEvent, _e = props.multiple, multiple = _e === void 0 ? false : _e, delimiter = props.delimiter, joinValues = props.joinValues, extractValue = props.extractValue, searchable = props.searchable, _f = props.showIcon, showIcon = _f === void 0 ? true : _f, _g = props.showRadio, showRadio = _g === void 0 ? false : _g, showOutline = props.showOutline, initiallyOpen = props.initiallyOpen, unfoldedLevel = props.unfoldedLevel, treeContainerClassName = props.treeContainerClassName, _h = props.amis, amis = _h === void 0 ? {} : _h;
19288
19314
  // console.log(`=====onEvent`, onEvent)
19289
- return __assign$2({ type: mode, id: id, label: label, name: name, options: [], multiple: multiple, delimiter: delimiter, joinValues: joinValues, extractValue: extractValue, searchable: searchable, showOutline: showOutline, initiallyOpen: initiallyOpen, unfoldedLevel: unfoldedLevel, className: "overflow-y-auto " + className, required: required, treeContainerClassName: treeContainerClassName, heightAuto: true, menuTpl: mode === 'input-tree' ? {
19315
+ return __assign$2({ type: mode, id: id, label: label, name: name, options: [], multiple: multiple, delimiter: delimiter, joinValues: joinValues, extractValue: extractValue, searchable: searchable, showOutline: showOutline, initiallyOpen: initiallyOpen, unfoldedLevel: unfoldedLevel,
19316
+ // className: `overflow-y-auto ` + className,
19317
+ className: className, required: required, treeContainerClassName: treeContainerClassName, heightAuto: true, menuTpl: mode === 'input-tree' ? {
19290
19318
  type: "tpl",
19291
19319
  tpl: "<div class='flex'><span>${label}</span><span class='rounded p-1 text-xs text-center w-14 ${value == 'startFlows' ? '' : 'hidden'}'><button class='antd-Button antd-Button--link m-none p-none'>设置</button></span></div>",
19292
19320
  onEvent: {