@steedos-widgets/amis-lib 1.2.34 → 1.2.35-beta.2

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.cjs.js CHANGED
@@ -426,8 +426,8 @@ function getContrastColor(bgColor) {
426
426
  /*
427
427
  * @Author: baozhoutao@steedos.com
428
428
  * @Date: 2022-05-23 09:53:08
429
- * @LastEditors: Please set LastEditors
430
- * @LastEditTime: 2023-05-22 15:13:18
429
+ * @LastEditors: liaodaxue
430
+ * @LastEditTime: 2023-07-28 16:26:31
431
431
  * @Description:
432
432
  */
433
433
 
@@ -611,6 +611,9 @@ function getPasswordTpl(field){
611
611
  <% } %>`
612
612
  }
613
613
 
614
+ function getLocationTpl(field){
615
+ return `\${${field.name} ? ${field.name}.address : ''}`
616
+ }
614
617
 
615
618
  async function getFieldTpl (field, options){
616
619
  if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLabel){
@@ -635,6 +638,8 @@ async function getFieldTpl (field, options){
635
638
  return await getRelatedFieldTpl(field, options);
636
639
  case 'master_detail':
637
640
  return await getRelatedFieldTpl(field, options);
641
+ case 'location':
642
+ return await getLocationTpl(field);
638
643
  case 'number':
639
644
  case 'currency':
640
645
  return await getNumberTpl(field);
@@ -647,9 +652,10 @@ async function getFieldTpl (field, options){
647
652
  }
648
653
  }
649
654
 
650
- async function getFieldsTemplate(fields, expand){
651
- if(expand != false){
652
- expand = true;
655
+ async function getFieldsTemplate(fields, display){
656
+ let expandFields = [];
657
+ if(display != false){
658
+ display = true;
653
659
  }
654
660
  let fieldsName = ['_id'];
655
661
  let displayFields = [];
@@ -661,33 +667,43 @@ async function getFieldsTemplate(fields, expand){
661
667
  }
662
668
  for (const field of fieldsArr) {
663
669
  //graphql 的 ui\display 中使用的字段需要先在query中查询. 否则会返回null
664
- if(field.name.indexOf('.') < 0){
665
- if(expand && (field.type == 'lookup' || field.type == 'master_detail')){
666
- fieldsName.push(`${field.name}`);
667
- displayFields.push(`${field.name}`);
670
+ if(field.expand){
671
+ expandFields.push(field);
672
+ }else {
673
+ if(field.name.indexOf('.') < 0){
674
+ if(display && (field.type == 'lookup' || field.type == 'master_detail')){
675
+ fieldsName.push(`${field.name}`);
676
+ displayFields.push(`${field.name}`);
677
+ }else {
678
+ fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
679
+ }
680
+ if(_$1.includes(['time','date','datetime','boolean','number','currency'], field.type)){
681
+ fieldsName.push(`${field.name}`);
682
+ }
683
+ if(_$1.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
684
+ displayFields.push(`${field.name}`);
685
+ }
668
686
  }else {
669
- fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
670
- }
671
- if(_$1.includes(['time','date','datetime','boolean','number','currency'], field.type)){
672
- fieldsName.push(`${field.name}`);
687
+ objectFieldName = field.name.split('.')[0];
688
+ fieldsName.push(objectFieldName);
689
+ displayFields.push(objectFieldName);
673
690
  }
674
- if(_$1.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
675
- displayFields.push(`${field.name}`);
676
- }
677
- }else {
678
- objectFieldName = field.name.split('.')[0];
679
- fieldsName.push(objectFieldName);
680
- displayFields.push(objectFieldName);
681
691
  }
682
692
  }
683
693
 
684
694
  displayFields = ___namespace.uniq(displayFields);
685
695
  fieldsName = ___namespace.uniq(fieldsName);
696
+ let expandFieldsQuery = "";
697
+ if(expandFields.length > 0){
698
+ ___namespace.each(expandFields, function(field){
699
+ expandFieldsQuery = expandFieldsQuery + `${field.expandInfo.fieldName}:${field.expandInfo.fieldName}__expand{${field.expandInfo.displayName}}`;
700
+ });
701
+ }
686
702
 
687
703
  if(displayFields.length > 0){
688
- return `${fieldsName.join(',')},_display:_ui{${displayFields.join(',')}}`;
704
+ return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
689
705
  }
690
- return `${fieldsName.join(' ')}`
706
+ return `${fieldsName.join(' ')},${expandFieldsQuery}`
691
707
  }
692
708
 
693
709
  function getRecordPermissionsTemplate(){
@@ -977,6 +993,7 @@ var frontend_form_save_and_new$1 = "Save and New";
977
993
  var frontend_form_cancel$1 = "Cancel";
978
994
  var frontend_form_new$1 = "New";
979
995
  var frontend_form_edit$1 = "Edit";
996
+ var frontend_form_preview$1 = "Preview";
980
997
  var frontend_form_select$1 = "Select";
981
998
  var frontend_form_please_select$1 = "Please select";
982
999
  var frontend_form_confirm$1 = "Confirm";
@@ -1059,6 +1076,7 @@ var en_us = {
1059
1076
  frontend_form_cancel: frontend_form_cancel$1,
1060
1077
  frontend_form_new: frontend_form_new$1,
1061
1078
  frontend_form_edit: frontend_form_edit$1,
1079
+ frontend_form_preview: frontend_form_preview$1,
1062
1080
  frontend_form_select: frontend_form_select$1,
1063
1081
  frontend_form_please_select: frontend_form_please_select$1,
1064
1082
  frontend_form_confirm: frontend_form_confirm$1,
@@ -1142,6 +1160,7 @@ var frontend_form_save_and_new = "保存并新建";
1142
1160
  var frontend_form_cancel = "取消";
1143
1161
  var frontend_form_new = "新建";
1144
1162
  var frontend_form_edit = "编辑";
1163
+ var frontend_form_preview = "预览";
1145
1164
  var frontend_form_select = "选择";
1146
1165
  var frontend_form_please_select = "请选择";
1147
1166
  var frontend_form_confirm = "确认";
@@ -1225,6 +1244,7 @@ var zh_cn = {
1225
1244
  frontend_form_cancel: frontend_form_cancel,
1226
1245
  frontend_form_new: frontend_form_new,
1227
1246
  frontend_form_edit: frontend_form_edit,
1247
+ frontend_form_preview: frontend_form_preview,
1228
1248
  frontend_form_select: frontend_form_select,
1229
1249
  frontend_form_please_select: frontend_form_please_select,
1230
1250
  frontend_form_confirm: frontend_form_confirm,
@@ -6487,11 +6507,10 @@ async function getIdsPickerSchema(field, readonly, ctx){
6487
6507
  * @Author: baozhoutao@steedos.com
6488
6508
  * @Date: 2023-01-13 17:27:54
6489
6509
  * @LastEditors: liaodaxue
6490
- * @LastEditTime: 2023-07-24 15:23:12
6510
+ * @LastEditTime: 2023-07-27 17:33:54
6491
6511
  * @Description:
6492
6512
  */
6493
6513
 
6494
-
6495
6514
  const getMarkdownFieldSchema = (field, readonly, ctx)=>{
6496
6515
  if(readonly){
6497
6516
  return {
@@ -6518,7 +6537,7 @@ const getMarkdownFieldSchema = (field, readonly, ctx)=>{
6518
6537
  "className": "steedos-markdown",
6519
6538
  "tabs": [
6520
6539
  {
6521
- "title": "Write",
6540
+ "title": i18next__default["default"].t('frontend_form_edit'),
6522
6541
  "tab": [
6523
6542
  {
6524
6543
  "type": "editor",
@@ -6528,7 +6547,7 @@ const getMarkdownFieldSchema = (field, readonly, ctx)=>{
6528
6547
  ]
6529
6548
  },
6530
6549
  {
6531
- "title": "Preview",
6550
+ "title": i18next__default["default"].t('frontend_form_preview'),
6532
6551
  "tab": [
6533
6552
  {
6534
6553
  "type": "markdown",
@@ -6585,7 +6604,7 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
6585
6604
  * @Author: baozhoutao@steedos.com
6586
6605
  * @Date: 2022-10-28 14:52:55
6587
6606
  * @LastEditors: liaodaxue
6588
- * @LastEditTime: 2023-07-14 17:18:42
6607
+ * @LastEditTime: 2023-07-28 16:16:29
6589
6608
  * @Description:
6590
6609
  */
6591
6610
 
@@ -6609,6 +6628,8 @@ function getAmisStaticFieldType(type, readonly, options){
6609
6628
  if(!readonly){
6610
6629
  if(___namespace.includes(AmisFormInputs, type)){
6611
6630
  return `input-${type}`;
6631
+ }else if(type === 'location'){
6632
+ return "location-picker"
6612
6633
  }
6613
6634
  return type;
6614
6635
  }
@@ -7166,6 +7187,30 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
7166
7187
  type: getAmisStaticFieldType('email', readonly)
7167
7188
  };
7168
7189
  break;
7190
+ case 'location':
7191
+ // 申请ak后需要设置白名单; https://lbsyun.baidu.com/apiconsole/key/create#/home
7192
+ // console.log('fie==>', field.name, field);
7193
+ let ak = "LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7";
7194
+ let vendor = "baidu"; /* 'baidu' | 'gaode' */
7195
+ if(window.Meteor){
7196
+ const map_ak = Meteor.settings?.public?.amis?.map_ak;
7197
+ if(map_ak){
7198
+ ak = map_ak;
7199
+ }
7200
+ const map_vendor = Meteor.settings?.public?.amis?.map_vendor;
7201
+ if(map_vendor){
7202
+ vendor = map_vendor;
7203
+ }
7204
+ }
7205
+
7206
+ convertData = {
7207
+ type: getAmisStaticFieldType('location', readonly),
7208
+ tpl: readonly ? getLocationTpl(field) : null,
7209
+ ak,
7210
+ vendor,
7211
+ label: field.label
7212
+ };
7213
+ break;
7169
7214
  case 'avatar':
7170
7215
  convertData = getAmisFileSchema(field, readonly);
7171
7216
  break;
@@ -7657,6 +7702,10 @@ async function getTableColumns(fields, options){
7657
7702
  for (const field of fields) {
7658
7703
  //增加quickEdit属性,实现快速编辑
7659
7704
  const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
7705
+ let className = "";
7706
+ if(field.wrap != true){
7707
+ className += " whitespace-nowrap";
7708
+ }
7660
7709
  if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
7661
7710
  const previewFileScript = `
7662
7711
  var data = event.data;
@@ -7667,7 +7716,7 @@ async function getTableColumns(fields, options){
7667
7716
  columns.push({
7668
7717
  "type": "button",
7669
7718
  "label": `<%=data.versions ? data.name : "${field.label}"%>`,
7670
- "className": "whitespace-nowrap",
7719
+ className,
7671
7720
  "level": "link",
7672
7721
  "quickEdit": quickEditSchema,
7673
7722
  "onEvent": {
@@ -7704,7 +7753,7 @@ async function getTableColumns(fields, options){
7704
7753
  width: getFieldWidth(field.width),
7705
7754
  toggled: field.toggled,
7706
7755
  static: true,
7707
- className:"whitespace-nowrap",
7756
+ className,
7708
7757
  quickEdit: quickEditSchema
7709
7758
  }, field.amis, {name: field.name}));
7710
7759
  }else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
@@ -7716,16 +7765,12 @@ async function getTableColumns(fields, options){
7716
7765
  toggled: field.toggled,
7717
7766
  quickEdit: quickEditSchema,
7718
7767
  static: true,
7719
- className:"whitespace-nowrap",
7768
+ className,
7720
7769
  ...getAmisFileReadonlySchema(field)
7721
7770
  }, field.amis, {name: field.name}));
