@steedos-widgets/amis-lib 1.2.6-beta.17 → 1.2.6-beta.19

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
@@ -1376,21 +1376,6 @@
1376
1376
  }
1377
1377
  };
1378
1378
 
1379
- /*
1380
- * @Author: baozhoutao@steedos.com
1381
- * @Date: 2022-08-04 10:42:49
1382
- * @LastEditors: baozhoutao@steedos.com
1383
- * @LastEditTime: 2022-08-25 10:28:47
1384
- * @Description:
1385
- */
1386
- var config = {
1387
- listView: {
1388
- newRecordMode: 'modal',
1389
- editRecordMode: 'modal',
1390
- perPage: 20
1391
- }
1392
- };
1393
-
1394
1379
  /*
1395
1380
  * @Author: baozhoutao@steedos.com
1396
1381
  * @Date: 2022-11-01 15:51:00
@@ -2406,6 +2391,166 @@
2406
2391
 
2407
2392
  const executeButton = execute;
2408
2393
 
2394
+
2395
+ const getObjectDetailHeaderButtons = (objectSchema, recordId)=>{
2396
+ const { name } = objectSchema;
2397
+ const buttons = getObjectDetailButtons(objectSchema, {});
2398
+ const moreButtons = getObjectDetailMoreButtons(objectSchema, {
2399
+ recordId: recordId,
2400
+ objectName: name
2401
+ });
2402
+ let amisButtonsSchema = ___default["default"].map(buttons, (button) => {
2403
+ return {
2404
+ type: 'steedos-object-button',
2405
+ name: button.name,
2406
+ objectName: button.objectName,
2407
+ visibleOn: getButtonVisibleOn$1(button),
2408
+ className: `button_${button.name}`
2409
+ }
2410
+ });
2411
+ let dropdownButtons = ___default["default"].map(moreButtons, (button) => {
2412
+ return {
2413
+ type: 'steedos-object-button',
2414
+ name: button.name,
2415
+ objectName: button.objectName,
2416
+ visibleOn: getButtonVisibleOn$1(button),
2417
+ }
2418
+ });
2419
+ return {
2420
+ buttons: amisButtonsSchema,
2421
+ moreButtons: dropdownButtons
2422
+ };
2423
+ };
2424
+
2425
+ const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
2426
+ const { buttons, moreButtons } = getObjectDetailHeaderButtons(objectSchema, recordId);
2427
+ if(ctx.formFactor === 'SMALL'){
2428
+ return {
2429
+ "type": "button",
2430
+ "icon": "fa fa-angle-down",
2431
+ "onEvent": {
2432
+ "click": {
2433
+ "actions": [
2434
+ {
2435
+ "actionType": "drawer",
2436
+ "drawer": {
2437
+ "type": "drawer",
2438
+ "title": "操作",
2439
+ "body": [
2440
+ {
2441
+ "type": "button-group",
2442
+ "id": "u:fd837823be5b",
2443
+ "vertical": true,
2444
+ "tiled": true,
2445
+ "buttons": [
2446
+ ...___default["default"].map(buttons, (button)=>{
2447
+ button.className += ' w-full';
2448
+ return button;
2449
+ }),
2450
+ ...___default["default"].map(moreButtons, (button)=>{
2451
+ button.className += ' w-full';
2452
+ return button;
2453
+ })
2454
+ ],
2455
+ "btnLevel": "enhance",
2456
+ "className": "w-full",
2457
+ "btnClassName": "w-full",
2458
+ "size": "lg"
2459
+ }
2460
+ ],
2461
+ "id": "u:9815f7366b9f",
2462
+ "position": "bottom",
2463
+ "closeOnOutside": true,
2464
+ "resizable": false,
2465
+ "className": "buttons-drawer",
2466
+ "bodyClassName": "m-none p-none",
2467
+ "actions": []
2468
+ }
2469
+ }
2470
+ ]
2471
+ }
2472
+ },
2473
+ "id": "u:ee7c7929e6ae"
2474
+ }
2475
+ }else {
2476
+ if(moreButtons.length > 0){
2477
+ const dropdownButtonsSchema = {
2478
+ type: "steedos-dropdown-button",
2479
+ label: "",
2480
+ buttons: moreButtons,
2481
+ className: 'slds-icon'
2482
+ };
2483
+ buttons.push(dropdownButtonsSchema);
2484
+ }
2485
+ return buttons;
2486
+ }
2487
+ };
2488
+
2489
+
2490
+ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
2491
+ const buttons = getListViewButtons(objectSchema, ctx);
2492
+ if(ctx.formFactor === 'SMALL'){
2493
+ return {
2494
+ "type": "button",
2495
+ "icon": "fa fa-angle-down",
2496
+ "onEvent": {
2497
+ "click": {
2498
+ "actions": [
2499
+ {
2500
+ "actionType": "drawer",
2501
+ "drawer": {
2502
+ "type": "drawer",
2503
+ "title": "操作",
2504
+ "body": [
2505
+ {
2506
+ "type": "button-group",
2507
+ "id": "u:fd837823be5b",
2508
+ "vertical": true,
2509
+ "tiled": true,
2510
+ "buttons": [
2511
+ ...___default["default"].map(buttons, (button)=>{
2512
+ return {
2513
+ type: 'steedos-object-button',
2514
+ name: button.name,
2515
+ objectName: button.objectName,
2516
+ visibleOn: getButtonVisibleOn$1(button),
2517
+ className: `button_${button.name} w-full`
2518
+ }
2519
+ })
2520
+ ],
2521
+ "btnLevel": "enhance",
2522
+ "className": "w-full",
2523
+ "btnClassName": "w-full",
2524
+ "size": "lg"
2525
+ }
2526
+ ],
2527
+ "id": "u:9815f7366b9f",
2528
+ "position": "bottom",
2529
+ "closeOnOutside": true,
2530
+ "resizable": false,
2531
+ "className": "buttons-drawer",
2532
+ "bodyClassName": "m-none p-none",
2533
+ "actions": []
2534
+ }
2535
+ }
2536
+ ]
2537
+ }
2538
+ },
2539
+ "id": "u:ee7c7929e6ae"
2540
+ }
2541
+ }else {
2542
+ return ___default["default"].map(buttons, (button) => {
2543
+ return {
2544
+ type: 'steedos-object-button',
2545
+ name: button.name,
2546
+ objectName: button.objectName,
2547
+ visibleOn: getButtonVisibleOn$1(button),
2548
+ className: `button_${button.name}`
2549
+ }
2550
+ });
2551
+ }
2552
+ };
2553
+
2409
2554
  async function getObjectFieldsFilterButtonSchema(objectSchema) {
2410
2555
  // const amisListViewId = `listview_${objectSchema.name}`;
2411
2556
  return {
@@ -2888,17 +3033,7 @@
2888
3033
  }
2889
3034
  );
2890
3035
 
2891
- const buttons = getListViewButtons(objectSchema, {});
2892
- let amisButtonsSchema = _$1.map(buttons, (button) => {
2893
- return {
2894
- type: 'steedos-object-button',
2895
- name: button.name,
2896
- objectName: button.objectName,
2897
- visibleOn: getButtonVisibleOn$1(button),
2898
- className: `button_${button.name}`
2899
- }
2900
- });
2901
-
3036
+ let amisButtonsSchema = getObjectListViewButtonsSchemas(objectSchema, {formFactor: ctx.formFactor});
2902
3037
  const reg = new RegExp('_', 'g');
2903
3038
  const standardIcon = icon && icon.replace(reg, '-');
2904
3039
  return {
@@ -3080,7 +3215,10 @@
3080
3215
  * @returns amisSchema
3081
3216
  */
