@steedos-widgets/amis-lib 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.
package/dist/index.umd.js CHANGED
@@ -423,8 +423,8 @@
423
423
  /*
424
424
  * @Author: baozhoutao@steedos.com
425
425
  * @Date: 2022-05-23 09:53:08
426
- * @LastEditors: liaodaxue
427
- * @LastEditTime: 2023-07-28 16:26:31
426
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
427
+ * @LastEditTime: 2023-08-03 18:07:54
428
428
  * @Description:
429
429
  */
430
430
 
@@ -506,7 +506,11 @@
506
506
 
507
507
  function getNameTpl(field, ctx){
508
508
  const href = getNameTplUrl(field, ctx);
509
- return `<a href="${href}">\${${field.name}}</a>`
509
+ let linkTarget = "";
510
+ if(ctx && ctx.isLookup){
511
+ linkTarget = "target='_blank'";
512
+ }
513
+ return `<a href="${href}" ${linkTarget}>\${${field.name}}</a>`
510
514
  }
511
515
 
512
516
  function getRelatedFieldTpl(field, ctx){
@@ -519,6 +523,11 @@
519
523
  }
520
524
  }
521
525
 
526
+ let linkTarget = "";
527
+ if(ctx && ctx.isLookup){
528
+ linkTarget = "target='_blank'";
529
+ }
530
+
522
531
  const onlyDisplayLabel = ctx.onlyDisplayLabel;
523
532
 
524
533
  let fieldDataStrTpl = `data._display.${field.name}`;
@@ -534,7 +543,7 @@
534
543
  const href = Router.getObjectDetailPath({
535
544
  formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
536
545
  });
537
- labelTpl = `<a href="${href}"><%=item.label%></a>`;
546
+ labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
538
547
  }
539
548
  tpl = `
540
549
  <% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item,index) { %> <% if(index>0 && index<${fieldDataStrTpl}.length){ %> , <% } %> ${labelTpl} <% }); %><% } %>
@@ -552,7 +561,7 @@
552
561
  const href = Router.getObjectDetailPath({
553
562
  formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
554
563
  });
555
- labelTpl = `<a href="${href}">${labelTpl}</a>`;
564
+ labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
556
565
  }
557
566
  tpl = labelTpl;
558
567
  }
@@ -564,7 +573,7 @@
564
573
  const href = Router.getObjectDetailPath({
565
574
  formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
566
575
  });
567
- labelTpl = `<a href="${href}"><%=item.label%></a>`;
576
+ labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
568
577
  }
569
578
  tpl = `
570
579
  <% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item) { %> ${labelTpl} <% }); %><% } %>
@@ -700,7 +709,7 @@
700
709
  if(displayFields.length > 0){
701
710
  return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
702
711
  }
703
- return `${fieldsName.join(' ')},${expandFieldsQuery}`
712
+ return _$1.trimEnd(`${fieldsName.join(' ')},${expandFieldsQuery}`, ",")
704
713
  }
705
714
 