7722
7771
  }
7723
7772
  else if(field.type === 'select'){
7724
7773
  const map = getSelectMap(field.options);
7725
- let className = "";
7726
- if(field.wrap === false){
7727
- className += " whitespace-nowrap";
7728
- }
7729
7774
  columns.push(Object.assign({}, {
7730
7775
  type: "mapping",
7731
7776
  name: field.name,
@@ -7753,12 +7798,8 @@ async function getTableColumns(fields, options){
7753
7798
  type = 'input-url';
7754
7799
  }
7755
7800
  }
7756
- let className = "";
7757
7801
  if(field.type === 'textarea'){
7758
- className = 'min-w-56';
7759
- }
7760
- if(field.wrap === false){
7761
- className += " whitespace-nowrap";
7802
+ className += 'min-w-56';
7762
7803
  }
7763
7804
  if(!field.hidden && !field.extra){
7764
7805
  columns.push(Object.assign({}, {
@@ -7778,6 +7819,7 @@ async function getTableColumns(fields, options){
7778
7819
  }, field.amis, {name: field.name}));
7779
7820
  }
7780
7821
  }
7822
+
7781
7823
  }
7782
7824
  // columns.push(getOperation(fields));
7783
7825
  if(!___namespace.some(columns, { name: options.labelFieldName })){
@@ -9318,13 +9360,13 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
9318
9360
  "selectMirror": permissions.allowCreate,
9319
9361
  "initialView": initialView,
9320
9362
  "businessHours": businessHours,
9321
- ...config,
9322
- "onEvent": onEvent,
9323
9363
  "views":{
9324
9364
  listWeek: {
9325
9365
  buttonText: i18next__default["default"].t('frontend_calendar_listWeek')
9326
9366
  }
9327
- }
9367
+ },
9368
+ ...config,
9369
+ "onEvent": onEvent
9328
9370
  };
9329
9371
  return amisSchema;
9330
9372
  }
