@steedos-widgets/sortable 3.6.15 → 6.3.0-beta.11

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.
@@ -20446,10 +20446,23 @@
20446
20446
  if(ctx && ctx.isLookup){
20447
20447
  linkTarget = "target='_blank'";
20448
20448
  }
20449
+ let nameLabel = field.name;
20450
+ //若字段类型是lookup,则按照相关表tpl的label规则显示;若是其它类型,则显示_display或字段本身的值
20451
+ if (field.type == "lookup") {
20452
+ if(!field.reference_to && (field.optionsFunction || field._optionsFunction || field.options)){
20453
+ if(!field.isTableField){
20454
+ nameLabel = `\${${field.name}__label}`;
20455
+ }
20456
+ } else {
20457
+ nameLabel = `\${_display.${field.name}.label}`;
20458
+ }
20459
+ } else {
20460
+ nameLabel = `\${_display.${field.name} || ${field.name}}`;
20461
+ }
20449
20462
  if(ctx.isRelated && window.innerWidth >= 768){
20450
- return `<a href="${href}" ${linkTarget} onclick="return false;">\${${field.name} | raw}</a>`
20463
+ return `<a href="${href}" ${linkTarget} onclick="return false;">\${${nameLabel} | raw}</a>`
20451
20464
  }else {
20452
- return `<a href="${href}" ${linkTarget}>\${${field.name} | raw}</a>`
20465
+ return `<a href="${href}" ${linkTarget}>\${${nameLabel} | raw}</a>`
20453
20466
  }
20454
20467
  }
20455
20468
 
@@ -20574,7 +20587,7 @@
20574
20587
  }
20575
20588
 
20576
20589
  async function getFieldTpl (field, options){
20577
- if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel){
20590
+ if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel && field.multiple !== true){
20578
20591
  return getNameTpl(field, options)
20579
20592
  }
20580
20593
  switch (field.type) {
@@ -20615,7 +20628,7 @@
20615
20628
  if(display != false){
20616
20629
  display = true;
20617
20630
  }
20618
- let fieldsName = ['_id'];
20631
+ let fieldsName = ['_id', 'space'];
20619
20632
  let displayFields = [];
20620
20633
  let fieldsArr = [];
20621
20634
  if(lodash.exports.isArray(fields)){
@@ -21304,6 +21317,29 @@
21304
21317
  }
21305
21318
  });
21306
21319
 
21320
+ /*
21321
+ * @Author: baozhoutao@steedos.com
21322
+ * @Date: 2022-07-13 15:18:03
21323
+ * @LastEditors: baozhoutao@steedos.com
21324
+ * @LastEditTime: 2023-04-11 10:34:26
21325
+ * @Description:
21326
+ */
21327
+
21328
+ async function getPage({type, pageId = '', appId, objectName = '', recordId = '', formFactor = 'LARGE'}){
21329
+ const api = `/api/pageSchema/${type}?app=${appId}&objectApiName=${objectName}&recordId=${recordId}&pageId=${pageId}&formFactor=${formFactor}`;
21330
+ const page = await fetchAPI(api);
21331
+ if (page && page.schema) {
21332
+ page.schema = JSON.parse(page.schema);
21333
+ if(page.schema.data){
21334
+ delete page.schema.data.recordId;
21335
+ delete page.schema.data.objectName;
21336
+ delete page.schema.data.context;
21337
+ delete page.schema.data.global;
21338
+ }
21339
+ return page;
21340
+ }
21341
+ }
21342
+
21307
21343
  async function getQuickEditSchema(object, columnField, options){
21308
21344
  let field = object.fields[columnField.name];
21309
21345
  //判断在amis3.2以上环境下,放开批量编辑与lookup的单元格编辑
@@ -21938,20 +21974,26 @@
21938
21974
  }
21939
21975
 
