@steedos-widgets/sortable 3.6.4-beta.2 → 3.6.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.
@@ -59026,7 +59026,22 @@ if(typeof window != 'undefined'){
59026
59026
  async function getSource(field, ctx) {
59027
59027
  // 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} }"
59028
59028
  const refObjectName = ctx.objectName;
59029
- const data = await getFindQuery({ name: refObjectName }, null, [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }, { name: "children" }], {
59029
+ let optionQueryFields = [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }, { name: "children" }];
59030
+ let defaultOptionQueryFields = optionQueryFields.filter(function (f) { return f.name !== "children" });
59031
+
59032
+ // 把自动填充规则中依赖的字段也加到api请求中
59033
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
59034
+ if (autoFillMapping && autoFillMapping.length) {
59035
+ autoFillMapping.forEach(function (item) {
59036
+ if(item.from !== "children"){
59037
+ optionQueryFields.push({ name: item.from });
59038
+ }
59039
+ defaultOptionQueryFields.push({ name: item.from });
59040
+ });
59041
+ }
59042
+
59043
+ const data = await getFindQuery({ name: refObjectName }, null, optionQueryFields, {
59044
+ expand: false,
59030
59045
  alias: "options",
59031
59046
  filters: "{__filters}"
59032
59047
  });
@@ -59037,7 +59052,8 @@ async function getSource(field, ctx) {
59037
59052
  // });
59038
59053
  // childrenData.query = childrenData.query.replace(/,count\:.+/, "}");
59039
59054
  // data.query = data.query.replace(/}$/, "," + childrenData.query.replace(/{(.+)}/, "$1}"));
59040
- const defaultValueOptionsData = await getFindQuery({ name: refObjectName }, null, [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }], {
59055
+ const defaultValueOptionsData = await getFindQuery({ name: refObjectName }, null, defaultOptionQueryFields, {
59056
+ expand: false,
59041
59057
  alias: "defaultValueOptions",
59042
59058
  filters: "{__options_filters}"
59043
59059
  });
@@ -59104,7 +59120,20 @@ async function getSource(field, ctx) {
59104
59120
  async function getDeferApi(field, ctx) {
59105
59121
  // data.query 最终格式 "{ \toptions:{__object_name}(filters:{__filters}){{__fields}} }"
59106
59122
  const refObjectName = ctx.objectName;
59107
- const data = await getFindQuery({ name: "{__object_name}" }, null, [], {
59123
+ let optionQueryFields = [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }, { name: "children" }];
59124
+
59125
+ // 把自动填充规则中依赖的字段也加到api请求中
59126
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
59127
+ if (autoFillMapping && autoFillMapping.length) {
59128
+ autoFillMapping.forEach(function (item) {
59129
+ if(item.from !== "children"){
59130
+ optionQueryFields.push({ name: item.from });
59131
+ }
59132
+ });
59133
+ }
59134
+
59135
+ const data = await getFindQuery({ name: "{__object_name}" }, null, optionQueryFields, {
59136
+ expand: false,
59108
59137
  alias: "options",
59109
59138
  // filters: "{__filters}",
59110
59139
  queryOptions: `filters: {__filters}, sort: "{__sort}"`
@@ -59119,8 +59148,6 @@ async function getDeferApi(field, ctx) {
59119
59148
  filters = filters(field);
59120
59149
  }
59121
59150
  data.query = data.query.replace(/,count\:.+/, "}");
59122
- // 字段要根据请求参数动态生成,写死为__fields后续在发送适配器中替换
59123
- data.query = data.query.replace("{_id}", "{{__fields}}");
59124
59151
  const requestAdaptor = `
59125
59152
  var dep = api.query.dep;
59126
59153
  var term = api.query.term;
@@ -59130,11 +59157,10 @@ async function getDeferApi(field, ctx) {
59130
59157
  var sort = "";
59131
59158
  if (dep) {
59132
59159
  objectName = "${refObjectName}";
59133
- fields = "_id,value:${ctx.valueField},label:${ctx.labelField},children";
59134
59160
  filters = [['parent', '=', dep]];
59135
59161
  sort = "${ctx.sort}";
59136
59162
  }
59137
- api.data.query = api.data.query.replace(/{__object_name}/g, objectName).replace(/{__fields}/g, fields).replace(/{__filters}/g, JSON.stringify(filters)).replace('{__sort}', sort.trim());
59163
+ api.data.query = api.data.query.replace(/{__object_name}/g, objectName).replace(/{__filters}/g, JSON.stringify(filters)).replace('{__sort}', sort.trim());
59138
59164
  return api;
59139
59165
  `;
59140
59166
  const adaptor = `
@@ -59488,6 +59514,18 @@ async function lookupToAmisPicker(field, readonly, ctx){
59488
59514
  }
59489
59515
  });
59490
59516
 
59517
+ // 把自动填充规则中依赖的字段也加到api请求中
59518
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
59519
+ if (autoFillMapping && autoFillMapping.length) {
59520
+ autoFillMapping.forEach(function (item) {
59521
+ if(!lodash.exports.find(tableFields, function(f){
59522
+ return f.name === item.from
59523
+ })){
59524
+ tableFields.push(refObjectConfig.fields[item.from]);
59525
+ }
59526
+ });
59527
+ }
59528
+
59491
59529
  lodash.exports.each(refObjectConfig.fields, function (field) {
59492
59530
  if(isFieldQuickSearchable(field, refObjectConfig.NAME_FIELD_KEY)){
59493
59531
  searchableFields.push(field.name);
@@ -59919,22 +59957,31 @@ async function lookupToAmisSelect(field, readonly, ctx){
59919
59957
 
59920
59958
  let apiInfo;
59921
59959
  let defaultValueOptionsQueryData;
59960
+ const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
59922
59961
  if(referenceTo){
59923
- // 字段值单独走一个请求合并到source的同一个GraphQL接口中
59924
- defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, [
59962
+ let queryFields = [
59925
59963
  Object.assign({}, referenceTo.labelField, {alias: 'label'}),
59926
59964
  Object.assign({}, referenceTo.valueField, {alias: 'value'})
59927
- ], {
59965
+ ];
59966
+
59967
+ // 把自动填充规则中依赖的字段也加到api请求中
59968
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
59969
+ if (autoFillMapping && autoFillMapping.length) {
59970
+ autoFillMapping.forEach(function (item) {
59971
+ queryFields.push(refObjectConfig.fields[item.from]);
59972
+ });
59973
+ }
59974
+
59975
+ // 字段值单独走一个请求合并到source的同一个GraphQL接口中
59976
+ defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, queryFields, {
59977
+ expand: false,
59928
59978
  alias: "defaultValueOptions",
59929
59979
  filters: "{__options_filters}",
59930
59980
  count: false
59931
59981
  });
59932
59982
  apiInfo = await getApi({
59933
59983
  name: referenceTo.objectName
59934
- }, null, [
59935
- Object.assign({}, referenceTo.labelField, {alias: 'label'}),
59936
- Object.assign({}, referenceTo.valueField, {alias: 'value'})
59937
- ], {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"`});
59984
+ }, null, queryFields, {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"`});
59938
59985
 
59939
59986
  apiInfo.adaptor = `
59940
59987
  const data = payload.data;
@@ -59958,7 +60005,6 @@ async function lookupToAmisSelect(field, readonly, ctx){
59958
60005
  };
59959
60006
  }
59960
60007
 
59961
- const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
59962
60008
  let listView = getLookupListView(refObjectConfig);
59963
60009
 
59964
60010
  let listviewFilter = getListViewFilter(listView);
@@ -60144,13 +60190,13 @@ async function getApi(object, recordId, fields, options){
60144
60190
  }
60145
60191
 
60146
60192
  async function getAutoFill(field, refObject) {
60147
- let autoFillMapping = field.auto_fill_mapping;
60193
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
60148
60194
  if (autoFillMapping && autoFillMapping.length) {
60149
60195
  let fillMapping = {};
60150
- let fieldsForApi = [];
60196
+ // let fieldsForApi = [];
60151
60197
  autoFillMapping.forEach(function (item) {
60152
60198
  fillMapping[item.to] = `\${${item.from}}`;
60153
- fieldsForApi.push(item.from);
60199
+ // fieldsForApi.push(item.from);
60154
60200
  });
60155
60201
  // let api = {
60156
60202
  // // "url": "/amis/api/mock2/form/autoUpdate?browser=${browser}&version=${version}",