@steedos-widgets/amis-lib 1.2.11 → 1.2.13
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 +152 -20
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +152 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +152 -20
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/fields/editor.d.ts +10 -0
- package/dist/types/lib/converter/amis/header.d.ts +5 -0
- package/dist/types/lib/converter/amis/index.d.ts +2 -5
- package/dist/types/lib/converter/amis/toolbars/setting_listview.d.ts +1 -0
- package/dist/types/lib/objects.d.ts +2 -5
- package/dist/types/schema/standard_import_data.amis.d.ts +16 -0
- package/dist/types/standard/button.d.ts +16 -0
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -1894,7 +1894,23 @@
|
|
|
1894
1894
|
{
|
|
1895
1895
|
name: "template_url",
|
|
1896
1896
|
label: "导入模板",
|
|
1897
|
-
type: "
|
|
1897
|
+
type: "button-group",
|
|
1898
|
+
buttons: [
|
|
1899
|
+
{
|
|
1900
|
+
type: "button",
|
|
1901
|
+
label: "下载",
|
|
1902
|
+
visibleOn: "${template_url}",
|
|
1903
|
+
level: "link",
|
|
1904
|
+
actionType: "download",
|
|
1905
|
+
api:{
|
|
1906
|
+
url: "${template_url}",
|
|
1907
|
+
method: "get",
|
|
1908
|
+
headers: {
|
|
1909
|
+
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
],
|
|
1898
1914
|
options: {
|
|
1899
1915
|
html: true
|
|
1900
1916
|
},
|
|
@@ -2442,7 +2458,14 @@
|
|
|
2442
2458
|
className: `button_${button.name}`
|
|
2443
2459
|
}
|
|
2444
2460
|
});
|
|
2445
|
-
let
|
|
2461
|
+
let moreButtonsVisibleOn = '';
|
|
2462
|
+
let dropdownButtons = ___default["default"].map(moreButtons, (button, index) => {
|
|
2463
|
+
if(index === 0){
|
|
2464
|
+
moreButtonsVisibleOn = getButtonVisibleOn$1(button);
|
|
2465
|
+
}else {
|
|
2466
|
+
moreButtonsVisibleOn = moreButtonsVisibleOn + ' || ' +getButtonVisibleOn$1(button);
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2446
2469
|
return {
|
|
2447
2470
|
type: 'steedos-object-button',
|
|
2448
2471
|
name: button.name,
|
|
@@ -2452,12 +2475,13 @@
|
|
|
2452
2475
|
});
|
|
2453
2476
|
return {
|
|
2454
2477
|
buttons: amisButtonsSchema,
|
|
2455
|
-
moreButtons: dropdownButtons
|
|
2478
|
+
moreButtons: dropdownButtons,
|
|
2479
|
+
moreButtonsVisibleOn
|
|
2456
2480
|
};
|
|
2457
2481
|
};
|
|
2458
2482
|
|
|
2459
2483
|
const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
|
|
2460
|
-
const { buttons, moreButtons } = getObjectDetailHeaderButtons(objectSchema, recordId);
|
|
2484
|
+
const { buttons, moreButtons, moreButtonsVisibleOn } = getObjectDetailHeaderButtons(objectSchema, recordId);
|
|
2461
2485
|
if(ctx.formFactor === 'SMALL'){
|
|
2462
2486
|
return {
|
|
2463
2487
|
"type": "button",
|
|
@@ -2512,7 +2536,8 @@
|
|
|
2512
2536
|
type: "steedos-dropdown-button",
|
|
2513
2537
|
label: "",
|
|
2514
2538
|
buttons: moreButtons,
|
|
2515
|
-
className: 'slds-icon'
|
|
2539
|
+
className: 'slds-icon',
|
|
2540
|
+
visibleOn: moreButtonsVisibleOn
|
|
2516
2541
|
};
|
|
2517
2542
|
buttons.push(dropdownButtonsSchema);
|
|
2518
2543
|
}
|
|
@@ -4645,12 +4670,13 @@
|
|
|
4645
4670
|
"type": "dropdown-button",
|
|
4646
4671
|
"trigger": "click",
|
|
4647
4672
|
"icon": "fa fa-cog",
|
|
4673
|
+
"tooltip": "列表视图控制",
|
|
4648
4674
|
"btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
4649
4675
|
"align": "right",
|
|
4650
4676
|
"visibleOn": "${!isLookup}",
|
|
4651
4677
|
"buttons": [
|
|
4652
4678
|
{
|
|
4653
|
-
"label": "
|
|
4679
|
+
"label": "列表视图控制",
|
|
4654
4680
|
"children": [
|
|
4655
4681
|
getNewListviewButtonSchema(),
|
|
4656
4682
|
getCopyListviewButtonSchema(),
|
|
@@ -4684,9 +4710,11 @@
|
|
|
4684
4710
|
"rightIconClassName": "m-l-sm"
|
|
4685
4711
|
}
|
|
4686
4712
|
];
|
|
4713
|
+
const displayAsLabel = displayAs === 'split'? "分栏视图" : "表格";
|
|
4687
4714
|
return {
|
|
4688
4715
|
"type": "dropdown-button",
|
|
4689
4716
|
"icon": "fa fa-table-columns",
|
|
4717
|
+
"tooltip": `显示为 ${displayAsLabel}`,
|
|
4690
4718
|
"btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
4691
4719
|
"align": "right",
|
|
4692
4720
|
"visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
|
|
@@ -4766,6 +4794,7 @@ else{
|
|
|
4766
4794
|
// "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
|
|
4767
4795
|
"type": "button",
|
|
4768
4796
|
"align": "right",
|
|
4797
|
+
"tooltip": "刷新",
|
|
4769
4798
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
4770
4799
|
"label": "",
|
|
4771
4800
|
"icon": "fa fa-sync",
|
|
@@ -4785,6 +4814,7 @@ else{
|
|
|
4785
4814
|
"label": "",
|
|
4786
4815
|
"icon": "fa fa-search",
|
|
4787
4816
|
"type": "button",
|
|
4817
|
+
"tooltip": "搜索",
|
|
4788
4818
|
"badge": {
|
|
4789
4819
|
"offset": [
|
|
4790
4820
|
-5,
|
|
@@ -4829,6 +4859,7 @@ else{
|
|
|
4829
4859
|
{
|
|
4830
4860
|
"type": "reload",
|
|
4831
4861
|
"align": "right",
|
|
4862
|
+
"tooltip": "刷新",
|
|
4832
4863
|
"tooltipPlacement": "bottom",
|
|
4833
4864
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500"
|
|
4834
4865
|
},
|
|
@@ -4836,6 +4867,8 @@ else{
|
|
|
4836
4867
|
filterVisible ? {
|
|
4837
4868
|
"label": "",
|
|
4838
4869
|
"icon": "fa fa-search",
|
|
4870
|
+
"tooltip": "搜索",
|
|
4871
|
+
"tooltipPlacement": "bottom",
|
|
4839
4872
|
"type": "button",
|
|
4840
4873
|
"align": "right",
|
|
4841
4874
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
@@ -5860,8 +5893,8 @@ else{
|
|
|
5860
5893
|
/*
|
|
5861
5894
|
* @Author: baozhoutao@steedos.com
|
|
5862
5895
|
* @Date: 2023-01-13 17:27:54
|
|
5863
|
-
* @LastEditors:
|
|
5864
|
-
* @LastEditTime: 2023-
|
|
5896
|
+
* @LastEditors: Please set LastEditors
|
|
5897
|
+
* @LastEditTime: 2023-05-31 13:34:22
|
|
5865
5898
|
* @Description:
|
|
5866
5899
|
*/
|
|
5867
5900
|
|
|
@@ -5903,8 +5936,12 @@ else{
|
|
|
5903
5936
|
const getHtmlFieldSchema = (field, readonly, ctx)=>{
|
|
5904
5937
|
if(readonly){
|
|
5905
5938
|
return {
|
|
5906
|
-
"type": "
|
|
5907
|
-
"
|
|
5939
|
+
"type": "control",
|
|
5940
|
+
"label": field.label,
|
|
5941
|
+
"body": {
|
|
5942
|
+
"type": "html",
|
|
5943
|
+
"name": field.name
|
|
5944
|
+
}
|
|
5908
5945
|
}
|
|
5909
5946
|
}else {
|
|
5910
5947
|
return {
|
|
@@ -5931,8 +5968,8 @@ else{
|
|
|
5931
5968
|
/*
|
|
5932
5969
|
* @Author: baozhoutao@steedos.com
|
|
5933
5970
|
* @Date: 2022-10-28 14:52:55
|
|
5934
|
-
* @LastEditors:
|
|
5935
|
-
* @LastEditTime:
|
|
5971
|
+
* @LastEditors: Please set LastEditors
|
|
5972
|
+
* @LastEditTime: 2023-05-31 13:25:53
|
|
5936
5973
|
* @Description:
|
|
5937
5974
|
*/
|
|
5938
5975
|
|
|
@@ -6481,8 +6518,19 @@ else{
|
|
|
6481
6518
|
break;
|
|
6482
6519
|
case 'url':
|
|
6483
6520
|
convertData = {
|
|
6484
|
-
type: getAmisStaticFieldType('url', readonly)
|
|
6521
|
+
type: getAmisStaticFieldType('url', readonly, field)
|
|
6485
6522
|
};
|
|
6523
|
+
if(readonly && field.show_as_qr){
|
|
6524
|
+
convertData = {
|
|
6525
|
+
type: "control",
|
|
6526
|
+
label: field.label,
|
|
6527
|
+
body: {
|
|
6528
|
+
type: "qr-code",
|
|
6529
|
+
codeSize: 128,
|
|
6530
|
+
name: field.name
|
|
6531
|
+
}
|
|
6532
|
+
};
|
|
6533
|
+
}
|
|
6486
6534
|
break;
|
|
6487
6535
|
case 'email':
|
|
6488
6536
|
convertData = {
|
|
@@ -6517,6 +6565,7 @@ else{
|
|
|
6517
6565
|
case 'code':
|
|
6518
6566
|
convertData = {
|
|
6519
6567
|
type: "editor",
|
|
6568
|
+
disabled: readonly ? true : false,
|
|
6520
6569
|
language: field.language,
|
|
6521
6570
|
editorDidMount: new Function('editor', 'monaco', field.editorDidMount)
|
|
6522
6571
|
};
|
|
@@ -7174,12 +7223,43 @@ else{
|
|
|
7174
7223
|
const fieldSchemaArray = getFieldSchemaArray(formFields);
|
|
7175
7224
|
const _sections = ___namespace.groupBy(fieldSchemaArray, 'group');
|
|
7176
7225
|
const sections = [];
|
|
7226
|
+
var sectionHeaderVisibleOn=[];
|
|
7177
7227
|
for (const key in _sections) {
|
|
7178
7228
|
const section = await getSection(formFields, permissionFields, fieldSchemaArray, key, ctx);
|
|
7179
7229
|
if(section.body.length > 0){
|
|
7230
|
+
if(section.visibleOn){
|
|
7231
|
+
sectionHeaderVisibleOn.push(section.visibleOn);
|
|
7232
|
+
}
|
|
7180
7233
|
sections.push(section);
|
|
7181
7234
|
}
|
|
7182
7235
|
}
|
|
7236
|
+
/*
|
|
7237
|
+
为了实现只有一个分组时隐藏该分组标题,需要分三种情况(分组如果没有visibleon属性就代表一定显示,有visibleon需要进行判断)
|
|
7238
|
+
1.所有分组中只有一个分组没有visibleon,还需要判断其他有visibleon的分组是否显示,只有其他都不显示时,才需要隐藏标题;反之,有任何一个显示,就不需要隐藏标题
|
|
7239
|
+
2.所有分组都有visibleon
|
|
7240
|
+
2.1 当前分组为隐藏时,标题就设置为隐藏
|
|
7241
|
+
2.2 当前分组为显示时,其他分组只要有一个是显示,就显示该分组标题
|
|
7242
|
+
2.3 当前分组为显示时,其他分组都隐藏,就隐藏该分组标题
|
|
7243
|
+
3.所有分组中有两个以上的分组没有visibleon(这种情况不用处理)
|
|
7244
|
+
*/
|
|
7245
|
+
if(ctx.mode == "edit"){
|
|
7246
|
+
if (sections.length - sectionHeaderVisibleOn.length == 1) {
|
|
7247
|
+
sections.forEach((section) => {
|
|
7248
|
+
section.headingClassName = {
|
|
7249
|
+
"hidden": `!(${sectionHeaderVisibleOn.join(" || ") || 'false'})`
|
|
7250
|
+
};
|
|
7251
|
+
});
|
|
7252
|
+
} else if (sections.length == sectionHeaderVisibleOn.length) {
|
|
7253
|
+
sections.forEach((section, index) => {
|
|
7254
|
+
var tempSectionHeaderVisibleOn = sectionHeaderVisibleOn.slice();
|
|
7255
|
+
tempSectionHeaderVisibleOn.splice(index, 1);
|
|
7256
|
+
section.headingClassName = {
|
|
7257
|
+
"hidden": `!((${tempSectionHeaderVisibleOn.join(" || ") || 'false'}) && ${sectionHeaderVisibleOn[index]})`
|
|
7258
|
+
};
|
|
7259
|
+
});
|
|
7260
|
+
}
|
|
7261
|
+
}
|
|
7262
|
+
|
|
7183
7263
|
return sections;
|
|
7184
7264
|
};
|
|
7185
7265
|
|
|
@@ -7550,11 +7630,12 @@ else{
|
|
|
7550
7630
|
"expression": "this.__deletedRecord != true"
|
|
7551
7631
|
},
|
|
7552
7632
|
{
|
|
7553
|
-
"args": {
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
},
|
|
7557
|
-
"actionType": "
|
|
7633
|
+
// "args": {
|
|
7634
|
+
// "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
|
|
7635
|
+
// "blank": false
|
|
7636
|
+
// },
|
|
7637
|
+
"actionType": "custom",
|
|
7638
|
+
"script": "Steedos.goBack()",
|
|
7558
7639
|
"expression": "this.__deletedRecord === true"
|
|
7559
7640
|
}
|
|
7560
7641
|
]
|
|
@@ -7693,6 +7774,8 @@ else{
|
|
|
7693
7774
|
type = 'tpl';
|
|
7694
7775
|
}else if(field.type === 'html'){
|
|
7695
7776
|
type = 'markdown';
|
|
7777
|
+
}else if(field.type === 'url' && field.show_as_qr){
|
|
7778
|
+
type = 'qr-code';
|
|
7696
7779
|
}
|
|
7697
7780
|
let className = "";
|
|
7698
7781
|
if(field.type === 'textarea'){
|
|
@@ -7720,7 +7803,13 @@ else{
|
|
|
7720
7803
|
|
|
7721
7804
|
}
|
|
7722
7805
|
// columns.push(getOperation(fields));
|
|
7723
|
-
|
|
7806
|
+
if(!___namespace.some(columns, { name: options.labelFieldName })){
|
|
7807
|
+
const href = Router.getObjectDetailPath({
|
|
7808
|
+
...options, formFactor: options.formFactor, appId: "${appId}", objectName: options.objectName || "${objectName}", recordId: `\${${options.idFieldName}}`
|
|
7809
|
+
});
|
|
7810
|
+
columns[0].type = "tpl";
|
|
7811
|
+
columns[0].tpl = `<a href="${href}">\${${columns[0].name}}</a>`;
|
|
7812
|
+
}
|
|
7724
7813
|
return columns;
|
|
7725
7814
|
}
|
|
7726
7815
|
|
|
@@ -8086,6 +8175,8 @@ else{
|
|
|
8086
8175
|
|
|
8087
8176
|
const fileFields = {};
|
|
8088
8177
|
const fileFieldsKeys = [];
|
|
8178
|
+
// 含有optionsFunction属性, 无reference_to属性的lookup字段
|
|
8179
|
+
const lookupFields = {};
|
|
8089
8180
|
fields.forEach((item)=>{
|
|
8090
8181
|
if(___namespace.includes(['image','avatar','file'], item.type)){
|
|
8091
8182
|
fileFieldsKeys.push(item.name);
|
|
@@ -8095,6 +8186,9 @@ else{
|
|
|
8095
8186
|
multiple: item.multiple
|
|
8096
8187
|
};
|
|
8097
8188
|
}
|
|
8189
|
+
if(___namespace.includes(['lookup'], item.type) && !item.reference_to ){
|
|
8190
|
+
lookupFields[item.name] = item;
|
|
8191
|
+
}
|
|
8098
8192
|
});
|
|
8099
8193
|
|
|
8100
8194
|
let valueField = mainObject.key_field || '_id';
|
|
@@ -8111,6 +8205,7 @@ else{
|
|
|
8111
8205
|
api.data.filter = "$filter";
|
|
8112
8206
|
api.data.loaded = "${loaded}";
|
|
8113
8207
|
api.data.listViewId = "${listViewId}";
|
|
8208
|
+
api.data.listName = "${listName}";
|
|
8114
8209
|
api.requestAdaptor = `
|
|
8115
8210
|
// selfData 中的数据由 CRUD 控制. selfData中,只能获取到 CRUD 给定的data. 无法从数据链中获取数据.
|
|
8116
8211
|
let selfData = JSON.parse(JSON.stringify(api.data.$self));
|
|
@@ -8141,9 +8236,13 @@ else{
|
|
|
8141
8236
|
console.error("本地存储中crud参数解析异常:", ex);
|
|
8142
8237
|
}
|
|
8143
8238
|
${baseFilters ? `var systemFilters = ${JSON.stringify(baseFilters)};` : 'var systemFilters = [];'}
|
|
8239
|
+
var _ids = []
|
|
8144
8240
|
const filtersFunction = ${filtersFunction};
|
|
8145
8241
|
if(filtersFunction){
|
|
8146
8242
|
const _filters = filtersFunction(systemFilters, api.data.$self);
|
|
8243
|
+
if(api.data.listName == "recent"){
|
|
8244
|
+
_ids = _filters[2]
|
|
8245
|
+
}
|
|
8147
8246
|
if(_filters && _filters.length > 0){
|
|
8148
8247
|
if(_.isEmpty(systemFilters)){
|
|
8149
8248
|
systemFilters = _filters || [];
|
|
@@ -8255,6 +8354,7 @@ else{
|
|
|
8255
8354
|
filters = [filters, 'and', userFilters]
|
|
8256
8355
|
}
|
|
8257
8356
|
}
|
|
8357
|
+
api.data._ids = _ids;
|
|
8258
8358
|
api.data = {
|
|
8259
8359
|
query: api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim())
|
|
8260
8360
|
}
|
|
@@ -8262,6 +8362,11 @@ else{
|
|
|
8262
8362
|
return api;
|
|
8263
8363
|
`;
|
|
8264
8364
|
api.adaptor = `
|
|
8365
|
+
if(api.body.listName == "recent"){
|
|
8366
|
+
payload.data.rows = _.sortBy(payload.data.rows, function(item){
|
|
8367
|
+
return _.indexOf(api.body._ids, item._id)
|
|
8368
|
+
});
|
|
8369
|
+
}
|
|
8265
8370
|
const enable_tree = ${mainObject.enable_tree};
|
|
8266
8371
|
if(!enable_tree){
|
|
8267
8372
|
_.each(payload.data.rows, function(item, index){
|
|
@@ -8272,9 +8377,10 @@ else{
|
|
|
8272
8377
|
}
|
|
8273
8378
|
window.postMessage(Object.assign({type: "listview.loaded"}), "*");
|
|
8274
8379
|
let fileFields = ${JSON.stringify(fileFields)};
|
|
8380
|
+
let lookupFields = ${JSON.stringify(lookupFields)};
|
|
8275
8381
|
_.each(payload.data.rows, function(item, index){
|
|
8276
8382
|
_.each(fileFields , (field, key)=>{
|
|
8277
|
-
if(item[key] && item._display && item._display
|
|
8383
|
+
if(item[key] && item._display && item._display[key]){
|
|
8278
8384
|
let value = item._display[key];
|
|
8279
8385
|
if(!_.isArray(value)){
|
|
8280
8386
|
value = [value]
|
|
@@ -8286,6 +8392,14 @@ else{
|
|
|
8286
8392
|
}
|
|
8287
8393
|
}
|
|
8288
8394
|
})
|
|
8395
|
+
_.each(lookupFields , (field, key)=>{
|
|
8396
|
+
if(item[key]){
|
|
8397
|
+
if(field._optionsFunction){
|
|
8398
|
+
const optionsFunction = eval("(" + field._optionsFunction+ ")")(item);
|
|
8399
|
+
item[key + '__label'] = _.map(_.filter(optionsFunction, function(option){return _.includes(item[key], option.value)}), 'label').join(' ');
|
|
8400
|
+
}
|
|
8401
|
+
}
|
|
8402
|
+
})
|
|
8289
8403
|
})
|
|
8290
8404
|
|
|
8291
8405
|
if(enable_tree){
|
|
@@ -9615,6 +9729,24 @@ else{
|
|
|
9615
9729
|
|
|
9616
9730
|
ctx.defaults = defaults;
|
|
9617
9731
|
|
|
9732
|
+
if (listViewName == "recent") {
|
|
9733
|
+
listview_filters = `
|
|
9734
|
+
function(filters, data) {
|
|
9735
|
+
var result = Steedos.authRequest('/graphql', {
|
|
9736
|
+
type: 'POST',
|
|
9737
|
+
async: false,
|
|
9738
|
+
data: JSON.stringify({
|
|
9739
|
+
query: '{object_recent_viewed(filters: [["record.o","=","' + data.objectName + '"],["space","=","' + data.context.tenantId + '"],["owner","=","' + data.context.userId + '"]],sort:"modified desc",top:50){ _id,record} }'
|
|
9740
|
+
}),
|
|
9741
|
+
});
|
|
9742
|
+
var _ids = []
|
|
9743
|
+
result.data.object_recent_viewed.forEach(function (item) {
|
|
9744
|
+
_ids = _ids.concat(item.record.ids)
|
|
9745
|
+
})
|
|
9746
|
+
return ["_id", "=", _ids];
|
|
9747
|
+
}
|
|
9748
|
+
`;
|
|
9749
|
+
}
|
|
9618
9750
|
const amisSchema = {
|
|
9619
9751
|
"type": "steedos-object-table",
|
|
9620
9752
|
"objectApiName": objectName,
|