From 5017de328decaef9f340d9f5fc00223892e8439a Mon Sep 17 00:00:00 2001 From: Pranav C <61551451+pranavxc@users.noreply.github.com> Date: Thu, 15 Jul 2021 17:31:04 +0530 Subject: [PATCH] feat: modify nestedList params Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com> --- .../components/project/spreadsheet/apis/gqlApi.js | 12 ++++++------ .../components/virtualCell/belogsToCell.vue | 7 ++++--- .../components/virtualCell/hasManyCell.vue | 7 ++++--- .../components/virtualCell/manyToManyCell.vue | 7 ++++--- .../project/spreadsheet/mixins/spreadsheet.js | 7 ++++--- .../src/lib/dataMapper/lib/sql/BaseModelSql.ts | 4 ++-- .../src/lib/sqlMgr/code/routers/xc-ts/SwaggerXc.ts | 6 +++--- 7 files changed, 27 insertions(+), 23 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/apis/gqlApi.js b/packages/nc-gui/components/project/spreadsheet/apis/gqlApi.js index 2ef272997f..82b3be20dd 100644 --- a/packages/nc-gui/components/project/spreadsheet/apis/gqlApi.js +++ b/packages/nc-gui/components/project/spreadsheet/apis/gqlApi.js @@ -91,8 +91,8 @@ export default class GqlApi { async gqlRelationReqBody(params) { let str = ''; - if (params.childs) { - for (const child of params.childs.split(',')) { + if (params.hm) { + for (const child of params.hm.split(',')) { await this.$ctx.$store.dispatch('meta/ActLoadMeta', { dbAlias: this.$ctx.nodes.dbAlias, env: this.$ctx.nodes.env, @@ -104,8 +104,8 @@ export default class GqlApi { } } } - if (params.parents) { - for (const parent of params.parents.split(',')) { + if (params.bt) { + for (const parent of params.bt.split(',')) { await this.$ctx.$store.dispatch('meta/ActLoadMeta', { dbAlias: this.$ctx.nodes.dbAlias, env: this.$ctx.nodes.env, @@ -117,8 +117,8 @@ export default class GqlApi { } } } - if (params.many) { - for (const mm of params.many.split(',')) { + if (params.mm) { + for (const mm of params.mm.split(',')) { await this.$ctx.$store.dispatch('meta/ActLoadMeta', { dbAlias: this.$ctx.nodes.dbAlias, env: this.$ctx.nodes.env, diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/belogsToCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/belogsToCell.vue index 982cc83564..3e82df6bea 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/belogsToCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/belogsToCell.vue @@ -282,10 +282,11 @@ export default { }, parentQueryParams() { if (!this.parentMeta) return {} + // todo: use reduce return { - childs: (this.parentMeta && this.parentMeta.v && this.parentMeta.v.filter(v => v.hm).map(({hm}) => hm.tn).join()) || '', - parents: (this.parentMeta && this.parentMeta.v && this.parentMeta.v.filter(v => v.bt).map(({bt}) => bt.rtn).join()) || '', - many: (this.parentMeta && this.parentMeta.v && this.parentMeta.v.filter(v => v.mm).map(({mm}) => mm.rtn).join()) || '' + hm: (this.parentMeta && this.parentMeta.v && this.parentMeta.v.filter(v => v.hm).map(({hm}) => hm.tn).join()) || '', + bt: (this.parentMeta && this.parentMeta.v && this.parentMeta.v.filter(v => v.bt).map(({bt}) => bt.rtn).join()) || '', + mm: (this.parentMeta && this.parentMeta.v && this.parentMeta.v.filter(v => v.mm).map(({mm}) => mm.rtn).join()) || '' } }, parentAvailableColumns() { diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue index e5149bd7b4..eeb881a47d 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue @@ -363,10 +363,11 @@ export default { }, childQueryParams() { if (!this.childMeta) return {} + // todo: use reduce return { - childs: (this.childMeta && this.childMeta.v && this.childMeta.v.filter(v => v.hm).map(({hm}) => hm.tn).join()) || '', - parents: (this.childMeta && this.childMeta.v && this.childMeta.v.filter(v => v.bt).map(({bt}) => bt.rtn).join()) || '', - many: (this.childMeta && this.childMeta.v && this.childMeta.v.filter(v => v.mm).map(({mm}) => mm.rtn).join()) || '' + hm: (this.childMeta && this.childMeta.v && this.childMeta.v.filter(v => v.hm).map(({hm}) => hm.tn).join()) || '', + bt: (this.childMeta && this.childMeta.v && this.childMeta.v.filter(v => v.bt).map(({bt}) => bt.rtn).join()) || '', + mm: (this.childMeta && this.childMeta.v && this.childMeta.v.filter(v => v.mm).map(({mm}) => mm.rtn).join()) || '' } }, parentId() { diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue index 5dd351e900..7e41ac949d 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue @@ -364,10 +364,11 @@ export default { }, childQueryParams() { if (!this.childMeta) return {} + // todo: use reduce return { - childs: (this.childMeta && this.childMeta.v && this.childMeta.v.filter(v => v.hm).map(({hm}) => hm.tn).join()) || '', - parents: (this.childMeta && this.childMeta.v && this.childMeta.v.filter(v => v.bt).map(({bt}) => bt.rtn).join()) || '', - many: (this.childMeta && this.childMeta.v && this.childMeta.v.filter(v => v.mm).map(({mm}) => mm.rtn).join()) || '' + hm: (this.childMeta && this.childMeta.v && this.childMeta.v.filter(v => v.hm).map(({hm}) => hm.tn).join()) || '', + bt: (this.childMeta && this.childMeta.v && this.childMeta.v.filter(v => v.bt).map(({bt}) => bt.rtn).join()) || '', + mm: (this.childMeta && this.childMeta.v && this.childMeta.v.filter(v => v.mm).map(({mm}) => mm.rtn).join()) || '' } }, conditionGraph() { diff --git a/packages/nc-gui/components/project/spreadsheet/mixins/spreadsheet.js b/packages/nc-gui/components/project/spreadsheet/mixins/spreadsheet.js index 2c8559a56c..f9eacc7f10 100644 --- a/packages/nc-gui/components/project/spreadsheet/mixins/spreadsheet.js +++ b/packages/nc-gui/components/project/spreadsheet/mixins/spreadsheet.js @@ -120,9 +120,10 @@ export default { // condition: this.condition, where: this.concatenatedXWhere, sort: this.sort, - childs: (this.meta && this.meta.v && this.meta.v.filter(v => v.hm).map(({hm}) => hm.tn).join()) || '', - parents: (this.meta && this.meta.v && this.meta.v.filter(v => v.bt).map(({bt}) => bt.rtn).join()) || '', - many: (this.meta && this.meta.v && this.meta.v.filter(v => v.mm).map(({mm}) => mm.rtn).join()) || '' + // todo: use reduce + hm: (this.meta && this.meta.v && this.meta.v.filter(v => v.hm).map(({hm}) => hm.tn).join()) || '', + bt: (this.meta && this.meta.v && this.meta.v.filter(v => v.bt).map(({bt}) => bt.rtn).join()) || '', + mm: (this.meta && this.meta.v && this.meta.v.filter(v => v.mm).map(({mm}) => mm.rtn).join()) || '' } }, colLength() { return (this.availableColumns && this.availableColumns.length) || 0 diff --git a/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts b/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts index 20813d3662..259877b13c 100644 --- a/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts +++ b/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts @@ -1287,7 +1287,7 @@ class BaseModelSql extends BaseModel { // todo : add conditionGraph // todo : implement nestedread - async nestedList({childs = '', parents = '', many = '', where, fields: fields1, f, ...rest}) { + async nestedList({hm: childs = '', bt: parents = '', mm: many = '', where, fields: fields1, f, ...rest}) { let fields = fields1 || f || '*'; try { @@ -1504,7 +1504,7 @@ class BaseModelSql extends BaseModel { this._paginateAndSort(query, {limit, offset}, child); return this.isSqlite() ? this.dbDriver.select().from(query) : query; }), !this.isSqlite() - ), {sort,limit:1000} as any, child)); + ), {sort, limit: 1000} as any, child)); // return _.groupBy(childs, cn); diff --git a/packages/nocodb/src/lib/sqlMgr/code/routers/xc-ts/SwaggerXc.ts b/packages/nocodb/src/lib/sqlMgr/code/routers/xc-ts/SwaggerXc.ts index 74f6b256c4..89d56cf6b8 100644 --- a/packages/nocodb/src/lib/sqlMgr/code/routers/xc-ts/SwaggerXc.ts +++ b/packages/nocodb/src/lib/sqlMgr/code/routers/xc-ts/SwaggerXc.ts @@ -150,19 +150,19 @@ class SwaggerXc extends BaseRender { }, { "in": "query", - "name": "parents", + "name": "bt", "type": "String", "description": "Comma separated parent table names(Belongs To)" }, { "in": "query", - "name": "childs", + "name": "hm", "type": "String", "description": "Comma separated child table names(Has Many)" }, { "in": "query", - "name": "many", + "name": "mm", "type": "String", "description": "Comma separated child table names(Many to Many)" },