@@ -10357,8 +10399,8 @@ async function getRelatedListSchema(
10357
10399
  /*
10358
10400
  * @Author: baozhoutao@steedos.com
10359
10401
  * @Date: 2022-07-05 15:55:39
10360
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
10361
- * @LastEditTime: 2023-06-04 17:36:49
10402
+ * @LastEditors: baozhoutao@steedos.com
10403
+ * @LastEditTime: 2023-07-29 13:58:07
10362
10404
  * @Description:
10363
10405
  */
10364
10406
 
@@ -10692,6 +10734,7 @@ async function getListSchema(
10692
10734
  "filterVisible": ctx.filterVisible,
10693
10735
  "rowClassNameExpr": ctx.rowClassNameExpr
10694
10736
  };
10737
+ // console.log(`getListSchema===>`,amisSchema)
10695
10738
  return {
10696
10739
  uiSchema,
10697
10740
  amisSchema,
@@ -10705,7 +10748,7 @@ async function getTableSchema(
10705
10748
  columns,
10706
10749
  ctx = {}
10707
10750
  ) {
10708
- // console.time('getTableSchema');
10751
+ // console.time('getTableSchema', columns);
10709
10752
  const uiSchema = await getUISchema(objectName);
10710
10753
 
10711
10754
  let sort = ctx.sort;
@@ -10719,19 +10762,52 @@ async function getTableSchema(
10719
10762
  }
10720
10763
 
10721
10764
  let fields = [];
10722
- _$1.each(columns, function (column) {
10723
- if (_$1.isString(column) && uiSchema.fields[column]) {
10724
- fields.push(uiSchema.fields[column]);
10725
- } else if (_$1.isObject(column) && uiSchema.fields[column.field]) {
10726
- fields.push(
10727
- Object.assign({}, uiSchema.fields[column.field], {
10728
- width: column.width,
10729
- wrap: column.wrap, // wrap = true 是没效果的
10730
- amis: column.amis
10731
- })
10732
- );
10765
+ for(const column of columns){
10766
+ if (_$1.isString(column)) {
10767
+ if(column.indexOf('.') > 0){
10768
+ const fieldName = column.split('.')[0];
10769
+ const displayName = column.split('.')[1];
10770
+ const filedInfo = uiSchema.fields[fieldName];
10771
+ if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && _$1.isString(filedInfo.reference_to) ){
10772
+ const rfUiSchema = await getUISchema(filedInfo.reference_to);
10773
+ const rfFieldInfo = rfUiSchema.fields[displayName];
10774
+ fields.push(Object.assign({}, rfFieldInfo, {name: column, expand: true, expandInfo: {fieldName, displayName}}));
10775
+ }
10776
+ }else {
10777
+ if(uiSchema.fields[column]){
10778
+ fields.push(uiSchema.fields[column]);
10779
+ }
10780
+ }
10781
+ } else if (_$1.isObject(column)) {
10782
+ if(column.field.indexOf('.') > 0){
10783
+ const fieldName = column.field.split('.')[0];
10784
+ const displayName = column.field.split('.')[1];
10785
+ const filedInfo = uiSchema.fields[fieldName];
10786
+ if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && _$1.isString(filedInfo.reference_to) ){
10787
+ const rfUiSchema = await getUISchema(filedInfo.reference_to);
10788
+ const rfFieldInfo = rfUiSchema.fields[displayName];
10789
+ fields.push(Object.assign({}, rfFieldInfo,
10790
+ {name: column.field, expand: true, expandInfo: {fieldName, displayName}},
10791
+ {
10792
+ width: column.width,
10793
+ wrap: column.wrap, // wrap = true 是没效果的
10794
+ amis: column.amis
10795
+ }
10796
+ ));
10797
+ }
10798
+ }else {
10799
+ if(uiSchema.fields[column.field]){
10800
+ fields.push(
10801
+ Object.assign({}, uiSchema.fields[column.field], {
10802
+ width: column.width,
10803
+ wrap: column.wrap, // wrap = true 是没效果的
10804
+ amis: column.amis
10805
+ })
10806
+ );
10807
+ }
10808
+ }
10733
10809
  }
10734
- });
10810
+ }
10735
10811
 
10736
10812
  const extraColumns = ctx.extraColumns;
10737
10813