@steedos-widgets/amis-object 1.2.0-beta.1 → 1.2.0

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.
@@ -304,8 +304,8 @@ body {
304
304
  .top-0 {
305
305
  top: 0px
306
306
  }
307
- .z-50 {
308
- z-index: 50
307
+ .z-10 {
308
+ z-index: 10
309
309
  }
310
310
  .col-span-2 {
311
311
  grid-column: span 2 / span 2
@@ -719,7 +719,7 @@
719
719
  * @Author: baozhoutao@steedos.com
720
720
  * @Date: 2022-08-16 17:02:08
721
721
  * @LastEditors: baozhoutao@steedos.com
722
- * @LastEditTime: 2023-03-03 14:52:18
722
+ * @LastEditTime: 2023-04-11 09:57:37
723
723
  * @Description:
724
724
  */
725
725
 
@@ -746,10 +746,11 @@
746
746
  },
747
747
  getObjectDetailPath(props){
748
748
  const {formFactor, appId, objectName, recordId, listViewName, _templateType} = props;
749
+ // var urlParams = new URLSearchParams(window.location.search);
749
750
  // if(objectName === 'instances'){
750
751
  // return `/workflow/space/\${context.tenantId}/\${listName}/${recordId}`;
751
752
  // }
752
- const displayAs = Router$1.getTabDisplayAs(objectName);
753
+ const displayAs = Router$1.getTabDisplayAs(objectName); //urlParams.get("display") ||
753
754
  if(_templateType === 'JavaScript'){
754
755
  return `/app/${appId}/${objectName}/view/${recordId}?display=${displayAs}&side_object=<%=item.objectName%>&side_listview_id=<%=item.listName%>`;
755
756
  }
@@ -765,7 +766,7 @@
765
766
  * @Author: baozhoutao@steedos.com
766
767
  * @Date: 2022-05-23 09:53:08
767
768
  * @LastEditors: baozhoutao@steedos.com
768
- * @LastEditTime: 2023-03-09 10:00:44
769
+ * @LastEditTime: 2023-04-10 11:22:54
769
770
  * @Description:
770
771
  */
771
772
 
@@ -960,6 +961,7 @@
960
961
  case 'number':
961
962
  case 'currency':
962
963
  return await getNumberTpl(field);
964
+ case 'percent':
963
965
  case 'formula':
964
966
  case 'summary':
965
967
  return getUiFieldTpl(field)
@@ -992,7 +994,7 @@
992
994
  if(___default.includes(['time','date','datetime','boolean','number','currency'], field.type)){
993
995
  fieldsName.push(`${field.name}`);
994
996
  }
995
- if(___default.includes(['time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
997
+ if(___default.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
996
998
  displayFields.push(`${field.name}`);
997
999
  }
998
1000
  }
@@ -1747,7 +1749,7 @@
1747
1749
  * @Author: baozhoutao@steedos.com
1748
1750
  * @Date: 2022-11-01 15:51:00
1749
1751
  * @LastEditors: Please set LastEditors
1750
- * @LastEditTime: 2023-04-08 12:05:19
1752
+ * @LastEditTime: 2023-04-11 13:58:24
1751
1753
  * @Description:
1752
1754
  */
1753
1755
 
@@ -1771,16 +1773,20 @@
1771
1773
  const relatedKey = _master.relatedKey;
1772
1774
  const masterObjectName = _master.objectName;
1773
1775
  const recordId = _master.recordId;
1776
+ let relatedKeySaveValue = recordId;
1774
1777
  const fields = ${JSON.stringify(uiSchema.fields)};
1775
1778
  const relatedField = fields[relatedKey];
1779
+ if(relatedField.reference_to_field && relatedField.reference_to_field !== '_id'){
1780
+ relatedKeySaveValue = _master.record[relatedField.reference_to_field];
1781
+ }
1776
1782
  let defaultData = {};
1777
1783
  let relatedKeyValue;
1778
1784
  if(!_.isString(relatedField.reference_to)){
1779
- relatedKeyValue = { o: masterObjectName, ids: [recordId] };
1785
+ relatedKeyValue = { o: masterObjectName, ids: [relatedKeySaveValue] };
1780
1786
  }else if (relatedField.multiple) {
1781
- relatedKeyValue = [recordId];
1787
+ relatedKeyValue = [relatedKeySaveValue];
1782
1788
  } else {
1783
- relatedKeyValue = recordId;
1789
+ relatedKeyValue = relatedKeySaveValue;
1784
1790
  }
1785
1791
  defaultData[relatedKey]=relatedKeyValue;
1786
1792
  if(payload.schema){
@@ -1816,7 +1822,6 @@
1816
1822
  "_master": "${_master}",
1817
1823
  "_master._isRelated": "${_isRelated}",
1818
1824
  "_master.relatedKey": "${relatedKey}",
1819
- "defaultData": "${defaultData}",
1820
1825
  "appId": "${appId}",
1821
1826
  "objectName": "${objectName}",
1822
1827
  "context": "${context}",
@@ -1873,7 +1878,7 @@
1873
1878
  * @Author: baozhoutao@steedos.com
1874
1879
  * @Date: 2022-07-13 15:18:03
1875
1880
  * @LastEditors: baozhoutao@steedos.com
1876
- * @LastEditTime: 2022-11-08 09:35:03
1881
+ * @LastEditTime: 2023-04-11 10:34:26
1877
1882
  * @Description:
1878
1883
  */
1879
1884
 
@@ -1881,6 +1886,13 @@
1881
1886
  const api = `/api/pageSchema/${type}?app=${appId}&objectApiName=${objectName}&recordId=${recordId}&pageId=${pageId}&formFactor=${formFactor}`;
1882
1887
  const page = await fetchAPI(api);
1883
1888
  if (page && page.schema) {
1889
+ page.schema = JSON.parse(page.schema);
1890
+ if(page.schema.data){
1891
+ delete page.schema.data.recordId;
1892
+ delete page.schema.data.objectName;
1893
+ delete page.schema.data.context;
1894
+ delete page.schema.data.global;
1895
+ }
1884
1896
  return page;
1885
1897
  }
1886
1898
  }
@@ -7861,8 +7873,8 @@ setTimeout(()=>{
7861
7873
  /*
7862
7874
  * @Author: baozhoutao@steedos.com
7863
7875
  * @Date: 2022-07-05 15:55:39
7864
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
7865
- * @LastEditTime: 2023-04-08 18:14:55
7876
+ * @LastEditors: Please set LastEditors
7877
+ * @LastEditTime: 2023-04-11 13:13:00
7866
7878
  * @Description:
7867
7879
  */
7868
7880
 
@@ -7984,8 +7996,6 @@ setTimeout(()=>{
7984
7996
  }
7985
7997
  }
7986
7998
  }
7987
-
7988
- let relatedValue = "${recordId}";
7989
7999
  // if(refField.reference_to_field && refField.reference_to_field != '_id'){
7990
8000
  // const masterRecord = await getRecord(objectName, recordId, [refField.reference_to_field]);
7991
8001
  // relatedValue = masterRecord[refField.reference_to_field]
@@ -8047,14 +8057,7 @@ setTimeout(()=>{
8047
8057
  _isRelated: true
8048
8058
  },
8049
8059
  body:[
8050
- {
8051
- ...amisSchema,
8052
- data: {
8053
- defaultData: {
8054
- ...{[relatedKey]: getRelatedFieldValue(objectName, relatedValue, relatedObjectUiSchema, relatedKey)}
8055
- }
8056
- }
8057
- }
8060
+ amisSchema
8058
8061
  ]
8059
8062
  }
8060
8063
  };
@@ -8207,7 +8210,7 @@ setTimeout(()=>{
8207
8210
  * @Author: baozhoutao@steedos.com
8208
8211
  * @Date: 2022-07-05 15:55:39
8209
8212
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
8210
- * @LastEditTime: 2023-04-08 17:31:57
8213
+ * @LastEditTime: 2023-04-11 11:28:11
8211
8214
  * @Description:
8212
8215
  */
8213
8216
 
@@ -8656,35 +8659,19 @@ setTimeout(()=>{
8656
8659
  amisSchema: {
8657
8660
  "type": "service",
8658
8661
  "body": [
8659
- {
8660
- "type": "steedos-record-detail-header",
8661
- "label": "标题面板",
8662
- "objectApiName": "${objectName}",
8663
- "recordId": "${recordId}",
8664
- "id": "u:48d2c28eb755",
8665
- onEvent: {
8666
- "recordLoaded": {
8667
- "actions": [
8668
- {
8669
- "actionType": "reload",
8670
- "data": {
8671
- "name": `\${event.data.record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
8672
- "record": `\${event.data.record}`,
8673
- "_id": "\${event.data.record._id}",
8674
- "recordId": "\${event.data.record._id}",
8675
- "recordLoaded": true,
8676
- }
8677
- }
8678
- ]
8679
- }
8662
+ {
8663
+ "type": "steedos-record-detail-header",
8664
+ "label": "标题面板",
8665
+ "objectApiName": "${objectName}",
8666
+ "recordId": "${recordId}",
8667
+ "id": "u:48d2c28eb755"
8680
8668
  },
8681
- },
8682
- content
8669
+ content
8683
8670
  ],
8684
- // data: {
8685
- // "_master.objectName": "${objectName}",
8686
- // "_master.recordId": "${recordId}"
8687
- // },
8671
+ data: {
8672
+ "_master.objectName": "${objectName}",
8673
+ "_master.recordId": "${recordId}"
8674
+ },
8688
8675
  onEvent: {
8689
8676
  "recordLoaded": {
8690
8677
  "actions": [
@@ -8692,10 +8679,10 @@ setTimeout(()=>{
8692
8679
  "actionType": "reload",
8693
8680
  "data": {
8694
8681
  "name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
8695
- // "_master.record": `\${record}`,
8696
- // // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
8697
- // "_master.objectName": "${objectName}",
8698
- // "_master.recordId": "${recordId}"
8682
+ "_master.record": `\${record}`,
8683
+ // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
8684
+ "_master.objectName": "${objectName}",
8685
+ "_master.recordId": "${recordId}"
8699
8686
  }
8700
8687
  }
8701
8688
  ]
@@ -12351,7 +12338,7 @@ setTimeout(()=>{
12351
12338
  return __generator(this, function (_d) {
12352
12339
  switch (_d.label) {
12353
12340
  case 0:
12354
- _a = props.className, className = _a === void 0 ? 'sticky top-0 z-50 bg-gray-100 border-b sm:shadow sm:rounded sm:border border-slate-300 p-4' : _a;
12341
+ _a = props.className, className = _a === void 0 ? 'sticky top-0 z-10 bg-gray-100 border-b sm:shadow sm:rounded sm:border border-slate-300 p-4' : _a;
12355
12342
  return [4 /*yield*/, getUISchema(props.objectApiName || "space_users", false)];
12356
12343
  case 1:
12357
12344
  objectUiSchema = _d.sent();
@@ -12361,17 +12348,11 @@ setTimeout(()=>{
12361
12348
  {
12362
12349
  "actionType": "reload",
12363
12350
  "data": {
12364
- "name": "${record.".concat((objectUiSchema === null || objectUiSchema === void 0 ? void 0 : objectUiSchema.NAME_FIELD_KEY) || 'name', "}"),
12365
- "record": "${record}",
12366
- "recordLoaded": true
12367
- }
12368
- },
12369
- {
12370
- "actionType": "setValue",
12371
- "args": {
12372
- "value": {
12373
- "recordLoaded": true,
12374
- }
12351
+ "name": "${event.data.record.".concat((objectUiSchema === null || objectUiSchema === void 0 ? void 0 : objectUiSchema.NAME_FIELD_KEY) || 'name', "}"),
12352
+ "record": "${event.data.record}",
12353
+ "_id": "\${event.data.record._id}",
12354
+ "recordId": "\${event.data.record._id}",
12355
+ "recordLoaded": true,
12375
12356
  }
12376
12357
  }
12377
12358
  ]
@@ -12392,17 +12373,17 @@ setTimeout(()=>{
12392
12373
  /*
12393
12374
  * @Author: baozhoutao@steedos.com
12394
12375
  * @Date: 2022-12-08 10:32:17
12395
- * @LastEditors: baozhoutao@steedos.com
12396
- * @LastEditTime: 2023-03-22 15:41:38
12376
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12377
+ * @LastEditTime: 2023-04-11 11:28:41
12397
12378
  * @Description:
12398
12379
  */
12399
12380
  var AmisRecordDetail = function (props) { return __awaiter(void 0, void 0, void 0, function () {
12400
- var className, appId, _a, objectApiName, recordId, onEvent, schema, recordDetailData;
12381
+ var className, appId, _a, objectApiName, recordId, body, schema, recordDetailData;
12401
12382
  return __generator(this, function (_b) {
12402
12383
  switch (_b.label) {
12403
12384
  case 0:
12404
- className = props.className, props.$schema, appId = props.appId, _a = props.objectApiName, objectApiName = _a === void 0 ? "space_users" : _a, recordId = props.recordId, onEvent = props.onEvent, props.defaultData;
12405
- return [4 /*yield*/, getRecordDetailSchema(objectApiName, appId, { onEvent: onEvent })];
12385
+ className = props.className, props.$schema, appId = props.appId, _a = props.objectApiName, objectApiName = _a === void 0 ? "space_users" : _a, recordId = props.recordId, props.onEvent, props.defaultData, body = props.body;
12386
+ return [4 /*yield*/, getRecordDetailSchema(objectApiName, appId)];
12406
12387
  case 1:
12407
12388
  schema = (_b.sent()).amisSchema;
12408
12389
  recordDetailData = {};
@@ -12411,6 +12392,9 @@ setTimeout(()=>{
12411
12392
  }
12412
12393
  schema.data = Object.assign({}, schema.data, recordDetailData);
12413
12394
  schema.className = className;
12395
+ if (body) {
12396
+ schema.body = body;
12397
+ }
12414
12398
  return [2 /*return*/, schema];
12415
12399
  }
12416
12400
  });
@@ -12661,8 +12645,6 @@ setTimeout(()=>{
12661
12645
  "items": {
12662
12646
  "type": "button",
12663
12647
  "level": "link",
12664
- "actionType": "link",
12665
- "link": "${path}",
12666
12648
  "body": [{
12667
12649
  "type": "tpl",
12668
12650
  "tpl": "<div class='slds-app-launcher__tile slds-text-link_reset'><div class='slds-app-launcher__tile-figure'><svg class='w-12 h-12 slds-icon slds-icon_container slds-icon-standard-${REPLACE(icon, '_', '-')}' aria-hidden='true'><use xlink:href='/assets/icons/standard-sprite/svg/symbols.svg#${icon}'></use></svg><span class='slds-assistive-text'>${name}</span></div><div class='slds-app-launcher__tile-body'><span class='slds-link text-blue-600 text-lg'><span title='${name}'>${name}</span></span><div style='display: -webkit-box; -webkit-line-clamp: 1;-webkit-box-orient: vertical;overflow: hidden;'><span title='${description}'>${description}</span></div></div></div>",
@@ -12689,6 +12671,21 @@ setTimeout(()=>{
12689
12671
  "actions": [
12690
12672
  {
12691
12673
  "actionType": "closeDialog"
12674
+ },
12675
+ {
12676
+ "actionType": "link",
12677
+ "args": {
12678
+ "link": "${path}"
12679
+ },
12680
+ "expression": "${!blank}"
12681
+ },
12682
+ {
12683
+ "actionType": "url",
12684
+ "args": {
12685
+ "url": "${path}",
12686
+ "blank": true
12687
+ },
12688
+ "expression": "${blank}"
12692
12689
  }
12693
12690
  ]
12694
12691
  }
@@ -13420,7 +13417,7 @@ setTimeout(()=>{
13420
13417
  appId: appId,
13421
13418
  name: objectApiName,
13422
13419
  });
13423
- listSchema = page ? JSON.parse(page.schema) : {
13420
+ listSchema = page ? page.schema : {
13424
13421
  "type": "steedos-object-listview",
13425
13422
  "objectApiName": objectApiName,
13426
13423
  "columnsTogglable": false,
@@ -13474,7 +13471,7 @@ setTimeout(()=>{
13474
13471
  return [4 /*yield*/, getPage({ type: 'record', appId: appId, objectName: objectApiName, formFactor: defaultFormFactor })];
13475
13472
  case 2:
13476
13473
  recordPage = _a.sent();
13477
- recordSchema = recordPage ? JSON.parse(recordPage.schema) : {
13474
+ recordSchema = recordPage ? recordPage.schema : {
13478
13475
  "type": "wrapper",
13479
13476
  "className": "overflow-y-auto p-0 m-0 flex-1 h-full",
13480
13477
  "name": "amis-".concat(appId, "-").concat(objectApiName, "-detail"),
@@ -13488,32 +13485,9 @@ setTimeout(()=>{
13488
13485
  }
13489
13486
  ],
13490
13487
  };
13491
- recordSchema = {
13492
- "type": "service",
13493
- "body": [recordSchema],
13494
- data: {
13495
- "_master.objectName": "${objectName}",
13496
- "_master.recordId": "${recordId}"
13497
- },
13498
- onEvent: {
13499
- "recordLoaded": {
13500
- "actions": [
13501
- {
13502
- "actionType": "reload",
13503
- "data": {
13504
- "_master.record": "${record}",
13505
- // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
13506
- "_master.objectName": "${objectName}",
13507
- "_master.recordId": "${recordId}"
13508
- }
13509
- }
13510
- ]
13511
- }
13512
- }
13513
- };
13514
13488
  _a.label = 3;
13515
13489
  case 3:
13516
- listSchema = listPage ? JSON.parse(listPage.schema) : {
13490
+ listSchema = listPage ? listPage.schema : {
13517
13491
  "type": "steedos-object-listview",
13518
13492
  "objectApiName": sideObject,
13519
13493
  "columnsTogglable": false,
@@ -13538,7 +13512,7 @@ setTimeout(()=>{
13538
13512
  },
13539
13513
  {
13540
13514
  "type": "wrapper",
13541
- "className": 'p-0 flex-1 focus:outline-none lg:order-last h-full',
13515
+ "className": 'overflow-y-auto p-0 flex-1 focus:outline-none lg:order-last h-full',
13542
13516
  "body": ___default.defaultsDeep({ data: defData }, recordSchema)
13543
13517
  }
13544
13518
  ]