@steedos-widgets/amis-lib 1.1.4-beta.2 → 1.1.4-beta.3

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
@@ -1046,7 +1046,7 @@
1046
1046
 
1047
1047
  async function getSource$1(field, ctx) {
1048
1048
  // data.query 最终格式 "{ \tleftOptions:organizations(filters: {__filters}){value:_id,label:name,children}, children:organizations(filters: {__filters}){ref:_id,children}, defaultValueOptions:space_users(filters: {__options_filters}){user,name} }"
1049
- const data = await getFindQuery({ name: refOrgsObjectName }, null, [{ name: "_id", alias: "value" }, { name: "name", alias: "label" }, { name: "children" }], {
1049
+ const data = await getFindQuery({ name: refOrgsObjectName }, null, [{ name: "_id", alias: "value" },{name: "parent"}, { name: "name", alias: "label" }, { name: "children" }], {
1050
1050
  alias: "leftOptions",
1051
1051
  filters: "{__filters}"
1052
1052
  });
@@ -1076,7 +1076,7 @@
1076
1076
  // data["&"] = "$$";
1077
1077
 
1078
1078
  const requestAdaptor = `
1079
- var filters = [['parent', '=', null]];
1079
+ var filters = [];
1080
1080
  api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters));
1081
1081
  var defaultValue = api.data.$value;
1082
1082
  var optionsFiltersOp = "${field.multiple ? "in" : "="}";
@@ -1089,17 +1089,18 @@
1089
1089
  `;
1090
1090
  const adaptor = `
1091
1091
  const data = payload.data;
1092
+ const rows = data.leftOptions
1092
1093
  data.children = data.children.map(function (child) {
1093
1094
  // child.defer = !!(child.children && child.children.length);
1094
1095
  child.defer = true;
1095
1096
  delete child.children;
1096
1097
  return child;
1097
1098
  });
1098
- data.leftOptions = data.leftOptions.map(function (leftOption) {
1099
- leftOption.defer = !!(leftOption.children && leftOption.children.length);
1100
- delete leftOption.children;
1101
- return leftOption;
1102
- });
1099
+
1100
+ var getTreeOptions = SteedosUI.getTreeOptions
1101
+ data.leftOptions = getTreeOptions(rows);
1102
+
1103
+
1103
1104
  var defaultValueOptions = data.defaultValueOptions;
1104
1105
  data.children = _.union(data.children, defaultValueOptions);
1105
1106
  delete data.defaultValueOptions;
@@ -2058,7 +2059,7 @@
2058
2059
  if(visible.trim().startsWith('function')){
2059
2060
  return `${visible}.apply({
2060
2061
  object: uiSchema
2061
- }, [objectName, _id, record.recordPermissions, data])`
2062
+ }, [objectName, _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data])`
2062
2063
  }
2063
2064
  return visible;
2064
2065
  }
@@ -4000,6 +4001,19 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
4000
4001
  if(enable_tree){
4001
4002
  const records = payload.data.rows;
4002
4003
  const treeRecords = [];
4004
+
4005
+ const getParentIds = (records)=>{
4006
+ const ids = _.map(records, (item)=>{
4007
+ return item._id;
4008
+ });
4009
+ const parents = _.filter(records,(record)=>{
4010
+ return !record.parent || !_.includes(ids,record.parent);
4011
+ })
4012
+ const parentsIds = _.map(parents,(item)=>{
4013
+ return item._id;
4014
+ })
4015
+ return parentsIds;
4016
+ }
4003
4017
  const getChildren = (records, childrenIds)=>{
4004
4018
  if(!childrenIds){
4005
4019
  return;
@@ -4015,8 +4029,9 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
4015
4029
  return children;
4016
4030
  }
4017
4031
 
4032
+ const parentIds = getParentIds(records);
4018
4033
  _.each(records, (record)=>{
4019
- if(!record.parent){
4034
+ if(!record.parent || _.includes(parentIds, record._id)){
4020
4035
  treeRecords.push(Object.assign({}, record, {children: getChildren(records, record.children)}));
4021
4036
  }
4022
4037
  });
@@ -5690,7 +5705,7 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
5690
5705
  footerToolbar: getObjectFooterToolbar(objectSchema, options.formFactor, {
5691
5706
  disableStatistics: options.queryCount === false
5692
5707
  }),
5693
- filter: !!options.filterVisible && await getObjectFilter(objectSchema, fields, options),
5708
+ filter: options.filterVisible !== false && await getObjectFilter(objectSchema, fields, options),
5694
5709
  };
5695
5710
  if(options.formFactor !== 'SMALL'){
5696
5711
  Object.assign(bodyProps, {
@@ -6253,7 +6268,7 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
6253
6268
  // return 'false';
6254
6269
  // }
6255
6270
  if(visible.trim().startsWith('function')){
6256
- return `${visible}(objectName, _id, record.recordPermissions, data)`
6271
+ return `${visible}(objectName, _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
6257
6272
  }
6258
6273
  return visible;
6259
6274
  }
@@ -6322,14 +6337,15 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
6322
6337
  formFactor: "${formFactor}",
6323
6338
  context: `\${context}`
6324
6339
  },
6325
- "responseData": {
6326
- "recordPermissions": "$$"
6327
- },
6328
6340
  headers: {
6329
6341
  Authorization: "Bearer ${context.tenantId},${context.authToken}"
6330
6342
  },
6331
6343
  adaptor: `
6332
- payload.recordPermissions = payload;
6344
+ payload = {
6345
+ record: {
6346
+ recordPermissions: payload
6347
+ }
6348
+ };
6333
6349
  return payload;
6334
6350
  `,
6335
6351
  }