@steedos-widgets/amis-lib 1.2.9 → 1.2.11
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 +109 -99
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +110 -100
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +109 -99
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/fields_filter.d.ts +7 -5
- package/dist/types/lib/converter/amis/header.d.ts +9 -5
- package/dist/types/lib/converter/amis/toolbar.d.ts +7 -5
- package/dist/types/lib/converter/amis/toolbars/setting_listview/columns.d.ts +1 -1
- package/dist/types/lib/converter/amis/toolbars/setting_listview/copy.d.ts +1 -1
- package/dist/types/lib/converter/amis/toolbars/setting_listview/filters.d.ts +1 -0
- package/dist/types/lib/converter/amis/toolbars/setting_listview/new.d.ts +1 -1
- package/dist/types/lib/converter/amis/toolbars/setting_listview/rename.d.ts +1 -0
- package/dist/types/lib/converter/amis/toolbars/setting_listview/share.d.ts +1 -0
- package/dist/types/lib/converter/amis/toolbars/setting_listview/sort.d.ts +1 -1
- package/dist/types/lib/converter/amis/toolbars/setting_listview.d.ts +6 -4
- package/dist/types/lib/converter/amis/tpl.d.ts +1 -0
- package/dist/types/lib/converter/amis/util.d.ts +1 -1
- package/dist/types/lib/objects.d.ts +2 -0
- package/dist/types/schema/standard_import_data.amis.d.ts +5 -0
- package/dist/types/standard/button.d.ts +5 -0
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -409,11 +409,28 @@ const Router = {
|
|
|
409
409
|
|
|
410
410
|
};
|
|
411
411
|
|
|
412
|
+
/*
|
|
413
|
+
* @Author: baozhoutao@steedos.com
|
|
414
|
+
* @Date: 2022-07-20 16:29:22
|
|
415
|
+
* @LastEditors: Please set LastEditors
|
|
416
|
+
* @LastEditTime: 2023-05-18 15:22:51
|
|
417
|
+
* @Description:
|
|
418
|
+
*/
|
|
419
|
+
|
|
420
|
+
function getContrastColor(bgColor) {
|
|
421
|
+
var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
|
|
422
|
+
var r = parseInt(backgroundColor.substr(0, 2), 16);
|
|
423
|
+
var g = parseInt(backgroundColor.substr(2, 2), 16);
|
|
424
|
+
var b = parseInt(backgroundColor.substr(4, 2), 16);
|
|
425
|
+
var brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
426
|
+
return brightness < 128 ? "#ffffff" : "#000000";
|
|
427
|
+
}
|
|
428
|
+
|
|
412
429
|
/*
|
|
413
430
|
* @Author: baozhoutao@steedos.com
|
|
414
431
|
* @Date: 2022-05-23 09:53:08
|
|
415
|
-
* @LastEditors:
|
|
416
|
-
* @LastEditTime: 2023-
|
|
432
|
+
* @LastEditors: Please set LastEditors
|
|
433
|
+
* @LastEditTime: 2023-05-22 15:13:18
|
|
417
434
|
* @Description:
|
|
418
435
|
*/
|
|
419
436
|
|
|
@@ -466,6 +483,22 @@ async function getRefObjectNameFieldName(field){
|
|
|
466
483
|
function getSelectTpl(field){
|
|
467
484
|
return `<div>\${_display.${field.name}}</div>`
|
|
468
485
|
}
|
|
486
|
+
function getSelectMap(selectOptions){
|
|
487
|
+
let map = {};
|
|
488
|
+
_$1.forEach(selectOptions,(option)=>{
|
|
489
|
+
const optionValue = option.value + '';
|
|
490
|
+
const optionColor = option.color + '';
|
|
491
|
+
if(optionColor){
|
|
492
|
+
const background = optionColor.charAt(0) === '#' ? optionColor : '#'+optionColor;
|
|
493
|
+
const color = getContrastColor(background);
|
|
494
|
+
const optionColorStyle = 'background:'+background+';color:'+color;
|
|
495
|
+
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
496
|
+
}else {
|
|
497
|
+
map[optionValue] = option.label;
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
return map;
|
|
501
|
+
}
|
|
469
502
|
|
|
470
503
|
function getNameTplUrl(field, ctx){
|
|
471
504
|
if(ctx.objectName === 'cms_files'){
|
|
@@ -1862,9 +1895,10 @@ const getSchema$1 = (uiSchema) => {
|
|
|
1862
1895
|
{
|
|
1863
1896
|
name: "template_url",
|
|
1864
1897
|
label: "导入模板",
|
|
1865
|
-
type: "
|
|
1866
|
-
|
|
1867
|
-
|
|
1898
|
+
type: "markdown",
|
|
1899
|
+
options: {
|
|
1900
|
+
html: true
|
|
1901
|
+
},
|
|
1868
1902
|
className: "whitespace-nowrap",
|
|
1869
1903
|
},
|
|
1870
1904
|
null,
|
|
@@ -2711,6 +2745,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
2711
2745
|
if (!ctx) {
|
|
2712
2746
|
ctx = {};
|
|
2713
2747
|
}
|
|
2748
|
+
const btnSearchId = "btn_filter_form_search_" + new Date().getTime();
|
|
2714
2749
|
const filterFormSchema = await getObjectFieldsFilterFormSchema(ctx);
|
|
2715
2750
|
const onSearchScript = `
|
|
2716
2751
|
const scope = event.context.scoped;
|
|
@@ -2727,7 +2762,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
2727
2762
|
// // 这会造成handleFilterSubmit时把移除掉的搜索项字段之前的值加到过滤条件中
|
|
2728
2763
|
// for(var k in filterFormValues){
|
|
2729
2764
|
// if(filterFormValues[k] === "" && !filterFormValues.hasOwnProperty(k)){
|
|
2730
|
-
// removedValues[k] =
|
|
2765
|
+
// removedValues[k] = null;
|
|
2731
2766
|
// }
|
|
2732
2767
|
// }
|
|
2733
2768
|
// listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
|
|
@@ -2766,7 +2801,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
2766
2801
|
const removedValues = {};
|
|
2767
2802
|
for(var k in filterFormValues){
|
|
2768
2803
|
if(/^__searchable__/.test(k)){
|
|
2769
|
-
removedValues[k] =
|
|
2804
|
+
removedValues[k] = null;
|
|
2770
2805
|
}
|
|
2771
2806
|
}
|
|
2772
2807
|
if(!event.data.isLookup){
|
|
@@ -2777,7 +2812,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
2777
2812
|
if(localListViewProps){
|
|
2778
2813
|
localListViewProps = JSON.parse(localListViewProps);
|
|
2779
2814
|
for(var k in localListViewProps){
|
|
2780
|
-
removedValues[k] =
|
|
2815
|
+
removedValues[k] = null;
|
|
2781
2816
|
}
|
|
2782
2817
|
}
|
|
2783
2818
|
}
|
|
@@ -2935,7 +2970,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
2935
2970
|
});
|
|
2936
2971
|
const removedValues = {};
|
|
2937
2972
|
removedKeys.forEach(function(key){
|
|
2938
|
-
removedValues[key] =
|
|
2973
|
+
removedValues[key] = null;
|
|
2939
2974
|
});
|
|
2940
2975
|
filterForm.setValues(removedValues);//这里使用filterInnerForm也可以
|
|
2941
2976
|
|
|
@@ -2948,10 +2983,14 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
2948
2983
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
2949
2984
|
if(localListViewProps){
|
|
2950
2985
|
localListViewProps = JSON.parse(localListViewProps);
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2986
|
+
_.each(localListViewProps, function(n,k){
|
|
2987
|
+
// __searchable__开头的不在searchableFields范围则清除其值
|
|
2988
|
+
let isRemoved = !!removedFields.find(function(fieldName){
|
|
2989
|
+
return new RegExp("__searchable__\.*" + fieldName + "$").test(k);
|
|
2990
|
+
});
|
|
2991
|
+
if(isRemoved){
|
|
2992
|
+
delete localListViewProps[k];
|
|
2993
|
+
}
|
|
2955
2994
|
});
|
|
2956
2995
|
sessionStorage.setItem(listViewPropsStoreKey, JSON.stringify(localListViewProps));
|
|
2957
2996
|
}
|
|
@@ -2985,9 +3024,10 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
2985
3024
|
"body": [
|
|
2986
3025
|
{
|
|
2987
3026
|
"type": "button",
|
|
3027
|
+
"id": btnSearchId,
|
|
2988
3028
|
"label": "搜索",
|
|
2989
3029
|
"icon": "fa fa-search",
|
|
2990
|
-
"visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
3030
|
+
// "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
2991
3031
|
"onEvent": {
|
|
2992
3032
|
"click": {
|
|
2993
3033
|
"actions": [
|
|
@@ -3003,7 +3043,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3003
3043
|
"type": "button",
|
|
3004
3044
|
"label": "取消",
|
|
3005
3045
|
"name": "btn_filter_form_cancel",
|
|
3006
|
-
"visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
3046
|
+
// "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
3007
3047
|
"onEvent": {
|
|
3008
3048
|
"click": {
|
|
3009
3049
|
"actions": [
|
|
@@ -3118,6 +3158,10 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3118
3158
|
"actionType": "custom",
|
|
3119
3159
|
"script": onSearchableFieldsChangeScript
|
|
3120
3160
|
},
|
|
3161
|
+
{
|
|
3162
|
+
"actionType": "click",
|
|
3163
|
+
"componentId": btnSearchId
|
|
3164
|
+
},
|
|
3121
3165
|
{
|
|
3122
3166
|
"componentId": "",
|
|
3123
3167
|
"args": {},
|
|
@@ -3425,8 +3469,8 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
3425
3469
|
},
|
|
3426
3470
|
"body":[{
|
|
3427
3471
|
"type": "button",
|
|
3428
|
-
"visibleOn": "${window:innerWidth > 768 && window:historyPaths.length > 1}",
|
|
3429
|
-
"className":"flex mr-
|
|
3472
|
+
"visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
|
|
3473
|
+
"className":"flex mr-4",
|
|
3430
3474
|
"onEvent": {
|
|
3431
3475
|
"click": {
|
|
3432
3476
|
"actions": [
|
|
@@ -3443,7 +3487,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
3443
3487
|
"category": "utility",
|
|
3444
3488
|
"name": "back",
|
|
3445
3489
|
"colorVariant": "default",
|
|
3446
|
-
"className": "slds-button_icon slds-global-header__icon"
|
|
3490
|
+
"className": "slds-button_icon slds-global-header__icon w-4"
|
|
3447
3491
|
}
|
|
3448
3492
|
]
|
|
3449
3493
|
}]
|
|
@@ -3472,7 +3516,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
3472
3516
|
// "tpl": "${(record && uiSchema && record[uiSchema.NAME_FIELD_KEY]) || name}",
|
|
3473
3517
|
"inline": false,
|
|
3474
3518
|
"wrapperComponent": "",
|
|
3475
|
-
"className": "leading-5 text-xl font-bold"
|
|
3519
|
+
"className": "record-detail-header-name leading-5 text-xl font-bold"
|
|
3476
3520
|
}
|
|
3477
3521
|
],
|
|
3478
3522
|
"columnClassName": "p-l-xs"
|
|
@@ -3481,6 +3525,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
3481
3525
|
"className": "flex justify-between"
|
|
3482
3526
|
}
|
|
3483
3527
|
],
|
|
3528
|
+
"columnClassName": "flex-initial",
|
|
3484
3529
|
"md": "auto",
|
|
3485
3530
|
});
|
|
3486
3531
|
}
|
|
@@ -3501,7 +3546,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
3501
3546
|
{
|
|
3502
3547
|
"type": "grid",
|
|
3503
3548
|
"columns": gridBody,
|
|
3504
|
-
"className": "flex justify-between"
|
|
3549
|
+
"className": "flex justify-between flex-nowrap"
|
|
3505
3550
|
}
|
|
3506
3551
|
],
|
|
3507
3552
|
"hiddenOn": "${recordLoaded != true}"
|
|
@@ -3718,12 +3763,13 @@ const getNewListviewButtonSchema = ()=>{
|
|
|
3718
3763
|
"type": "dialog",
|
|
3719
3764
|
"title": "新建 列表视图",
|
|
3720
3765
|
"data": {
|
|
3721
|
-
"&":
|
|
3766
|
+
//"&":"$$",2.7、2.9、3.0在此处失效
|
|
3722
3767
|
"all": "${uiSchema.list_views.all}",
|
|
3723
3768
|
"list_view": "${uiSchema.list_views[listName]}",
|
|
3724
3769
|
"appId": "${appId}",
|
|
3725
3770
|
"global": "${global}",
|
|
3726
3771
|
"targetObjectName": "${objectName}",
|
|
3772
|
+
"context": "${context}"
|
|
3727
3773
|
},
|
|
3728
3774
|
"body": [
|
|
3729
3775
|
{
|
|
@@ -3867,12 +3913,13 @@ const getCopyListviewButtonSchema = ()=>{
|
|
|
3867
3913
|
"type": "dialog",
|
|
3868
3914
|
"title": "复制 列表视图",
|
|
3869
3915
|
"data": {
|
|
3870
|
-
"&":
|
|
3916
|
+
//"&":"$$",2.7、2.9、3.0在此处失效
|
|
3871
3917
|
"listName": "${listName}",
|
|
3872
3918
|
"targetObjectName": "${objectName}",
|
|
3873
3919
|
"list_view": "${uiSchema.list_views[listName]}",
|
|
3874
3920
|
"appId": "${appId}",
|
|
3875
|
-
"global": "${global}"
|
|
3921
|
+
"global": "${global}",
|
|
3922
|
+
"context": "${context}"
|
|
3876
3923
|
},
|
|
3877
3924
|
"body": [
|
|
3878
3925
|
{
|
|
@@ -4014,7 +4061,8 @@ const getRenameListviewButtonSchema = ()=>{
|
|
|
4014
4061
|
"data": {
|
|
4015
4062
|
"targetObjectName": "${objectName}",
|
|
4016
4063
|
"recordId": "${uiSchema.list_views[listName]._id}",
|
|
4017
|
-
"appId": "${appId}"
|
|
4064
|
+
"appId": "${appId}",
|
|
4065
|
+
"context": "${context}"
|
|
4018
4066
|
},
|
|
4019
4067
|
"body": [
|
|
4020
4068
|
{
|
|
@@ -4071,6 +4119,7 @@ const getSetListviewShareButtonSchema = ()=>{
|
|
|
4071
4119
|
"title": "共享设置",
|
|
4072
4120
|
"data": {
|
|
4073
4121
|
"recordId": "${uiSchema.list_views[listName]._id}",
|
|
4122
|
+
"context": "${context}"
|
|
4074
4123
|
},
|
|
4075
4124
|
"body": [
|
|
4076
4125
|
{
|
|
@@ -4116,7 +4165,8 @@ const getSetListviewFiltersButtonSchema = ()=>{
|
|
|
4116
4165
|
"targetObjectName": "${objectName}",
|
|
4117
4166
|
"recordId": "${uiSchema.list_views[listName]._id}",
|
|
4118
4167
|
"listName": "${listName}",
|
|
4119
|
-
"appId": "${appId}"
|
|
4168
|
+
"appId": "${appId}",
|
|
4169
|
+
"context": "${context}"
|
|
4120
4170
|
},
|
|
4121
4171
|
"body": [
|
|
4122
4172
|
{
|
|
@@ -4260,11 +4310,12 @@ const getSetListviewColumnsButtonSchema = ()=>{
|
|
|
4260
4310
|
"type": "dialog",
|
|
4261
4311
|
"title": "显示的列",
|
|
4262
4312
|
"data": {
|
|
4263
|
-
"&":
|
|
4313
|
+
//"&":"$$",2.7、2.9、3.0在此处失效
|
|
4264
4314
|
"targetObjectName": "${objectName}",
|
|
4265
4315
|
"recordId": "${uiSchema.list_views[listName]._id}",
|
|
4266
4316
|
"listName": "${listName}",
|
|
4267
|
-
"appId": "${appId}"
|
|
4317
|
+
"appId": "${appId}",
|
|
4318
|
+
"context": "${context}"
|
|
4268
4319
|
},
|
|
4269
4320
|
"body": [
|
|
4270
4321
|
{
|
|
@@ -4411,13 +4462,14 @@ const getSetListviewSortButtonSchema = ()=>{
|
|
|
4411
4462
|
{
|
|
4412
4463
|
"dialog": {
|
|
4413
4464
|
"type": "dialog",
|
|
4414
|
-
"title": "
|
|
4465
|
+
"title": "默认排序规则",
|
|
4415
4466
|
"data": {
|
|
4416
|
-
"&":
|
|
4467
|
+
//"&":"$$",2.7、2.9、3.0在此处失效
|
|
4417
4468
|
"targetObjectName": "${objectName}",
|
|
4418
4469
|
"recordId": "${uiSchema.list_views[listName]._id}",
|
|
4419
4470
|
"listName": "${listName}",
|
|
4420
|
-
"appId": "${appId}"
|
|
4471
|
+
"appId": "${appId}",
|
|
4472
|
+
"context": "${context}"
|
|
4421
4473
|
},
|
|
4422
4474
|
"body": [
|
|
4423
4475
|
{
|
|
@@ -5107,24 +5159,13 @@ function getLookupSapceUserTreeSchema(){
|
|
|
5107
5159
|
"actionType": "custom",
|
|
5108
5160
|
"script": `
|
|
5109
5161
|
const scope = event.context.scoped;
|
|
5110
|
-
|
|
5111
|
-
// var filterForm = scope.parent.parent.getComponents().find(function(n){
|
|
5112
|
-
// return n.props.type === "form";
|
|
5113
|
-
// });
|
|
5114
|
-
// var filterFormValues = filterForm.getValues();
|
|
5115
|
-
filterFormValues={
|
|
5162
|
+
var filterFormValues={
|
|
5116
5163
|
"__searchable__organizations_parents":event.data.value.value
|
|
5117
5164
|
}
|
|
5118
5165
|
var listView = scope.parent.getComponents().find(function(n){
|
|
5119
5166
|
return n.props.type === "crud";
|
|
5120
5167
|
});
|
|
5121
|
-
|
|
5122
|
-
// for(var k in filterFormValues){
|
|
5123
|
-
// if(filterFormValues[k] === "" && !filterFormValues.hasOwnProperty(k)){
|
|
5124
|
-
// removedValues[k] = "";
|
|
5125
|
-
// }
|
|
5126
|
-
// }
|
|
5127
|
-
listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
|
|
5168
|
+
listView.handleFilterSubmit(Object.assign({}, filterFormValues));
|
|
5128
5169
|
`
|
|
5129
5170
|
}
|
|
5130
5171
|
]
|
|
@@ -5238,7 +5279,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
5238
5279
|
|
|
5239
5280
|
const source = await getApi$1(refObjectConfig, null, fields, {expand: true, alias: 'rows', queryOptions: `filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"`});
|
|
5240
5281
|
|
|
5241
|
-
if(source.url){
|
|
5282
|
+
if(source.url && !ctx.inFilterForm){
|
|
5242
5283
|
const depend_on = [];
|
|
5243
5284
|
const sendOn = [];
|
|
5244
5285
|
___namespace.each(field.depend_on, (fName)=>{
|
|
@@ -5302,9 +5343,10 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
5302
5343
|
filters.push(fieldFilters);
|
|
5303
5344
|
}
|
|
5304
5345
|
|
|
5346
|
+
const inFilterForm = ${ctx.inFilterForm};
|
|
5305
5347
|
const filtersFunction = ${field.filtersFunction || field._filtersFunction};
|
|
5306
5348
|
|
|
5307
|
-
if(filtersFunction){
|
|
5349
|
+
if(filtersFunction && !inFilterForm){
|
|
5308
5350
|
const _filters = filtersFunction(filters, api.data.$self.__super.__super);
|
|
5309
5351
|
if(_filters && _filters.length > 0){
|
|
5310
5352
|
filters.push(_filters);
|
|
@@ -5524,7 +5566,8 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
5524
5566
|
sort = getListViewSort(listView);
|
|
5525
5567
|
}
|
|
5526
5568
|
|
|
5527
|
-
|
|
5569
|
+
// 列表视图搜索栏中,即inFilterForm=true时,不需要执行depend_on
|
|
5570
|
+
if(apiInfo.url && !ctx.inFilterForm){
|
|
5528
5571
|
const depend_on = [];
|
|
5529
5572
|
const sendOn = [];
|
|
5530
5573
|
___namespace.each(field.depend_on, (fName)=>{
|
|
@@ -5561,9 +5604,10 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
5561
5604
|
filters.push(fieldFilters);
|
|
5562
5605
|
}
|
|
5563
5606
|
|
|
5607
|
+
const inFilterForm = ${ctx.inFilterForm};
|
|
5564
5608
|
const filtersFunction = ${field.filtersFunction || field._filtersFunction};
|
|
5565
5609
|
|
|
5566
|
-
if(filtersFunction){
|
|
5610
|
+
if(filtersFunction && !inFilterForm){
|
|
5567
5611
|
const _filters = filtersFunction(filters, api.data.$);
|
|
5568
5612
|
if(_filters && _filters.length > 0){
|
|
5569
5613
|
filters.push(_filters);
|
|
@@ -5589,7 +5633,14 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
5589
5633
|
referenceTo ? referenceTo.valueField.name : '';
|
|
5590
5634
|
if(field.optionsFunction || field._optionsFunction){
|
|
5591
5635
|
apiInfo.adaptor = `
|
|
5592
|
-
|
|
5636
|
+
var options = eval(${field.optionsFunction || field._optionsFunction})(api.data.$);
|
|
5637
|
+
if(api.data.$term){
|
|
5638
|
+
options = _.filter(options, function(o) {
|
|
5639
|
+
var label = o.label;
|
|
5640
|
+
return label.toLowerCase().indexOf(api.data.$term.toLowerCase()) > -1;
|
|
5641
|
+
});
|
|
5642
|
+
}
|
|
5643
|
+
payload.data.options = options;
|
|
5593
5644
|
return payload;
|
|
5594
5645
|
`;
|
|
5595
5646
|
}
|
|
@@ -5725,7 +5776,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
|
|
|
5725
5776
|
source.data.$term = "$term";
|
|
5726
5777
|
source.data.$self = "$$";
|
|
5727
5778
|
|
|
5728
|
-
if(idsDependOn && source.url){
|
|
5779
|
+
if(idsDependOn && source.url && !ctx.inFilterForm){
|
|
5729
5780
|
source.sendOn = `\${${idsDependOn} && ${idsDependOn}.length}`;
|
|
5730
5781
|
source.url = `${source.url}&depend_on_${idsDependOn}=\${${idsDependOn}|join}`;
|
|
5731
5782
|
}
|
|
@@ -6011,23 +6062,6 @@ const getAmisFileSchema = (steedosField, readonly)=>{
|
|
|
6011
6062
|
return readonly ? getAmisFileReadonlySchema(steedosField) : getAmisFileEditSchema(steedosField);
|
|
6012
6063
|
};
|
|
6013
6064
|
|
|
6014
|
-
/*
|
|
6015
|
-
* @Author: baozhoutao@steedos.com
|
|
6016
|
-
* @Date: 2022-07-20 16:29:22
|
|
6017
|
-
* @LastEditors: Please set LastEditors
|
|
6018
|
-
* @LastEditTime: 2023-05-11 11:19:54
|
|
6019
|
-
* @Description:
|
|
6020
|
-
*/
|
|
6021
|
-
|
|
6022
|
-
function getContrastColor(bgColor) {
|
|
6023
|
-
var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
|
|
6024
|
-
var r = parseInt(backgroundColor.substr(0, 2), 16);
|
|
6025
|
-
var g = parseInt(backgroundColor.substr(2, 2), 16);
|
|
6026
|
-
var b = parseInt(backgroundColor.substr(4, 2), 16);
|
|
6027
|
-
var brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
6028
|
-
return brightness >= 128 ? "#000000" : "#ffffff";
|
|
6029
|
-
}
|
|
6030
|
-
|
|
6031
6065
|
const OMIT_FIELDS = ['created', 'created_by', 'modified', 'modified_by'];
|
|
6032
6066
|
// const Lookup = require('./lookup');
|
|
6033
6067
|
|
|
@@ -6218,19 +6252,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
6218
6252
|
// break;
|
|
6219
6253
|
case 'select':
|
|
6220
6254
|
if(readonly){
|
|
6221
|
-
const
|
|
6222
|
-
let map = {};
|
|
6223
|
-
___namespace.forEach(selectOptions,(option)=>{
|
|
6224
|
-
const optionValue = option.value + '';
|
|
6225
|
-
if(option.color){
|
|
6226
|
-
const background = '#'+option.color;
|
|
6227
|
-
const color = getContrastColor(background);
|
|
6228
|
-
const optionColorStyle = 'background:'+background+';color:'+color;
|
|
6229
|
-
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
6230
|
-
}else {
|
|
6231
|
-
map[optionValue] = option.label;
|
|
6232
|
-
}
|
|
6233
|
-
});
|
|
6255
|
+
const map = getSelectMap(field.options);
|
|
6234
6256
|
convertData = {
|
|
6235
6257
|
type: "static-mapping",
|
|
6236
6258
|
name: field.name,
|
|
@@ -6596,7 +6618,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
6596
6618
|
convertData.className = fieldTypeClassName;
|
|
6597
6619
|
}
|
|
6598
6620
|
|
|
6599
|
-
if(field.visible_on){
|
|
6621
|
+
if(field.visible_on && !ctx.inFilterForm){
|
|
6600
6622
|
// convertData.visibleOn = `\$${field.visible_on.substring(1, field.visible_on.length -1).replace(/formData./g, '')}`;
|
|
6601
6623
|
if(field.visible_on.startsWith("{{")){
|
|
6602
6624
|
convertData.visibleOn = `${field.visible_on.substring(2, field.visible_on.length -2).replace(/formData./g, 'data.')}`;
|
|
@@ -6689,7 +6711,7 @@ async function getFieldSearchable(perField, permissionFields, ctx){
|
|
|
6689
6711
|
_field.multiple = true;
|
|
6690
6712
|
_field.is_wide = false;
|
|
6691
6713
|
_field.defaultValue = undefined;
|
|
6692
|
-
const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true}));
|
|
6714
|
+
const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
|
|
6693
6715
|
if(amisField){
|
|
6694
6716
|
return amisField;
|
|
6695
6717
|
}
|
|
@@ -6929,7 +6951,8 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
6929
6951
|
data.global = "${global}";
|
|
6930
6952
|
data.context = "${context}";
|
|
6931
6953
|
data.defaultData = "${defaultData}";
|
|
6932
|
-
|
|
6954
|
+
data._master = "${_master}";
|
|
6955
|
+
|
|
6933
6956
|
return {
|
|
6934
6957
|
method: "post",
|
|
6935
6958
|
url: getApi$2() + '&objectName=${objectName}' ,
|
|
@@ -6995,7 +7018,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
6995
7018
|
formInitialValuesFun = new Function("return " + formInitialValuesFun)();
|
|
6996
7019
|
}
|
|
6997
7020
|
if(typeof formInitialValuesFun === "function"){
|
|
6998
|
-
initialValues = formInitialValuesFun.apply({doc: defaultValues || {} , global: api.body.global})
|
|
7021
|
+
initialValues = formInitialValuesFun.apply({doc: defaultValues || {} , global: api.body.global, master: api.body._master })
|
|
6999
7022
|
}
|
|
7000
7023
|
}
|
|
7001
7024
|
catch(ex){
|
|
@@ -7651,19 +7674,7 @@ async function getTableColumns(fields, options){
|
|
|
7651
7674
|
}, field.amis, {name: field.name}));
|
|
7652
7675
|
}
|
|
7653
7676
|
else if(field.type === 'select'){
|
|
7654
|
-
const
|
|
7655
|
-
let map = {};
|
|
7656
|
-
_$1.forEach(selectOptions,(option)=>{
|
|
7657
|
-
const optionValue = option.value + '';
|
|
7658
|
-
if(option.color){
|
|
7659
|
-
const background = '#'+option.color;
|
|
7660
|
-
const color = getContrastColor(background);
|
|
7661
|
-
const optionColorStyle = 'background:'+background+';color:'+color;
|
|
7662
|
-
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
7663
|
-
}else {
|
|
7664
|
-
map[optionValue] = option.label;
|
|
7665
|
-
}
|
|
7666
|
-
});
|
|
7677
|
+
const map = getSelectMap(field.options);
|
|
7667
7678
|
columns.push(Object.assign({}, {
|
|
7668
7679
|
type: "mapping",
|
|
7669
7680
|
name: field.name,
|
|
@@ -7702,7 +7713,7 @@ async function getTableColumns(fields, options){
|
|
|
7702
7713
|
tpl: tpl,
|
|
7703
7714
|
toggled: field.toggled,
|
|
7704
7715
|
className,
|
|
7705
|
-
|
|
7716
|
+
options: field.type === 'html' ? {html: true} : null
|
|
7706
7717
|
// toggled: true
|
|
7707
7718
|
}, field.amis, {name: field.name}));
|
|
7708
7719
|
}
|
|
@@ -8216,11 +8227,10 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8216
8227
|
if(api.data.$self._isRelated){
|
|
8217
8228
|
const self = api.data.$self;
|
|
8218
8229
|
const relatedKey = self.relatedKey;
|
|
8219
|
-
const recordId = self.recordId;
|
|
8220
8230
|
const refField = self.uiSchema.fields[relatedKey];
|
|
8221
8231
|
const masterRecord = self._master.record;
|
|
8222
8232
|
const masterObjectName = self._master.objectName;
|
|
8223
|
-
let relatedValue = recordId;
|
|
8233
|
+
let relatedValue = self._master.recordId;
|
|
8224
8234
|
if(refField.reference_to_field && refField.reference_to_field != '_id'){
|
|
8225
8235
|
relatedValue = masterRecord[refField.reference_to_field]
|
|
8226
8236
|
}
|