Browse Source

feat: modify nestedList params

Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com>
pull/350/head
Pranav C 3 years ago
parent
commit
5017de328d
  1. 12
      packages/nc-gui/components/project/spreadsheet/apis/gqlApi.js
  2. 7
      packages/nc-gui/components/project/spreadsheet/components/virtualCell/belogsToCell.vue
  3. 7
      packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue
  4. 7
      packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue
  5. 7
      packages/nc-gui/components/project/spreadsheet/mixins/spreadsheet.js
  6. 2
      packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts
  7. 6
      packages/nocodb/src/lib/sqlMgr/code/routers/xc-ts/SwaggerXc.ts

12
packages/nc-gui/components/project/spreadsheet/apis/gqlApi.js

@ -91,8 +91,8 @@ export default class GqlApi {
async gqlRelationReqBody(params) { async gqlRelationReqBody(params) {
let str = ''; let str = '';
if (params.childs) { if (params.hm) {
for (const child of params.childs.split(',')) { for (const child of params.hm.split(',')) {
await this.$ctx.$store.dispatch('meta/ActLoadMeta', { await this.$ctx.$store.dispatch('meta/ActLoadMeta', {
dbAlias: this.$ctx.nodes.dbAlias, dbAlias: this.$ctx.nodes.dbAlias,
env: this.$ctx.nodes.env, env: this.$ctx.nodes.env,
@ -104,8 +104,8 @@ export default class GqlApi {
} }
} }
} }
if (params.parents) { if (params.bt) {
for (const parent of params.parents.split(',')) { for (const parent of params.bt.split(',')) {
await this.$ctx.$store.dispatch('meta/ActLoadMeta', { await this.$ctx.$store.dispatch('meta/ActLoadMeta', {
dbAlias: this.$ctx.nodes.dbAlias, dbAlias: this.$ctx.nodes.dbAlias,
env: this.$ctx.nodes.env, env: this.$ctx.nodes.env,
@ -117,8 +117,8 @@ export default class GqlApi {
} }
} }
} }
if (params.many) { if (params.mm) {
for (const mm of params.many.split(',')) { for (const mm of params.mm.split(',')) {
await this.$ctx.$store.dispatch('meta/ActLoadMeta', { await this.$ctx.$store.dispatch('meta/ActLoadMeta', {
dbAlias: this.$ctx.nodes.dbAlias, dbAlias: this.$ctx.nodes.dbAlias,
env: this.$ctx.nodes.env, env: this.$ctx.nodes.env,

7
packages/nc-gui/components/project/spreadsheet/components/virtualCell/belogsToCell.vue

@ -282,10 +282,11 @@ export default {
}, },
parentQueryParams() { parentQueryParams() {
if (!this.parentMeta) return {} if (!this.parentMeta) return {}
// todo: use reduce
return { return {
childs: (this.parentMeta && this.parentMeta.v && this.parentMeta.v.filter(v => v.hm).map(({hm}) => hm.tn).join()) || '', hm: (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()) || '', bt: (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()) || '' mm: (this.parentMeta && this.parentMeta.v && this.parentMeta.v.filter(v => v.mm).map(({mm}) => mm.rtn).join()) || ''
} }
}, },
parentAvailableColumns() { parentAvailableColumns() {

7
packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue

@ -363,10 +363,11 @@ export default {
}, },
childQueryParams() { childQueryParams() {
if (!this.childMeta) return {} if (!this.childMeta) return {}
// todo: use reduce
return { return {
childs: (this.childMeta && this.childMeta.v && this.childMeta.v.filter(v => v.hm).map(({hm}) => hm.tn).join()) || '', hm: (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()) || '', bt: (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()) || '' mm: (this.childMeta && this.childMeta.v && this.childMeta.v.filter(v => v.mm).map(({mm}) => mm.rtn).join()) || ''
} }
}, },
parentId() { parentId() {

7
packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue

@ -364,10 +364,11 @@ export default {
}, },
childQueryParams() { childQueryParams() {
if (!this.childMeta) return {} if (!this.childMeta) return {}
// todo: use reduce
return { return {
childs: (this.childMeta && this.childMeta.v && this.childMeta.v.filter(v => v.hm).map(({hm}) => hm.tn).join()) || '', hm: (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()) || '', bt: (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()) || '' mm: (this.childMeta && this.childMeta.v && this.childMeta.v.filter(v => v.mm).map(({mm}) => mm.rtn).join()) || ''
} }
}, },
conditionGraph() { conditionGraph() {

7
packages/nc-gui/components/project/spreadsheet/mixins/spreadsheet.js

@ -120,9 +120,10 @@ export default {
// condition: this.condition, // condition: this.condition,
where: this.concatenatedXWhere, where: this.concatenatedXWhere,
sort: this.sort, sort: this.sort,
childs: (this.meta && this.meta.v && this.meta.v.filter(v => v.hm).map(({hm}) => hm.tn).join()) || '', // todo: use reduce
parents: (this.meta && this.meta.v && this.meta.v.filter(v => v.bt).map(({bt}) => bt.rtn).join()) || '', hm: (this.meta && this.meta.v && this.meta.v.filter(v => v.hm).map(({hm}) => hm.tn).join()) || '',
many: (this.meta && this.meta.v && this.meta.v.filter(v => v.mm).map(({mm}) => mm.rtn).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() { }, colLength() {
return (this.availableColumns && this.availableColumns.length) || 0 return (this.availableColumns && this.availableColumns.length) || 0

2
packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts

@ -1287,7 +1287,7 @@ class BaseModelSql extends BaseModel {
// todo : add conditionGraph // todo : add conditionGraph
// todo : implement nestedread // 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 || '*'; let fields = fields1 || f || '*';
try { try {

6
packages/nocodb/src/lib/sqlMgr/code/routers/xc-ts/SwaggerXc.ts

@ -150,19 +150,19 @@ class SwaggerXc extends BaseRender {
}, },
{ {
"in": "query", "in": "query",
"name": "parents", "name": "bt",
"type": "String", "type": "String",
"description": "Comma separated parent table names(Belongs To)" "description": "Comma separated parent table names(Belongs To)"
}, },
{ {
"in": "query", "in": "query",
"name": "childs", "name": "hm",
"type": "String", "type": "String",
"description": "Comma separated child table names(Has Many)" "description": "Comma separated child table names(Has Many)"
}, },
{ {
"in": "query", "in": "query",
"name": "many", "name": "mm",
"type": "String", "type": "String",
"description": "Comma separated child table names(Many to Many)" "description": "Comma separated child table names(Many to Many)"
}, },

Loading…
Cancel
Save