@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.
@@ -54141,7 +54141,7 @@ function getNameTpl(field, ctx){
54141
54141
  if(ctx && ctx.isLookup){
54142
54142
  linkTarget = "target='_blank'";
54143
54143
  }
54144
- if(ctx.isRelated){
54144
+ if(ctx.isRelated && window.innerWidth >= 768){
54145
54145
  return `<a href="${href}" ${linkTarget} onclick="return false;">\${${field.name} | raw}</a>`
54146
54146
  }else {
54147
54147
  return `<a href="${href}" ${linkTarget}>\${${field.name} | raw}</a>`
@@ -54199,7 +54199,7 @@ function getRelatedFieldTpl(field, ctx){
54199
54199
  const href = Router.getObjectDetailPath({
54200
54200
  formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
54201
54201
  });
54202
- if(ctx.isRelated){
54202
+ if(ctx.isRelated && window.innerWidth >= 768){
54203
54203
  labelTpl = `<a href="${href}" ${linkTarget} onclick="return false;">${labelTpl}</a>`;
54204
54204
  }else {
54205
54205
  labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
@@ -55624,7 +55624,7 @@ async function getTableColumns(fields, options){
55624
55624
  columnItem.defaultColor = null;
55625
55625
  }
55626
55626
 
55627
- 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){
55627
+ 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){
55628
55628
 
55629
55629
  const drawerRecordDetailSchema = {
55630
55630
  "type": "steedos-record-detail",
@@ -55652,16 +55652,17 @@ async function getTableColumns(fields, options){
55652
55652
  "drawer": {
55653
55653
  "type": "drawer",
55654
55654
  "title": "&nbsp;",
55655
- "headerClassName": "",
55655
+ "headerClassName": "hidden",
55656
55656
  "size": "lg",
55657
- "bodyClassName": "p-0 m-0 border-t",
55657
+ "bodyClassName": "p-0 m-0",
55658
55658
  "closeOnEsc": true,
55659
+ "closeOnOutside": true,
55659
55660
  "resizable": true,
55660
55661
  "actions": [],
55661
55662
  "body": [
55662
55663
  drawerRecordDetailSchema
55663
55664
  ],
55664
- "className": "app-popover",
55665
+ "className": "steedos-record-detail-drawer app-popover",
55665
55666
  "id": "u:fc5f055afa8c"
55666
55667
  },
55667
55668
  "preventDefault": true
@@ -55719,7 +55720,7 @@ function getMobileLines(tpls){
55719
55720
  let isNewLine = false;
55720
55721
  let isLeft = true;
55721
55722
  let lineChildrenClassName = "";
55722
- let lineClassName = "flex items-center justify-between";
55723
+ let lineClassName = "flex items-center justify-between mb-1";
55723
55724
  tpls.forEach(function(item){
55724
55725
  if(isNewLine && lines.length < maxLineCount){
55725
55726
  lines.push({
@@ -59025,7 +59026,22 @@ if(typeof window != 'undefined'){
59025
59026
  async function getSource(field, ctx) {
59026
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} }"
59027
59028
  const refObjectName = ctx.objectName;
59028
- 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,
59029
59045
  alias: "options",
59030
59046
  filters: "{__filters}"
59031
59047
  });
@@ -59036,7 +59052,8 @@ async function getSource(field, ctx) {
59036
59052
  // });
59037
59053
  // childrenData.query = childrenData.query.replace(/,count\:.+/, "}");
59038
59054
  // data.query = data.query.replace(/}$/, "," + childrenData.query.replace(/{(.+)}/, "$1}"));
59039
- 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,
59040
59057
  alias: "defaultValueOptions",
59041
59058
  filters: "{__options_filters}"
59042
59059
  });
@@ -59103,7 +59120,20 @@ async function getSource(field, ctx) {
59103
59120
  async function getDeferApi(field, ctx) {
59104
59121
  // data.query 最终格式 "{ \toptions:{__object_name}(filters:{__filters}){{__fields}} }"
59105
59122
  const refObjectName = ctx.objectName;
59106
- 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,
59107
59137
  alias: "options",
59108
59138
  // filters: "{__filters}",
59109
59139
  queryOptions: `filters: {__filters}, sort: "{__sort}"`
@@ -59118,8 +59148,6 @@ async function getDeferApi(field, ctx) {
59118
59148
  filters = filters(field);
59119
59149
  }
59120
59150
  data.query = data.query.replace(/,count\:.+/, "}");
59121
- // 字段要根据请求参数动态生成,写死为__fields后续在发送适配器中替换
59122
- data.query = data.query.replace("{_id}", "{{__fields}}");
59123
59151
  const requestAdaptor = `
59124
59152
  var dep = api.query.dep;
59125
59153
  var term = api.query.term;
@@ -59129,11 +59157,10 @@ async function getDeferApi(field, ctx) {
59129
59157
  var sort = "";
59130
59158
  if (dep) {
59131
59159
  objectName = "${refObjectName}";
59132
- fields = "_id,value:${ctx.valueField},label:${ctx.labelField},children";
59133
59160
  filters = [['parent', '=', dep]];
59134
59161
  sort = "${ctx.sort}";
59135
59162
  }
59136
- 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());
59137
59164
  return api;
59138
59165
  `;
59139
59166
  const adaptor = `
@@ -59487,6 +59514,18 @@ async function lookupToAmisPicker(field, readonly, ctx){
59487
59514
  }
59488
59515
  });
59489
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
+
59490
59529
  lodash.exports.each(refObjectConfig.fields, function (field) {
59491
59530
  if(isFieldQuickSearchable(field, refObjectConfig.NAME_FIELD_KEY)){
59492
59531
  searchableFields.push(field.name);
@@ -59918,22 +59957,31 @@ async function lookupToAmisSelect(field, readonly, ctx){
59918
59957
 
59919
59958
  let apiInfo;
59920
59959
  let defaultValueOptionsQueryData;
59960
+ const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
59921
59961
  if(referenceTo){
59922
- // 字段值单独走一个请求合并到source的同一个GraphQL接口中
59923
- defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, [
59962
+ let queryFields = [
59924
59963
  Object.assign({}, referenceTo.labelField, {alias: 'label'}),
59925
59964
  Object.assign({}, referenceTo.valueField, {alias: 'value'})
59926
- ], {
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,
59927
59978
  alias: "defaultValueOptions",
59928
59979
  filters: "{__options_filters}",
59929
59980
  count: false
59930
59981
  });
59931
59982
  apiInfo = await getApi({
59932
59983
  name: referenceTo.objectName
59933
- }, null, [
59934
- Object.assign({}, referenceTo.labelField, {alias: 'label'}),
59935
- Object.assign({}, referenceTo.valueField, {alias: 'value'})
59936
- ], {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}"`});
59937
59985
 
59938
59986
  apiInfo.adaptor = `
59939
59987
  const data = payload.data;
@@ -59957,7 +60005,6 @@ async function lookupToAmisSelect(field, readonly, ctx){
59957
60005
  };
59958
60006
  }
59959
60007
 
59960
- const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
59961
60008
  let listView = getLookupListView(refObjectConfig);
59962
60009
 
59963
60010
  let listviewFilter = getListViewFilter(listView);
@@ -60142,6 +60189,33 @@ async function getApi(object, recordId, fields, options){
60142
60189
  }
60143
60190
  }
60144
60191
 
60192
+ async function getAutoFill(field, refObject) {
60193
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
60194
+ if (autoFillMapping && autoFillMapping.length) {
60195
+ let fillMapping = {};
60196
+ // let fieldsForApi = [];
60197
+ autoFillMapping.forEach(function (item) {
60198
+ fillMapping[item.to] = `\${${item.from}}`;
60199
+ // fieldsForApi.push(item.from);
60200
+ });
60201
+ // let api = {
60202
+ // // "url": "/amis/api/mock2/form/autoUpdate?browser=${browser}&version=${version}",
60203
+ // "url": `/api/v1/${refObject.name}/\${${field.name}}?fields=${JSON.stringify(fieldsForApi)}`,
60204
+ // // "responseData": {
60205
+ // // "name": "${name}"
60206
+ // // },
60207
+ // "silent": false
60208
+ // }
60209
+ // return {
60210
+ // fillMapping,
60211
+ // // api
60212
+ // }
60213
+ // 因为autoFill中配置了api的话,在表单初始化(比如新建记录)时并不会触发执行autoFill,所以只能暂时不用api
60214
+ // 给amis报过问题了,见:https://github.com/baidu/amis/issues/9631
60215
+ return fillMapping;
60216
+ }
60217
+ }
60218
+
60145
60219
  async function lookupToAmis(field, readonly, ctx){
60146
60220
  if(!ctx){
60147
60221
  ctx = {};
@@ -60225,6 +60299,10 @@ async function lookupToAmis(field, readonly, ctx){
60225
60299
  amisSchema = lodash.exports.defaultsDeep({}, pageAmisSchema, amisSchema);
60226
60300
  }
60227
60301
  }
60302
+ const autoFill = await getAutoFill(field);
60303
+ if(autoFill){
60304
+ amisSchema.autoFill = autoFill;
60305
+ }
60228
60306
  return amisSchema;
60229
60307
  }
60230
60308
 
@@ -60396,6 +60474,7 @@ const getMarkdownFieldSchema = (field, readonly, ctx)=>{
60396
60474
  {
60397
60475
  "type": "editor",
60398
60476
  "name": field.name,
60477
+ "labelClassName": "none",
60399
60478
  "language": "markdown",
60400
60479
  }
60401
60480
  ]