@steedos-widgets/amis-lib 1.2.35 → 1.2.37
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 +73 -47
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +74 -48
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +73 -47
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/objects.d.ts +1 -10
- package/package.json +2 -2
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:
|
|
430
|
-
* @LastEditTime: 2023-
|
|
429
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
430
|
+
* @LastEditTime: 2023-08-03 18:07:54
|
|
431
431
|
* @Description:
|
|
432
432
|
*/
|
|
433
433
|
|
|
@@ -509,7 +509,11 @@ function getNameTplUrl(field, ctx){
|
|
|
509
509
|
|
|
510
510
|
function getNameTpl(field, ctx){
|
|
511
511
|
const href = getNameTplUrl(field, ctx);
|
|
512
|
-
|
|
512
|
+
let linkTarget = "";
|
|
513
|
+
if(ctx && ctx.isLookup){
|
|
514
|
+
linkTarget = "target='_blank'";
|
|
515
|
+
}
|
|
516
|
+
return `<a href="${href}" ${linkTarget}>\${${field.name}}</a>`
|
|
513
517
|
}
|
|
514
518
|
|
|
515
519
|
function getRelatedFieldTpl(field, ctx){
|
|
@@ -522,6 +526,11 @@ function getRelatedFieldTpl(field, ctx){
|
|
|
522
526
|
}
|
|
523
527
|
}
|
|
524
528
|
|
|
529
|
+
let linkTarget = "";
|
|
530
|
+
if(ctx && ctx.isLookup){
|
|
531
|
+
linkTarget = "target='_blank'";
|
|
532
|
+
}
|
|
533
|
+
|
|
525
534
|
const onlyDisplayLabel = ctx.onlyDisplayLabel;
|
|
526
535
|
|
|
527
536
|
let fieldDataStrTpl = `data._display.${field.name}`;
|
|
@@ -537,7 +546,7 @@ function getRelatedFieldTpl(field, ctx){
|
|
|
537
546
|
const href = Router.getObjectDetailPath({
|
|
538
547
|
formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
|
|
539
548
|
});
|
|
540
|
-
labelTpl = `<a href="${href}"><%=item.label%></a>`;
|
|
549
|
+
labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
|
|
541
550
|
}
|
|
542
551
|
tpl = `
|
|
543
552
|
<% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item,index) { %> <% if(index>0 && index<${fieldDataStrTpl}.length){ %> , <% } %> ${labelTpl} <% }); %><% } %>
|
|
@@ -555,7 +564,7 @@ function getRelatedFieldTpl(field, ctx){
|
|
|
555
564
|
const href = Router.getObjectDetailPath({
|
|
556
565
|
formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
|
|
557
566
|
});
|
|
558
|
-
labelTpl = `<a href="${href}">${labelTpl}</a>`;
|
|
567
|
+
labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
|
|
559
568
|
}
|
|
560
569
|
tpl = labelTpl;
|
|
561
570
|
}
|
|
@@ -567,7 +576,7 @@ function getRelatedFieldTpl(field, ctx){
|
|
|
567
576
|
const href = Router.getObjectDetailPath({
|
|
568
577
|
formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
|
|
569
578
|
});
|
|
570
|
-
labelTpl = `<a href="${href}"><%=item.label%></a>`;
|
|
579
|
+
labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
|
|
571
580
|
}
|
|
572
581
|
tpl = `
|
|
573
582
|
<% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item) { %> ${labelTpl} <% }); %><% } %>
|
|
@@ -703,7 +712,7 @@ async function getFieldsTemplate(fields, display){
|
|
|
703
712
|
if(displayFields.length > 0){
|
|
704
713
|
return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
|
|
705
714
|
}
|
|
706
|
-
return `${fieldsName.join(' ')},${expandFieldsQuery}
|
|
715
|
+
return _$1.trimEnd(`${fieldsName.join(' ')},${expandFieldsQuery}`, ",")
|
|
707
716
|
}
|
|
708
717
|
|
|
709
718
|
function getRecordPermissionsTemplate(){
|
|
@@ -3278,12 +3287,6 @@ async function getObjectFieldsFilterFormSchema(ctx) {
|
|
|
3278
3287
|
if (
|
|
3279
3288
|
field && window.isFieldTypeSearchable(field.type)
|
|
3280
3289
|
) {
|
|
3281
|
-
delete field.defaultValue;
|
|
3282
|
-
delete field.required;
|
|
3283
|
-
delete field.is_wide;
|
|
3284
|
-
delete field.readonly;
|
|
3285
|
-
delete field.hidden;
|
|
3286
|
-
delete field.omit;
|
|
3287
3290
|
var ctx = ${JSON.stringify(ctx)};
|
|
3288
3291
|
const amisField = window.getFieldSearchable(field, fields, ctx);
|
|
3289
3292
|
return amisField;
|
|
@@ -3378,8 +3381,8 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3378
3381
|
}
|
|
3379
3382
|
if(!event.data.isLookup){
|
|
3380
3383
|
// 刷新浏览器后,filterFormValues值是空的,只能从本地存储中取出并重置为空值
|
|
3381
|
-
const
|
|
3382
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + (
|
|
3384
|
+
const listName = event.data.listName;
|
|
3385
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
|
|
3383
3386
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
3384
3387
|
if(localListViewProps){
|
|
3385
3388
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -3405,13 +3408,13 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3405
3408
|
const dataProviderInited = `
|
|
3406
3409
|
const objectName = data.objectName;
|
|
3407
3410
|
const isLookup = data.isLookup;
|
|
3408
|
-
const
|
|
3411
|
+
const listName = data.listName;
|
|
3409
3412
|
let searchableFieldsStoreKey = location.pathname + "/searchable_fields/";
|
|
3410
3413
|
if(isLookup){
|
|
3411
3414
|
searchableFieldsStoreKey += "lookup/" + objectName;
|
|
3412
3415
|
}
|
|
3413
3416
|
else{
|
|
3414
|
-
searchableFieldsStoreKey += (
|
|
3417
|
+
searchableFieldsStoreKey += (listName || "");
|
|
3415
3418
|
}
|
|
3416
3419
|
let defaultSearchableFields = sessionStorage.getItem(searchableFieldsStoreKey);
|
|
3417
3420
|
if(defaultSearchableFields){
|
|
@@ -3438,9 +3441,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3438
3441
|
setData({ showFieldsFilter: false });
|
|
3439
3442
|
}
|
|
3440
3443
|
else{
|
|
3441
|
-
|
|
3442
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + (data.listViewId || "");
|
|
3443
|
-
console.log("===listViewPropsStoreKey=122==", listViewPropsStoreKey);
|
|
3444
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
|
|
3444
3445
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
3445
3446
|
if(localListViewProps){
|
|
3446
3447
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -3470,7 +3471,6 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3470
3471
|
const listName = data.listName;
|
|
3471
3472
|
const objectName = data.objectName;
|
|
3472
3473
|
const isLookup = data.isLookup;
|
|
3473
|
-
const listViewId = data.listViewId;
|
|
3474
3474
|
const value = data.fields;
|
|
3475
3475
|
const scope = event.context.scoped;
|
|
3476
3476
|
// 这里的filterForm不是name为"listview-filter-form"的内部form,而是crud自带的filter form
|
|
@@ -3486,7 +3486,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3486
3486
|
searchableFieldsStoreKey += "lookup/" + objectName;
|
|
3487
3487
|
}
|
|
3488
3488
|
else{
|
|
3489
|
-
searchableFieldsStoreKey += (
|
|
3489
|
+
searchableFieldsStoreKey += (listName || "");
|
|
3490
3490
|
}
|
|
3491
3491
|
sessionStorage.setItem(searchableFieldsStoreKey, value);
|
|
3492
3492
|
|
|
@@ -3544,7 +3544,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3544
3544
|
}
|
|
3545
3545
|
|
|
3546
3546
|
// 列表视图crud支持本地缓存,所以需要进一步清除浏览器本地缓存里面用户在可搜索项中移除的字段值
|
|
3547
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + (
|
|
3547
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
|
|
3548
3548
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
3549
3549
|
if(localListViewProps){
|
|
3550
3550
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -5763,6 +5763,10 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
5763
5763
|
return ;
|
|
5764
5764
|
}
|
|
5765
5765
|
const refObjectConfig = await getUISchema(referenceTo.objectName);
|
|
5766
|
+
|
|
5767
|
+
ctx.idFieldName = refObjectConfig.idFieldName;
|
|
5768
|
+
ctx.objectName = refObjectConfig.name;
|
|
5769
|
+
|
|
5766
5770
|
const tableFields = [];
|
|
5767
5771
|
let i = 0;
|
|
5768
5772
|
const searchableFields = [];
|
|
@@ -6130,7 +6134,6 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
6130
6134
|
if(readonly){
|
|
6131
6135
|
data.tpl = await getLookupTpl(field, ctx);
|
|
6132
6136
|
}
|
|
6133
|
-
|
|
6134
6137
|
return data;
|
|
6135
6138
|
}
|
|
6136
6139
|
|
|
@@ -7460,6 +7463,24 @@ async function getFieldSearchable(perField, permissionFields, ctx){
|
|
|
7460
7463
|
_field.multiple = true;
|
|
7461
7464
|
_field.is_wide = false;
|
|
7462
7465
|
_field.defaultValue = undefined;
|
|
7466
|
+
_field.required = false;
|
|
7467
|
+
_field.hidden = false;
|
|
7468
|
+
_field.omit = false;
|
|
7469
|
+
|
|
7470
|
+
if(_field.amis){
|
|
7471
|
+
delete _field.amis.static;
|
|
7472
|
+
delete _field.amis.staticOn;
|
|
7473
|
+
delete _field.amis.disabled;
|
|
7474
|
+
delete _field.amis.disabledOn;
|
|
7475
|
+
delete _field.amis.required;
|
|
7476
|
+
delete _field.amis.requiredOn;
|
|
7477
|
+
delete _field.amis.visible;
|
|
7478
|
+
delete _field.amis.visibleOn;
|
|
7479
|
+
delete _field.amis.hidden;
|
|
7480
|
+
delete _field.amis.hiddenOn;
|
|
7481
|
+
delete _field.amis.autoFill;
|
|
7482
|
+
}
|
|
7483
|
+
|
|
7463
7484
|
const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
|
|
7464
7485
|
if(amisField){
|
|
7465
7486
|
return amisField;
|
|
@@ -7737,6 +7758,7 @@ async function getTableColumns(fields, options){
|
|
|
7737
7758
|
if(field.wrap != true){
|
|
7738
7759
|
className += " whitespace-nowrap";
|
|
7739
7760
|
}
|
|
7761
|
+
let columnItem;
|
|
7740
7762
|
if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
|
|
7741
7763
|
const previewFileScript = `
|
|
7742
7764
|
var data = event.data;
|
|
@@ -7744,12 +7766,11 @@ async function getTableColumns(fields, options){
|
|
|
7744
7766
|
var file_id = data._id;
|
|
7745
7767
|
SteedosUI.previewFile && SteedosUI.previewFile({file_name, file_id});
|
|
7746
7768
|
`;
|
|
7747
|
-
|
|
7769
|
+
columnItem = {
|
|
7748
7770
|
"type": "button",
|
|
7749
7771
|
"label": `<%=data.versions ? data.name : "${field.label}"%>`,
|
|
7750
7772
|
className,
|
|
7751
7773
|
"level": "link",
|
|
7752
|
-
"quickEdit": quickEditSchema,
|
|
7753
7774
|
"onEvent": {
|
|
7754
7775
|
"click": {
|
|
7755
7776
|
"actions": [
|
|
@@ -7775,9 +7796,9 @@ async function getTableColumns(fields, options){
|
|
|
7775
7796
|
]
|
|
7776
7797
|
}
|
|
7777
7798
|
}
|
|
7778
|
-
}
|
|
7799
|
+
};
|
|
7779
7800
|
}else if(field.type === 'toggle'){
|
|
7780
|
-
|
|
7801
|
+
columnItem = Object.assign({}, {
|
|
7781
7802
|
type: "switch",
|
|
7782
7803
|
name: field.name,
|
|
7783
7804
|
label: field.label,
|
|
@@ -7785,24 +7806,22 @@ async function getTableColumns(fields, options){
|
|
|
7785
7806
|
toggled: field.toggled,
|
|
7786
7807
|
static: true,
|
|
7787
7808
|
className,
|
|
7788
|
-
|
|
7789
|
-
}, field.amis, {name: field.name}));
|
|
7809
|
+
}, field.amis, {name: field.name});
|
|
7790
7810
|
}else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
|
|
7791
|
-
|
|
7811
|
+
columnItem = Object.assign({}, {
|
|
7792
7812
|
type: "switch",
|
|
7793
7813
|
name: field.name,
|
|
7794
7814
|
label: field.label,
|
|
7795
7815
|
width: getFieldWidth(field.width),
|
|
7796
7816
|
toggled: field.toggled,
|
|
7797
|
-
quickEdit: quickEditSchema,
|
|
7798
7817
|
static: true,
|
|
7799
7818
|
className,
|
|
7800
7819
|
...getAmisFileReadonlySchema(field)
|
|
7801
|
-
}, field.amis, {name: field.name})
|
|
7820
|
+
}, field.amis, {name: field.name});
|
|
7802
7821
|
}
|
|
7803
7822
|
else if(field.type === 'select'){
|
|
7804
7823
|
const map = getSelectMap(field.options);
|
|
7805
|
-
|
|
7824
|
+
columnItem = Object.assign({}, {
|
|
7806
7825
|
type: "mapping",
|
|
7807
7826
|
name: field.name,
|
|
7808
7827
|
label: field.label,
|
|
@@ -7812,8 +7831,7 @@ async function getTableColumns(fields, options){
|
|
|
7812
7831
|
toggled: field.toggled,
|
|
7813
7832
|
className,
|
|
7814
7833
|
static: true,
|
|
7815
|
-
|
|
7816
|
-
}, field.amis, {name: field.name}));
|
|
7834
|
+
}, field.amis, {name: field.name});
|
|
7817
7835
|
}
|
|
7818
7836
|
else {
|
|
7819
7837
|
const tpl = await getFieldTpl(field, options);
|
|
@@ -7833,7 +7851,7 @@ async function getTableColumns(fields, options){
|
|
|
7833
7851
|
className += 'min-w-56';
|
|
7834
7852
|
}
|
|
7835
7853
|
if(!field.hidden && !field.extra){
|
|
7836
|
-
|
|
7854
|
+
columnItem = Object.assign({}, {
|
|
7837
7855
|
name: field.name,
|
|
7838
7856
|
label: field.label,
|
|
7839
7857
|
sortable: field.sortable,
|
|
@@ -7844,13 +7862,18 @@ async function getTableColumns(fields, options){
|
|
|
7844
7862
|
toggled: field.toggled,
|
|
7845
7863
|
className,
|
|
7846
7864
|
static: true,
|
|
7847
|
-
quickEdit: quickEditSchema,
|
|
7848
7865
|
options: field.type === 'html' ? {html: true} : null
|
|
7849
7866
|
// toggled: true
|
|
7850
|
-
}, field.amis, {name: field.name})
|
|
7867
|
+
}, field.amis, {name: field.name});
|
|
7851
7868
|
}
|
|
7852
7869
|
}
|
|
7853
|
-
|
|
7870
|
+
if(columnItem){
|
|
7871
|
+
if(quickEditSchema){
|
|
7872
|
+
columnItem.quickEdit = quickEditSchema;
|
|
7873
|
+
columnItem.quickEditEnabledOn = "${is_system !== true}";
|
|
7874
|
+
}
|
|
7875
|
+
columns.push(columnItem);
|
|
7876
|
+
}
|
|
7854
7877
|
}
|
|
7855
7878
|
// columns.push(getOperation(fields));
|
|
7856
7879
|
if(!___namespace.some(columns, { name: options.labelFieldName })){
|
|
@@ -8156,6 +8179,7 @@ async function getTableOperation(ctx){
|
|
|
8156
8179
|
}
|
|
8157
8180
|
|
|
8158
8181
|
async function getTableSchema$1(fields, options){
|
|
8182
|
+
let isLookup = options && options.isLookup;
|
|
8159
8183
|
if(!options){
|
|
8160
8184
|
options = {};
|
|
8161
8185
|
}
|
|
@@ -8165,7 +8189,9 @@ async function getTableSchema$1(fields, options){
|
|
|
8165
8189
|
}
|
|
8166
8190
|
else {
|
|
8167
8191
|
columns = await getTableColumns(fields, options);
|
|
8168
|
-
|
|
8192
|
+
if(!isLookup){
|
|
8193
|
+
columns.push(await getTableOperation(options));
|
|
8194
|
+
}
|
|
8169
8195
|
}
|
|
8170
8196
|
return {
|
|
8171
8197
|
mode: "table",
|
|
@@ -8260,8 +8286,8 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8260
8286
|
const data = _.cloneDeep(api.data);
|
|
8261
8287
|
try{
|
|
8262
8288
|
// TODO: 不应该直接在这里取localStorage,应该从外面传入
|
|
8263
|
-
const
|
|
8264
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + (
|
|
8289
|
+
const listName = api.data.listName;
|
|
8290
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
|
|
8265
8291
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
8266
8292
|
if(localListViewProps){
|
|
8267
8293
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -8461,8 +8487,8 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8461
8487
|
|
|
8462
8488
|
try{
|
|
8463
8489
|
// TODO: 不应该直接在这里取localStorage,应该从外面传入
|
|
8464
|
-
const
|
|
8465
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + (
|
|
8490
|
+
const listName = api.body.listName;
|
|
8491
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
|
|
8466
8492
|
/**
|
|
8467
8493
|
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|
|
8468
8494
|
* 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
|
|
@@ -10431,7 +10457,7 @@ async function getRelatedListSchema(
|
|
|
10431
10457
|
* @Author: baozhoutao@steedos.com
|
|
10432
10458
|
* @Date: 2022-07-05 15:55:39
|
|
10433
10459
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
10434
|
-
* @LastEditTime: 2023-08-
|
|
10460
|
+
* @LastEditTime: 2023-08-04 12:27:48
|
|
10435
10461
|
* @Description:
|
|
10436
10462
|
*/
|
|
10437
10463
|
|
|
@@ -10696,7 +10722,7 @@ async function getListSchema(
|
|
|
10696
10722
|
* 本次存储代码段
|
|
10697
10723
|
*/
|
|
10698
10724
|
try {
|
|
10699
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + (
|
|
10725
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewName || "");
|
|
10700
10726
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
10701
10727
|
/**
|
|
10702
10728
|
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|