处理了contextMenuFactory中路径为空字符串情况的边界
This commit is contained in:
parent
942345a4d2
commit
f37a130333
|
|
@ -47,29 +47,36 @@ var ContextMenuFactory = /** @class */ (function (_super) {
|
|||
});
|
||||
return paths.map(function (path) {
|
||||
var p = path[1];
|
||||
var ps = p.split('.');
|
||||
var makeFilterInner = function (entity, idx) {
|
||||
var _a, _b;
|
||||
var attr = ps[idx];
|
||||
var rel = (0, relation_1.judgeRelation)(_this.cache.getSchema(), entity, attr);
|
||||
if (idx === ps.length - 1) {
|
||||
if (rel === 2) {
|
||||
return {
|
||||
entity: attr,
|
||||
entityId: entityId,
|
||||
};
|
||||
if (p === '') {
|
||||
return {
|
||||
id: entityId,
|
||||
};
|
||||
}
|
||||
else {
|
||||
var ps_1 = p.split('.');
|
||||
var makeFilterInner_1 = function (entity, idx) {
|
||||
var _a, _b;
|
||||
var attr = ps_1[idx];
|
||||
var rel = (0, relation_1.judgeRelation)(_this.cache.getSchema(), entity, attr);
|
||||
if (idx === ps_1.length - 1) {
|
||||
if (rel === 2) {
|
||||
return {
|
||||
entity: attr,
|
||||
entityId: entityId,
|
||||
};
|
||||
}
|
||||
(0, assert_1.default)(typeof rel === 'string');
|
||||
return _a = {},
|
||||
_a["".concat(attr, "Id")] = entityId,
|
||||
_a;
|
||||
}
|
||||
(0, assert_1.default)(typeof rel === 'string');
|
||||
return _a = {},
|
||||
_a["".concat(attr, "Id")] = entityId,
|
||||
_a;
|
||||
}
|
||||
var e = rel === 2 ? attr : rel;
|
||||
return _b = {},
|
||||
_b[attr] = makeFilterInner(e, idx + 1),
|
||||
_b;
|
||||
};
|
||||
return makeFilterInner(destEntity, 0);
|
||||
var e = rel === 2 ? attr : rel;
|
||||
return _b = {},
|
||||
_b[attr] = makeFilterInner_1(e, idx + 1),
|
||||
_b;
|
||||
};
|
||||
return makeFilterInner_1(destEntity, 0);
|
||||
}
|
||||
});
|
||||
};
|
||||
return Object.assign({}, menu, {
|
||||
|
|
|
|||
|
|
@ -73,28 +73,35 @@ export class ContextMenuFactory<
|
|||
return paths.map(
|
||||
(path) => {
|
||||
const p = path[1];
|
||||
const ps = p.split('.');
|
||||
const makeFilterInner = (entity: keyof ED, idx: number): ED[keyof ED]['Selection']['filter'] => {
|
||||
const attr = ps[idx];
|
||||
const rel = judgeRelation(this.cache.getSchema(), entity, attr);
|
||||
if (idx === ps.length - 1) {
|
||||
if (rel === 2) {
|
||||
return {
|
||||
entity: attr,
|
||||
entityId,
|
||||
};
|
||||
}
|
||||
assert(typeof rel === 'string');
|
||||
return {
|
||||
[`${attr}Id`]: entityId,
|
||||
};
|
||||
}
|
||||
const e = rel === 2 ? attr : rel as string;
|
||||
if (p === '') {
|
||||
return {
|
||||
[attr]: makeFilterInner(e, idx + 1),
|
||||
id: entityId,
|
||||
};
|
||||
}
|
||||
return makeFilterInner(destEntity, 0);
|
||||
else {
|
||||
const ps = p.split('.');
|
||||
const makeFilterInner = (entity: keyof ED, idx: number): ED[keyof ED]['Selection']['filter'] => {
|
||||
const attr = ps[idx];
|
||||
const rel = judgeRelation(this.cache.getSchema(), entity, attr);
|
||||
if (idx === ps.length - 1) {
|
||||
if (rel === 2) {
|
||||
return {
|
||||
entity: attr,
|
||||
entityId,
|
||||
};
|
||||
}
|
||||
assert(typeof rel === 'string');
|
||||
return {
|
||||
[`${attr}Id`]: entityId,
|
||||
};
|
||||
}
|
||||
const e = rel === 2 ? attr : rel as string;
|
||||
return {
|
||||
[attr]: makeFilterInner(e, idx + 1),
|
||||
};
|
||||
};
|
||||
return makeFilterInner(destEntity, 0);
|
||||
}
|
||||
}
|
||||
)
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue