@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.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _$1 from 'lodash';
|
|
2
|
-
import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, forEach, includes, get, isBoolean, omitBy, isNil, toArray, mergeWith, map, isString, union, has, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, filter, startsWith } from 'lodash';
|
|
2
|
+
import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, forEach, includes, trimEnd, get, isBoolean, omitBy, isNil, toArray, mergeWith, map, isString, union, has, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, filter, startsWith } from 'lodash';
|
|
3
3
|
import i18next from 'i18next';
|
|
4
4
|
export { default as i18next } from 'i18next';
|
|
5
5
|
import { initReactI18next } from 'react-i18next';
|
|
@@ -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: 殷亮辉 yinlianghui@hotoa.com
|
|
403
|
+
* @LastEditTime: 2023-08-03 18:07:54
|
|
404
404
|
* @Description:
|
|
405
405
|
*/
|
|
406
406
|
|
|
@@ -482,7 +482,11 @@ function getNameTplUrl(field, ctx){
|
|
|
482
482
|
|
|
483
483
|
function getNameTpl(field, ctx){
|
|
484
484
|
const href = getNameTplUrl(field, ctx);
|
|
485
|
-
|
|
485
|
+
let linkTarget = "";
|
|
486
|
+
if(ctx && ctx.isLookup){
|
|
487
|
+
linkTarget = "target='_blank'";
|
|
488
|
+
}
|
|
489
|
+
return `<a href="${href}" ${linkTarget}>\${${field.name}}</a>`
|
|
486
490
|
}
|
|
487
491
|
|
|
488
492
|
function getRelatedFieldTpl(field, ctx){
|
|
@@ -495,6 +499,11 @@ function getRelatedFieldTpl(field, ctx){
|
|
|
495
499
|
}
|
|
496
500
|
}
|
|
497
501
|
|
|
502
|
+
let linkTarget = "";
|
|
503
|
+
if(ctx && ctx.isLookup){
|
|
504
|
+
linkTarget = "target='_blank'";
|
|
505
|
+
}
|
|
506
|
+
|
|
498
507
|
const onlyDisplayLabel = ctx.onlyDisplayLabel;
|
|
499
508
|
|
|
500
509
|
let fieldDataStrTpl = `data._display.${field.name}`;
|
|
@@ -510,7 +519,7 @@ function getRelatedFieldTpl(field, ctx){
|
|
|
510
519
|
const href = Router.getObjectDetailPath({
|
|
511
520
|
formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
|
|
512
521
|
});
|
|
513
|
-
labelTpl = `<a href="${href}"><%=item.label%></a>`;
|
|
522
|
+
labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
|
|
514
523
|
}
|
|
515
524
|
tpl = `
|
|
516
525
|
<% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item,index) { %> <% if(index>0 && index<${fieldDataStrTpl}.length){ %> , <% } %> ${labelTpl} <% }); %><% } %>
|
|
@@ -528,7 +537,7 @@ function getRelatedFieldTpl(field, ctx){
|
|
|
528
537
|
const href = Router.getObjectDetailPath({
|
|
529
538
|
formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
|
|
530
539
|
});
|
|
531
|
-
labelTpl = `<a href="${href}">${labelTpl}</a>`;
|
|
540
|
+
labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
|
|
532
541
|
}
|
|
533
542
|
tpl = labelTpl;
|
|
534
543
|
}
|
|
@@ -540,7 +549,7 @@ function getRelatedFieldTpl(field, ctx){
|
|
|
540
549
|
const href = Router.getObjectDetailPath({
|
|
541
550
|
formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
|
|
542
551
|
});
|
|
543
|
-
labelTpl = `<a href="${href}"><%=item.label%></a>`;
|
|
552
|
+
labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
|
|
544
553
|
}
|
|
545
554
|
tpl = `
|
|
546
555
|
<% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item) { %> ${labelTpl} <% }); %><% } %>
|
|
@@ -676,7 +685,7 @@ async function getFieldsTemplate(fields, display){
|
|
|
676
685
|
if(displayFields.length > 0){
|
|
677
686
|
return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
|
|
678
687
|
}
|
|
679
|
-
return `${fieldsName.join(' ')},${expandFieldsQuery}
|
|
688
|
+
return trimEnd(`${fieldsName.join(' ')},${expandFieldsQuery}`, ",")
|
|
680
689
|
}
|
|
681
690
|
|
|
682
691
|
function getRecordPermissionsTemplate(){
|
|
@@ -3251,12 +3260,6 @@ async function getObjectFieldsFilterFormSchema(ctx) {
|
|
|
3251
3260
|
if (
|
|
3252
3261
|
field && window.isFieldTypeSearchable(field.type)
|
|
3253
3262
|
) {
|
|
3254
|
-
delete field.defaultValue;
|
|
3255
|
-
delete field.required;
|
|
3256
|
-
delete field.is_wide;
|
|
3257
|
-
delete field.readonly;
|
|
3258
|
-
delete field.hidden;
|
|
3259
|
-
delete field.omit;
|
|
3260
3263
|
var ctx = ${JSON.stringify(ctx)};
|
|
3261
3264
|
const amisField = window.getFieldSearchable(field, fields, ctx);
|
|
3262
3265
|
return amisField;
|
|
@@ -3351,8 +3354,8 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3351
3354
|
}
|
|
3352
3355
|
if(!event.data.isLookup){
|
|
3353
3356
|
// 刷新浏览器后,filterFormValues值是空的,只能从本地存储中取出并重置为空值
|
|
3354
|
-
const
|
|
3355
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + (
|
|
3357
|
+
const listName = event.data.listName;
|
|
3358
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
|
|
3356
3359
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
3357
3360
|
if(localListViewProps){
|
|
3358
3361
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -3378,13 +3381,13 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3378
3381
|
const dataProviderInited = `
|
|
3379
3382
|
const objectName = data.objectName;
|
|
3380
3383
|
const isLookup = data.isLookup;
|
|
3381
|
-
const
|
|
3384
|
+
const listName = data.listName;
|
|
3382
3385
|
let searchableFieldsStoreKey = location.pathname + "/searchable_fields/";
|
|
3383
3386
|
if(isLookup){
|
|
3384
3387
|
searchableFieldsStoreKey += "lookup/" + objectName;
|
|
3385
3388
|
}
|
|
3386
3389
|
else{
|
|
3387
|
-
searchableFieldsStoreKey += (
|
|
3390
|
+
searchableFieldsStoreKey += (listName || "");
|
|
3388
3391
|
}
|
|
3389
3392
|
let defaultSearchableFields = sessionStorage.getItem(searchableFieldsStoreKey);
|
|
3390
3393
|
if(defaultSearchableFields){
|
|
@@ -3411,9 +3414,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3411
3414
|
setData({ showFieldsFilter: false });
|
|
3412
3415
|
}
|
|
3413
3416
|
else{
|
|
3414
|
-
|
|
3415
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + (data.listViewId || "");
|
|
3416
|
-
console.log("===listViewPropsStoreKey=122==", listViewPropsStoreKey);
|
|
3417
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
|
|
3417
3418
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
3418
3419
|
if(localListViewProps){
|
|
3419
3420
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -3443,7 +3444,6 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3443
3444
|
const listName = data.listName;
|
|
3444
3445
|
const objectName = data.objectName;
|
|
3445
3446
|
const isLookup = data.isLookup;
|
|
3446
|
-
const listViewId = data.listViewId;
|
|
3447
3447
|
const value = data.fields;
|
|
3448
3448
|
const scope = event.context.scoped;
|
|
3449
3449
|
// 这里的filterForm不是name为"listview-filter-form"的内部form,而是crud自带的filter form
|
|
@@ -3459,7 +3459,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3459
3459
|
searchableFieldsStoreKey += "lookup/" + objectName;
|
|
3460
3460
|
}
|
|
3461
3461
|
else{
|
|
3462
|
-
searchableFieldsStoreKey += (
|
|
3462
|
+
searchableFieldsStoreKey += (listName || "");
|
|
3463
3463
|
}
|
|
3464
3464
|
sessionStorage.setItem(searchableFieldsStoreKey, value);
|
|
3465
3465
|
|
|
@@ -3517,7 +3517,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3517
3517
|
}
|
|
3518
3518
|
|
|
3519
3519
|
// 列表视图crud支持本地缓存,所以需要进一步清除浏览器本地缓存里面用户在可搜索项中移除的字段值
|
|
3520
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + (
|
|
3520
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
|
|
3521
3521
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
3522
3522
|
if(localListViewProps){
|
|
3523
3523
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -5736,6 +5736,10 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
5736
5736
|
return ;
|
|
5737
5737
|
}
|
|
5738
5738
|
const refObjectConfig = await getUISchema(referenceTo.objectName);
|
|
5739
|
+
|
|
5740
|
+
ctx.idFieldName = refObjectConfig.idFieldName;
|
|
5741
|
+
ctx.objectName = refObjectConfig.name;
|
|
5742
|
+
|
|
5739
5743
|
const tableFields = [];
|
|
5740
5744
|
let i = 0;
|
|
5741
5745
|
const searchableFields = [];
|
|
@@ -6103,7 +6107,6 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
6103
6107
|
if(readonly){
|
|
6104
6108
|
data.tpl = await getLookupTpl(field, ctx);
|
|
6105
6109
|
}
|
|
6106
|
-
|
|
6107
6110
|
return data;
|
|
6108
6111
|
}
|
|
6109
6112
|
|
|
@@ -7433,6 +7436,24 @@ async function getFieldSearchable(perField, permissionFields, ctx){
|
|
|
7433
7436
|
_field.multiple = true;
|
|
7434
7437
|
_field.is_wide = false;
|
|
7435
7438
|
_field.defaultValue = undefined;
|
|
7439
|
+
_field.required = false;
|
|
7440
|
+
_field.hidden = false;
|
|
7441
|
+
_field.omit = false;
|
|
7442
|
+
|
|
7443
|
+
if(_field.amis){
|
|
7444
|
+
delete _field.amis.static;
|
|
7445
|
+
delete _field.amis.staticOn;
|
|
7446
|
+
delete _field.amis.disabled;
|
|
7447
|
+
delete _field.amis.disabledOn;
|
|
7448
|
+
delete _field.amis.required;
|
|
7449
|
+
delete _field.amis.requiredOn;
|
|
7450
|
+
delete _field.amis.visible;
|
|
7451
|
+
delete _field.amis.visibleOn;
|
|
7452
|
+
delete _field.amis.hidden;
|
|
7453
|
+
delete _field.amis.hiddenOn;
|
|
7454
|
+
delete _field.amis.autoFill;
|
|
7455
|
+
}
|
|
7456
|
+
|
|
7436
7457
|
const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
|
|
7437
7458
|
if(amisField){
|
|
7438
7459
|
return amisField;
|
|
@@ -7710,6 +7731,7 @@ async function getTableColumns(fields, options){
|
|
|
7710
7731
|
if(field.wrap != true){
|
|
7711
7732
|
className += " whitespace-nowrap";
|
|
7712
7733
|
}
|
|
7734
|
+
let columnItem;
|
|
7713
7735
|
if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
|
|
7714
7736
|
const previewFileScript = `
|
|
7715
7737
|
var data = event.data;
|
|
@@ -7717,12 +7739,11 @@ async function getTableColumns(fields, options){
|
|
|
7717
7739
|
var file_id = data._id;
|
|
7718
7740
|
SteedosUI.previewFile && SteedosUI.previewFile({file_name, file_id});
|
|
7719
7741
|
`;
|
|
7720
|
-
|
|
7742
|
+
columnItem = {
|
|
7721
7743
|
"type": "button",
|
|
7722
7744
|
"label": `<%=data.versions ? data.name : "${field.label}"%>`,
|
|
7723
7745
|
className,
|
|
7724
7746
|
"level": "link",
|
|
7725
|
-
"quickEdit": quickEditSchema,
|
|
7726
7747
|
"onEvent": {
|
|
7727
7748
|
"click": {
|
|
7728
7749
|
"actions": [
|
|
@@ -7748,9 +7769,9 @@ async function getTableColumns(fields, options){
|
|
|
7748
7769
|
]
|
|
7749
7770
|
}
|
|
7750
7771
|
}
|
|
7751
|
-
}
|
|
7772
|
+
};
|
|
7752
7773
|
}else if(field.type === 'toggle'){
|
|
7753
|
-
|
|
7774
|
+
columnItem = Object.assign({}, {
|
|
7754
7775
|
type: "switch",
|
|
7755
7776
|
name: field.name,
|
|
7756
7777
|
label: field.label,
|
|
@@ -7758,24 +7779,22 @@ async function getTableColumns(fields, options){
|
|
|
7758
7779
|
toggled: field.toggled,
|
|
7759
7780
|
static: true,
|
|
7760
7781
|
className,
|
|
7761
|
-
|
|
7762
|
-
}, field.amis, {name: field.name}));
|
|
7782
|
+
}, field.amis, {name: field.name});
|
|
7763
7783
|
}else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
|
|
7764
|
-
|
|
7784
|
+
columnItem = Object.assign({}, {
|
|
7765
7785
|
type: "switch",
|
|
7766
7786
|
name: field.name,
|
|
7767
7787
|
label: field.label,
|
|
7768
7788
|
width: getFieldWidth(field.width),
|
|
7769
7789
|
toggled: field.toggled,
|
|
7770
|
-
quickEdit: quickEditSchema,
|
|
7771
7790
|
static: true,
|
|
7772
7791
|
className,
|
|
7773
7792
|
...getAmisFileReadonlySchema(field)
|
|
7774
|
-
}, field.amis, {name: field.name})
|
|
7793
|
+
}, field.amis, {name: field.name});
|
|
7775
7794
|
}
|
|
7776
7795
|
else if(field.type === 'select'){
|
|
7777
7796
|
const map = getSelectMap(field.options);
|
|
7778
|
-
|
|
7797
|
+
columnItem = Object.assign({}, {
|
|
7779
7798
|
type: "mapping",
|
|
7780
7799
|
name: field.name,
|
|
7781
7800
|
label: field.label,
|
|
@@ -7785,8 +7804,7 @@ async function getTableColumns(fields, options){
|
|
|
7785
7804
|
toggled: field.toggled,
|
|
7786
7805
|
className,
|
|
7787
7806
|
static: true,
|
|
7788
|
-
|
|
7789
|
-
}, field.amis, {name: field.name}));
|
|
7807
|
+
}, field.amis, {name: field.name});
|
|
7790
7808
|
}
|
|
7791
7809
|
else {
|
|
7792
7810
|
const tpl = await getFieldTpl(field, options);
|
|
@@ -7806,7 +7824,7 @@ async function getTableColumns(fields, options){
|
|
|
7806
7824
|
className += 'min-w-56';
|
|
7807
7825
|
}
|
|
7808
7826
|
if(!field.hidden && !field.extra){
|
|
7809
|
-
|
|
7827
|
+
columnItem = Object.assign({}, {
|
|
7810
7828
|
name: field.name,
|
|
7811
7829
|
label: field.label,
|
|
7812
7830
|
sortable: field.sortable,
|
|
@@ -7817,13 +7835,18 @@ async function getTableColumns(fields, options){
|
|
|
7817
7835
|
toggled: field.toggled,
|
|
7818
7836
|
className,
|
|
7819
7837
|
static: true,
|
|
7820
|
-
quickEdit: quickEditSchema,
|
|
7821
7838
|
options: field.type === 'html' ? {html: true} : null
|
|
7822
7839
|
// toggled: true
|
|
7823
|
-
}, field.amis, {name: field.name})
|
|
7840
|
+
}, field.amis, {name: field.name});
|
|
7824
7841
|
}
|
|
7825
7842
|
}
|
|
7826
|
-
|
|
7843
|
+
if(columnItem){
|
|
7844
|
+
if(quickEditSchema){
|
|
7845
|
+
columnItem.quickEdit = quickEditSchema;
|
|
7846
|
+
columnItem.quickEditEnabledOn = "${is_system !== true}";
|
|
7847
|
+
}
|
|
7848
|
+
columns.push(columnItem);
|
|
7849
|
+
}
|
|
7827
7850
|
}
|
|
7828
7851
|
// columns.push(getOperation(fields));
|
|
7829
7852
|
if(!_$1.some(columns, { name: options.labelFieldName })){
|
|
@@ -8129,6 +8152,7 @@ async function getTableOperation(ctx){
|
|
|
8129
8152
|
}
|
|
8130
8153
|
|
|
8131
8154
|
async function getTableSchema$1(fields, options){
|
|
8155
|
+
let isLookup = options && options.isLookup;
|
|
8132
8156
|
if(!options){
|
|
8133
8157
|
options = {};
|
|
8134
8158
|
}
|
|
@@ -8138,7 +8162,9 @@ async function getTableSchema$1(fields, options){
|
|
|
8138
8162
|
}
|
|
8139
8163
|
else {
|
|
8140
8164
|
columns = await getTableColumns(fields, options);
|
|
8141
|
-
|
|
8165
|
+
if(!isLookup){
|
|
8166
|
+
columns.push(await getTableOperation(options));
|
|
8167
|
+
}
|
|
8142
8168
|
}
|
|
8143
8169
|
return {
|
|
8144
8170
|
mode: "table",
|
|
@@ -8233,8 +8259,8 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8233
8259
|
const data = _.cloneDeep(api.data);
|
|
8234
8260
|
try{
|
|
8235
8261
|
// TODO: 不应该直接在这里取localStorage,应该从外面传入
|
|
8236
|
-
const
|
|
8237
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + (
|
|
8262
|
+
const listName = api.data.listName;
|
|
8263
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
|
|
8238
8264
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
8239
8265
|
if(localListViewProps){
|
|
8240
8266
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -8434,8 +8460,8 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8434
8460
|
|
|
8435
8461
|
try{
|
|
8436
8462
|
// TODO: 不应该直接在这里取localStorage,应该从外面传入
|
|
8437
|
-
const
|
|
8438
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + (
|
|
8463
|
+
const listName = api.body.listName;
|
|
8464
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
|
|
8439
8465
|
/**
|
|
8440
8466
|
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|
|
8441
8467
|
* 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
|
|
@@ -10404,7 +10430,7 @@ async function getRelatedListSchema(
|
|
|
10404
10430
|
* @Author: baozhoutao@steedos.com
|
|
10405
10431
|
* @Date: 2022-07-05 15:55:39
|
|
10406
10432
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
10407
|
-
* @LastEditTime: 2023-08-
|
|
10433
|
+
* @LastEditTime: 2023-08-04 12:27:48
|
|
10408
10434
|
* @Description:
|
|
10409
10435
|
*/
|
|
10410
10436
|
|
|
@@ -10669,7 +10695,7 @@ async function getListSchema(
|
|
|
10669
10695
|
* 本次存储代码段
|
|
10670
10696
|
*/
|
|
10671
10697
|
try {
|
|
10672
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + (
|
|
10698
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewName || "");
|
|
10673
10699
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
10674
10700
|
/**
|
|
10675
10701
|
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|