21940
21976
  if(window.innerWidth >= 768 && ((field.is_name || field.name === options.labelFieldName) || ((field.type == 'lookup' || field.type == 'master_detail') && lodash.exports.isString(field.reference_to) && field.multiple != true)) && options.isRelated){
21941
-
21942
- const drawerRecordDetailSchema = {
21977
+ const recordPage = await getPage({ type: 'record', appId: options.appId, objectName: options.objectName, formFactor: options.formFactor });
21978
+ const drawerRecordDetailSchema = recordPage ? Object.assign({}, recordPage.schema, {
21979
+ "recordId": `\${${options.idFieldName}}`,
21980
+ "data": {
21981
+ ...recordPage.schema.data,
21982
+ "_inDrawer": true, // 用于判断是否在抽屉中
21983
+ "recordLoaded": false, // 重置数据加载状态
21984
+ }
21985
+ }) : {
21943
21986
  "type": "steedos-record-detail",
21944
21987
  "objectApiName": "${objectName}",
21945
21988
  "recordId": `\${${options.idFieldName}}`,
21946
21989
  "showBackButton": false,
21947
21990
  "showButtons": true,
21948
21991
  "data": {
21949
- "_inDrawer": true, // 用于判断是否在抽屉中
21950
- "recordLoaded": false, // 重置数据加载状态
21992
+ "_inDrawer": true, // 用于判断是否在抽屉中
21993
+ "recordLoaded": false, // 重置数据加载状态
21951
21994
  }
21952
21995
  };
21953
21996
 
21954
-
21955
21997
  if(!(field.is_name || field.name === options.labelFieldName)){
21956
21998
  drawerRecordDetailSchema.objectApiName = field.reference_to;
21957
21999
  drawerRecordDetailSchema.recordId = `\${_display.${field.name}.value}`;
@@ -21967,7 +22009,7 @@
21967
22009
  "title": "&nbsp;",
21968
22010
  "headerClassName": "hidden",
21969
22011
  "size": "lg",
21970
- "bodyClassName": "p-0 m-0",
22012
+ "bodyClassName": "p-0 m-0 bg-gray-100",
21971
22013
  "closeOnEsc": true,
21972
22014
  "closeOnOutside": true,
21973
22015
  "resizable": true,
@@ -22829,7 +22871,8 @@
22829
22871
  type: 'button',
22830
22872
  actionType: 'confirm',
22831
22873
  label: instance.t('frontend_form_save'),
22832
- primary: true
22874
+ primary: true,
22875
+ close: `object_actions_drawer_${uiSchema.name}`
22833
22876
  },
22834
22877
  ]
22835
22878
  }
@@ -25047,7 +25090,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
25047
25090
  * @Author: baozhoutao@steedos.com
25048
25091
  * @Date: 2022-07-05 15:55:39
25049
25092
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
25050
- * @LastEditTime: 2024-02-23 16:37:06
25093
+ * @LastEditTime: 2024-04-26 16:46:44
25051
25094
  * @Description:
25052
25095
  */
25053
25096
 
@@ -25280,37 +25323,44 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
25280
25323
  * 本次存储代码段
25281
25324
  */
