@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/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs.js +133 -57
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +133 -57
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +133 -57
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/graphql.d.ts +1 -1
- package/dist/types/lib/converter/amis/tpl.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -399,8 +399,8 @@ function getContrastColor(bgColor) {
|
|
|
399
399
|
/*
|
|
400
400
|
* @Author: baozhoutao@steedos.com
|
|
401
401
|
* @Date: 2022-05-23 09:53:08
|
|
402
|
-
* @LastEditors:
|
|
403
|
-
* @LastEditTime: 2023-
|
|
402
|
+
* @LastEditors: liaodaxue
|
|
403
|
+
* @LastEditTime: 2023-07-28 16:26:31
|
|
404
404
|
* @Description:
|
|
405
405
|
*/
|
|
406
406
|
|
|
@@ -584,6 +584,9 @@ function getPasswordTpl(field){
|
|
|
584
584
|
<% } %>`
|
|
585
585
|
}
|
|
586
586
|
|
|
587
|
+
function getLocationTpl(field){
|
|
588
|
+
return `\${${field.name} ? ${field.name}.address : ''}`
|
|
589
|
+
}
|
|
587
590
|
|
|
588
591
|
async function getFieldTpl (field, options){
|
|
589
592
|
if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLabel){
|
|
@@ -608,6 +611,8 @@ async function getFieldTpl (field, options){
|
|
|
608
611
|
return await getRelatedFieldTpl(field, options);
|
|
609
612
|
case 'master_detail':
|
|
610
613
|
return await getRelatedFieldTpl(field, options);
|
|
614
|
+
case 'location':
|
|
615
|
+
return await getLocationTpl(field);
|
|
611
616
|
case 'number':
|
|
612
617
|
case 'currency':
|
|
613
618
|
return await getNumberTpl(field);
|
|
@@ -620,9 +625,10 @@ async function getFieldTpl (field, options){
|
|
|
620
625
|
}
|
|
621
626
|
}
|
|
622
627
|
|
|
623
|
-
async function getFieldsTemplate(fields,
|
|
624
|
-
|
|
625
|
-
|
|
628
|
+
async function getFieldsTemplate(fields, display){
|
|
629
|
+
let expandFields = [];
|
|
630
|
+
if(display != false){
|
|
631
|
+
display = true;
|
|
626
632
|
}
|
|
627
633
|
let fieldsName = ['_id'];
|
|
628
634
|
let displayFields = [];
|
|
@@ -634,33 +640,43 @@ async function getFieldsTemplate(fields, expand){
|
|
|
634
640
|
}
|
|
635
641
|
for (const field of fieldsArr) {
|
|
636
642
|
//graphql 的 ui\display 中使用的字段需要先在query中查询. 否则会返回null
|
|
637
|
-
if(field.
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
643
|
+
if(field.expand){
|
|
644
|
+
expandFields.push(field);
|
|
645
|
+
}else {
|
|
646
|
+
if(field.name.indexOf('.') < 0){
|
|
647
|
+
if(display && (field.type == 'lookup' || field.type == 'master_detail')){
|
|
648
|
+
fieldsName.push(`${field.name}`);
|
|
649
|
+
displayFields.push(`${field.name}`);
|
|
650
|
+
}else {
|
|
651
|
+
fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
|
|
652
|
+
}
|
|
653
|
+
if(includes(['time','date','datetime','boolean','number','currency'], field.type)){
|
|
654
|
+
fieldsName.push(`${field.name}`);
|
|
655
|
+
}
|
|
656
|
+
if(includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
|
|
657
|
+
displayFields.push(`${field.name}`);
|
|
658
|
+
}
|
|
641
659
|
}else {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
fieldsName.push(`${field.name}`);
|
|
660
|
+
objectFieldName = field.name.split('.')[0];
|
|
661
|
+
fieldsName.push(objectFieldName);
|
|
662
|
+
displayFields.push(objectFieldName);
|
|
646
663
|
}
|
|
647
|
-
if(includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
|
|
648
|
-
displayFields.push(`${field.name}`);
|
|
649
|
-
}
|
|
650
|
-
}else {
|
|
651
|
-
objectFieldName = field.name.split('.')[0];
|
|
652
|
-
fieldsName.push(objectFieldName);
|
|
653
|
-
displayFields.push(objectFieldName);
|
|
654
664
|
}
|
|
655
665
|
}
|
|
656
666
|
|
|
657
667
|
displayFields = _$1.uniq(displayFields);
|
|
658
668
|
fieldsName = _$1.uniq(fieldsName);
|
|
669
|
+
let expandFieldsQuery = "";
|
|
670
|
+
if(expandFields.length > 0){
|
|
671
|
+
_$1.each(expandFields, function(field){
|
|
672
|
+
expandFieldsQuery = expandFieldsQuery + `${field.expandInfo.fieldName}:${field.expandInfo.fieldName}__expand{${field.expandInfo.displayName}}`;
|
|
673
|
+
});
|
|
674
|
+
}
|
|
659
675
|
|
|
660
676
|
if(displayFields.length > 0){
|
|
661
|
-
return `${fieldsName.join(',')},_display:_ui{${displayFields.join(',')}}`;
|
|
677
|
+
return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
|
|
662
678
|
}
|
|
663
|
-
return `${fieldsName.join(' ')}`
|
|
679
|
+
return `${fieldsName.join(' ')},${expandFieldsQuery}`
|
|
664
680
|
}
|
|
665
681
|
|
|
666
682
|
function getRecordPermissionsTemplate(){
|
|
@@ -950,6 +966,7 @@ var frontend_form_save_and_new$1 = "Save and New";
|
|
|
950
966
|
var frontend_form_cancel$1 = "Cancel";
|
|
951
967
|
var frontend_form_new$1 = "New";
|
|
952
968
|
var frontend_form_edit$1 = "Edit";
|
|
969
|
+
var frontend_form_preview$1 = "Preview";
|
|
953
970
|
var frontend_form_select$1 = "Select";
|
|
954
971
|
var frontend_form_please_select$1 = "Please select";
|
|
955
972
|
var frontend_form_confirm$1 = "Confirm";
|
|
@@ -1032,6 +1049,7 @@ var en_us = {
|
|
|
1032
1049
|
frontend_form_cancel: frontend_form_cancel$1,
|
|
1033
1050
|
frontend_form_new: frontend_form_new$1,
|
|
1034
1051
|
frontend_form_edit: frontend_form_edit$1,
|
|
1052
|
+
frontend_form_preview: frontend_form_preview$1,
|
|
1035
1053
|
frontend_form_select: frontend_form_select$1,
|
|
1036
1054
|
frontend_form_please_select: frontend_form_please_select$1,
|
|
1037
1055
|
frontend_form_confirm: frontend_form_confirm$1,
|
|
@@ -1115,6 +1133,7 @@ var frontend_form_save_and_new = "保存并新建";
|
|
|
1115
1133
|
var frontend_form_cancel = "取消";
|
|
1116
1134
|
var frontend_form_new = "新建";
|
|
1117
1135
|
var frontend_form_edit = "编辑";
|
|
1136
|
+
var frontend_form_preview = "预览";
|
|
1118
1137
|
var frontend_form_select = "选择";
|
|
1119
1138
|
var frontend_form_please_select = "请选择";
|
|
1120
1139
|
var frontend_form_confirm = "确认";
|
|
@@ -1198,6 +1217,7 @@ var zh_cn = {
|
|
|
1198
1217
|
frontend_form_cancel: frontend_form_cancel,
|
|
1199
1218
|
frontend_form_new: frontend_form_new,
|
|
1200
1219
|
frontend_form_edit: frontend_form_edit,
|
|
1220
|
+
frontend_form_preview: frontend_form_preview,
|
|
1201
1221
|
frontend_form_select: frontend_form_select,
|
|
1202
1222
|
frontend_form_please_select: frontend_form_please_select,
|
|
1203
1223
|
frontend_form_confirm: frontend_form_confirm,
|
|
@@ -6460,11 +6480,10 @@ async function getIdsPickerSchema(field, readonly, ctx){
|
|
|
6460
6480
|
* @Author: baozhoutao@steedos.com
|
|
6461
6481
|
* @Date: 2023-01-13 17:27:54
|
|
6462
6482
|
* @LastEditors: liaodaxue
|
|
6463
|
-
* @LastEditTime: 2023-07-
|
|
6483
|
+
* @LastEditTime: 2023-07-27 17:33:54
|
|
6464
6484
|
* @Description:
|
|
6465
6485
|
*/
|
|
6466
6486
|
|
|
6467
|
-
|
|
6468
6487
|
const getMarkdownFieldSchema = (field, readonly, ctx)=>{
|
|
6469
6488
|
if(readonly){
|
|
6470
6489
|
return {
|
|
@@ -6491,7 +6510,7 @@ const getMarkdownFieldSchema = (field, readonly, ctx)=>{
|
|
|
6491
6510
|
"className": "steedos-markdown",
|
|
6492
6511
|
"tabs": [
|
|
6493
6512
|
{
|
|
6494
|
-
"title":
|
|
6513
|
+
"title": i18next.t('frontend_form_edit'),
|
|
6495
6514
|
"tab": [
|
|
6496
6515
|
{
|
|
6497
6516
|
"type": "editor",
|
|
@@ -6501,7 +6520,7 @@ const getMarkdownFieldSchema = (field, readonly, ctx)=>{
|
|
|
6501
6520
|
]
|
|
6502
6521
|
},
|
|
6503
6522
|
{
|
|
6504
|
-
"title":
|
|
6523
|
+
"title": i18next.t('frontend_form_preview'),
|
|
6505
6524
|
"tab": [
|
|
6506
6525
|
{
|
|
6507
6526
|
"type": "markdown",
|
|
@@ -6558,7 +6577,7 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
|
|
|
6558
6577
|
* @Author: baozhoutao@steedos.com
|
|
6559
6578
|
* @Date: 2022-10-28 14:52:55
|
|
6560
6579
|
* @LastEditors: liaodaxue
|
|
6561
|
-
* @LastEditTime: 2023-07-
|
|
6580
|
+
* @LastEditTime: 2023-07-28 16:16:29
|
|
6562
6581
|
* @Description:
|
|
6563
6582
|
*/
|
|
6564
6583
|
|
|
@@ -6582,6 +6601,8 @@ function getAmisStaticFieldType(type, readonly, options){
|
|
|
6582
6601
|
if(!readonly){
|
|
6583
6602
|
if(_$1.includes(AmisFormInputs, type)){
|
|
6584
6603
|
return `input-${type}`;
|
|
6604
|
+
}else if(type === 'location'){
|
|
6605
|
+
return "location-picker"
|
|
6585
6606
|
}
|
|
6586
6607
|
return type;
|
|
6587
6608
|
}
|
|
@@ -7139,6 +7160,30 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
7139
7160
|
type: getAmisStaticFieldType('email', readonly)
|
|
7140
7161
|
};
|
|
7141
7162
|
break;
|
|
7163
|
+
case 'location':
|
|
7164
|
+
// 申请ak后需要设置白名单; https://lbsyun.baidu.com/apiconsole/key/create#/home
|
|
7165
|
+
// console.log('fie==>', field.name, field);
|
|
7166
|
+
let ak = "LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7";
|
|
7167
|
+
let vendor = "baidu"; /* 'baidu' | 'gaode' */
|
|
7168
|
+
if(window.Meteor){
|
|
7169
|
+
const map_ak = Meteor.settings?.public?.amis?.map_ak;
|
|
7170
|
+
if(map_ak){
|
|
7171
|
+
ak = map_ak;
|
|
7172
|
+
}
|
|
7173
|
+
const map_vendor = Meteor.settings?.public?.amis?.map_vendor;
|
|
7174
|
+
if(map_vendor){
|
|
7175
|
+
vendor = map_vendor;
|
|
7176
|
+
}
|
|
7177
|
+
}
|
|
7178
|
+
|
|
7179
|
+
convertData = {
|
|
7180
|
+
type: getAmisStaticFieldType('location', readonly),
|
|
7181
|
+
tpl: readonly ? getLocationTpl(field) : null,
|
|
7182
|
+
ak,
|
|
7183
|
+
vendor,
|
|
7184
|
+
label: field.label
|
|
7185
|
+
};
|
|
7186
|
+
break;
|
|
7142
7187
|
case 'avatar':
|
|
7143
7188
|
convertData = getAmisFileSchema(field, readonly);
|
|
7144
7189
|
break;
|
|
@@ -7630,6 +7675,10 @@ async function getTableColumns(fields, options){
|
|
|
7630
7675
|
for (const field of fields) {
|
|
7631
7676
|
//增加quickEdit属性,实现快速编辑
|
|
7632
7677
|
const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
|
|
7678
|
+
let className = "";
|
|
7679
|
+
if(field.wrap != true){
|
|
7680
|
+
className += " whitespace-nowrap";
|
|
7681
|
+
}
|
|
7633
7682
|
if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
|
|
7634
7683
|
const previewFileScript = `
|
|
7635
7684
|
var data = event.data;
|
|
@@ -7640,7 +7689,7 @@ async function getTableColumns(fields, options){
|
|
|
7640
7689
|
columns.push({
|
|
7641
7690
|
"type": "button",
|
|
7642
7691
|
"label": `<%=data.versions ? data.name : "${field.label}"%>`,
|
|
7643
|
-
|
|
7692
|
+
className,
|
|
7644
7693
|
"level": "link",
|
|
7645
7694
|
"quickEdit": quickEditSchema,
|
|
7646
7695
|
"onEvent": {
|
|
@@ -7677,7 +7726,7 @@ async function getTableColumns(fields, options){
|
|
|
7677
7726
|
width: getFieldWidth(field.width),
|
|
7678
7727
|
toggled: field.toggled,
|
|
7679
7728
|
static: true,
|
|
7680
|
-
className
|
|
7729
|
+
className,
|
|
7681
7730
|
quickEdit: quickEditSchema
|
|
7682
7731
|
}, field.amis, {name: field.name}));
|
|
7683
7732
|
}else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
|
|
@@ -7689,16 +7738,12 @@ async function getTableColumns(fields, options){
|
|
|
7689
7738
|
toggled: field.toggled,
|
|
7690
7739
|
quickEdit: quickEditSchema,
|
|
7691
7740
|
static: true,
|
|
7692
|
-
className
|
|
7741
|
+
className,
|
|
7693
7742
|
...getAmisFileReadonlySchema(field)
|
|
7694
7743
|
}, field.amis, {name: field.name}));
|
|
7695
7744
|
}
|
|
7696
7745
|
else if(field.type === 'select'){
|
|
7697
7746
|
const map = getSelectMap(field.options);
|
|
7698
|
-
let className = "";
|
|
7699
|
-
if(field.wrap === false){
|
|
7700
|
-
className += " whitespace-nowrap";
|
|
7701
|
-
}
|
|
7702
7747
|
columns.push(Object.assign({}, {
|
|
7703
7748
|
type: "mapping",
|
|
7704
7749
|
name: field.name,
|
|
@@ -7726,12 +7771,8 @@ async function getTableColumns(fields, options){
|
|
|
7726
7771
|
type = 'input-url';
|
|
7727
7772
|
}
|
|
7728
7773
|
}
|
|
7729
|
-
let className = "";
|
|
7730
7774
|
if(field.type === 'textarea'){
|
|
7731
|
-
className
|
|
7732
|
-
}
|
|
7733
|
-
if(field.wrap === false){
|
|
7734
|
-
className += " whitespace-nowrap";
|
|
7775
|
+
className += 'min-w-56';
|
|
7735
7776
|
}
|
|
7736
7777
|
if(!field.hidden && !field.extra){
|
|
7737
7778
|
columns.push(Object.assign({}, {
|
|
@@ -7751,6 +7792,7 @@ async function getTableColumns(fields, options){
|
|
|
7751
7792
|
}, field.amis, {name: field.name}));
|
|
7752
7793
|
}
|
|
7753
7794
|
}
|
|
7795
|
+
|
|
7754
7796
|
}
|
|
7755
7797
|
// columns.push(getOperation(fields));
|
|
7756
7798
|
if(!_$1.some(columns, { name: options.labelFieldName })){
|
|
@@ -9291,13 +9333,13 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
9291
9333
|
"selectMirror": permissions.allowCreate,
|
|
9292
9334
|
"initialView": initialView,
|
|
9293
9335
|
"businessHours": businessHours,
|
|
9294
|
-
...config,
|
|
9295
|
-
"onEvent": onEvent,
|
|
9296
9336
|
"views":{
|
|
9297
9337
|
listWeek: {
|
|
9298
9338
|
buttonText: i18next.t('frontend_calendar_listWeek')
|
|
9299
9339
|
}
|
|
9300
|
-
}
|
|
9340
|
+
},
|
|
9341
|
+
...config,
|
|
9342
|
+
"onEvent": onEvent
|
|
9301
9343
|
};
|
|
9302
9344
|
return amisSchema;
|
|
9303
9345
|
}
|
|
@@ -10330,8 +10372,8 @@ async function getRelatedListSchema(
|
|
|
10330
10372
|
/*
|
|
10331
10373
|
* @Author: baozhoutao@steedos.com
|
|
10332
10374
|
* @Date: 2022-07-05 15:55:39
|
|
10333
|
-
* @LastEditors:
|
|
10334
|
-
* @LastEditTime: 2023-
|
|
10375
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
10376
|
+
* @LastEditTime: 2023-07-29 13:58:07
|
|
10335
10377
|
* @Description:
|
|
10336
10378
|
*/
|
|
10337
10379
|
|
|
@@ -10665,6 +10707,7 @@ async function getListSchema(
|
|
|
10665
10707
|
"filterVisible": ctx.filterVisible,
|
|
10666
10708
|
"rowClassNameExpr": ctx.rowClassNameExpr
|
|
10667
10709
|
};
|
|
10710
|
+
// console.log(`getListSchema===>`,amisSchema)
|
|
10668
10711
|
return {
|
|
10669
10712
|
uiSchema,
|
|
10670
10713
|
amisSchema,
|
|
@@ -10678,7 +10721,7 @@ async function getTableSchema(
|
|
|
10678
10721
|
columns,
|
|
10679
10722
|
ctx = {}
|
|
10680
10723
|
) {
|
|
10681
|
-
// console.time('getTableSchema');
|
|
10724
|
+
// console.time('getTableSchema', columns);
|
|
10682
10725
|
const uiSchema = await getUISchema(objectName);
|
|
10683
10726
|
|
|
10684
10727
|
let sort = ctx.sort;
|
|
@@ -10692,19 +10735,52 @@ async function getTableSchema(
|
|
|
10692
10735
|
}
|
|
10693
10736
|
|
|
10694
10737
|
let fields = [];
|
|
10695
|
-
|
|
10696
|
-
if (isString(column)
|
|
10697
|
-
|
|
10698
|
-
|
|
10699
|
-
|
|
10700
|
-
|
|
10701
|
-
|
|
10702
|
-
|
|
10703
|
-
|
|
10704
|
-
|
|
10705
|
-
|
|
10738
|
+
for(const column of columns){
|
|
10739
|
+
if (isString(column)) {
|
|
10740
|
+
if(column.indexOf('.') > 0){
|
|
10741
|
+
const fieldName = column.split('.')[0];
|
|
10742
|
+
const displayName = column.split('.')[1];
|
|
10743
|
+
const filedInfo = uiSchema.fields[fieldName];
|
|
10744
|
+
if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to) ){
|
|
10745
|
+
const rfUiSchema = await getUISchema(filedInfo.reference_to);
|
|
10746
|
+
const rfFieldInfo = rfUiSchema.fields[displayName];
|
|
10747
|
+
fields.push(Object.assign({}, rfFieldInfo, {name: column, expand: true, expandInfo: {fieldName, displayName}}));
|
|
10748
|
+
}
|
|
10749
|
+
}else {
|
|
10750
|
+
if(uiSchema.fields[column]){
|
|
10751
|
+
fields.push(uiSchema.fields[column]);
|
|
10752
|
+
}
|
|
10753
|
+
}
|
|
10754
|
+
} else if (isObject$1(column)) {
|
|
10755
|
+
if(column.field.indexOf('.') > 0){
|
|
10756
|
+
const fieldName = column.field.split('.')[0];
|
|
10757
|
+
const displayName = column.field.split('.')[1];
|
|
10758
|
+
const filedInfo = uiSchema.fields[fieldName];
|
|
10759
|
+
if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to) ){
|
|
10760
|
+
const rfUiSchema = await getUISchema(filedInfo.reference_to);
|
|
10761
|
+
const rfFieldInfo = rfUiSchema.fields[displayName];
|
|
10762
|
+
fields.push(Object.assign({}, rfFieldInfo,
|
|
10763
|
+
{name: column.field, expand: true, expandInfo: {fieldName, displayName}},
|
|
10764
|
+
{
|
|
10765
|
+
width: column.width,
|
|
10766
|
+
wrap: column.wrap, // wrap = true 是没效果的
|
|
10767
|
+
amis: column.amis
|
|
10768
|
+
}
|
|
10769
|
+
));
|
|
10770
|
+
}
|
|
10771
|
+
}else {
|
|
10772
|
+
if(uiSchema.fields[column.field]){
|
|
10773
|
+
fields.push(
|
|
10774
|
+
Object.assign({}, uiSchema.fields[column.field], {
|
|
10775
|
+
width: column.width,
|
|
10776
|
+
wrap: column.wrap, // wrap = true 是没效果的
|
|
10777
|
+
amis: column.amis
|
|
10778
|
+
})
|
|
10779
|
+
);
|
|
10780
|
+
}
|
|
10781
|
+
}
|
|
10706
10782
|
}
|
|
10707
|
-
}
|
|
10783
|
+
}
|
|
10708
10784
|
|
|
10709
10785
|
const extraColumns = ctx.extraColumns;
|
|
10710
10786
|
|