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. 4
      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) {
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,

7
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() {

7
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() {

7
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() {

7
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

4
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);

6
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)"
},

Loading…
Cancel
Save