@steedos-widgets/amis-lib 1.1.4-beta.2 → 1.1.4-beta.3
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 +31 -15
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +31 -15
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +31 -15
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1020,7 +1020,7 @@ const refOrgsObjectName = "organizations";
|
|
|
1020
1020
|
|
|
1021
1021
|
async function getSource$1(field, ctx) {
|
|
1022
1022
|
// data.query 最终格式 "{ \tleftOptions:organizations(filters: {__filters}){value:_id,label:name,children}, children:organizations(filters: {__filters}){ref:_id,children}, defaultValueOptions:space_users(filters: {__options_filters}){user,name} }"
|
|
1023
|
-
const data = await getFindQuery({ name: refOrgsObjectName }, null, [{ name: "_id", alias: "value" }, { name: "name", alias: "label" }, { name: "children" }], {
|
|
1023
|
+
const data = await getFindQuery({ name: refOrgsObjectName }, null, [{ name: "_id", alias: "value" },{name: "parent"}, { name: "name", alias: "label" }, { name: "children" }], {
|
|
1024
1024
|
alias: "leftOptions",
|
|
1025
1025
|
filters: "{__filters}"
|
|
1026
1026
|
});
|
|
@@ -1050,7 +1050,7 @@ async function getSource$1(field, ctx) {
|
|
|
1050
1050
|
// data["&"] = "$$";
|
|
1051
1051
|
|
|
1052
1052
|
const requestAdaptor = `
|
|
1053
|
-
var filters = [
|
|
1053
|
+
var filters = [];
|
|
1054
1054
|
api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters));
|
|
1055
1055
|
var defaultValue = api.data.$value;
|
|
1056
1056
|
var optionsFiltersOp = "${field.multiple ? "in" : "="}";
|
|
@@ -1063,17 +1063,18 @@ async function getSource$1(field, ctx) {
|
|
|
1063
1063
|
`;
|
|
1064
1064
|
const adaptor = `
|
|
1065
1065
|
const data = payload.data;
|
|
1066
|
+
const rows = data.leftOptions
|
|
1066
1067
|
data.children = data.children.map(function (child) {
|
|
1067
1068
|
// child.defer = !!(child.children && child.children.length);
|
|
1068
1069
|
child.defer = true;
|
|
1069
1070
|
delete child.children;
|
|
1070
1071
|
return child;
|
|
1071
1072
|
});
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1073
|
+
|
|
1074
|
+
var getTreeOptions = SteedosUI.getTreeOptions
|
|
1075
|
+
data.leftOptions = getTreeOptions(rows);
|
|
1076
|
+
|
|
1077
|
+
|
|
1077
1078
|
var defaultValueOptions = data.defaultValueOptions;
|
|
1078
1079
|
data.children = _.union(data.children, defaultValueOptions);
|
|
1079
1080
|
delete data.defaultValueOptions;
|
|
@@ -2032,7 +2033,7 @@ function getButtonVisibleOn$1(button){
|
|
|
2032
2033
|
if(visible.trim().startsWith('function')){
|
|
2033
2034
|
return `${visible}.apply({
|
|
2034
2035
|
object: uiSchema
|
|
2035
|
-
}, [objectName, _id, record.recordPermissions, data])`
|
|
2036
|
+
}, [objectName, _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data])`
|
|
2036
2037
|
}
|
|
2037
2038
|
return visible;
|
|
2038
2039
|
}
|
|
@@ -3974,6 +3975,19 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
3974
3975
|
if(enable_tree){
|
|
3975
3976
|
const records = payload.data.rows;
|
|
3976
3977
|
const treeRecords = [];
|
|
3978
|
+
|
|
3979
|
+
const getParentIds = (records)=>{
|
|
3980
|
+
const ids = _.map(records, (item)=>{
|
|
3981
|
+
return item._id;
|
|
3982
|
+
});
|
|
3983
|
+
const parents = _.filter(records,(record)=>{
|
|
3984
|
+
return !record.parent || !_.includes(ids,record.parent);
|
|
3985
|
+
})
|
|
3986
|
+
const parentsIds = _.map(parents,(item)=>{
|
|
3987
|
+
return item._id;
|
|
3988
|
+
})
|
|
3989
|
+
return parentsIds;
|
|
3990
|
+
}
|
|
3977
3991
|
const getChildren = (records, childrenIds)=>{
|
|
3978
3992
|
if(!childrenIds){
|
|
3979
3993
|
return;
|
|
@@ -3989,8 +4003,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
3989
4003
|
return children;
|
|
3990
4004
|
}
|
|
3991
4005
|
|
|
4006
|
+
const parentIds = getParentIds(records);
|
|
3992
4007
|
_.each(records, (record)=>{
|
|
3993
|
-
if(!record.parent){
|
|
4008
|
+
if(!record.parent || _.includes(parentIds, record._id)){
|
|
3994
4009
|
treeRecords.push(Object.assign({}, record, {children: getChildren(records, record.children)}));
|
|
3995
4010
|
}
|
|
3996
4011
|
});
|
|
@@ -5664,7 +5679,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
5664
5679
|
footerToolbar: getObjectFooterToolbar(objectSchema, options.formFactor, {
|
|
5665
5680
|
disableStatistics: options.queryCount === false
|
|
5666
5681
|
}),
|
|
5667
|
-
filter:
|
|
5682
|
+
filter: options.filterVisible !== false && await getObjectFilter(objectSchema, fields, options),
|
|
5668
5683
|
};
|
|
5669
5684
|
if(options.formFactor !== 'SMALL'){
|
|
5670
5685
|
Object.assign(bodyProps, {
|
|
@@ -6227,7 +6242,7 @@ function getButtonVisibleOn(button){
|
|
|
6227
6242
|
// return 'false';
|
|
6228
6243
|
// }
|
|
6229
6244
|
if(visible.trim().startsWith('function')){
|
|
6230
|
-
return `${visible}(objectName, _id, record.recordPermissions, data)`
|
|
6245
|
+
return `${visible}(objectName, _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
|
|
6231
6246
|
}
|
|
6232
6247
|
return visible;
|
|
6233
6248
|
}
|
|
@@ -6296,14 +6311,15 @@ async function getTableOperation(ctx){
|
|
|
6296
6311
|
formFactor: "${formFactor}",
|
|
6297
6312
|
context: `\${context}`
|
|
6298
6313
|
},
|
|
6299
|
-
"responseData": {
|
|
6300
|
-
"recordPermissions": "$$"
|
|
6301
|
-
},
|
|
6302
6314
|
headers: {
|
|
6303
6315
|
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
6304
6316
|
},
|
|
6305
6317
|
adaptor: `
|
|
6306
|
-
payload
|
|
6318
|
+
payload = {
|
|
6319
|
+
record: {
|
|
6320
|
+
recordPermissions: payload
|
|
6321
|
+
}
|
|
6322
|
+
};
|
|
6307
6323
|
return payload;
|
|
6308
6324
|
`,
|
|
6309
6325
|
}
|