25282
25325
  try {
25283
- const listViewPropsStoreKey = location.pathname + "/crud";
25284
- let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
25285
- /**
25286
- * localListViewProps规范来自crud请求api中api.data.$self参数值的。
25287
- * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
25288
- * __searchable__...:顶部放大镜搜索条件
25289
- * filter:右侧过滤器
25290
- * perPage:每页条数
25291
- * page:当前页码
25292
- * orderBy:排序字段
25293
- * orderDir:排序方向
25294
- */
25295
- if (localListViewProps) {
25296
- localListViewProps = JSON.parse(localListViewProps);
25297
- // localListViewProps.perPage = 3;
25298
- let listSchema = {};
25299
- if(localListViewProps.orderBy){
25300
- listSchema.orderBy = localListViewProps.orderBy;
25301
- }
25302
- if(localListViewProps.orderDir){
25303
- listSchema.orderDir = localListViewProps.orderDir;
25304
- }
25326
+ const listViewPropsStoreKey = location.pathname + "/crud";
25327
+ let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
25328
+ /**
25329
+ * localListViewProps规范来自crud请求api中api.data.$self参数值的。
25330
+ * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
25331
+ * __searchable__...:顶部放大镜搜索条件
25332
+ * filter:右侧过滤器
25333
+ * perPage:每页条数
25334
+ * page:当前页码
25335
+ * orderBy:排序字段
25336
+ * orderDir:排序方向
25337
+ */
25338
+ if (localListViewProps) {
25339
+ localListViewProps = JSON.parse(localListViewProps);
25340
+ // localListViewProps.perPage = 3;
25341
+ let listSchema = {};
25342
+ if (localListViewProps.orderBy) {
25343
+ listSchema.orderBy = localListViewProps.orderBy;
25344
+ }
25345
+ if (localListViewProps.orderDir) {
25346
+ listSchema.orderDir = localListViewProps.orderDir;
25347
+ }
25305
25348
 
25306
- if(localListViewProps.perPage){
25307
- listSchema.perPage = localListViewProps.perPage;
25349
+ if (localListViewProps.perPage) {
25350
+ listSchema.perPage = localListViewProps.perPage;
25351
+ }
25352
+ defaults.listSchema = lodash.exports.defaultsDeep({}, listSchema, defaults.listSchema || {});
25308
25353
  }
25309
- defaults.listSchema = lodash.exports.defaultsDeep({}, listSchema, defaults.listSchema || {});
25310
- }
25311
25354
  }
25312
25355
  catch (ex) {
25313
- console.error("本地存储中crud参数解析异常:", ex);
25356
+ console.error("本地存储中crud参数解析异常:", ex);
25357
+ }
25358
+
25359
+ if (window.innerWidth > 768) {
25360
+ // 列表视图组件PC端高度自动计算实现满屏效果,手机端不需要满屏效果,所以不用autofillheight,且允许重写微页面中重新组件autoFillHeight属性
25361
+ defaults.listSchema = lodash.exports.defaultsDeep({}, defaults.listSchema || {}, {
25362
+ autoFillHeight: true
25363
+ });
25314
25364
  }
25315
25365
 
25316
25366
  ctx.defaults = defaults;
@@ -25871,7 +25921,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
25871
25921
  });
25872
25922
 
25873
25923
  // 把自动填充规则中依赖的字段也加到api请求中
