Browse Source

fix: lookup column rename issuea

Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com>
pull/401/head
Pranav C 3 years ago
parent
commit
b23d11392e
  1. 6
      packages/nc-gui/components/dynamicStyle.js
  2. 3
      packages/nc-gui/components/project/spreadsheet/mixins/spreadsheet.js
  3. 3
      packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue
  4. 15
      packages/nc-gui/components/project/spreadsheet/views/xcGridView.vue
  5. 46
      packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts
  6. 1
      packages/nocodb/src/lib/noco/gql/GqlApiBuilder.ts

6
packages/nc-gui/components/dynamicStyle.js

@ -0,0 +1,6 @@
export default {
name: 'DynamicStyle',
render(createElement) {
return createElement('style', this.$slots.default)
}
}

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

@ -253,6 +253,9 @@ export default {
}
},
watch: {
meta() {
this.mapFieldsAndShowFields()
},
'viewStatus.type'() {
if (!this.loadingMeta || !this.loadingData) {
this.syncDataDebounce(this)

3
packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue

@ -941,9 +941,6 @@ export default {
if (col) {
this.$set(this.showFields, col, true)
}
if (this.selectedViewId === tableMeta.id) {
this.columnsWidth = qp.columnsWidth || this.columnsWidth
}
} catch (e) {
}
}

15
packages/nc-gui/components/project/spreadsheet/views/xcGridView.vue

@ -208,11 +208,17 @@
</table>
<div is="style" v-html="style" />
<div is="style" v-html="resizeColStyle" />
<!-- <div is="style" v-html="resizeColStyle" />-->
<dynamic-style>
<template v-if="resizingCol">
[data-col="{{ resizingCol }}"]{min-width:{{ resizingColWidth }};max-width:{{ resizingColWidth }};width:{{ resizingColWidth }};}
</template>
</dynamic-style>
</div>
</template>
<script>
import DynamicStyle from '@/components/dynamicStyle'
import HeaderCell from '@/components/project/spreadsheet/components/headerCell'
import EditableCell from '@/components/project/spreadsheet/components/editableCell'
import EditColumn from '@/components/project/spreadsheet/components/editColumn'
@ -225,6 +231,7 @@ import VirtualHeaderCell from '@/components/project/spreadsheet/components/virtu
export default {
name: 'XcGridView',
components: {
DynamicStyle,
VirtualHeaderCell,
VirtualCell,
TableCell,
@ -299,10 +306,10 @@ export default {
}
return style
},
resizeColStyle() {
return this.resizingCol ? ` [data-col="${this.resizingCol}"]{min-width:${this.resizingColWidth};max-width:${this.resizingColWidth};width:${this.resizingColWidth};}` : ''
}
// resizeColStyle() {
// return this.resizingCol ? ` [data-col="${this.resizingCol}"]{min-width:${this.resizingColWidth};max-width:${this.resizingColWidth};width:${this.resizingColWidth};}` : ''
// }
},
watch: {
data() {

46
packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts

@ -342,10 +342,11 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami
title: tn
})
let queryParams;
let queryParams: any;
try {
queryParams = JSON.parse(oldModelRow.query_params);
} catch (e) {
queryParams = {}
}
@ -434,7 +435,8 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami
aclOper.push(async () => this.modifyColumnNameInACL(tn, column.cno, column.cn));
// virtual views param update
for (const qp of virtualViewsParamsArr) {
for (const qp of [queryParams, ...virtualViewsParamsArr]) {
if (!qp) continue
// @ts-ignore
const {filters, sortList, showFields} = qp;
/* update sort field */
@ -533,8 +535,8 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami
// update lookup columns
this.metas[mm.rtn].v?.forEach(v => {
if (v.lk &&v.lk.ltn === tn && v.lk.lcn === column.cno) {
relationTableMetas.add(this.metas[mm.tn])
if (v.lk && v.lk.ltn === tn && v.lk.lcn === column.cno) {
relationTableMetas.add(this.metas[mm.rtn])
v.lk.lcn = column.cn;
v.lk._lcn = column._cn;
}
@ -626,9 +628,9 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami
if (newMeta.manyToMany?.length) {
for (const mm of newMeta.manyToMany) {
// filter out lookup columns which maps to current col
this.metas[mm.rtn].v=this.metas[mm.rtn].v?.filter(v => {
this.metas[mm.rtn].v = this.metas[mm.rtn].v?.filter(v => {
if (v.lk && v.lk.ltn === tn && v.lk.lcn === column.cn) {
relationTableMetas.add(this.metas[mm.tn])
relationTableMetas.add(this.metas[mm.rtn])
return false;
}
return true;
@ -668,12 +670,27 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami
}
}
// update relation tables metadata
for (const relMeta of relationTableMetas) {
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_models', {
meta: JSON.stringify(relMeta)
}, {
title: relMeta.tn
});
this.models[relMeta.tn] = this.getBaseModel(relMeta);
XcCache.del([this.projectId, this.dbAlias, 'table', relMeta.tn].join('::'));
}
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_models', {
meta: JSON.stringify(newMeta),
...(queryParams ? {query_params: JSON.stringify(queryParams)} : {})
}, {
title: tn
});
XcCache.del([this.projectId, this.dbAlias, 'table', tn].join('::'));
this.models[tn] = this.getBaseModel(newMeta);
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_acl', {
acl: JSON.stringify(acl)
@ -691,21 +708,11 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami
}
this.baseLog(`onTableUpdate : Generating model instance for '%s' table`, tn)
this.models[tn] = this.getBaseModel(newMeta);
await NcHelp.executeOperations(aclOper, this.connectionConfig.client);
// update relation tables metadata
for (const relMeta of relationTableMetas) {
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_models', {
meta: JSON.stringify(relMeta)
}, {
title: relMeta.tn
});
this.models[relMeta.tn] = this.getBaseModel(relMeta);
XcCache.del([this.projectId, this.dbAlias, 'table', relMeta.tn].join('::'));
}
}
@ -945,6 +952,9 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami
protected initDbDriver(): void {
if (!this.dbDriver) {
if(this.projectBuilder?.prefix){
this.dbDriver = this.xcMeta.knex
}else {
if (this.connectionConfig?.connection?.ssl && typeof this.connectionConfig?.connection?.ssl === 'object') {
if (this.connectionConfig.connection.ssl.caFilePath) {
this.connectionConfig.connection.ssl.ca = fs
@ -984,8 +994,8 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami
})
}
}
}
if (!this.sqlClient) {
this.sqlClient = SqlClientFactory.create(this.connectionConfig) as MysqlClient;
// close knex connection in sqlclient and reuse existing connection
this.sqlClient.knex.destroy();

1
packages/nocodb/src/lib/noco/gql/GqlApiBuilder.ts

@ -77,7 +77,6 @@ export class GqlApiBuilder extends BaseApiBuilder<Noco> implements XcMetaMgr {
super(app, projectBuilder, config, connectionConfig);
this.config = config;
this.connectionConfig = connectionConfig;
this.models = {};
this.resolvers = {};
this.schemas = {};
this.types = {};

Loading…
Cancel
Save