3082
3217
  function getObjectListHeader$1(objectSchema, listViewName, ctx) {
3083
- let firstLineSchema = getObjectListHeaderFirstLine(objectSchema);
3218
+ if (!ctx) {
3219
+ ctx = {};
3220
+ }
3221
+ let firstLineSchema = getObjectListHeaderFirstLine(objectSchema, listViewName, ctx);
3084
3222
  let body = [firstLineSchema];
3085
3223
  let headerSchema = [{
3086
3224
  "type": "wrapper",
@@ -3101,35 +3239,11 @@
3101
3239
  const { showRecordTitle = true } = options || {};
3102
3240
  // console.log('getObjectRecordDetailHeader==>', objectSchema, recordId)
3103
3241
  const { name, label, icon, NAME_FIELD_KEY } = objectSchema;
3104
- const buttons = getObjectDetailButtons(objectSchema, {});
3105
- const moreButtons = getObjectDetailMoreButtons(objectSchema, {
3106
- recordId: recordId,
3107
- objectName: name
3108
- });
3109
- let amisButtonsSchema = _$1.map(buttons, (button) => {
3110
- return {
3111
- type: 'steedos-object-button',
3112
- name: button.name,
3113
- objectName: button.objectName,
3114
- visibleOn: getButtonVisibleOn$1(button),
3115
- className: `button_${button.name}`
3116
- }
3117
- });
3118
- let dropdownButtons = _$1.map(moreButtons, (button) => {
3119
- return {
3120
- type: 'steedos-object-button',
3121
- name: button.name,
3122
- objectName: button.objectName,
3123
- visibleOn: getButtonVisibleOn$1(button),
3124
- }
3125
- });
3126
- const dropdownButtonsSchema = {
3127
- type: "steedos-dropdown-button",
3128
- label: "",
3129
- buttons: dropdownButtons,
3130
- className: 'slds-icon'
3131
- };
3132
- amisButtonsSchema.push(dropdownButtonsSchema);
3242
+
3243
+ let amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
3244
+
3245
+ // console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
3246
+
3133
3247
  const reg = new RegExp('_', 'g');
3134
3248
  const standardIcon = icon && icon.replace(reg, '-');
3135
3249
 
@@ -4888,11 +5002,12 @@ setTimeout(()=>{
4888
5002
  autoComplete: apiInfo,
4889
5003
  searchable: true,
4890
5004
  };
5005
+ //删除xlink:href中的rootUrl前缀,解决客户端svg为空的问题
4891
5006
  const select_menuTpl = `<span class='flex items-center mt-0.5'>
4892
5007
  <span role='img' aria-label='smile' class='anticon anticon-smile'>
4893
5008
  <span class='slds-icon_container slds-icon-standard-\${REPLACE(icon,'_','-')}'>
4894
5009
  <svg class='slds-icon slds-icon_x-small' aria-hidden='true'>
4895
- <use xlink:href='\${context.rootUrl}/assets/icons/standard-sprite/svg/symbols.svg#\${icon}'></use>
5010
+ <use xlink:href='/assets/icons/standard-sprite/svg/symbols.svg#\${icon}'></use>
4896
5011
  </svg>
4897
5012
  </span>
4898
5013
  </span>
@@ -6374,7 +6489,7 @@ setTimeout(()=>{
6374
6489
  }),
6375
6490
  filter: options.filterVisible !== false && await getObjectFilter(objectSchema, fields, options),
6376
6491
  };
6377
- if(options.formFactor !== 'SMALL'){
6492
+ if(options.formFactor !== 'SMALL' || ["split"].indexOf(options.displayAs) == -1){
6378
6493
  Object.assign(bodyProps, {
6379
6494
  bulkActions: options.bulkActions != false ? bulkActions : false
6380
6495
  });
@@ -6707,6 +6822,21 @@ setTimeout(()=>{
6707
6822
  }
6708
6823
  }
6709
6824
 
6825
+ /*
6826
+ * @Author: baozhoutao@steedos.com
6827
+ * @Date: 2022-08-04 10:42:49
6828
+ * @LastEditors: baozhoutao@steedos.com
6829
+ * @LastEditTime: 2022-08-25 10:28:47
6830
+ * @Description:
6831
+ */
6832
+ var config = {
6833
+ listView: {
6834
+ newRecordMode: 'modal',
6835
+ editRecordMode: 'modal',
6836
+ perPage: 20
6837
+ }
6838
+ };
6839
+
6710
6840
  async function getTableColumns(fields, options){
6711
6841
  const columns = [{name: '_index',type: 'text', width: 32, placeholder: ""}];
6712
6842
  for (const field of fields) {
@@ -6922,8 +7052,9 @@ setTimeout(()=>{
6922
7052
  const url = getNameTplUrl(nameField, options);
6923
7053
 
6924
7054
  const columnLines = getMobileLines(tpls);
6925
-
6926
- columns.push({
7055
+
7056
+
7057
+ let column = {
6927
7058
  name: nameField.name,
6928
7059
  label: nameField.label,
6929
7060
  sortable: nameField.sortable,
@@ -6932,13 +7063,66 @@ setTimeout(()=>{
6932
7063
  actionType: "link",
6933
7064
  link: url,
6934
7065
  innerClassName: "steedos-listview-item block text-gray-500",
6935
- body:{
7066
+ body: {
6936
7067
  "type": "wrapper",
6937
7068
  "body": columnLines,
6938
7069
  "size": "none",
6939
7070
  "className": "p-1"
6940
7071
  }
6941
- });
7072
+ };
7073
+
7074
+ if(options.objectName === 'cms_files'){
7075
+ if(window.Meteor?.isCordova){
7076
+ column = {
7077
+ ...column,
7078
+ actionType: "",
7079
+ link: "",
7080
+ onEvent: {
7081
+ "click": {
7082
+ "actions": [
7083
+ {
7084
+ "script": `
7085
+ let cms_url = "/api/files/files/"+event.data.versions[0]+"?download=true"
7086
+ Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(cms_url)), event.data.name);
7087
+ `,
7088
+ "actionType": "custom"
7089
+ }
7090
+ ],
7091
+ "weight": 0
7092
+ }
7093
+ }
7094
+ };
7095
+ }else {
7096
+ column = {
7097
+ ...column,
7098
+ actionType: "",
7099
+ link: "",
7100
+ onEvent: {
7101
+ "click": {
7102
+ "actions": [
7103
+ {
7104
+ "args": {
7105
+ "api": {
7106
+ "url": url,
7107
+ "method": "get",
7108
+ "headers": {
7109
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
7110
+ }
7111
+ }
7112
+ },
7113
+ "actionType": "download"
7114
+ }
7115
+ ],
7116
+ "weight": 0
7117
+ }
7118
+ }
7119
+ };
7120
+ }
7121
+
7122
+ }
7123
+
7124
+ columns.push(column);
7125
+
6942
7126
 
6943
7127
  return columns;
6944
7128
  }
@@ -7057,7 +7241,7 @@ setTimeout(()=>{
7057
7241
  options = {};
7058
7242
  }
7059
7243
  let columns = [];
7060
- if(options.formFactor === 'SMALL'){
7244
+ if(options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1){
7061
7245
  columns = await getMobileTableColumns(fields, options);
7062
7246
  }
7063
7247
  else {
@@ -8029,7 +8213,7 @@ setTimeout(()=>{
8029
8213
  * @Author: baozhoutao@steedos.com
8030
8214
  * @Date: 2022-07-05 15:55:39
8031
8215
  * @LastEditors: Please set LastEditors
8032
- * @LastEditTime: 2023-04-20 11:43:14
8216
+ * @LastEditTime: 2023-05-08 16:34:25
8033
8217
  * @Description:
8034
8218
  */
8035
8219
 
@@ -8283,7 +8467,7 @@ setTimeout(()=>{
8283
8467
  }
8284
8468
  function getRelatedListProps(uiSchema, listViewName, ctx) {
8285
8469
  if (ctx.columns) {
8286
- const sort = getListViewSort(ctx.sort);
8470
+ const sort = getListViewSort({sort: ctx.sort});
8287
8471
  let { filters , filtersFunction} = ctx;
8288
8472
  if(!filtersFunction && filters){
8289
8473
  filtersFunction = str2function(
@@ -9126,7 +9310,10 @@ setTimeout(()=>{
9126
9310
  const defaults = ctx.defaults || {};
9127
9311
  if(!defaults.headerSchema){
9128
9312
  //传入isListviewInit是区别于对象列表类型的微页面,即getListPageInitSchema函数中该属性为false
9129
- const headerSchema = await getObjectListHeader$1(uiSchema);
9313
+ const headerSchema = await getObjectListHeader$1(uiSchema, listViewName, {
9314
+ onlySecordLine: true,
9315
+ isListviewInit: true
9316
+ });
9130
9317
  defaults.headerSchema = headerSchema;
9131
9318
  }
9132
9319
  ctx.defaults = defaults;
@@ -11802,6 +11989,7 @@ setTimeout(()=>{
11802
11989
  exports.getLookupSapceUserTreeSchema = getLookupSapceUserTreeSchema;
11803
11990
  exports.getNotifications = getNotifications;
11804
11991
  exports.getObjectDetailButtons = getObjectDetailButtons;
11992
+ exports.getObjectDetailButtonsSchemas = getObjectDetailButtonsSchemas;
11805
11993
  exports.getObjectDetailMoreButtons = getObjectDetailMoreButtons;
11806
11994
  exports.getObjectFieldsFilterBarSchema = getObjectFieldsFilterBarSchema;
11807
11995
  exports.getObjectFieldsFilterButtonSchema = getObjectFieldsFilterButtonSchema;
@@ -11810,6 +11998,7 @@ setTimeout(()=>{
11810
11998
  exports.getObjectListHeaderFieldsFilterBar = getObjectListHeaderFieldsFilterBar;
11811
11999
  exports.getObjectListHeaderFirstLine = getObjectListHeaderFirstLine;
11812
12000
  exports.getObjectListHeaderSecordLine = getObjectListHeaderSecordLine;
12001
+ exports.getObjectListViewButtonsSchemas = getObjectListViewButtonsSchemas;
11813
12002
  exports.getObjectRecordDetailHeader = getObjectRecordDetailHeader;
11814
12003
  exports.getObjectRecordDetailRelatedListHeader = getObjectRecordDetailRelatedListHeader;
11815
12004
  exports.getObjectRelated = getObjectRelated;