@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.
@@ -1,6 +1,6 @@
1
1
  import React, { createContext, useState, useEffect, createElement } from 'react';
2
2
  import * as ___default from 'lodash';
3
- import ___default__default, { isEmpty, isArray, each, find, endsWith, cloneDeep, includes, toArray, mergeWith, isString, union, has, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, map, filter, get as get$1, isBoolean, omitBy, isNil, forEach, startsWith, isFunction, compact, difference, keys, pick, first, values, pickBy, random, assign, isNumber } from 'lodash';
3
+ import ___default__default, { isEmpty, isArray, each, find, endsWith, cloneDeep, includes, toArray, mergeWith, isString, union, has, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, map, filter, get as get$1, isBoolean, omitBy, isNil, forEach, trimEnd, startsWith, isFunction, compact, difference, keys, pick, first, values, pickBy, random, assign, isNumber } from 'lodash';
4
4
  import { Dropdown, Tabs, Spin, Badge, Skeleton, Modal as Modal$1, message, notification, Button, Space, Drawer as Drawer$1 } from 'antd';
5
5
  import ReactDOM, { createRoot } from 'react-dom';
6
6
 
@@ -3540,8 +3540,8 @@ function getContrastColor(bgColor) {
3540
3540
  /*
3541
3541
  * @Author: baozhoutao@steedos.com
3542
3542
  * @Date: 2022-05-23 09:53:08
3543
- * @LastEditors: liaodaxue
3544
- * @LastEditTime: 2023-07-28 16:26:31
3543
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
3544
+ * @LastEditTime: 2023-08-03 18:07:54
3545
3545
  * @Description:
3546
3546
  */
3547
3547
 
@@ -3623,7 +3623,11 @@ function getNameTplUrl(field, ctx){
3623
3623
 
3624
3624
  function getNameTpl(field, ctx){
3625
3625
  const href = getNameTplUrl(field, ctx);
3626
- return `<a href="${href}">\${${field.name}}</a>`
3626
+ let linkTarget = "";
3627
+ if(ctx && ctx.isLookup){
3628
+ linkTarget = "target='_blank'";
3629
+ }
3630
+ return `<a href="${href}" ${linkTarget}>\${${field.name}}</a>`
3627
3631
  }
3628
3632
 
3629
3633
  function getRelatedFieldTpl(field, ctx){
@@ -3636,6 +3640,11 @@ function getRelatedFieldTpl(field, ctx){
3636
3640
  }
3637
3641
  }
3638
3642
 
3643
+ let linkTarget = "";
3644
+ if(ctx && ctx.isLookup){
3645
+ linkTarget = "target='_blank'";
3646
+ }
3647
+
3639
3648
  const onlyDisplayLabel = ctx.onlyDisplayLabel;
3640
3649
 
3641
3650
  let fieldDataStrTpl = `data._display.${field.name}`;
@@ -3651,7 +3660,7 @@ function getRelatedFieldTpl(field, ctx){
3651
3660
  const href = Router$1.getObjectDetailPath({
3652
3661
  formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
3653
3662
  });
3654
- labelTpl = `<a href="${href}"><%=item.label%></a>`;
3663
+ labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
3655
3664
  }
3656
3665
  tpl = `
3657
3666
  <% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item,index) { %> <% if(index>0 && index<${fieldDataStrTpl}.length){ %> , <% } %> ${labelTpl} <% }); %><% } %>
@@ -3669,7 +3678,7 @@ function getRelatedFieldTpl(field, ctx){
3669
3678
  const href = Router$1.getObjectDetailPath({
3670
3679
  formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
3671
3680
  });
3672
- labelTpl = `<a href="${href}">${labelTpl}</a>`;
3681
+ labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
3673
3682
  }
3674
3683
  tpl = labelTpl;
3675
3684
  }
@@ -3681,7 +3690,7 @@ function getRelatedFieldTpl(field, ctx){
3681
3690
  const href = Router$1.getObjectDetailPath({
3682
3691
  formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
3683
3692
  });
3684
- labelTpl = `<a href="${href}"><%=item.label%></a>`;
3693
+ labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
3685
3694
  }
3686
3695
  tpl = `
3687
3696
  <% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item) { %> ${labelTpl} <% }); %><% } %>
@@ -3817,7 +3826,7 @@ async function getFieldsTemplate(fields, display){
3817
3826
  if(displayFields.length > 0){
3818
3827
  return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
3819
3828
  }
3820
- return `${fieldsName.join(' ')},${expandFieldsQuery}`
3829
+ return trimEnd(`${fieldsName.join(' ')},${expandFieldsQuery}`, ",")
3821
3830
  }
