@steedos-widgets/amis-lib 1.2.30 → 1.2.32

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
@@ -514,7 +514,7 @@ function getNameTpl(field, ctx){
514
514
 
515
515
  function getRelatedFieldTpl(field, ctx){
516
516
  let tpl = '';
517
- if(!field.reference_to && (field.optionsFunction || field._optionsFunction)){
517
+ if(!field.reference_to && (field.optionsFunction || field._optionsFunction || field.options)){
518
518
  if(field.isTableField){
519
519
  return `\${${field.name}}`
520
520
  }else {
@@ -978,6 +978,7 @@ var frontend_form_cancel$1 = "Cancel";
978
978
  var frontend_form_new$1 = "New";
979
979
  var frontend_form_edit$1 = "Edit";
980
980
  var frontend_form_select$1 = "Select";
981
+ var frontend_form_please_select$1 = "Please select";
981
982
  var frontend_form_confirm$1 = "Confirm";
982
983
  var frontend_form_delete$1 = "Delete";
983
984
  var frontend_form_view$1 = "view";
@@ -1059,6 +1060,7 @@ var en_us = {
1059
1060
  frontend_form_new: frontend_form_new$1,
1060
1061
  frontend_form_edit: frontend_form_edit$1,
1061
1062
  frontend_form_select: frontend_form_select$1,
1063
+ frontend_form_please_select: frontend_form_please_select$1,
1062
1064
  frontend_form_confirm: frontend_form_confirm$1,
1063
1065
  frontend_form_delete: frontend_form_delete$1,
1064
1066
  frontend_form_view: frontend_form_view$1,
@@ -1141,6 +1143,7 @@ var frontend_form_cancel = "取消";
1141
1143
  var frontend_form_new = "新建";
1142
1144
  var frontend_form_edit = "编辑";
1143
1145
  var frontend_form_select = "选择";
1146
+ var frontend_form_please_select = "请选择";
1144
1147
  var frontend_form_confirm = "确认";
1145
1148
  var frontend_form_delete = "删除";
1146
1149
  var frontend_form_view = "查看";
@@ -1223,6 +1226,7 @@ var zh_cn = {
1223
1226
  frontend_form_new: frontend_form_new,
1224
1227
  frontend_form_edit: frontend_form_edit,
1225
1228
  frontend_form_select: frontend_form_select,
1229
+ frontend_form_please_select: frontend_form_please_select,
1226
1230
  frontend_form_confirm: frontend_form_confirm,
1227
1231
  frontend_form_delete: frontend_form_delete,
1228
1232
  frontend_form_view: frontend_form_view,
@@ -2589,7 +2593,8 @@ const StandardButtons = {
2589
2593
  } = this;
2590
2594
  const scopeId = this.scopeId || `amis-${appId}-${objectName}-listview`;
2591
2595
  const scope = this.scope || SteedosUI?.getRef(scopeId);
2592
- const listViewRef = scope.getComponentById(`listview_${uiSchema.name}`);
2596
+ //https://github.com/baidu/amis/pull/6807 .parent的改动是为适应3.2getComponentById的规则改动,不影响2.9
2597
+ const listViewRef = scope.parent?.getComponentById(`listview_${uiSchema.name}`);
2593
2598
  if(_.isEmpty(listViewRef.props.store.toJSON().selectedItems)){
2594
2599
  listViewRef.handleAction({}, {
2595
2600
  "actionType": "toast",
@@ -5135,7 +5140,7 @@ const getSettingListviewToolbarButtonSchema = ()=>{
5135
5140
  "trigger": "click",
5136
5141
  "icon": "fa fa-cog",
5137
5142
  "tooltip": i18next__default["default"].t('frontend_button_listview_control_tooltip'),
5138
- "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
5143
+ "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded border-gray-300 text-gray-500",
5139
5144
  "align": "right",
5140
5145
  "visibleOn": "${!isLookup}",
5141
5146
  "buttons": [
@@ -5179,7 +5184,7 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
5179
5184
  "type": "dropdown-button",
5180
5185
  "icon": "fa fa-table-columns",
5181
5186
  "tooltip": `${i18next__default["default"].t('frontend_display_as')} ${displayAsLabel}`,
5182
- "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
5187
+ "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded border-gray-300 text-gray-500",
5183
5188
  "align": "right",
5184
5189
  "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
5185
5190
  "buttons": [
@@ -5841,6 +5846,14 @@ async function lookupToAmisPicker(field, readonly, ctx){
5841
5846
  }
5842
5847
  }
5843
5848
 
5849
+ if(${referenceTo?.objectName === "space_users"} && ${field.reference_to_field === "user"}){
5850
+ if(filters.length > 0){
5851
+ filters = [ ["user_accepted", "=", true], "and", filters ]
5852
+ }else{
5853
+ filters = [["user_accepted", "=", true]];
5854
+ }
5855
+ }
5856
+
5844
5857
 
5845
5858
  if(allowSearchFields){
5846
5859
  allowSearchFields.forEach(function(key){
@@ -6057,6 +6070,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
6057
6070
 
6058
6071
  const data = {
6059
6072
  type: getAmisStaticFieldType('picker', readonly),
6073
+ modalTitle: i18next__default["default"].t('frontend_form_please_select') + " " + refObjectConfig.label,
6060
6074
  labelField: referenceTo.labelField.name,
6061
6075
  valueField: referenceTo.valueField.name,
6062
6076
  modalMode: 'dialog', //TODO 设置 dialog 或者 drawer,用来配置弹出方式
@@ -6173,6 +6187,14 @@ async function lookupToAmisSelect(field, readonly, ctx){
6173
6187
  filters.push(fieldFilters);
6174
6188
  }
6175
6189
 
6190
+ if(${referenceTo?.objectName === "space_users"} && ${field.reference_to_field === "user"}){
6191
+ if(filters.length > 0){
6192
+ filters = [ ["user_accepted", "=", true], "and", filters ]
6193
+ }else{
6194
+ filters = [["user_accepted", "=", true]];
6195
+ }
6196
+ }
6197
+
6176
6198
  const inFilterForm = ${ctx.inFilterForm};
6177
6199
  const filtersFunction = ${field.filtersFunction || field._filtersFunction};
6178
6200
 
@@ -6212,6 +6234,18 @@ async function lookupToAmisSelect(field, readonly, ctx){
6212
6234
  payload.data.options = options;
6213
6235
  return payload;
6214
6236
  `;
6237
+ }else if(field.options){
6238
+ apiInfo.adaptor = `
6239
+ var options = ${JSON.stringify(field.options)}
6240
+ if(api.data.$term){
6241
+ options = _.filter(options, function(o) {
6242
+ var label = o.label;
6243
+ return label.toLowerCase().indexOf(api.data.$term.toLowerCase()) > -1;
6244
+ });
6245
+ }
6246
+ payload.data.options = options;
6247
+ return payload;
6248
+ `;
6215
6249
  }
6216
6250
 
6217
6251
  const data = {
@@ -6291,11 +6325,6 @@ async function lookupToAmis(field, readonly, ctx){
6291
6325
  // ids人员点选模式
6292
6326
  return await lookupToAmisIdsPicker(field, readonly, ctx);
6293
6327
  }
6294
- if(!field.filters || field.filters.length == 0){
6295
- field.filters = [["user_accepted", "=", true]];
6296
- }else {
6297
- field.filters = [ ["user_accepted", "=", true], "and", field.filters ];
6298
- }
6299
6328
  // 左侧树右侧人员列表的下拉框模式,不再支持,而是执行下面的lookupToAmisPicker函数弹出选人窗口
6300
6329
  // return await lookupToAmisSelectUser(field, readonly, ctx);
6301
6330
  }
@@ -6515,8 +6544,8 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
6515
6544
  /*
6516
6545
  * @Author: baozhoutao@steedos.com
6517
6546
  * @Date: 2022-10-28 14:52:55
6518
- * @LastEditors: Please set LastEditors
6519
- * @LastEditTime: 2023-05-31 13:25:53
6547
+ * @LastEditors: liaodaxue
6548
+ * @LastEditTime: 2023-07-14 17:18:42
6520
6549
  * @Description:
6521
6550
  */
6522
6551
 
@@ -6548,6 +6577,8 @@ function getAmisStaticFieldType(type, readonly, options){
6548
6577
  return `static-images`;
6549
6578
  }
6550
6579
  return `static-${type}`;
6580
+ }else if(type === 'url'){
6581
+ return "input-url"
6551
6582
  }else {
6552
6583
  return 'static';
6553
6584
  }
@@ -6783,13 +6814,13 @@ function getSelectFieldOptions(field){
6783
6814
  ___namespace.each(field.options, (item)=>{
6784
6815
  switch (dataType) {
6785
6816
  case 'number':
6786
- options.push({label: item.label, value: Number(item.value)});
6817
+ options.push({label: item.label, value: Number(item.value), icon: item.icon});
6787
6818
  break;
6788
6819
  case 'text':
6789
- options.push({label: item.label, value: String(item.value)});
6820
+ options.push({label: item.label, value: String(item.value), icon: item.icon});
6790
6821
  break;
6791
6822
  case 'boolean':
6792
- options.push({label: item.label, value: item.value === 'false' ? false : true});
6823
+ options.push({label: item.label, value: item.value === 'false' ? false : true, icon: item.icon});
6793
6824
  break;
6794
6825
  }
6795
6826
  });
@@ -6851,6 +6882,17 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
6851
6882
  labelField: 'label',
6852
6883
  valueField: 'value'
6853
6884
  };
6885
+ const select_menuTpl = `<span class='flex items-center mt-0.5'>
6886
+ <span role='img' aria-label='smile' class='anticon anticon-smile'>
6887
+ <span class='slds-icon_container slds-icon-standard-\${REPLACE(icon,'_','-')}'>
6888
+ <svg class='slds-icon slds-icon_x-small' aria-hidden='true'>
6889
+ <use xlink:href='/assets/icons/standard-sprite/svg/symbols.svg#\${icon}'></use>
6890
+ </svg>
6891
+ </span>
6892
+ </span>
6893
+ <span class='pl-1.5'>\${label}</span>
6894
+ </span>`;
6895
+ convertData.menuTpl = "${icon ? `"+select_menuTpl+"` : label}";
6854
6896
  if(field.multiple){
6855
6897
  convertData.multiple = true;
6856
6898
  convertData.extractValue = true;
@@ -7064,7 +7106,8 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
7064
7106
  break;
7065
7107
  case 'url':
7066
7108
  convertData = {
7067
- type: getAmisStaticFieldType('url', readonly, field)
7109
+ type: getAmisStaticFieldType('url', readonly, field),
7110
+ static: readonly ? true : false
7068
7111
  };
7069
7112
  if(readonly && field.show_as_qr){
7070
7113
  convertData = {
@@ -7398,17 +7441,19 @@ async function getQuickEditSchema(field, options){
7398
7441
  return EventType;
7399
7442
  };
7400
7443
  switch (field.type) {
7401
- //TODO:amis的picker组件直接点击选项x时不会触发change事件,待处理
7444
+ //TODO: amis的picker组件直接点击选项x时不会触发change事件,待处理
7402
7445
  case "lookup":
7403
7446
  case "master_detail":
7447
+ let labelField = quickEditSchema.body[0].labelField || "label";
7448
+ let valueField = quickEditSchema.body[0].valueField || "value";
7404
7449
  if (field.multiple) {
7405
7450
  TempDisplayField = `
7406
7451
  _display["${field.name}"] = [];
7407
- event.data.value.forEach(function(item,index){
7452
+ event.data.selectedItems.forEach(function(item,index){
7408
7453
  _display["${field.name}"].push(
7409
7454
  {
7410
- "label": event.data.option[index].${quickEditSchema.body[0].labelField},
7411
- "value": event.data.option[index]._id,
7455
+ "label": item.${labelField},
7456
+ "value": item.${valueField},
7412
7457
  "objectName": "${field.reference_to}"
7413
7458
  }
7414
7459
  )
@@ -7417,8 +7462,8 @@ async function getQuickEditSchema(field, options){
7417
7462
  } else {
7418
7463
  TempDisplayField = `
7419
7464
  _display["${field.name}"] = {
7420
- "label": event.data.option.${quickEditSchema.body[0].labelField},
7421
- "value": event.data._id,
7465
+ "label": event.data.selectedItems.${labelField},
7466
+ "value": event.data.selectedItems.${valueField},
7422
7467
  "objectName": "${field.reference_to}"
7423
7468
  }
7424
7469
  `;
@@ -7582,7 +7627,7 @@ async function getTableColumns(fields, options){
7582
7627
  type: "switch",
7583
7628
  name: field.name,
7584
7629
  label: field.label,
7585
- width: field.width,
7630
+ width: field.width || defaultWidth,
7586
7631
  toggled: field.toggled,
7587
7632
  static: true,
7588
7633
  className:"whitespace-nowrap",
@@ -7603,6 +7648,10 @@ async function getTableColumns(fields, options){
7603
7648
  }
7604
7649
  else if(field.type === 'select'){
7605
7650
  const map = getSelectMap(field.options);
7651
+ let className = "";
7652
+ if(field.wrap === false){
7653
+ className += " whitespace-nowrap";
7654
+ }
7606
7655
  columns.push(Object.assign({}, {
7607
7656
  type: "mapping",
7608
7657
  name: field.name,
@@ -7611,7 +7660,7 @@ async function getTableColumns(fields, options){
7611
7660
  sortable: field.sortable,
7612
7661
  width: field.width || defaultWidth,
7613
7662
  toggled: field.toggled,
7614
- className:"whitespace-nowrap",
7663
+ className,
7615
7664
  static: true,
7616
7665
  quickEdit: quickEditSchema
7617
7666
  }, field.amis, {name: field.name}));
@@ -7623,8 +7672,12 @@ async function getTableColumns(fields, options){
7623
7672
  type = 'tpl';
7624
7673
  }else if(field.type === 'html'){
7625
7674
  type = 'markdown';
7626
- }else if(field.type === 'url' && field.show_as_qr){
7627
- type = 'qr-code';
7675
+ }else if(field.type === 'url'){
7676
+ if(field.show_as_qr){
7677
+ type = 'qr-code';
7678
+ }else {
7679
+ type = 'input-url';
7680
+ }
7628
7681
  }
7629
7682
  let className = "";
7630
7683
  if(field.type === 'textarea'){
@@ -8250,7 +8303,10 @@ async function getTableApi(mainObject, fields, options){
8250
8303
  if(item[key]){
8251
8304
  if(field._optionsFunction){
8252
8305
  const optionsFunction = eval("(" + field._optionsFunction+ ")")(item);
8253
- item[key + '__label'] = _.map(_.filter(optionsFunction, function(option){return _.includes(item[key], option.value)}), 'label').join(' ');
8306
+ item[key + '__label'] = _.map(_.filter(optionsFunction, function(option){return item[key] == option.value}), 'label').join(' ');
8307
+ }else if(field.options){
8308
+ const options = field.options;
8309
+ item[key + '__label'] = _.map(_.filter(options, function(option){return item[key] == option.value}), 'label').join(' ');
8254
8310
  }
8255
8311
  }
8256
8312
  })
@@ -8305,7 +8361,8 @@ async function getTableApi(mainObject, fields, options){
8305
8361
 
8306
8362
  const setDataToComponentId = "${setDataToComponentId}";
8307
8363
  if(setDataToComponentId){
8308
- SteedosUI.getRef(api.body.$self.$scopeId)?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
8364
+ //https://github.com/baidu/amis/pull/6807 .parent的改动是为适应3.2getComponentById的规则改动,不影响2.9
8365
+ SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
8309
8366
  };
8310
8367
  ${options.adaptor || ''}
8311
8368
  return payload;
@@ -8997,17 +9054,18 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
8997
9054
  "objectApiName": "\${objectName}",
8998
9055
  "mode": "edit",
8999
9056
  "defaultData": doc,
9000
- "onEvent": {
9001
- "submitSucc": {
9002
- "weight": 0,
9003
- "actions": [
9004
- {
9005
- "actionType": "custom",
9006
- "script": "event.data.view?.calendar.refetchEvents();"
9007
- }
9008
- ]
9009
- }
9010
- }
9057
+ //改回为通用的提交事件
9058
+ // "onEvent": {
9059
+ // "submitSucc": {
9060
+ // "weight": 0,
9061
+ // "actions": [
9062
+ // {
9063
+ // "actionType": "custom",
9064
+ // "script": "event.data.view?.calendar.refetchEvents();"
9065
+ // }
9066
+ // ]
9067
+ // }
9068
+ // }
9011
9069
  }
9012
9070
  ],
9013
9071
  "closeOnEsc": false,
@@ -9136,6 +9194,20 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
9136
9194
  "script": "console.log('eventsSet'); console.log(event);"
9137
9195
  }
9138
9196
  ]
9197
+ },
9198
+ "getRef": {
9199
+ "weight": 0,
9200
+ "actions": [
9201
+ {
9202
+ "componentId": `service_${options.id}`,
9203
+ "args": {
9204
+ "value":{
9205
+ "calendarRef": "${event.data.calendarRef}"
9206
+ }
9207
+ },
9208
+ "actionType": "setValue",
9209
+ }
9210
+ ]
9139
9211
  }
9140
9212
  };
9141
9213
 
@@ -9171,6 +9243,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
9171
9243
  const amisSchema = {
9172
9244
  "type": "steedos-fullcalendar",
9173
9245
  "label": "",
9246
+ "id": options.id,
9174
9247
  "name": "fullcalendar",
9175
9248
  "placeholder":"${additionalFilters}",//用于触发reload
9176
9249
  "editable": permissions.allowEdit,
@@ -9193,7 +9266,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
9193
9266
  * @Author: baozhoutao@steedos.com
9194
9267
  * @Date: 2022-05-26 16:02:08
9195
9268
  * @LastEditors: liaodaxue
9196
- * @LastEditTime: 2023-06-29 17:27:19
9269
+ * @LastEditTime: 2023-07-12 15:45:55
9197
9270
  * @Description:
9198
9271
  */
9199
9272
 
@@ -9252,7 +9325,11 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
9252
9325
 
9253
9326
  // fieldSet 已支持显隐控制
9254
9327
  const sectionFieldsVisibleOn = ___namespace.map(___namespace.compact(___namespace.map(fieldSetBody, 'visibleOn')), (visibleOn) => {
9255
- return visibleOn;
9328
+ let visible = visibleOn;
9329
+ if(visible.indexOf('${')>-1){
9330
+ visible = visible.substring(visible.indexOf('{')+1, visible.indexOf('}'));
9331
+ }
9332
+ return visible ? "("+visible+")" : visible;
9256
9333
  });
9257
9334
 
9258
9335
  let section = {
@@ -13695,6 +13772,7 @@ exports.getRecordDetailSchema = getRecordDetailSchema;
13695
13772
  exports.getRecordPageInitSchema = getRecordPageInitSchema;
13696
13773
  exports.getRecordPermissions = getRecordPermissions;
13697
13774
  exports.getRecordServiceSchema = getRecordServiceSchema;
13775
+ exports.getReferenceTo = getReferenceTo;
13698
13776
  exports.getRelatedFieldValue = getRelatedFieldValue;
13699
13777
  exports.getRelatedListSchema = getRelatedListSchema;
13700
13778
  exports.getRelatedsCount = getRelatedsCount;