25874
- let autoFillMapping = !field.multiple && field.auto_fill_mapping;
25924
+ let autoFillMapping = field.auto_fill_mapping;
25875
25925
  if (autoFillMapping && autoFillMapping.length) {
25876
25926
  autoFillMapping.forEach(function (item) {
25877
25927
  if(!lodash.exports.find(tableFields, function(f){
@@ -26021,7 +26071,11 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
26021
26071
  // 如果当前元素不是数组,则处理该元素
26022
26072
  // 下面正则用于匹配amis公式\${}
26023
26073
  if(/\\\$\\\{([^}]*)\\\}/.test(arr[i])) {
26024
- arr[i] = currentAmis.evaluate(arr[i], api.data.$);
26074
+ try{
26075
+ arr[i] = currentAmis.evaluate(arr[i], api.context);
26076
+ }catch(ex){
26077
+ console.error("运行lookup过滤公式时出现错误:",ex);
26078
+ }
26025
26079
  }
26026
26080
  }
26027
26081
  }
@@ -26343,7 +26397,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
26343
26397
  ];
26344
26398
 
26345
26399
  // 把自动填充规则中依赖的字段也加到api请求中
26346
- let autoFillMapping = !field.multiple && field.auto_fill_mapping;
26400
+ let autoFillMapping = field.auto_fill_mapping;
26347
26401
  if (autoFillMapping && autoFillMapping.length) {
26348
26402
  autoFillMapping.forEach(function (item) {
26349
26403
  queryFields.push(refObjectConfig.fields[item.from]);
@@ -26429,6 +26483,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
26429
26483
  var fieldFilters = ${JSON.stringify(field.filters)};
26430
26484
  var currentAmis = amisRequire('amis');
26431
26485
  //递归fieldFilters数组,检查每一个元素,判断若是公式,就仅把它解析
26486
+ debugger;
26432
26487
  function traverseNestedArray(arr) {
26433
26488
  for (let i = 0; i < arr.length; i++) {
26434
26489
  if (Array.isArray(arr[i])) {
@@ -26438,7 +26493,11 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
26438
26493
  // 如果当前元素不是数组,则处理该元素
26439
26494
  // 下面正则用于匹配amis公式\${}
26440
26495
  if(/\\\$\\\{([^}]*)\\\}/.test(arr[i])) {
26441
- arr[i] = currentAmis.evaluate(arr[i], api.data.$);
26496
+ try{
26497
+ arr[i] = currentAmis.evaluate(arr[i], api.context);
26498
+ }catch(ex){
26499
+ console.error("运行lookup过滤公式时出现错误:",ex);
26500
+ }
26442
26501
  }
26443
26502
  }
26444
26503
  }
@@ -26585,14 +26644,25 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
26585
26644
  }
26586
26645
 
26587
26646
  async function getAutoFill(field, refObject) {
26588
- let autoFillMapping = !field.multiple && field.auto_fill_mapping;
26647
+ let autoFillMapping = field.auto_fill_mapping;
26589
26648
  if (autoFillMapping && autoFillMapping.length) {
26590
26649
  let fillMapping = {};
26650
+ if (field.multiple) {
26651
+ autoFillMapping.forEach(function (item) {
26652
+ //from的字段类型为lookup、master_detail、select时,需要保留数组格式;其他类型需要转变为字符串格式
26653
+ if (lodash.exports.includes(["lookup","master_detail","select"], refObject.fields[item.from].type)) {
26654
+ fillMapping[item.to] = `\${items | pick:${item.from}}`;
26655
+ } else {
26656
+ fillMapping[item.to] = `\${items | pick:${item.from} | join}`;
26657
+ }
26658
+ });
26659
+ }else {
26660
+ autoFillMapping.forEach(function (item) {
26661
+ fillMapping[item.to] = `\${${item.from}}`;
26662
+ });
26663
+ }
26591
26664
  // let fieldsForApi = [];
26592
- autoFillMapping.forEach(function (item) {
26593
- fillMapping[item.to] = `\${${item.from}}`;
26594
- // fieldsForApi.push(item.from);
26595
- });
26665
+ // fieldsForApi.push(item.from);
26596
26666
  // let api = {
26597
26667
  // // "url": "/amis/api/mock2/form/autoUpdate?browser=${browser}&version=${version}",
26598
26668
  // "url": `/api/v1/${refObject.name}/\${${field.name}}?fields=${JSON.stringify(fieldsForApi)}`,
@@ -26694,7 +26764,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
26694
26764
  amisSchema = lodash.exports.defaultsDeep({}, pageAmisSchema, amisSchema);
26695
26765
  }
26696
26766
  }
26697
- const autoFill = await getAutoFill(field);
26767
+ const autoFill = await getAutoFill(field, refObject);
26698
26768
  if(autoFill){
26699
26769
  amisSchema.autoFill = autoFill;
26700
26770
  // 这里不配置initAutoFill值,按amis规则initAutoFill默认值为fillIfNotSet处理--需要amis sdk 版本 > 3.6.3-patch.6(不包括)版本
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos-widgets/sortable",
3
- "version": "3.6.15",
3
+ "version": "6.3.0-beta.11",
4
4
  "main": "dist/sortable.cjs.js",
5
5
  "module": "dist/sortable.esm.js",
6
6
  "unpkg": "dist/sortable.umd.js",
@@ -45,7 +45,7 @@
45
45
  "dependencies": {
46
46
  "@dnd-kit/core": "^6.0.5",
47
47
  "@dnd-kit/sortable": "^7.0.1",
48
- "@steedos-widgets/amis-lib": "3.6.15"
48
+ "@steedos-widgets/amis-lib": "6.3.0-beta.11"
49
49
  },
50
- "gitHead": "81c5cd906a7674f4ce9130f21e5ec0a090778554"
50
+ "gitHead": "0c2502e4d2a3f8c8c180613fed6b5618be19abfa"
51
51
  }