@steedos-widgets/sortable 3.6.4-beta.1 → 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.
@@ -20446,7 +20446,7 @@
20446
20446
  if(ctx && ctx.isLookup){
20447
20447
  linkTarget = "target='_blank'";
20448
20448
  }
20449
- if(ctx.isRelated){
20449
+ if(ctx.isRelated && window.innerWidth >= 768){
20450
20450
  return `<a href="${href}" ${linkTarget} onclick="return false;">\${${field.name} | raw}</a>`
20451
20451
  }else {
20452
20452
  return `<a href="${href}" ${linkTarget}>\${${field.name} | raw}</a>`
@@ -20504,7 +20504,7 @@
20504
20504
  const href = Router.getObjectDetailPath({
20505
20505
  formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
20506
20506
  });
20507
- if(ctx.isRelated){
20507
+ if(ctx.isRelated && window.innerWidth >= 768){
20508
20508
  labelTpl = `<a href="${href}" ${linkTarget} onclick="return false;">${labelTpl}</a>`;
20509
20509
  }else {
20510
20510
  labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
@@ -21929,7 +21929,7 @@
21929
21929
  columnItem.defaultColor = null;
21930
21930
  }
21931
21931
 
21932
- if(((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){
21932
+ 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){
21933
21933
 
21934
21934
  const drawerRecordDetailSchema = {
21935
21935
  "type": "steedos-record-detail",
@@ -21957,16 +21957,17 @@
21957
21957
  "drawer": {
21958
21958
  "type": "drawer",
21959
21959
  "title": "&nbsp;",
21960
- "headerClassName": "",
21960
+ "headerClassName": "hidden",
21961
21961
  "size": "lg",
21962
- "bodyClassName": "p-0 m-0 border-t",
21962
+ "bodyClassName": "p-0 m-0",
21963
21963
  "closeOnEsc": true,
21964
+ "closeOnOutside": true,
21964
21965
  "resizable": true,
21965
21966
  "actions": [],
21966
21967
  "body": [
21967
21968
  drawerRecordDetailSchema
21968
21969
  ],
21969
- "className": "app-popover",
21970
+ "className": "steedos-record-detail-drawer app-popover",
21970
21971
  "id": "u:fc5f055afa8c"
21971
21972
  },
21972
21973
  "preventDefault": true
@@ -22024,7 +22025,7 @@
22024
22025
  let isNewLine = false;
22025
22026
  let isLeft = true;
22026
22027
  let lineChildrenClassName = "";
22027
- let lineClassName = "flex items-center justify-between";
22028
+ let lineClassName = "flex items-center justify-between mb-1";
22028
22029
  tpls.forEach(function(item){
22029
22030
  if(isNewLine && lines.length < maxLineCount){
22030
22031
  lines.push({
@@ -25330,7 +25331,22 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
25330
25331
  async function getSource(field, ctx) {
25331
25332
  // 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} }"
25332
25333
  const refObjectName = ctx.objectName;
25333
- const data = await getFindQuery({ name: refObjectName }, null, [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }, { name: "children" }], {
25334
+ let optionQueryFields = [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }, { name: "children" }];
25335
+ let defaultOptionQueryFields = optionQueryFields.filter(function (f) { return f.name !== "children" });
25336
+
25337
+ // 把自动填充规则中依赖的字段也加到api请求中
25338
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
25339
+ if (autoFillMapping && autoFillMapping.length) {
25340
+ autoFillMapping.forEach(function (item) {
25341
+ if(item.from !== "children"){
25342
+ optionQueryFields.push({ name: item.from });
25343
+ }
25344
+ defaultOptionQueryFields.push({ name: item.from });
25345
+ });
25346
+ }
25347
+
25348
+ const data = await getFindQuery({ name: refObjectName }, null, optionQueryFields, {
25349
+ expand: false,
25334
25350
  alias: "options",
25335
25351
  filters: "{__filters}"
25336
25352
  });
@@ -25341,7 +25357,8 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
25341
25357
  // });
25342
25358
  // childrenData.query = childrenData.query.replace(/,count\:.+/, "}");
25343
25359
  // data.query = data.query.replace(/}$/, "," + childrenData.query.replace(/{(.+)}/, "$1}"));
25344
- const defaultValueOptionsData = await getFindQuery({ name: refObjectName }, null, [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }], {
25360
+ const defaultValueOptionsData = await getFindQuery({ name: refObjectName }, null, defaultOptionQueryFields, {
25361
+ expand: false,
25345
25362
  alias: "defaultValueOptions",
25346
25363
  filters: "{__options_filters}"
25347
25364
  });
@@ -25408,7 +25425,20 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
25408
25425
  async function getDeferApi(field, ctx) {
25409
25426
  // data.query 最终格式 "{ \toptions:{__object_name}(filters:{__filters}){{__fields}} }"
25410
25427
  const refObjectName = ctx.objectName;
25411
- const data = await getFindQuery({ name: "{__object_name}" }, null, [], {
25428
+ let optionQueryFields = [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }, { name: "children" }];
25429
+
25430
+ // 把自动填充规则中依赖的字段也加到api请求中
25431
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
25432
+ if (autoFillMapping && autoFillMapping.length) {
25433
+ autoFillMapping.forEach(function (item) {
25434
+ if(item.from !== "children"){
25435
+ optionQueryFields.push({ name: item.from });
25436
+ }
25437
+ });
25438
+ }
25439
+
25440
+ const data = await getFindQuery({ name: "{__object_name}" }, null, optionQueryFields, {
25441
+ expand: false,
25412
25442
  alias: "options",
25413
25443
  // filters: "{__filters}",
25414
25444
  queryOptions: `filters: {__filters}, sort: "{__sort}"`
@@ -25423,8 +25453,6 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
25423
25453
  filters = filters(field);
25424
25454
  }
25425
25455
  data.query = data.query.replace(/,count\:.+/, "}");
25426
- // 字段要根据请求参数动态生成,写死为__fields后续在发送适配器中替换
25427
- data.query = data.query.replace("{_id}", "{{__fields}}");
25428
25456
  const requestAdaptor = `
25429
25457
  var dep = api.query.dep;
25430
25458
  var term = api.query.term;
@@ -25434,11 +25462,10 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
25434
25462
  var sort = "";
25435
25463
  if (dep) {
25436
25464
  objectName = "${refObjectName}";
25437
- fields = "_id,value:${ctx.valueField},label:${ctx.labelField},children";
25438
25465
  filters = [['parent', '=', dep]];
25439
25466
  sort = "${ctx.sort}";
25440
25467
  }
25441
- 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());
25468
+ api.data.query = api.data.query.replace(/{__object_name}/g, objectName).replace(/{__filters}/g, JSON.stringify(filters)).replace('{__sort}', sort.trim());
25442
25469
  return api;
25443
25470
  `;
25444
25471
  const adaptor = `
@@ -25792,6 +25819,18 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
25792
25819
  }
25793
25820
  });
25794
25821
 
25822
+ // 把自动填充规则中依赖的字段也加到api请求中
25823
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
25824
+ if (autoFillMapping && autoFillMapping.length) {
25825
+ autoFillMapping.forEach(function (item) {
25826
+ if(!lodash.exports.find(tableFields, function(f){
25827
+ return f.name === item.from
25828
+ })){
25829
+ tableFields.push(refObjectConfig.fields[item.from]);
25830
+ }
25831
+ });
25832
+ }
25833
+
25795
25834
  lodash.exports.each(refObjectConfig.fields, function (field) {
25796
25835
  if(isFieldQuickSearchable(field, refObjectConfig.NAME_FIELD_KEY)){
25797
25836
  searchableFields.push(field.name);
@@ -26223,22 +26262,31 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
26223
26262
 
26224
26263
  let apiInfo;
26225
26264
  let defaultValueOptionsQueryData;
26265
+ const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
26226
26266
  if(referenceTo){
26227
- // 字段值单独走一个请求合并到source的同一个GraphQL接口中
26228
- defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, [
26267
+ let queryFields = [
26229
26268
  Object.assign({}, referenceTo.labelField, {alias: 'label'}),
26230
26269
  Object.assign({}, referenceTo.valueField, {alias: 'value'})
26231
- ], {
26270
+ ];
26271
+
26272
+ // 把自动填充规则中依赖的字段也加到api请求中
26273
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
26274
+ if (autoFillMapping && autoFillMapping.length) {
26275
+ autoFillMapping.forEach(function (item) {
26276
+ queryFields.push(refObjectConfig.fields[item.from]);
26277
+ });
26278
+ }
26279
+
26280
+ // 字段值单独走一个请求合并到source的同一个GraphQL接口中
26281
+ defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, queryFields, {
26282
+ expand: false,
26232
26283
  alias: "defaultValueOptions",
26233
26284
  filters: "{__options_filters}",
26234
26285
  count: false
26235
26286
  });
26236
26287
  apiInfo = await getApi({
26237
26288
  name: referenceTo.objectName
26238
- }, null, [
26239
- Object.assign({}, referenceTo.labelField, {alias: 'label'}),
26240
- Object.assign({}, referenceTo.valueField, {alias: 'value'})
26241
- ], {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"`});
26289
+ }, null, queryFields, {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"`});
26242
26290
 
26243
26291
  apiInfo.adaptor = `
26244
26292
  const data = payload.data;
@@ -26262,7 +26310,6 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
26262
26310
  };
26263
26311
  }
26264
26312
 
26265
- const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
26266
26313
  let listView = getLookupListView(refObjectConfig);
26267
26314
 
26268
26315
  let listviewFilter = getListViewFilter(listView);
@@ -26447,6 +26494,33 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
26447
26494
  }
26448
26495
  }
26449
26496
 
26497
+ async function getAutoFill(field, refObject) {
26498
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
26499
+ if (autoFillMapping && autoFillMapping.length) {
26500
+ let fillMapping = {};
26501
+ // let fieldsForApi = [];
26502
+ autoFillMapping.forEach(function (item) {
26503
+ fillMapping[item.to] = `\${${item.from}}`;
26504
+ // fieldsForApi.push(item.from);
26505
+ });
26506
+ // let api = {
26507
+ // // "url": "/amis/api/mock2/form/autoUpdate?browser=${browser}&version=${version}",
26508
+ // "url": `/api/v1/${refObject.name}/\${${field.name}}?fields=${JSON.stringify(fieldsForApi)}`,
26509
+ // // "responseData": {
26510
+ // // "name": "${name}"
26511
+ // // },
26512
+ // "silent": false
26513
+ // }
26514
+ // return {
26515
+ // fillMapping,
26516
+ // // api
26517
+ // }
26518
+ // 因为autoFill中配置了api的话,在表单初始化(比如新建记录)时并不会触发执行autoFill,所以只能暂时不用api
26519
+ // 给amis报过问题了,见:https://github.com/baidu/amis/issues/9631
26520
+ return fillMapping;
26521
+ }
26522
+ }
26523
+
26450
26524
  async function lookupToAmis(field, readonly, ctx){
26451
26525
  if(!ctx){
26452
26526
  ctx = {};
@@ -26530,6 +26604,10 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
26530
26604
  amisSchema = lodash.exports.defaultsDeep({}, pageAmisSchema, amisSchema);
26531
26605
  }
26532
26606
  }
26607
+ const autoFill = await getAutoFill(field);
26608
+ if(autoFill){
26609
+ amisSchema.autoFill = autoFill;
26610
+ }
26533
26611
  return amisSchema;
26534
26612
  }
26535
26613
 
@@ -26701,6 +26779,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
26701
26779
  {
26702
26780
  "type": "editor",
26703
26781
  "name": field.name,
26782
+ "labelClassName": "none",
26704
26783
  "language": "markdown",
26705
26784
  }
26706
26785
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos-widgets/sortable",
3
- "version": "3.6.4-beta.1",
3
+ "version": "3.6.4-beta.3",
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.1"
48
+ "@steedos-widgets/amis-lib": "3.6.4-beta.3"
49
49
  },
50
- "gitHead": "4845f0b33367b8873df484ef174863d6789d4d43"
50
+ "gitHead": "f33eb2d6fa30e93496e57d81c6c28a8575377e73"
51
51
  }