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

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.esm.js CHANGED
@@ -1020,7 +1020,7 @@ const refOrgsObjectName = "organizations";
1020
1020
 
1021
1021
  async function getSource$1(field, ctx) {
1022
1022
  // 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} }"
1023
- const data = await getFindQuery({ name: refOrgsObjectName }, null, [{ name: "_id", alias: "value" }, { name: "name", alias: "label" }, { name: "children" }], {
1023
+ const data = await getFindQuery({ name: refOrgsObjectName }, null, [{ name: "_id", alias: "value" },{name: "parent"}, { name: "name", alias: "label" }, { name: "children" }], {
1024
1024
  alias: "leftOptions",
1025
1025
  filters: "{__filters}"
1026
1026
  });
@@ -1050,7 +1050,7 @@ async function getSource$1(field, ctx) {
1050
1050
  // data["&"] = "$$";
1051
1051
 
1052
1052
  const requestAdaptor = `
1053
- var filters = [['parent', '=', null]];
1053
+ var filters = [];
1054
1054
  api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters));
1055
1055
  var defaultValue = api.data.$value;
1056
1056
  var optionsFiltersOp = "${field.multiple ? "in" : "="}";
@@ -1063,17 +1063,18 @@ async function getSource$1(field, ctx) {
1063
1063
  `;
1064
1064
  const adaptor = `
1065
1065
  const data = payload.data;
1066
+ const rows = data.leftOptions
1066
1067
  data.children = data.children.map(function (child) {
1067
1068
  // child.defer = !!(child.children && child.children.length);
1068
1069
  child.defer = true;
1069
1070
  delete child.children;
1070
1071
  return child;
1071
1072
  });
1072
- data.leftOptions = data.leftOptions.map(function (leftOption) {
1073
- leftOption.defer = !!(leftOption.children && leftOption.children.length);
1074
- delete leftOption.children;
1075
- return leftOption;
1076
- });
1073
+
1074
+ var getTreeOptions = SteedosUI.getTreeOptions
1075
+ data.leftOptions = getTreeOptions(rows);
1076
+
1077
+
1077
1078
  var defaultValueOptions = data.defaultValueOptions;
1078
1079
  data.children = _.union(data.children, defaultValueOptions);
1079
1080
  delete data.defaultValueOptions;
@@ -2032,7 +2033,7 @@ function getButtonVisibleOn$1(button){
2032
2033
  if(visible.trim().startsWith('function')){
2033
2034
  return `${visible}.apply({
2034
2035
  object: uiSchema
2035
- }, [objectName, _id, record.recordPermissions, data])`
2036
+ }, [objectName, _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data])`
2036
2037
  }
2037
2038
  return visible;
2038
2039
  }
@@ -3974,6 +3975,19 @@ async function lookupToAmisPicker(field, readonly, ctx){
3974
3975
  if(enable_tree){
3975
3976
  const records = payload.data.rows;
3976
3977
  const treeRecords = [];
3978
+
3979
+ const getParentIds = (records)=>{
3980
+ const ids = _.map(records, (item)=>{
3981
+ return item._id;
3982
+ });
3983
+ const parents = _.filter(records,(record)=>{
3984
+ return !record.parent || !_.includes(ids,record.parent);
3985
+ })
3986
+ const parentsIds = _.map(parents,(item)=>{
3987
+ return item._id;
3988
+ })
3989
+ return parentsIds;
3990
+ }
3977
3991
  const getChildren = (records, childrenIds)=>{
3978
3992
  if(!childrenIds){
3979
3993
  return;
@@ -3989,8 +4003,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
3989
4003
  return children;
3990
4004
  }
3991
4005
 
4006
+ const parentIds = getParentIds(records);
3992
4007
  _.each(records, (record)=>{
3993
- if(!record.parent){
4008
+ if(!record.parent || _.includes(parentIds, record._id)){
3994
4009
  treeRecords.push(Object.assign({}, record, {children: getChildren(records, record.children)}));
3995
4010
  }
3996
4011
  });
@@ -5664,7 +5679,7 @@ async function getObjectCRUD(objectSchema, fields, options){
5664
5679
  footerToolbar: getObjectFooterToolbar(objectSchema, options.formFactor, {
5665
5680
  disableStatistics: options.queryCount === false
5666
5681
  }),
5667
- filter: !!options.filterVisible && await getObjectFilter(objectSchema, fields, options),
5682
+ filter: options.filterVisible !== false && await getObjectFilter(objectSchema, fields, options),
5668
5683
  };
5669
5684
  if(options.formFactor !== 'SMALL'){
5670
5685
  Object.assign(bodyProps, {
@@ -5679,7 +5694,11 @@ async function getObjectCRUD(objectSchema, fields, options){
5679
5694
  options.queryCount = true; // 禁止翻页的时候, 需要查找总数
5680
5695
  }else if(top){
5681
5696
  bodyProps.footerToolbar = [];
5682
- options.queryCount = false;
5697
+ if(options.isRelated){
5698
+ options.queryCount = true;
5699
+ }else {
5700
+ options.queryCount = false;
5701
+ }
5683
5702
  }
5684
5703
 
5685
5704
  bodyProps.headerToolbar = getObjectHeaderToolbar(objectSchema, options.formFactor, {showDisplayAs, hiddenCount: options.queryCount === false});
@@ -6227,7 +6246,7 @@ function getButtonVisibleOn(button){
6227
6246
  // return 'false';
6228
6247
  // }
6229
6248
  if(visible.trim().startsWith('function')){
6230
- return `${visible}(objectName, _id, record.recordPermissions, data)`
6249
+ return `${visible}(objectName, _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
6231
6250
  }
6232
6251
  return visible;
6233
6252
  }
@@ -6296,14 +6315,15 @@ async function getTableOperation(ctx){
6296
6315
  formFactor: "${formFactor}",
6297
6316
  context: `\${context}`
6298
6317
  },
6299
- "responseData": {
6300
- "recordPermissions": "$$"
6301
- },
6302
6318
  headers: {
6303
6319
  Authorization: "Bearer ${context.tenantId},${context.authToken}"
6304
6320
  },
6305
6321
  adaptor: `
6306
- payload.recordPermissions = payload;
6322
+ payload = {
6323
+ record: {
6324
+ recordPermissions: payload
6325
+ }
6326
+ };
6307
6327
  return payload;
6308
6328
  `,
6309
6329
  }
@@ -6715,6 +6735,11 @@ async function getCalendarApi(mainObject, fields, options) {
6715
6735
  }else{
6716
6736
  filters = [filters, 'and', eventDurationFilters]
6717
6737
  }
6738
+
6739
+ if(api.data.$self.additionalFilters){
6740
+ filters.push(api.data.$self.additionalFilters)
6741
+ }
6742
+
6718
6743
  var pageSize = api.data.pageSize || 10;
6719
6744
  var pageNo = api.data.pageNo || 1;
6720
6745
  var skip = (pageNo - 1) * pageSize;
@@ -7178,6 +7203,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7178
7203
  "type": "steedos-fullcalendar",
7179
7204
  "label": "",
7180
7205
  "name": "fullcalendar",
7206
+ "placeholder":"${additionalFilters}",//用于触发reload
7181
7207
  "editable": permissions.allowEdit,
7182
7208
  "selectable": permissions.allowCreate,
7183
7209
  "selectMirror": permissions.allowCreate,
@@ -7265,8 +7291,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
7265
7291
  /*
7266
7292
  * @Author: baozhoutao@steedos.com
7267
7293
  * @Date: 2022-07-05 15:55:39
7268
- * @LastEditors: 廖大雪 2291335922@qq.com
7269
- * @LastEditTime: 2023-03-15 10:57:31
7294
+ * @LastEditors: Please set LastEditors
7295
+ * @LastEditTime: 2023-03-30 17:44:53
7270
7296
  * @Description:
7271
7297
  */
7272
7298
 
@@ -7341,6 +7367,13 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
7341
7367
  let { top, perPage, hiddenEmptyTable, appId, relatedLabel, className, columns, sort, filters, visible_on } = ctx;
7342
7368
  // console.log('getRecordDetailRelatedListSchema==>',objectName,recordId,relatedObjectName)
7343
7369
  const relatedObjectUiSchema = await getUISchema(relatedObjectName);
7370
+ if(!relatedObjectUiSchema){
7371
+ // 子表对象不存在时直接返回空值.
7372
+ return {
7373
+ uiSchema: {},
7374
+ amisSchema: {}
7375
+ }
7376
+ }
7344
7377
  const { label , fields } = relatedObjectUiSchema;
7345
7378
  if(!relatedLabel){
7346
7379
  relatedLabel = label;