706
715
  function getRecordPermissionsTemplate(){
@@ -3275,12 +3284,6 @@
3275
3284
  if (
3276
3285
  field && window.isFieldTypeSearchable(field.type)
3277
3286
  ) {
3278
- delete field.defaultValue;
3279
- delete field.required;
3280
- delete field.is_wide;
3281
- delete field.readonly;
3282
- delete field.hidden;
3283
- delete field.omit;
3284
3287
  var ctx = ${JSON.stringify(ctx)};
3285
3288
  const amisField = window.getFieldSearchable(field, fields, ctx);
3286
3289
  return amisField;
@@ -3375,8 +3378,8 @@
3375
3378
  }
3376
3379
  if(!event.data.isLookup){
3377
3380
  // 刷新浏览器后,filterFormValues值是空的,只能从本地存储中取出并重置为空值
3378
- const listViewId = event.data.listViewId;
3379
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
3381
+ const listName = event.data.listName;
3382
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
3380
3383
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
3381
3384
  if(localListViewProps){
3382
3385
  localListViewProps = JSON.parse(localListViewProps);
@@ -3402,13 +3405,13 @@
3402
3405
  const dataProviderInited = `
3403
3406
  const objectName = data.objectName;
3404
3407
  const isLookup = data.isLookup;
3405
- const listViewId = data.listViewId;
3408
+ const listName = data.listName;
3406
3409
  let searchableFieldsStoreKey = location.pathname + "/searchable_fields/";
3407
3410
  if(isLookup){
3408
3411
  searchableFieldsStoreKey += "lookup/" + objectName;
3409
3412
  }
3410
3413
  else{
3411
- searchableFieldsStoreKey += (listViewId || "");
3414
+ searchableFieldsStoreKey += (listName || "");
3412
3415
  }
3413
3416
  let defaultSearchableFields = sessionStorage.getItem(searchableFieldsStoreKey);
3414
3417
  if(defaultSearchableFields){
@@ -3435,9 +3438,7 @@
3435
3438
  setData({ showFieldsFilter: false });
3436
3439
  }
3437
3440
  else{
3438
- console.log("===listViewPropsStoreKey=data==", data);
3439
- const listViewPropsStoreKey = location.pathname + "/crud/" + (data.listViewId || "");
3440
- console.log("===listViewPropsStoreKey=122==", listViewPropsStoreKey);
3441
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
3441
3442
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
3442
3443
  if(localListViewProps){
3443
3444
  localListViewProps = JSON.parse(localListViewProps);
@@ -3467,7 +3468,6 @@
3467
3468
  const listName = data.listName;
3468
3469
  const objectName = data.objectName;
3469
3470
  const isLookup = data.isLookup;
3470
- const listViewId = data.listViewId;
3471
3471
  const value = data.fields;
3472
3472
  const scope = event.context.scoped;
3473
3473
  // 这里的filterForm不是name为"listview-filter-form"的内部form,而是crud自带的filter form
@@ -3483,7 +3483,7 @@
3483
3483
  searchableFieldsStoreKey += "lookup/" + objectName;
3484
3484
  }
3485
3485
  else{
3486
- searchableFieldsStoreKey += (listViewId || "");
3486
+ searchableFieldsStoreKey += (listName || "");
3487
3487
  }
3488
3488
  sessionStorage.setItem(searchableFieldsStoreKey, value);
3489
3489
 
@@ -3541,7 +3541,7 @@
3541
3541
  }
3542
3542
 
3543
3543
  // 列表视图crud支持本地缓存,所以需要进一步清除浏览器本地缓存里面用户在可搜索项中移除的字段值
3544
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
3544
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
3545
3545
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
3546
3546
  if(localListViewProps){
3547
3547
  localListViewProps = JSON.parse(localListViewProps);
@@ -5760,6 +5760,10 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5760
5760
  return ;
5761
5761
  }
5762
5762
  const refObjectConfig = await getUISchema(referenceTo.objectName);
5763
+
5764
+ ctx.idFieldName = refObjectConfig.idFieldName;
5765
+ ctx.objectName = refObjectConfig.name;
5766
+
5763
5767
  const tableFields = [];
5764
5768
  let i = 0;
5765
5769
  const searchableFields = [];
@@ -6127,7 +6131,6 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
6127
6131
  if(readonly){
6128
6132
  data.tpl = await getLookupTpl(field, ctx);
6129
6133
  }
6130
-
6131
6134
  return data;
6132
6135
  }
6133
6136
 
@@ -7457,6 +7460,24 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7457
7460
  _field.multiple = true;
7458
7461
  _field.is_wide = false;
7459
7462
  _field.defaultValue = undefined;
7463
+ _field.required = false;
7464
+ _field.hidden = false;
7465
+ _field.omit = false;
7466
+
7467
+ if(_field.amis){
7468
+ delete _field.amis.static;
7469
+ delete _field.amis.staticOn;
7470
+ delete _field.amis.disabled;
7471
+ delete _field.amis.disabledOn;
7472
+ delete _field.amis.required;
7473
+ delete _field.amis.requiredOn;
7474
+ delete _field.amis.visible;
7475
+ delete _field.amis.visibleOn;
7476
+ delete _field.amis.hidden;
7477
+ delete _field.amis.hiddenOn;
7478
+ delete _field.amis.autoFill;
7479
+ }
7480
+
7460
7481
  const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
7461
7482
  if(amisField){
7462
7483
  return amisField;
@@ -7734,6 +7755,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7734
7755
  if(field.wrap != true){
7735
7756
  className += " whitespace-nowrap";
7736
7757
  }
7758
+ let columnItem;
7737
7759
  if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
7738
7760
  const previewFileScript = `
7739
7761
  var data = event.data;
@@ -7741,12 +7763,11 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7741
7763
  var file_id = data._id;
7742
7764
  SteedosUI.previewFile && SteedosUI.previewFile({file_name, file_id});
7743
7765
  `;
7744
- columns.push({
7766
+ columnItem = {
7745
7767
  "type": "button",
7746
7768
  "label": `<%=data.versions ? data.name : "${field.label}"%>`,
7747
7769
  className,
7748
7770
  "level": "link",
7749
- "quickEdit": quickEditSchema,
7750
7771
  "onEvent": {
7751
7772
  "click": {
7752
7773
  "actions": [
@@ -7772,9 +7793,9 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7772
7793
  ]
7773
7794
  }
7774
7795
  }
7775
- });
7796
+ };
7776
7797
  }else if(field.type === 'toggle'){
7777
- columns.push(Object.assign({}, {
7798
+ columnItem = Object.assign({}, {
7778
7799
  type: "switch",
7779
7800
  name: field.name,
7780
7801
  label: field.label,
@@ -7782,24 +7803,22 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7782
7803
  toggled: field.toggled,
7783
7804
  static: true,
7784
7805
  className,
7785
- quickEdit: quickEditSchema
7786
- }, field.amis, {name: field.name}));
7806
+ }, field.amis, {name: field.name});
7787
7807
  }else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
7788
- columns.push(Object.assign({}, {
7808
+ columnItem = Object.assign({}, {
7789
7809
  type: "switch",
7790
7810
  name: field.name,
7791
7811
  label: field.label,
7792
7812
  width: getFieldWidth(field.width),
7793
7813
  toggled: field.toggled,
7794
- quickEdit: quickEditSchema,
7795
7814
  static: true,
7796
7815
  className,
7797
7816
  ...getAmisFileReadonlySchema(field)
7798
- }, field.amis, {name: field.name}));
7817
+ }, field.amis, {name: field.name});
7799
7818
  }
7800
7819
  else if(field.type === 'select'){
7801
7820
  const map = getSelectMap(field.options);
7802
- columns.push(Object.assign({}, {
7821
+ columnItem = Object.assign({}, {
7803
7822
  type: "mapping",
7804
7823
  name: field.name,
7805
7824
  label: field.label,
@@ -7809,8 +7828,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7809
7828
  toggled: field.toggled,
7810
7829
  className,
7811
7830
  static: true,
7812
- quickEdit: quickEditSchema
7813
- }, field.amis, {name: field.name}));
7831
+ }, field.amis, {name: field.name});
7814
7832
  }
7815
7833
  else {
7816
7834
  const tpl = await getFieldTpl(field, options);
@@ -7830,7 +7848,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7830
7848
  className += 'min-w-56';
7831
7849
  }
7832
7850
  if(!field.hidden && !field.extra){
7833
- columns.push(Object.assign({}, {
7851
+ columnItem = Object.assign({}, {
7834
7852
  name: field.name,
7835
7853
  label: field.label,
7836
7854
  sortable: field.sortable,
@@ -7841,13 +7859,18 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7841
7859
  toggled: field.toggled,
7842
7860
  className,
7843
7861
  static: true,
7844
- quickEdit: quickEditSchema,
7845
7862
  options: field.type === 'html' ? {html: true} : null
7846
7863
  // toggled: true
7847
- }, field.amis, {name: field.name}));
7864
+ }, field.amis, {name: field.name});
7848
7865
  }
7849
7866
  }
7850
-
7867
+ if(columnItem){
7868
+ if(quickEditSchema){
7869
+ columnItem.quickEdit = quickEditSchema;
7870
+ columnItem.quickEditEnabledOn = "${is_system !== true}";
7871
+ }
7872
+ columns.push(columnItem);
7873
+ }
7851
7874
  }
7852
7875
  // columns.push(getOperation(fields));
7853
7876
  if(!___namespace.some(columns, { name: options.labelFieldName })){
@@ -8153,6 +8176,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
8153
8176
  }
8154
8177
 
8155
8178
  async function getTableSchema$1(fields, options){
8179
+ let isLookup = options && options.isLookup;
8156
8180
  if(!options){
8157
8181
  options = {};
8158
8182
  }
@@ -8162,7 +8186,9 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
8162
8186
  }
8163
8187
  else {
8164
8188
  columns = await getTableColumns(fields, options);
8165
- columns.push(await getTableOperation(options));
8189
+ if(!isLookup){
8190
+ columns.push(await getTableOperation(options));
8191
+ }
8166
8192
  }
8167
8193
  return {
8168
8194
  mode: "table",
@@ -8257,8 +8283,8 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
8257
8283
  const data = _.cloneDeep(api.data);
8258
8284
  try{
8259
8285
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
8260
- const listViewId = api.data.listViewId;
8261
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
8286
+ const listName = api.data.listName;
8287
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
8262
8288
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
8263
8289
  if(localListViewProps){
8264
8290
  localListViewProps = JSON.parse(localListViewProps);
@@ -8458,8 +8484,8 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
8458
8484
 
8459
8485
  try{
8460
8486
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
8461
- const listViewId = api.body.listViewId;
8462
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
8487
+ const listName = api.body.listName;
8488
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
8463
8489
  /**
8464
8490
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。
8465
8491
  * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
@@ -10428,7 +10454,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
10428
10454
  * @Author: baozhoutao@steedos.com
10429
10455
  * @Date: 2022-07-05 15:55:39
10430
10456
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
10431
- * @LastEditTime: 2023-08-01 14:50:23
10457
+ * @LastEditTime: 2023-08-04 12:27:48
10432
10458
  * @Description:
10433
10459
  */
10434
10460
 
@@ -10693,7 +10719,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
10693
10719
  * 本次存储代码段
10694
10720
  */
10695
10721
  try {
10696
- const listViewPropsStoreKey = location.pathname + "/crud/" + (ctx.listViewId || "");
10722
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewName || "");
10697
10723
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
10698
10724
  /**
10699
10725
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。