Browse Source

fix: lookup columns in shared view

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/659/head
Pranav C 3 years ago
parent
commit
05475efc9d
  1. 11
      packages/nc-gui/components/project/spreadsheet/components/editColumn.vue
  2. 6
      packages/nc-gui/components/project/spreadsheet/components/editColumn/linkedToAnotherOptions.vue
  3. 4
      packages/nc-gui/components/project/spreadsheet/components/editColumn/relationOptions.vue
  4. 5
      packages/nc-gui/components/project/spreadsheet/components/virtualHeaderCell.vue
  5. 15
      packages/nc-gui/components/project/spreadsheet/helpers/uiTypes.js
  6. 20
      packages/nc-gui/components/project/spreadsheet/mixins/spreadsheet.js
  7. 10
      packages/nc-gui/components/project/spreadsheet/public/xcForm.vue
  8. 10
      packages/nc-gui/components/project/spreadsheet/public/xcTable.vue
  9. 43
      packages/nocodb/src/lib/noco/meta/NcMetaMgrEE.ts

11
packages/nc-gui/components/project/spreadsheet/components/editColumn.vue

@ -20,7 +20,6 @@
</v-col>
<v-col cols="12">
<v-text-field
v-if="!isLookup"
ref="column"
v-model="newColumn.cn"
hide-details="auto"
@ -158,6 +157,7 @@
>
<relation-options
ref="relation"
:alias="alias"
:column="newColumn"
:nodes="nodes"
:is-m-s-s-q-l="isMSSQL"
@ -225,7 +225,6 @@
<template #activator="{on}">
<div v-on="on">
<v-checkbox
v-model="newColumn.ai"
:disabled="sqlUi.colPropUNDisabled(newColumn) || !sqlUi.columnEditable(newColumn)"
class="mr-2 mt-0"
@ -398,10 +397,10 @@
</template>
<script>
import { uiTypes } from '../helpers/uiTypes'
import RollupOptions from './editColumn/rollupOptions'
import FormulaOptions from '@/components/project/spreadsheet/components/editColumn/formulaOptions'
import LookupOptions from '@/components/project/spreadsheet/components/editColumn/lookupOptions'
import { uiTypes } from '@/components/project/spreadsheet/helpers/uiTypes'
import CustomSelectOptions from '@/components/project/spreadsheet/components/editColumn/customSelectOptions'
import RelationOptions from '@/components/project/spreadsheet/components/editColumn/relationOptions'
import DlgLabelSubmitCancel from '@/components/utils/dlgLabelSubmitCancel'
@ -431,10 +430,12 @@ export default {
data: () => ({
valid: false,
relationDeleteDlg: false,
newColumn: {},
uiTypes
newColumn: {}
}),
computed: {
uiTypes() {
return uiTypes.filter(t => !this.editColumn || !t.virtual)
},
isEditDisabled() {
return this.editColumn && this.sqlUi === SqliteUi
},

6
packages/nc-gui/components/project/spreadsheet/components/editColumn/linkedToAnotherOptions.vue

@ -211,7 +211,8 @@ export default {
...this.relation,
type: this.isSQLite || this.relation.type === 'virtual' ? 'virtual' : 'real',
parentTable: this.meta.tn,
updateRelation: !!this.column.rtn
updateRelation: !!this.column.rtn,
alias: this.alias
}
])
// } catch (e) {
@ -274,7 +275,8 @@ export default {
parentTable: this.meta.tn,
parentColumn: parentPK.cn,
updateRelation: !!this.column.rtn,
type: 'real'
type: 'real',
alias: this.alias
}
])
// } catch (e) {

4
packages/nc-gui/components/project/spreadsheet/components/editColumn/relationOptions.vue

