diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 782d703ebc..446bb4574e 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -9,24 +9,24 @@ on: branches: [ master ] jobs: - cypress-run: - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Check for update - run: | - echo "CHANGED=$([[ $(lerna ls --since ${{github.event.before}} | grep nc-gui) = nc-gui ]] && echo 'OK')" >> $GITHUB_ENV - - - name: Cypress run - if: ${{ env.CHANGED == 'OK' }} - uses: cypress-io/github-action@v2 - with: - start: docker-compose -f ./docker-compose-cypress.yml up -d - wait-on: 'http://localhost:3000' - wait-on-timeout: 900 +# cypress-run: +# runs-on: ubuntu-20.04 +# steps: +# - name: Checkout +# uses: actions/checkout@v2 +# with: +# fetch-depth: 0 +# - name: Check for update +# run: | +# echo "CHANGED=$([[ $(lerna ls --since ${{github.event.before}} | grep nc-gui) = nc-gui ]] && echo 'OK')" >> $GITHUB_ENV +# +# - name: Cypress run +# if: ${{ env.CHANGED == 'OK' }} +# uses: cypress-io/github-action@v2 +# with: +# start: docker-compose -f ./docker-compose-cypress.yml up -d +# wait-on: 'http://localhost:3000' +# wait-on-timeout: 900 docker: runs-on: ubuntu-latest steps: diff --git a/packages/nc-gui/components/project/spreadsheet/components/spreadsheetNavDrawer.vue b/packages/nc-gui/components/project/spreadsheet/components/spreadsheetNavDrawer.vue index f2b4815b0f..fdda6c0822 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/spreadsheetNavDrawer.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/spreadsheetNavDrawer.vue @@ -695,10 +695,10 @@ export default { this.clipboardSuccessHandler() }, async updateViewName(view, index) { - if (view.title_temp === view.title || !view.edit) { this.$set(view, 'edit', false); return } + if (view.title_temp === view.title || !view.edit) { return } + this.$set(view, 'edit', false) if (this.viewsList.some((v, i) => i !== index && (v.alias || v.title) === view.title_temp)) { this.$toast.info('View name should be unique').goAway(3000) - this.$set(view, 'edit', false) return } try { @@ -713,12 +713,12 @@ export default { } await this.sqlOp({ dbAlias: this.nodes.dbAlias }, 'xcVirtualTableRename', { id: view.id, + old_title: view.title, title: view.title_temp, alias: view.alias, parent_model_title: this.meta._tn }) this.$toast.success('View renamed successfully').goAway(3000) - this.$set(view, 'edit', false) } catch (e) { this.$toast.error(e.message).goAway(3000) } @@ -738,6 +738,7 @@ export default { await this.sqlOp({ dbAlias: this.nodes.dbAlias }, 'xcVirtualTableDelete', { id: view.id, title: view.alias || view.title, + view_name: view.alias || view.title, parent_model_title: this.table }) this.$toast.success('View deleted successfully').goAway(3000) diff --git a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue index 945c56cea8..87abd331af 100644 --- a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue +++ b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue @@ -754,7 +754,8 @@ export default { await this.sqlOp({ dbAlias: this.nodes.dbAlias }, 'xcVirtualTableUpdate', { id: this.selectedViewId, query_params: queryParams, - tn: this.meta.tn + tn: this.meta.tn, + view_name: this.$route.query.view }) } catch (e) { // this.$toast.error(e.message).goAway(3000); diff --git a/packages/nc-gui/components/project/spreadsheet/views/formView.vue b/packages/nc-gui/components/project/spreadsheet/views/formView.vue index 7bb0aa34ce..9aaf6618e0 100644 --- a/packages/nc-gui/components/project/spreadsheet/views/formView.vue +++ b/packages/nc-gui/components/project/spreadsheet/views/formView.vue @@ -455,6 +455,9 @@ export default { return obj }, computed: { + allColumnsLoc() { + return this.allColumns.filter(c => !hiddenCols.includes(c.cn) && !(c.pk && c.ai) && this.meta.belongsTo.every(bt => c.cn !== bt.cn)) + }, isEditable() { return this._isUIAllowed('editFormView') }, @@ -473,13 +476,13 @@ export default { }, columns: { get() { - return this.allColumns.filter(c => this.showFields[c.alias] && !hiddenCols.includes(c.cn)).sort((a, b) => ((this.fieldsOrder.indexOf(a.alias) + 1) || Infinity) - ((this.fieldsOrder.indexOf(b.alias) + 1) || Infinity)) + return this.allColumnsLoc.filter(c => this.showFields[c.alias] && !hiddenCols.includes(c.cn)).sort((a, b) => ((this.fieldsOrder.indexOf(a.alias) + 1) || Infinity) - ((this.fieldsOrder.indexOf(b.alias) + 1) || Infinity)) }, set(val) { const showFields = val.reduce((o, v) => { o[v.alias] = true return o - }, this.allColumns.reduce((o, v) => { + }, this.allColumnsLoc.reduce((o, v) => { o[v.alias] = this.isDbRequired(v) return o }, {})) @@ -524,9 +527,10 @@ export default { }, methods: { addAllColumns() { - this.columns = [...this.allColumns.filter(c => !hiddenCols.includes(c.cn))] + this.columns = [...this.allColumnsLoc] }, isDbRequired(column) { + if (hiddenCols.includes(column.cn)) { return true } let isRequired = (!column.virtual && column.rqd && !column.default && this.meta.belongsTo.every(bt => column.cn !== bt.cn)) || (column.pk && !(column.ai || column.default)) @@ -587,7 +591,7 @@ export default { // if (this.isNew) { // todo: add params option in GraphQL - let data = await this.api.insert(this.localState, { params: { form: this.id } }) + let data = await this.api.insert(this.localState, { params: { form: this.$route.query.view } }) data = { ...this.localState, ...data } // save hasmany and manytomany relations from local state diff --git a/packages/nocodb/src/lib/noco/NcProjectBuilder.ts b/packages/nocodb/src/lib/noco/NcProjectBuilder.ts index 2c337b437b..833b646513 100644 --- a/packages/nocodb/src/lib/noco/NcProjectBuilder.ts +++ b/packages/nocodb/src/lib/noco/NcProjectBuilder.ts @@ -186,6 +186,9 @@ export default class NcProjectBuilder { case 'xcVirtualTableUpdate': await curBuilder.onVirtualTableUpdate(data.req.args); break; + case 'xcVirtualTableRename': + await curBuilder.onVirtualTableRename(data.req.args); + break; case 'xcVirtualTableCreate': await curBuilder.loadFormViews(); break; diff --git a/packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts b/packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts index 2d6e52adf3..f359d99779 100644 --- a/packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts +++ b/packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts @@ -1529,7 +1529,8 @@ export default abstract class BaseApiBuilder formView.query_params = formView.query_params && JSON.parse(formView.query_params); } catch (e) {} - this.formViews[formView.parent_model_title][formView.id] = formView; + // this.formViews[formView.parent_model_title][formView.id] = formView; + this.formViews[formView.parent_model_title][formView.title] = formView; } } @@ -2435,11 +2436,18 @@ export default abstract class BaseApiBuilder XcCache.del([this.projectId, this.dbAlias, 'table', args.tn].join('::')); // todo: update meta and model } - if (args?.query_params?.extraViewParams?.formParams) { - this.formViews[args.tn][args.id].query_params = args.query_params; + if ( + args?.query_params?.extraViewParams?.formParams && + this.formViews[args.tn]?.[args.view_name] + ) { + this.formViews[args.tn][args.view_name].query_params = args.query_params; } } + public async onVirtualTableRename(_args: any) { + await this.loadFormViews(); + } + public getMeta(tableName: string): any { return this.metas?.[tableName]; } diff --git a/packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts b/packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts index e5aee56f0c..b56be8b41b 100644 --- a/packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts +++ b/packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts @@ -3525,25 +3525,14 @@ export default class NcMetaMgr { for (const [key, obj] of Object.entries(args.args.nested)) { if (fields.includes(key)) { - // const colMeta = meta.v.find(c => c._cn === key); - // if (colMeta.bt) { - // insertObject[colMeta.bt.cn] = obj[colMeta.bt._rcn || colMeta.bt.rcn]; - // } else if (colMeta.hm) { - // // todo: insertObject[key] = obj; - // } else if (colMeta.mm) { - // // todo: - // insertObject[key] = obj; - // } } } const model = apiBuilder?.xcModels?.[viewMeta.model_name]; if (model) { - req.query.form = queryParams?.selectedViewId; + req.query.form = viewMeta.view_name; await model.nestedInsert(insertObject, null, req); - - // todo: map nested data } } @@ -4305,6 +4294,19 @@ export default class NcMetaMgr { args.args.id ); + await this.xcMeta.metaUpdate( + projectId, + dbAlias, + 'nc_shared_views', + { + view_name: args.args.title + }, + { + view_name: args.args.old_title, + model_name: args.args.parent_model_title + } + ); + this.xcMeta.audit(projectId, dbAlias, 'nc_audit', { op_type: 'TABLE_VIEW', op_sub_type: 'RENAMED', @@ -4396,6 +4398,12 @@ export default class NcMetaMgr { parent_model_title: args.args.parent_model_title, id: args.args.id }); + + await this.xcMeta.metaDelete(projectId, dbAlias, 'nc_shared_views', { + model_name: args.args.parent_model_title, + view_name: args.args.view_name + }); + this.xcMeta.audit(projectId, dbAlias, 'nc_audit', { op_type: 'TABLE_VIEW', op_sub_type: 'DELETED',