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