@ -92,7 +92,7 @@
<script>
export default {
name: 'RelationOptions',
props: ['nodes', 'column', 'isSQLite', 'isMSSQL'],
props: ['nodes', 'column', 'isSQLite', 'isMSSQL', 'alias'],
data: () => ({
refTables: [],
refColumns: [],
@ -185,7 +185,7 @@ export default {
dbAlias: this.nodes.dbAlias
},
this.relation.type === 'real' && !this.isSQLite ? 'relationCreate' : 'xcVirtualRelationCreate',
this.relation
{ alias: this.alias, ...this.relation }
])
// } catch (e) {
// throw e

5
packages/nc-gui/components/project/spreadsheet/components/virtualHeaderCell.vue

@ -57,7 +57,7 @@
</v-icon>
</template>
<v-list dense>
<v-list-item v-if="!column.lk" dense @click="editColumnMenu = true">
<v-list-item dense @click="editColumnMenu = true">
<x-icon small class="mr-1 nc-column-edit" color="primary">
mdi-pencil
</x-icon>
@ -141,7 +141,8 @@ export default {
}),
computed: {
alias() {
return this.column.lk ? `${this.column.lk._lcn} <small class="grey--text text--darken-1">(from ${this.column.lk._ltn})</small>` : this.column._cn
// return this.column.lk ? `${this.column.lk._lcn} <small class="grey--text text--darken-1">(from ${this.column.lk._ltn})</small>` : this.column._cn
return this.column._cn
},
type() {
if (this.column.bt) {

15
packages/nc-gui/components/project/spreadsheet/helpers/uiTypes.js

@ -5,15 +5,18 @@ const uiTypes = [
},
{
name: 'LinkToAnotherRecord',
icon: 'mdi-link-variant'
icon: 'mdi-link-variant',
virtual: 1
},
{
name: 'ForeignKey',
icon: 'mdi-link-variant'
icon: 'mdi-link-variant',
virtual: 1
},
{
name: 'Lookup',
icon: 'mdi-table-column-plus-before'
icon: 'mdi-table-column-plus-before',
virtual: 1
},
{
name: 'SingleLineText',
@ -93,11 +96,13 @@ const uiTypes = [
},
{
name: 'Formula',
icon: 'mdi-math-integral'
icon: 'mdi-math-integral',
virtual: 1
},
{
name: 'Rollup',
icon: 'mdi-movie-roll'
icon: 'mdi-movie-roll',
virtual: 1
},
{
name: 'Count',

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

@ -95,11 +95,11 @@ export default {
{
const _ref = {}
columns.forEach((c) => {
if (c.virtual && c.lk) {
c.alias = `${c.lk._lcn} (from ${c.lk._ltn})`
} else {
c.alias = c._cn
}
// if (c.virtual && c.lk) {
// c.alias = `${c.lk._lcn} (from ${c.lk._ltn})`
// } else {
c.alias = c._cn
// }
if (c.alias in _ref) {
c.alias += _ref[c.alias]++
} else {
@ -133,11 +133,11 @@ export default {
{
const _ref = {}
columns.forEach((c) => {
if (c.virtual && c.lk) {
c.alias = `${c.lk._lcn} (from ${c.lk._ltn})`
} else {
c.alias = c._cn
}
// if (c.virtual && c.lk) {
// c.alias = `${c.lk._lcn} (from ${c.lk._ltn})`
// } else {
c.alias = c._cn
// }
if (c.alias in _ref) {
c.alias += _ref[c.alias]++
} else {

10
packages/nc-gui/components/project/spreadsheet/public/xcForm.vue

@ -326,11 +326,11 @@ export default {
c.prop = `${c.hm.tn}List`
}
if (c.virtual && c.lk) {
c.alias = `${c.lk._lcn} (from ${c.lk._ltn})`
} else {
c.alias = c._cn
}
// if (c.virtual && c.lk) {
// c.alias = `${c.lk._lcn} (from ${c.lk._ltn})`
// } else {
c.alias = c._cn
// }
if (c.alias in _ref) {
c.alias += _ref[c.alias]++
} else {

10
packages/nc-gui/components/project/spreadsheet/public/xcTable.vue

@ -525,11 +525,11 @@ export default {
c.prop = `${c.hm.tn}List`
}
if (c.virtual && c.lk) {
c.alias = `${c.lk._lcn} (from ${c.lk._ltn})`
} else {
c.alias = c._cn
}
// if (c.virtual && c.lk) {
// c.alias = `${c.lk._lcn} (from ${c.lk._ltn})`
// } else {
c.alias = c._cn
// }
if (c.alias in _ref) {
c.alias += _ref[c.alias]++
} else {

43
packages/nocodb/src/lib/noco/meta/NcMetaMgrEE.ts

@ -163,6 +163,45 @@ export default class NcMetaMgrEE extends NcMetaMgr {
const fields = meta.columns.map(c => c._cn).join(',');
const nestedParams: any = {
hm: [],
mm: [],
bt: []
};
for (const v of meta.v) {
if (!queryParams?.showFields?.[v._cn]) continue;
if (v.bt || v.lk?.type === 'bt') {
const tn = v.bt?.rtn || v.lk?.rtn;
if (!nestedParams.bt.includes(tn)) nestedParams.bt.push(tn);
if (v.lk) {
const key = `bf${nestedParams.bt.indexOf(tn)}`;
nestedParams[key] =
(nestedParams[key] ? `${nestedParams[key]},` : '') + tn;
}
} else if (v.hm || v.lk?.type === 'hm') {
const tn = v.hm?.tn || v.lk?.tn;
if (!nestedParams.hm.includes(tn)) nestedParams.hm.push(tn);
if (v.lk) {
const key = `hf${nestedParams.hm.indexOf(tn)}`;
nestedParams[key] =
(nestedParams[key] ? `${nestedParams[key]},` : '') + tn;
}
} else if (v.mm || v.lk?.type === 'mm') {
const tn = v.mm?.rtn || v.lk?.rtn;
if (!nestedParams.mm.includes(tn)) nestedParams.mm.push(tn);
if (v.lk) {
const key = `mf${nestedParams.mm.indexOf(tn)}`;
nestedParams[key] =
(nestedParams[key] ? `${nestedParams[key]},` : '') + tn;
}
}
}
nestedParams.mm = nestedParams.mm.join(',');
nestedParams.hm = nestedParams.hm.join(',');
nestedParams.bt = nestedParams.bt.join(',');
return {
model_name: viewMeta.model_name,
// meta,
@ -170,7 +209,8 @@ export default class NcMetaMgrEE extends NcMetaMgr {
data: await model.nestedList({
...req.query,
where,
fields
fields,
...nestedParams
}),
...(await model.countByPk({
...req.query,
@ -180,6 +220,7 @@ export default class NcMetaMgrEE extends NcMetaMgr {
client: apiBuilder?.client
};
} catch (e) {
console.log(e);
throw e;
}
}

Loading…
Cancel
Save