diff --git a/lib/features/contextMenuFactory.js b/lib/features/contextMenuFactory.js index 8cf6e419..843f72ed 100644 --- a/lib/features/contextMenuFactory.js +++ b/lib/features/contextMenuFactory.js @@ -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, { diff --git a/src/features/contextMenuFactory.ts b/src/features/contextMenuFactory.ts index 5b64919b..d5fc2388 100644 --- a/src/features/contextMenuFactory.ts +++ b/src/features/contextMenuFactory.ts @@ -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); + } } ) };