Merge branch 'release'
This commit is contained in:
commit
48115c789b
42
es/store.js
42
es/store.js
|
|
@ -358,7 +358,7 @@ export default class TreeStore extends CascadeStore {
|
|||
if (expression.hasOwnProperty('#attr')) {
|
||||
// 说明是本结点的属性;
|
||||
const attr = row[expression['#attr']];
|
||||
if (attr === undefined && option.warnWhenAttributeMiss) {
|
||||
if (attr === undefined && option?.warnWhenAttributeMiss) {
|
||||
showWarningAttributeMiss(entity, expression['#attr']);
|
||||
}
|
||||
return attr;
|
||||
|
|
@ -407,7 +407,7 @@ export default class TreeStore extends CascadeStore {
|
|||
for (const attr of attributes) {
|
||||
const { name } = attr;
|
||||
const value = row[name];
|
||||
if (value === undefined && option.warnWhenAttributeMiss) {
|
||||
if (value === undefined && option?.warnWhenAttributeMiss) {
|
||||
showWarningAttributeMiss(entity, name);
|
||||
}
|
||||
if (typeof value === 'string' && row[name].includes($search)) {
|
||||
|
|
@ -424,7 +424,7 @@ export default class TreeStore extends CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data > value;
|
||||
};
|
||||
}
|
||||
|
|
@ -432,7 +432,7 @@ export default class TreeStore extends CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data < value;
|
||||
};
|
||||
}
|
||||
|
|
@ -440,7 +440,7 @@ export default class TreeStore extends CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data >= value;
|
||||
};
|
||||
}
|
||||
|
|
@ -448,7 +448,7 @@ export default class TreeStore extends CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data <= value;
|
||||
};
|
||||
}
|
||||
|
|
@ -456,7 +456,7 @@ export default class TreeStore extends CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data === value;
|
||||
};
|
||||
}
|
||||
|
|
@ -464,7 +464,7 @@ export default class TreeStore extends CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data !== value;
|
||||
};
|
||||
}
|
||||
|
|
@ -472,7 +472,7 @@ export default class TreeStore extends CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data >= value[0] && data <= value[1];
|
||||
};
|
||||
}
|
||||
|
|
@ -480,7 +480,7 @@ export default class TreeStore extends CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return typeof data === 'number' && data % value[0] === value[1];
|
||||
};
|
||||
}
|
||||
|
|
@ -488,7 +488,7 @@ export default class TreeStore extends CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['string'].includes(typeof data) && data.startsWith(value);
|
||||
};
|
||||
}
|
||||
|
|
@ -496,7 +496,7 @@ export default class TreeStore extends CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['string'].includes(typeof data) && data.endsWith(value);
|
||||
};
|
||||
}
|
||||
|
|
@ -504,7 +504,7 @@ export default class TreeStore extends CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['string'].includes(typeof data) && data.includes(value);
|
||||
};
|
||||
}
|
||||
|
|
@ -513,7 +513,7 @@ export default class TreeStore extends CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
if (value) {
|
||||
return ![null, undefined].includes(data);
|
||||
}
|
||||
|
|
@ -526,7 +526,7 @@ export default class TreeStore extends CascadeStore {
|
|||
assert(value instanceof Array);
|
||||
return (row) => {
|
||||
const data = get(row, path);
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return value.includes(data);
|
||||
};
|
||||
}
|
||||
|
|
@ -534,7 +534,7 @@ export default class TreeStore extends CascadeStore {
|
|||
assert(value instanceof Array);
|
||||
return (row) => {
|
||||
const data = get(row, path);
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return !value.includes(data);
|
||||
};
|
||||
}
|
||||
|
|
@ -543,7 +543,7 @@ export default class TreeStore extends CascadeStore {
|
|||
const array = value instanceof Array ? value : [value];
|
||||
return (row) => {
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return differenceBy(array, data, (value) => {
|
||||
if (typeof value === 'object') {
|
||||
return JSON.stringify(value);
|
||||
|
|
@ -557,7 +557,7 @@ export default class TreeStore extends CascadeStore {
|
|||
const array = value instanceof Array ? value : [value];
|
||||
return (row) => {
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return intersectionBy(array, data, (value) => {
|
||||
if (typeof value === 'object') {
|
||||
return JSON.stringify(value);
|
||||
|
|
@ -638,7 +638,7 @@ export default class TreeStore extends CascadeStore {
|
|||
const row = this.constructRow(node, context, option);
|
||||
if (row) {
|
||||
const value = row[attr];
|
||||
if (value === undefined && option.warnWhenAttributeMiss) {
|
||||
if (value === undefined && option?.warnWhenAttributeMiss) {
|
||||
showWarningAttributeMiss(entity, attr);
|
||||
}
|
||||
return value === filter;
|
||||
|
|
@ -738,7 +738,7 @@ export default class TreeStore extends CascadeStore {
|
|||
return false;
|
||||
}
|
||||
if (row.entityId === undefined || row.entity === undefined) {
|
||||
if (option.warnWhenAttributeMiss) {
|
||||
if (option?.warnWhenAttributeMiss) {
|
||||
showWarningAttributeMiss(entity, 'entity/entityId');
|
||||
}
|
||||
return false; // 若不能确定,认定为条件不满足
|
||||
|
|
@ -772,7 +772,7 @@ export default class TreeStore extends CascadeStore {
|
|||
return filterFn(node2, nodeDict, exprResolveFns);
|
||||
}
|
||||
if (row[`${attr}Id`] === undefined) {
|
||||
if (option.warnWhenAttributeMiss) {
|
||||
if (option?.warnWhenAttributeMiss) {
|
||||
showWarningAttributeMiss(entity, `${attr}Id`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
42
lib/store.js
42
lib/store.js
|
|
@ -360,7 +360,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
if (expression.hasOwnProperty('#attr')) {
|
||||
// 说明是本结点的属性;
|
||||
const attr = row[expression['#attr']];
|
||||
if (attr === undefined && option.warnWhenAttributeMiss) {
|
||||
if (attr === undefined && option?.warnWhenAttributeMiss) {
|
||||
showWarningAttributeMiss(entity, expression['#attr']);
|
||||
}
|
||||
return attr;
|
||||
|
|
@ -409,7 +409,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
for (const attr of attributes) {
|
||||
const { name } = attr;
|
||||
const value = row[name];
|
||||
if (value === undefined && option.warnWhenAttributeMiss) {
|
||||
if (value === undefined && option?.warnWhenAttributeMiss) {
|
||||
showWarningAttributeMiss(entity, name);
|
||||
}
|
||||
if (typeof value === 'string' && row[name].includes($search)) {
|
||||
|
|
@ -426,7 +426,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? (0, lodash_1.get)(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data > value;
|
||||
};
|
||||
}
|
||||
|
|
@ -434,7 +434,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? (0, lodash_1.get)(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data < value;
|
||||
};
|
||||
}
|
||||
|
|
@ -442,7 +442,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? (0, lodash_1.get)(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data >= value;
|
||||
};
|
||||
}
|
||||
|
|
@ -450,7 +450,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? (0, lodash_1.get)(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data <= value;
|
||||
};
|
||||
}
|
||||
|
|
@ -458,7 +458,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? (0, lodash_1.get)(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data === value;
|
||||
};
|
||||
}
|
||||
|
|
@ -466,7 +466,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? (0, lodash_1.get)(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data !== value;
|
||||
};
|
||||
}
|
||||
|
|
@ -474,7 +474,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? (0, lodash_1.get)(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data >= value[0] && data <= value[1];
|
||||
};
|
||||
}
|
||||
|
|
@ -482,7 +482,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? (0, lodash_1.get)(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return typeof data === 'number' && data % value[0] === value[1];
|
||||
};
|
||||
}
|
||||
|
|
@ -490,7 +490,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? (0, lodash_1.get)(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['string'].includes(typeof data) && data.startsWith(value);
|
||||
};
|
||||
}
|
||||
|
|
@ -498,7 +498,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? (0, lodash_1.get)(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['string'].includes(typeof data) && data.endsWith(value);
|
||||
};
|
||||
}
|
||||
|
|
@ -506,7 +506,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? (0, lodash_1.get)(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return ['string'].includes(typeof data) && data.includes(value);
|
||||
};
|
||||
}
|
||||
|
|
@ -515,7 +515,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? (0, lodash_1.get)(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
if (value) {
|
||||
return ![null, undefined].includes(data);
|
||||
}
|
||||
|
|
@ -528,7 +528,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
(0, assert_1.assert)(value instanceof Array);
|
||||
return (row) => {
|
||||
const data = (0, lodash_1.get)(row, path);
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return value.includes(data);
|
||||
};
|
||||
}
|
||||
|
|
@ -536,7 +536,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
(0, assert_1.assert)(value instanceof Array);
|
||||
return (row) => {
|
||||
const data = (0, lodash_1.get)(row, path);
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return !value.includes(data);
|
||||
};
|
||||
}
|
||||
|
|
@ -545,7 +545,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
const array = value instanceof Array ? value : [value];
|
||||
return (row) => {
|
||||
const data = path ? (0, lodash_1.get)(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return (0, lodash_1.differenceBy)(array, data, (value) => {
|
||||
if (typeof value === 'object') {
|
||||
return JSON.stringify(value);
|
||||
|
|
@ -559,7 +559,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
const array = value instanceof Array ? value : [value];
|
||||
return (row) => {
|
||||
const data = path ? (0, lodash_1.get)(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss(entity, path);
|
||||
return (0, lodash_1.intersectionBy)(array, data, (value) => {
|
||||
if (typeof value === 'object') {
|
||||
return JSON.stringify(value);
|
||||
|
|
@ -640,7 +640,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
const row = this.constructRow(node, context, option);
|
||||
if (row) {
|
||||
const value = row[attr];
|
||||
if (value === undefined && option.warnWhenAttributeMiss) {
|
||||
if (value === undefined && option?.warnWhenAttributeMiss) {
|
||||
showWarningAttributeMiss(entity, attr);
|
||||
}
|
||||
return value === filter;
|
||||
|
|
@ -740,7 +740,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
return false;
|
||||
}
|
||||
if (row.entityId === undefined || row.entity === undefined) {
|
||||
if (option.warnWhenAttributeMiss) {
|
||||
if (option?.warnWhenAttributeMiss) {
|
||||
showWarningAttributeMiss(entity, 'entity/entityId');
|
||||
}
|
||||
return false; // 若不能确定,认定为条件不满足
|
||||
|
|
@ -774,7 +774,7 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
return filterFn(node2, nodeDict, exprResolveFns);
|
||||
}
|
||||
if (row[`${attr}Id`] === undefined) {
|
||||
if (option.warnWhenAttributeMiss) {
|
||||
if (option?.warnWhenAttributeMiss) {
|
||||
showWarningAttributeMiss(entity, `${attr}Id`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "oak-memory-tree-store",
|
||||
"version": "3.3.8",
|
||||
"version": "3.3.9",
|
||||
"description": "oak框架中内存级store的实现",
|
||||
"author": {
|
||||
"name": "XuChang"
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
"es/**/*"
|
||||
],
|
||||
"dependencies": {
|
||||
"oak-domain": "^5.1.14",
|
||||
"oak-domain": "^5.1.15",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
|||
42
src/store.ts
42
src/store.ts
|
|
@ -479,7 +479,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
const attr = row[(expression as {
|
||||
'#attr': keyof ED[T]['Schema'];
|
||||
})['#attr']] as ExpressionConstant;
|
||||
if (attr === undefined && option.warnWhenAttributeMiss) {
|
||||
if (attr === undefined && option?.warnWhenAttributeMiss) {
|
||||
showWarningAttributeMiss<ED>(entity, (expression as {
|
||||
'#attr': string;
|
||||
})['#attr']);
|
||||
|
|
@ -547,7 +547,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
for (const attr of attributes) {
|
||||
const { name } = attr;
|
||||
const value = row[name];
|
||||
if (value === undefined && option.warnWhenAttributeMiss) {
|
||||
if (value === undefined && option?.warnWhenAttributeMiss) {
|
||||
showWarningAttributeMiss<ED>(entity, name as string);
|
||||
}
|
||||
|
||||
|
|
@ -566,7 +566,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data > value;
|
||||
};
|
||||
}
|
||||
|
|
@ -574,14 +574,14 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data < value;
|
||||
};
|
||||
} case '$gte': {
|
||||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data >= value;
|
||||
};
|
||||
}
|
||||
|
|
@ -589,7 +589,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data <= value;
|
||||
};
|
||||
}
|
||||
|
|
@ -597,7 +597,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data === value;
|
||||
};
|
||||
}
|
||||
|
|
@ -605,7 +605,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data !== value;
|
||||
};
|
||||
}
|
||||
|
|
@ -613,7 +613,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
return ['number', 'string'].includes(typeof data) && data >= value[0] && data <= value[1];
|
||||
};
|
||||
}
|
||||
|
|
@ -621,7 +621,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
return typeof data === 'number' && data % value[0] === value[1];
|
||||
};
|
||||
}
|
||||
|
|
@ -629,7 +629,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
return ['string'].includes(typeof data) && data.startsWith(value);
|
||||
};
|
||||
}
|
||||
|
|
@ -637,7 +637,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
return ['string'].includes(typeof data) && data.endsWith(value);
|
||||
};
|
||||
}
|
||||
|
|
@ -645,7 +645,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
return ['string'].includes(typeof data) && data.includes(value);
|
||||
};
|
||||
}
|
||||
|
|
@ -654,7 +654,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
return (row) => {
|
||||
// JsonFilter有可能是根结点,path为空
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
if (value) {
|
||||
return ![null, undefined].includes(data);
|
||||
}
|
||||
|
|
@ -667,7 +667,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
assert(value instanceof Array);
|
||||
return (row) => {
|
||||
const data = get(row, path);
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
return value.includes(data);
|
||||
};
|
||||
}
|
||||
|
|
@ -675,7 +675,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
assert(value instanceof Array);
|
||||
return (row) => {
|
||||
const data = get(row, path);
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
return !value.includes(data);
|
||||
};
|
||||
}
|
||||
|
|
@ -684,7 +684,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
const array = value instanceof Array ? value : [value];
|
||||
return (row) => {
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
return differenceBy(array, data, (value: any) => {
|
||||
if (typeof value === 'object') {
|
||||
return JSON.stringify(value);
|
||||
|
|
@ -698,7 +698,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
const array = value instanceof Array ? value : [value];
|
||||
return (row) => {
|
||||
const data = path ? get(row, path) : row;
|
||||
data === undefined && option.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
data === undefined && option?.warnWhenAttributeMiss && showWarningAttributeMiss<ED>(entity, path);
|
||||
return intersectionBy(array, data, (value: any) => {
|
||||
if (typeof value === 'object') {
|
||||
return JSON.stringify(value);
|
||||
|
|
@ -798,7 +798,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
const row = this.constructRow(node, context, option);
|
||||
if (row) {
|
||||
const value = row[attr];
|
||||
if (value === undefined && option.warnWhenAttributeMiss) {
|
||||
if (value === undefined && option?.warnWhenAttributeMiss) {
|
||||
showWarningAttributeMiss<ED>(entity, attr);
|
||||
}
|
||||
return value === filter;
|
||||
|
|
@ -916,7 +916,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
return false;
|
||||
}
|
||||
if ((row as any).entityId === undefined || (row as any).entity === undefined) {
|
||||
if (option.warnWhenAttributeMiss) {
|
||||
if (option?.warnWhenAttributeMiss) {
|
||||
showWarningAttributeMiss<ED>(entity, 'entity/entityId');
|
||||
}
|
||||
return false; // 若不能确定,认定为条件不满足
|
||||
|
|
@ -952,7 +952,7 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
return filterFn(node2, nodeDict, exprResolveFns);
|
||||
}
|
||||
if ((row as any)[`${attr}Id`] === undefined) {
|
||||
if (option.warnWhenAttributeMiss) {
|
||||
if (option?.warnWhenAttributeMiss) {
|
||||
showWarningAttributeMiss<ED>(entity, `${attr}Id`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue