diff --git a/src/modules/main/sections/MainWrapper.vue b/src/modules/main/sections/MainWrapper.vue index 40acb4599..684a204dc 100644 --- a/src/modules/main/sections/MainWrapper.vue +++ b/src/modules/main/sections/MainWrapper.vue @@ -68,8 +68,8 @@ export default { computed: { ...mapState(['activeRowId']), ...mapState({ - columns: state => state.data.columns, - rows: state => state.data.rows, + columns(state) { return state.data.columns[this.isView ? 'view-' + (this.element.id).toString() : (this.element.id).toString()] }, + rows(state) { return state.data.rows[this.isView ? 'view-' + (this.element.id).toString() : (this.element.id).toString()] }, }), }, @@ -79,7 +79,7 @@ export default { }, }, - mounted() { + beforeMount() { this.reload(true) }, @@ -107,14 +107,20 @@ export default { return } - if (!this.lastActiveElement || this.element.id !== this.lastActiveElement.id || this.isView !== this.lastActiveElement.isView || force) { + // Used to reload View from backend, in case there are Filter updates + const isLastElementSameAndView = this.element.id === this.lastActiveElement?.id && this.isView === this.lastActiveElement?.isView + + if (!this.lastActiveElement || this.element.id !== this.lastActiveElement.id || isLastElementSameAndView || this.isView !== this.lastActiveElement.isView || force) { this.localLoading = true + // Since we show one page at a time, no need keep other tables in the store + await this.$store.dispatch('clearState') + this.viewSetting = {} await this.$store.dispatch('loadColumnsFromBE', { view: this.isView ? this.element : null, - table: !this.isView ? this.element : null, + tableId: !this.isView ? this.element.id : null, }) if (this.canReadData(this.element)) { await this.$store.dispatch('loadRowsFromBE', { @@ -122,9 +128,12 @@ export default { tableId: !this.isView ? this.element.id : null, }) } else { - await this.$store.dispatch('removeRows') + await this.$store.dispatch('removeRows', { + isView: this.isView, + elementId: this.element.id, + }) } - this.lastActiveViewId = { + this.lastActiveElement = { id: this.element.id, isView: this.isView, } diff --git a/src/modules/modals/CreateColumn.vue b/src/modules/modals/CreateColumn.vue index 1c21fa746..1be09fe94 100644 --- a/src/modules/modals/CreateColumn.vue +++ b/src/modules/modals/CreateColumn.vue @@ -281,7 +281,7 @@ export default { data.numberSuffix = this.column.numberSuffix } } - const res = await this.$store.dispatch('insertNewColumn', { data }) + const res = await this.$store.dispatch('insertNewColumn', { isView: this.isView, elementId: this.element.id, data }) if (res) { showSuccess(t('tables', 'The column "{column}" was created.', { column: this.column.title })) } else { diff --git a/src/modules/modals/DeleteColumn.vue b/src/modules/modals/DeleteColumn.vue index fbcd61e63..a44885200 100644 --- a/src/modules/modals/DeleteColumn.vue +++ b/src/modules/modals/DeleteColumn.vue @@ -41,11 +41,13 @@ export default { }, methods: { async deleteColumn() { - const res = await this.$store.dispatch('removeColumn', { id: this.columnToDelete.id }) + const res = await this.$store.dispatch('removeColumn', { id: this.columnToDelete.id, isView: this.isView, elementId: this.elementId }) if (!res) { showError(t('tables', 'Error occurred while deleting column "{column}".', { column: this.columnToDelete.title })) } - await this.$store.dispatch('reloadViewsOfTable', { tableId: this.elementId }) + if (!this.isView) { + await this.$store.dispatch('reloadViewsOfTable', { tableId: this.elementId }) + } this.$emit('cancel') }, }, diff --git a/src/modules/modals/DeleteRows.vue b/src/modules/modals/DeleteRows.vue index dbcb2d176..b90032a9b 100644 --- a/src/modules/modals/DeleteRows.vue +++ b/src/modules/modals/DeleteRows.vue @@ -41,7 +41,8 @@ export default { this.rowsToDelete.forEach(rowId => { const res = this.$store.dispatch('removeRow', { rowId, - viewId: this.isView ? this.elementId : null, + isView: this.isView, + elementId: this.elementId, }) if (!res) { error = true diff --git a/src/modules/modals/EditColumn.vue b/src/modules/modals/EditColumn.vue index e7408f3f7..7337d659c 100644 --- a/src/modules/modals/EditColumn.vue +++ b/src/modules/modals/EditColumn.vue @@ -188,7 +188,7 @@ export default { delete data.lastEditAt delete data.lastEditBy console.debug('this column data will be send', data) - const res = await this.$store.dispatch('updateColumn', { id: this.editColumn.id, data }) + const res = await this.$store.dispatch('updateColumn', { id: this.editColumn.id, isView: this.isView, elementId: this.elementId, data }) if (res) { showSuccess(t('tables', 'The column "{column}" was updated.', { column: this.editColumn.title })) } diff --git a/src/modules/modals/EditRow.vue b/src/modules/modals/EditRow.vue index 6082e1d9f..40fc737bd 100644 --- a/src/modules/modals/EditRow.vue +++ b/src/modules/modals/EditRow.vue @@ -163,7 +163,8 @@ export default { } const res = await this.$store.dispatch('updateRow', { id: this.row.id, - viewId: this.isView ? this.element.id : null, + isView: this.isView, + elementId: this.element.id, data, }) if (!res) { @@ -182,7 +183,8 @@ export default { this.localLoading = true const res = await this.$store.dispatch('removeRow', { rowId, - viewId: this.isView ? this.element.id : null, + isView: this.isView, + elementId: this.element.id, }) if (!res) { showError(t('tables', 'Could not delete row.')) diff --git a/src/modules/modals/Import.vue b/src/modules/modals/Import.vue index 23b6f7da7..3a0b428bb 100644 --- a/src/modules/modals/Import.vue +++ b/src/modules/modals/Import.vue @@ -212,7 +212,7 @@ export default { await this.$store.dispatch('loadViewsSharedWithMeFromBE') await this.$store.dispatch('loadColumnsFromBE', { view: this.isElementView ? this.element : null, - table: !this.isElementView ? this.element : null, + tableId: !this.isElementView ? this.element.id : null, }) if (this.canReadData(this.element)) { await this.$store.dispatch('loadRowsFromBE', { diff --git a/src/shared/components/ncTable/NcTable.vue b/src/shared/components/ncTable/NcTable.vue index 973821815..7c7aa88c0 100644 --- a/src/shared/components/ncTable/NcTable.vue +++ b/src/shared/components/ncTable/NcTable.vue @@ -41,19 +41,19 @@ deselect-all-rows -> unselect all rows, e.g. after deleting selected rows
+ @delete-selected-rows="rowIds => $emit('delete-selected-rows', rowIds)" />