@steedos-widgets/sortable 3.6.4-beta.2 → 3.6.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.
@@ -21297,7 +21297,8 @@
21297
21297
  }
21298
21298
  });
21299
21299
 
21300
- async function getQuickEditSchema(field, options){
21300
+ async function getQuickEditSchema(object, columnField, options){
21301
+ let field = object.fields[columnField.name];
21301
21302
  //判断在amis3.2以上环境下,放开批量编辑与lookup的单元格编辑
21302
21303
  let isAmisVersionforBatchEdit = false;
21303
21304
  if(window.amisRequire && window.amisRequire('amis')){
@@ -21765,7 +21766,7 @@
21765
21766
  }
21766
21767
  }
21767
21768
 
21768
- async function getTableColumns(fields, options){
21769
+ async function getTableColumns(object, fields, options){
21769
21770
  const columns = [];
21770
21771
  if(!options.isLookup && !options.isInputTable){
21771
21772
  if(!options.enable_tree){
@@ -21779,7 +21780,7 @@
21779
21780
  continue;
21780
21781
  }
21781
21782
  //增加quickEdit属性,实现快速编辑
21782
- const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
21783
+ const quickEditSchema = allowEdit ? await getQuickEditSchema(object, field, options) : allowEdit;
21783
21784
  let className = "";
21784
21785
  const bowserType = getBowserType();
21785
21786
  if(bowserType === "Safari"){
@@ -22351,7 +22352,7 @@
22351
22352
  return card;
22352
22353
  }
22353
22354
 
22354
- async function getTableSchema$1(fields, options){
22355
+ async function getTableSchema$1(object, fields, options){
22355
22356
  if(!options){
22356
22357
  options = {};
22357
22358
  }
@@ -22373,7 +22374,7 @@
22373
22374
  columns = await getMobileTableColumns(fields, options);
22374
22375
  }
22375
22376
  else {
22376
- columns = await getTableColumns(fields, options);
22377
+ columns = await getTableColumns(object, fields, options);
22377
22378
 
22378
22379
  if(listSchema.mode === "cards"){
22379
22380
  let card = listSchema.card;
@@ -25008,8 +25009,8 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
25008
25009
  /*
25009
25010
  * @Author: baozhoutao@steedos.com
25010
25011
  * @Date: 2022-07-05 15:55:39
25011
- * @LastEditors: baozhoutao@steedos.com
25012
- * @LastEditTime: 2024-02-18 16:05:21
25012
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
25013
+ * @LastEditTime: 2024-02-23 16:37:06
25013
25014
  * @Description:
25014
25015
  */
25015
25016
 
@@ -25331,7 +25332,22 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
25331
25332
  async function getSource(field, ctx) {
25332
25333
  // 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} }"
25333
25334
  const refObjectName = ctx.objectName;
25334
- const data = await getFindQuery({ name: refObjectName }, null, [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }, { name: "children" }], {
25335
+ let optionQueryFields = [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }, { name: "children" }];
25336
+ let defaultOptionQueryFields = optionQueryFields.filter(function (f) { return f.name !== "children" });
25337
+
25338
+ // 把自动填充规则中依赖的字段也加到api请求中
25339
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
25340
+ if (autoFillMapping && autoFillMapping.length) {
25341
+ autoFillMapping.forEach(function (item) {
25342
+ if(item.from !== "children"){
25343
+ optionQueryFields.push({ name: item.from });
25344
+ }
25345
+ defaultOptionQueryFields.push({ name: item.from });
25346
+ });
25347
+ }
25348
+
25349
+ const data = await getFindQuery({ name: refObjectName }, null, optionQueryFields, {
25350
+ expand: false,
25335
25351
  alias: "options",
25336
25352
  filters: "{__filters}"
25337
25353
  });
@@ -25342,7 +25358,8 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
25342
25358
  // });
25343
25359
  // childrenData.query = childrenData.query.replace(/,count\:.+/, "}");
25344
25360
  // data.query = data.query.replace(/}$/, "," + childrenData.query.replace(/{(.+)}/, "$1}"));
25345
- const defaultValueOptionsData = await getFindQuery({ name: refObjectName }, null, [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }], {
25361
+ const defaultValueOptionsData = await getFindQuery({ name: refObjectName }, null, defaultOptionQueryFields, {
25362
+ expand: false,
25346
25363
  alias: "defaultValueOptions",
25347
25364
  filters: "{__options_filters}"
25348
25365
  });
@@ -25409,7 +25426,20 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
25409
25426
  async function getDeferApi(field, ctx) {
25410
25427
  // data.query 最终格式 "{ \toptions:{__object_name}(filters:{__filters}){{__fields}} }"
25411
25428
  const refObjectName = ctx.objectName;
25412
- const data = await getFindQuery({ name: "{__object_name}" }, null, [], {
25429
+ let optionQueryFields = [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }, { name: "children" }];
25430
+
25431
+ // 把自动填充规则中依赖的字段也加到api请求中
25432
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
25433
+ if (autoFillMapping && autoFillMapping.length) {
25434
+ autoFillMapping.forEach(function (item) {
25435
+ if(item.from !== "children"){
25436
+ optionQueryFields.push({ name: item.from });
25437
+ }
25438
+ });
25439
+ }
25440
+
25441
+ const data = await getFindQuery({ name: "{__object_name}" }, null, optionQueryFields, {
25442
+ expand: false,
25413
25443
  alias: "options",
25414
25444
  // filters: "{__filters}",
25415
25445
  queryOptions: `filters: {__filters}, sort: "{__sort}"`
@@ -25424,8 +25454,6 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
25424
25454
  filters = filters(field);
25425
25455
  }
25426
25456
  data.query = data.query.replace(/,count\:.+/, "}");
25427
- // 字段要根据请求参数动态生成,写死为__fields后续在发送适配器中替换
25428
- data.query = data.query.replace("{_id}", "{{__fields}}");
25429
25457
  const requestAdaptor = `
25430
25458
  var dep = api.query.dep;
25431
25459
  var term = api.query.term;
@@ -25435,11 +25463,10 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
25435
25463
  var sort = "";
25436
25464
  if (dep) {
25437
25465
  objectName = "${refObjectName}";
25438
- fields = "_id,value:${ctx.valueField},label:${ctx.labelField},children";
25439
25466
  filters = [['parent', '=', dep]];
25440
25467
  sort = "${ctx.sort}";
25441
25468
  }
25442
- 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());
25469
+ api.data.query = api.data.query.replace(/{__object_name}/g, objectName).replace(/{__filters}/g, JSON.stringify(filters)).replace('{__sort}', sort.trim());
25443
25470
  return api;
25444
25471
  `;
25445
25472
  const adaptor = `
@@ -25793,6 +25820,18 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
25793
25820
  }
25794
25821
  });
25795
25822
 
25823
+ // 把自动填充规则中依赖的字段也加到api请求中
25824
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
25825
+ if (autoFillMapping && autoFillMapping.length) {
25826
+ autoFillMapping.forEach(function (item) {
25827
+ if(!lodash.exports.find(tableFields, function(f){
25828
+ return f.name === item.from
25829
+ })){
25830
+ tableFields.push(refObjectConfig.fields[item.from]);
25831
+ }
25832
+ });
25833
+ }
25834
+
25796
25835
  lodash.exports.each(refObjectConfig.fields, function (field) {
25797
25836
  if(isFieldQuickSearchable(field, refObjectConfig.NAME_FIELD_KEY)){
25798
25837
  searchableFields.push(field.name);
@@ -26049,7 +26088,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
26049
26088
  if(refObjectConfig.name === 'organizations'){
26050
26089
  labelFieldName = 'name';
26051
26090
  }
26052
- pickerSchema = await getTableSchema$1(tableFields, {
26091
+ pickerSchema = await getTableSchema$1(refObjectConfig, tableFields, {
26053
26092
  labelFieldName,
26054
26093
  top: top,
26055
26094
  isLookup: true,
@@ -26224,22 +26263,31 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
26224
26263
 
26225
26264
  let apiInfo;
26226
26265
  let defaultValueOptionsQueryData;
26266
+ const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
26227
26267
  if(referenceTo){
26228
- // 字段值单独走一个请求合并到source的同一个GraphQL接口中
26229
- defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, [
26268
+ let queryFields = [
26230
26269
  Object.assign({}, referenceTo.labelField, {alias: 'label'}),
26231
26270
  Object.assign({}, referenceTo.valueField, {alias: 'value'})
26232
- ], {
26271
+ ];
26272
+
26273
+ // 把自动填充规则中依赖的字段也加到api请求中
26274
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
26275
+ if (autoFillMapping && autoFillMapping.length) {
26276
+ autoFillMapping.forEach(function (item) {
26277
+ queryFields.push(refObjectConfig.fields[item.from]);
26278
+ });
26279
+ }
26280
+
26281
+ // 字段值单独走一个请求合并到source的同一个GraphQL接口中
26282
+ defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, queryFields, {
26283
+ expand: false,
26233
26284
  alias: "defaultValueOptions",
26234
26285
  filters: "{__options_filters}",
26235
26286
  count: false
26236
26287
  });
26237
26288
  apiInfo = await getApi({
26238
26289
  name: referenceTo.objectName
26239
- }, null, [
26240
- Object.assign({}, referenceTo.labelField, {alias: 'label'}),
26241
- Object.assign({}, referenceTo.valueField, {alias: 'value'})
26242
- ], {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"`});
26290
+ }, null, queryFields, {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"`});
26243
26291
 
26244
26292
  apiInfo.adaptor = `
26245
26293
  const data = payload.data;
@@ -26263,7 +26311,6 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
26263
26311
  };
26264
26312
  }
26265
26313
 
26266
- const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
26267
26314
  let listView = getLookupListView(refObjectConfig);
26268
26315
 
26269
26316
  let listviewFilter = getListViewFilter(listView);
@@ -26449,13 +26496,13 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
26449
26496
  }
26450
26497
 
26451
26498
  async function getAutoFill(field, refObject) {
26452
- let autoFillMapping = field.auto_fill_mapping;
26499
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
26453
26500
  if (autoFillMapping && autoFillMapping.length) {
26454
26501
  let fillMapping = {};
26455
- let fieldsForApi = [];
26502
+ // let fieldsForApi = [];
26456
26503
  autoFillMapping.forEach(function (item) {
26457
26504
  fillMapping[item.to] = `\${${item.from}}`;
26458
- fieldsForApi.push(item.from);
26505
+ // fieldsForApi.push(item.from);
26459
26506
  });
26460
26507
  // let api = {
26461
26508
  // // "url": "/amis/api/mock2/form/autoUpdate?browser=${browser}&version=${version}",
@@ -26645,7 +26692,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
26645
26692
  actions: false
26646
26693
  });
26647
26694
  }else {
26648
- pickerSchema = await getTableSchema$1(tableFields, {
26695
+ pickerSchema = await getTableSchema$1(refObjectConfig, tableFields, {
26649
26696
  labelFieldName: refObjectConfig.NAME_FIELD_KEY,
26650
26697
  top: top,
26651
26698
  isLookup: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos-widgets/sortable",
3
- "version": "3.6.4-beta.2",
3
+ "version": "3.6.4-beta.4",
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.4-beta.2"
48
+ "@steedos-widgets/amis-lib": "3.6.4-beta.4"
49
49
  },
50
- "gitHead": "74e7975b7f134d1192dea186f90e0a1c6c11275c"
50
+ "gitHead": "68fe9858b14e597c08872caa7057c23ffc254573"
51
51
  }