3822
3831
 
3823
3832
  function getRecordPermissionsTemplate(){
@@ -6392,12 +6401,6 @@ async function getObjectFieldsFilterFormSchema(ctx) {
6392
6401
  if (
6393
6402
  field && window.isFieldTypeSearchable(field.type)
6394
6403
  ) {
6395
- delete field.defaultValue;
6396
- delete field.required;
6397
- delete field.is_wide;
6398
- delete field.readonly;
6399
- delete field.hidden;
6400
- delete field.omit;
6401
6404
  var ctx = ${JSON.stringify(ctx)};
6402
6405
  const amisField = window.getFieldSearchable(field, fields, ctx);
6403
6406
  return amisField;
@@ -6492,8 +6495,8 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6492
6495
  }
6493
6496
  if(!event.data.isLookup){
6494
6497
  // 刷新浏览器后,filterFormValues值是空的,只能从本地存储中取出并重置为空值
6495
- const listViewId = event.data.listViewId;
6496
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
6498
+ const listName = event.data.listName;
6499
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
6497
6500
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
6498
6501
  if(localListViewProps){
6499
6502
  localListViewProps = JSON.parse(localListViewProps);
@@ -6519,13 +6522,13 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6519
6522
  const dataProviderInited = `
6520
6523
  const objectName = data.objectName;
6521
6524
  const isLookup = data.isLookup;
6522
- const listViewId = data.listViewId;
6525
+ const listName = data.listName;
6523
6526
  let searchableFieldsStoreKey = location.pathname + "/searchable_fields/";
6524
6527
  if(isLookup){
6525
6528
  searchableFieldsStoreKey += "lookup/" + objectName;
6526
6529
  }
6527
6530
  else{
6528
- searchableFieldsStoreKey += (listViewId || "");
6531
+ searchableFieldsStoreKey += (listName || "");
6529
6532
  }
6530
6533
  let defaultSearchableFields = sessionStorage.getItem(searchableFieldsStoreKey);
6531
6534
  if(defaultSearchableFields){
@@ -6552,9 +6555,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6552
6555
  setData({ showFieldsFilter: false });
6553
6556
  }
6554
6557
  else{
6555
- console.log("===listViewPropsStoreKey=data==", data);
6556
- const listViewPropsStoreKey = location.pathname + "/crud/" + (data.listViewId || "");
6557
- console.log("===listViewPropsStoreKey=122==", listViewPropsStoreKey);
6558
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
6558
6559
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
6559
6560
  if(localListViewProps){
6560
6561
  localListViewProps = JSON.parse(localListViewProps);
@@ -6584,7 +6585,6 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6584
6585
  const listName = data.listName;
6585
6586
  const objectName = data.objectName;
6586
6587
  const isLookup = data.isLookup;
6587
- const listViewId = data.listViewId;
6588
6588
  const value = data.fields;
6589
6589
  const scope = event.context.scoped;
6590
6590
  // 这里的filterForm不是name为"listview-filter-form"的内部form,而是crud自带的filter form
@@ -6600,7 +6600,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6600
6600
  searchableFieldsStoreKey += "lookup/" + objectName;
6601
6601
  }
6602
6602
  else{
6603
- searchableFieldsStoreKey += (listViewId || "");
6603
+ searchableFieldsStoreKey += (listName || "");
6604
6604
  }
6605
6605
  sessionStorage.setItem(searchableFieldsStoreKey, value);
6606
6606
 
@@ -6658,7 +6658,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6658
6658
  }
6659
6659
 
6660
6660
  // 列表视图crud支持本地缓存,所以需要进一步清除浏览器本地缓存里面用户在可搜索项中移除的字段值
6661
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
6661
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
6662
6662
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
6663
6663
  if(localListViewProps){
6664
6664
  localListViewProps = JSON.parse(localListViewProps);
@@ -8877,6 +8877,10 @@ async function lookupToAmisPicker(field, readonly, ctx){
8877
8877
  return ;
8878
8878
  }
8879
8879
  const refObjectConfig = await getUISchema(referenceTo.objectName);
8880
+
8881
+ ctx.idFieldName = refObjectConfig.idFieldName;
8882
+ ctx.objectName = refObjectConfig.name;
8883
+
8880
8884
  const tableFields = [];
8881
8885
  let i = 0;
8882
8886
  const searchableFields = [];
@@ -9244,7 +9248,6 @@ async function lookupToAmisPicker(field, readonly, ctx){
9244
9248
  if(readonly){
9245
9249
  data.tpl = await getLookupTpl(field, ctx);
9246
9250
  }
9247
-
9248
9251
  return data;
9249
9252
  }
9250
9253
 
@@ -10574,6 +10577,24 @@ async function getFieldSearchable(perField, permissionFields, ctx){
10574
10577
  _field.multiple = true;
10575
10578
  _field.is_wide = false;
10576
10579
  _field.defaultValue = undefined;
10580
+ _field.required = false;
10581
+ _field.hidden = false;
10582
+ _field.omit = false;
10583
+
10584
+ if(_field.amis){
10585
+ delete _field.amis.static;
10586
+ delete _field.amis.staticOn;
10587
+ delete _field.amis.disabled;
10588
+ delete _field.amis.disabledOn;
10589
+ delete _field.amis.required;
10590
+ delete _field.amis.requiredOn;
10591
+ delete _field.amis.visible;
10592
+ delete _field.amis.visibleOn;
10593
+ delete _field.amis.hidden;
10594
+ delete _field.amis.hiddenOn;
10595
+ delete _field.amis.autoFill;
10596
+ }
10597
+
10577
10598
  const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
10578
10599
  if(amisField){
10579
10600
  return amisField;
@@ -10851,6 +10872,7 @@ async function getTableColumns$1(fields, options){
10851
10872
  if(field.wrap != true){
10852
10873
  className += " whitespace-nowrap";
10853
10874
  }
10875
+ let columnItem;
10854
10876
  if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
10855
10877
  const previewFileScript = `
10856
10878
  var data = event.data;
@@ -10858,12 +10880,11 @@ async function getTableColumns$1(fields, options){
10858
10880
  var file_id = data._id;
10859
10881
  SteedosUI.previewFile && SteedosUI.previewFile({file_name, file_id});
10860
10882
  `;
10861
- columns.push({
10883
+ columnItem = {
10862
10884
  "type": "button",
10863
10885
  "label": `<%=data.versions ? data.name : "${field.label}"%>`,
10864
10886
  className,
10865
10887
  "level": "link",
10866
- "quickEdit": quickEditSchema,
10867
10888
  "onEvent": {
10868
10889
  "click": {
10869
10890
  "actions": [
@@ -10889,9 +10910,9 @@ async function getTableColumns$1(fields, options){
10889
10910
  ]
10890
10911
  }
10891
10912
  }
10892
- });
10913
+ };
10893
10914
  }else if(field.type === 'toggle'){
10894
- columns.push(Object.assign({}, {
10915
+ columnItem = Object.assign({}, {
10895
10916
  type: "switch",
10896
10917
  name: field.name,
10897
10918
  label: field.label,
@@ -10899,24 +10920,22 @@ async function getTableColumns$1(fields, options){
10899
10920
  toggled: field.toggled,
10900
10921
  static: true,
10901
10922
  className,
10902
- quickEdit: quickEditSchema
10903
- }, field.amis, {name: field.name}));
10923
+ }, field.amis, {name: field.name});
10904
10924
  }else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
10905
- columns.push(Object.assign({}, {
10925
+ columnItem = Object.assign({}, {
10906
10926
  type: "switch",
10907
10927
  name: field.name,
10908
10928
  label: field.label,
10909
10929
  width: getFieldWidth(field.width),
10910
10930
  toggled: field.toggled,
10911
- quickEdit: quickEditSchema,
10912
10931
  static: true,
10913
10932
  className,
10914
10933
  ...getAmisFileReadonlySchema(field)
10915
- }, field.amis, {name: field.name}));
10934
+ }, field.amis, {name: field.name});
10916
10935
  }
10917
10936
  else if(field.type === 'select'){
10918
10937
  const map = getSelectMap(field.options);
10919
- columns.push(Object.assign({}, {
10938
+ columnItem = Object.assign({}, {
10920
10939
  type: "mapping",
10921
10940
  name: field.name,
10922
10941
  label: field.label,
@@ -10926,8 +10945,7 @@ async function getTableColumns$1(fields, options){
10926
10945
  toggled: field.toggled,
10927
10946
  className,
10928
10947
  static: true,
10929
- quickEdit: quickEditSchema
10930
- }, field.amis, {name: field.name}));
10948
+ }, field.amis, {name: field.name});
10931
10949
  }
10932
10950
  else {
10933
10951
  const tpl = await getFieldTpl(field, options);
@@ -10947,7 +10965,7 @@ async function getTableColumns$1(fields, options){
10947
10965
  className += 'min-w-56';
10948
10966
  }
10949
10967
  if(!field.hidden && !field.extra){
10950
- columns.push(Object.assign({}, {
10968
+ columnItem = Object.assign({}, {
10951
10969
  name: field.name,
10952
10970
  label: field.label,
10953
10971
  sortable: field.sortable,
@@ -10958,13 +10976,18 @@ async function getTableColumns$1(fields, options){
10958
10976
  toggled: field.toggled,
10959
10977
  className,
10960
10978
  static: true,
10961
- quickEdit: quickEditSchema,
10962
10979
  options: field.type === 'html' ? {html: true} : null
10963
10980
  // toggled: true
10964
- }, field.amis, {name: field.name}));
10981
+ }, field.amis, {name: field.name});
10965
10982
  }
10966
10983
  }
10967
-
10984
+ if(columnItem){
10985
+ if(quickEditSchema){
10986
+ columnItem.quickEdit = quickEditSchema;
10987
+ columnItem.quickEditEnabledOn = "${is_system !== true}";
10988
+ }
10989
+ columns.push(columnItem);
10990
+ }
10968
10991
  }
10969
10992
  // columns.push(getOperation(fields));
10970
10993
  if(!___default.some(columns, { name: options.labelFieldName })){
@@ -11270,6 +11293,7 @@ async function getTableOperation(ctx){
11270
11293
  }
11271
11294
 
11272
11295
  async function getTableSchema$1(fields, options){
11296
+ let isLookup = options && options.isLookup;
11273
11297
  if(!options){
11274
11298
  options = {};
11275
11299
  }
@@ -11279,7 +11303,9 @@ async function getTableSchema$1(fields, options){
11279
11303
  }
11280
11304
  else {
11281
11305
  columns = await getTableColumns$1(fields, options);
11282
- columns.push(await getTableOperation(options));
11306
+ if(!isLookup){
11307
+ columns.push(await getTableOperation(options));
11308
+ }
11283
11309
  }
11284
11310
  return {
11285
11311
  mode: "table",
@@ -11374,8 +11400,8 @@ async function getTableApi(mainObject, fields, options){
11374
11400
  const data = _.cloneDeep(api.data);
11375
11401
  try{
11376
11402
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
11377
- const listViewId = api.data.listViewId;
11378
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
11403
+ const listName = api.data.listName;
11404
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
11379
11405
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
11380
11406
  if(localListViewProps){
11381
11407
  localListViewProps = JSON.parse(localListViewProps);
@@ -11575,8 +11601,8 @@ async function getTableApi(mainObject, fields, options){
11575
11601
 
11576
11602
  try{
11577
11603
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
11578
- const listViewId = api.body.listViewId;
11579
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
11604
+ const listName = api.body.listName;
11605
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
11580
11606
  /**
11581
11607
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。
11582
11608
  * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
@@ -13545,7 +13571,7 @@ async function getRelatedListSchema(
13545
13571
  * @Author: baozhoutao@steedos.com
13546
13572
  * @Date: 2022-07-05 15:55:39
13547
13573
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
13548
- * @LastEditTime: 2023-08-01 14:50:23
13574
+ * @LastEditTime: 2023-08-04 12:27:48
13549
13575
  * @Description:
13550
13576
  */
13551
13577
 
@@ -13810,7 +13836,7 @@ async function getListSchema(
13810
13836
  * 本次存储代码段
13811
13837
  */
13812
13838
  try {
13813
- const listViewPropsStoreKey = location.pathname + "/crud/" + (ctx.listViewId || "");
13839
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewName || "");
13814
13840
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
13815
13841
  /**
13816
13842
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。
@@ -19251,14 +19277,16 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
19251
19277
  /*
19252
19278
  * @Author: baozhoutao@steedos.com
19253
19279
  * @Date: 2023-01-14 16:41:24
19254
- * @LastEditors: baozhoutao@steedos.com
19255
- * @LastEditTime: 2023-07-31 10:22:56
19280
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
19281
+ * @LastEditTime: 2023-08-03 13:32:08
19256
19282
  * @Description:
19257
19283
  */
19258
19284
  var getSelectFlowSchema = function (id, props) {
19259
19285
  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;
19260
19286
  // console.log(`=====onEvent`, onEvent)
19261
- 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' ? {
19287
+ 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,
19288
+ // className: `overflow-y-auto ` + className,
19289
+ className: className, required: required, treeContainerClassName: treeContainerClassName, heightAuto: true, menuTpl: mode === 'input-tree' ? {
19262
19290
  type: "tpl",
19263
19291
  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>",
19264
19292
  onEvent: {