From 0a71fd6dd019ad679c7270f27fb65ff112d78794 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 21 Feb 2024 13:03:26 +0100 Subject: [PATCH 01/28] feat(Contexts): API endpoint for getting Contexts Signed-off-by: Arthur Schiwon --- lib/Controller/ContextController.php | 2 +- lib/Db/ContextMapper.php | 2 +- lib/Service/ContextService.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Controller/ContextController.php b/lib/Controller/ContextController.php index bd71417a1..29001de3e 100644 --- a/lib/Controller/ContextController.php +++ b/lib/Controller/ContextController.php @@ -282,4 +282,4 @@ protected function contextsToArray(array $contexts): array { } return $result; } -} +} \ No newline at end of file diff --git a/lib/Db/ContextMapper.php b/lib/Db/ContextMapper.php index 702af3767..37ae0b4eb 100644 --- a/lib/Db/ContextMapper.php +++ b/lib/Db/ContextMapper.php @@ -216,4 +216,4 @@ protected function applyOwnedOrSharedQuery(IQueryBuilder $qb, string $userId): v $qb->andWhere($whereExpression); } } -} +} \ No newline at end of file diff --git a/lib/Service/ContextService.php b/lib/Service/ContextService.php index ee31cc7ad..8b065d24d 100644 --- a/lib/Service/ContextService.php +++ b/lib/Service/ContextService.php @@ -423,4 +423,4 @@ protected function insertNodesFromArray(Context $context, array $nodes): void { } $context->setNodes($addedNodes); } -} +} \ No newline at end of file From a6d0b11537ef461f40ff98bee7eaa055c775f4ac Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 27 Feb 2024 14:07:32 +0100 Subject: [PATCH 02/28] feat(Contexts): API to add and remove a node to a Context Signed-off-by: Arthur Schiwon --- lib/Db/PageContentMapper.php | 2 +- lib/Middleware/PermissionMiddleware.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Db/PageContentMapper.php b/lib/Db/PageContentMapper.php index dcd88fc01..e78008bad 100644 --- a/lib/Db/PageContentMapper.php +++ b/lib/Db/PageContentMapper.php @@ -57,4 +57,4 @@ public function findByNodeRelation(int $nodeRelId): array { return $this->findEntities($qb); } -} +} \ No newline at end of file diff --git a/lib/Middleware/PermissionMiddleware.php b/lib/Middleware/PermissionMiddleware.php index 49b239936..b32261e5d 100644 --- a/lib/Middleware/PermissionMiddleware.php +++ b/lib/Middleware/PermissionMiddleware.php @@ -87,4 +87,4 @@ protected function assertCanManageContext(): void { } } } -} +} \ No newline at end of file From ffeed86096bcf5e52ef0e79d62986765360cf2f3 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 21 Feb 2024 13:03:26 +0100 Subject: [PATCH 03/28] feat(Contexts): API endpoint for getting Contexts Signed-off-by: Arthur Schiwon --- lib/Db/Context.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Db/Context.php b/lib/Db/Context.php index 8da45c6b3..9fdc97c34 100644 --- a/lib/Db/Context.php +++ b/lib/Db/Context.php @@ -60,4 +60,4 @@ public function jsonSerialize(): array { return $data; } -} +} \ No newline at end of file From 5f5b8f27ddf350773720efd90ed8ae1b79897104 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 21 Feb 2024 22:10:38 +0100 Subject: [PATCH 04/28] feat(Contexts): API to get full context info Signed-off-by: Arthur Schiwon --- lib/Controller/ContextController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Controller/ContextController.php b/lib/Controller/ContextController.php index 29001de3e..bd71417a1 100644 --- a/lib/Controller/ContextController.php +++ b/lib/Controller/ContextController.php @@ -282,4 +282,4 @@ protected function contextsToArray(array $contexts): array { } return $result; } -} \ No newline at end of file +} From a9365d73691a0f51e59d55223f5d2580b524a176 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 26 Feb 2024 18:04:28 +0100 Subject: [PATCH 05/28] feat(Contexts): API to create a new Context Signed-off-by: Arthur Schiwon --- appinfo/routes.php | 2 +- lib/Controller/ContextController.php | 2 +- lib/Db/ContextNodeRelation.php | 2 +- lib/Db/ContextNodeRelationMapper.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/appinfo/routes.php b/appinfo/routes.php index da22566e5..631e641fe 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -137,4 +137,4 @@ ['name' => 'Context#removeNode', 'url' => '/api/2/contexts/{contextId}/nodes/{nodeRelId}', 'verb' => 'DELETE'], ['name' => 'Context#updateContentOrder', 'url' => '/api/2/contexts/{contextId}/pages/{pageId}', 'verb' => 'PUT'], ] -]; +]; \ No newline at end of file diff --git a/lib/Controller/ContextController.php b/lib/Controller/ContextController.php index bd71417a1..29001de3e 100644 --- a/lib/Controller/ContextController.php +++ b/lib/Controller/ContextController.php @@ -282,4 +282,4 @@ protected function contextsToArray(array $contexts): array { } return $result; } -} +} \ No newline at end of file diff --git a/lib/Db/ContextNodeRelation.php b/lib/Db/ContextNodeRelation.php index 7981ffcd1..2945ba1b9 100644 --- a/lib/Db/ContextNodeRelation.php +++ b/lib/Db/ContextNodeRelation.php @@ -36,4 +36,4 @@ public function jsonSerialize(): array { 'permissions' => $this->getPermissions() ]; } -} +} \ No newline at end of file diff --git a/lib/Db/ContextNodeRelationMapper.php b/lib/Db/ContextNodeRelationMapper.php index 7709ca5de..704114244 100644 --- a/lib/Db/ContextNodeRelationMapper.php +++ b/lib/Db/ContextNodeRelationMapper.php @@ -32,4 +32,4 @@ public function findById(int $nodeRelId): ContextNodeRelation { $row = $this->findOneQuery($qb); return $this->mapRowToEntity($row); } -} +} \ No newline at end of file From 21a7d2c9f55f0d525ba451e05740a4861c51e070 Mon Sep 17 00:00:00 2001 From: Cleopatra Enjeck M Date: Wed, 14 Feb 2024 15:12:17 +0100 Subject: [PATCH 06/28] show that multiple tables can be on same page Signed-off-by: Cleopatra Enjeck M --- src/pages/Context.vue | 123 ++++++++++++++++++++++++++++++++++++++++++ src/router.js | 13 ++++- 2 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 src/pages/Context.vue diff --git a/src/pages/Context.vue b/src/pages/Context.vue new file mode 100644 index 000000000..4c562fd49 --- /dev/null +++ b/src/pages/Context.vue @@ -0,0 +1,123 @@ + + + + + \ No newline at end of file diff --git a/src/router.js b/src/router.js index cb0f7a7e0..101682d72 100644 --- a/src/router.js +++ b/src/router.js @@ -4,6 +4,7 @@ import { generateUrl } from '@nextcloud/router' import MainViewWrapper from './pages/View.vue' import MainDashboardWrapper from './pages/Table.vue' import Startpage from './pages/Startpage.vue' +import Context from './pages/Context.vue' Vue.use(Router) @@ -15,6 +16,16 @@ export default new Router({ path: '/', component: Startpage, }, + { + path: '/context/:contextId', + component: Context, + name: 'context', + }, + { + path: '/context/:contextId/row/:rowId', + component: Context, + name: 'contextRow', + }, { path: '/table/:tableId', component: MainDashboardWrapper, @@ -46,4 +57,4 @@ export default new Router({ name: 'viewRow', }, ], -}) +}) \ No newline at end of file From ea9caeeecd579bc31d7f9b00704d5906026fc67a Mon Sep 17 00:00:00 2001 From: Cleopatra Enjeck M Date: Mon, 19 Feb 2024 12:40:37 +0100 Subject: [PATCH 07/28] update Signed-off-by: Cleopatra Enjeck M --- src/modules/main/sections/TableWrapper.vue | 71 ++++++++++ src/pages/Context.vue | 131 ++++++++---------- src/router.js | 6 +- .../columnTypePartials/forms/MainForm.vue | 2 +- 4 files changed, 133 insertions(+), 77 deletions(-) create mode 100644 src/modules/main/sections/TableWrapper.vue diff --git a/src/modules/main/sections/TableWrapper.vue b/src/modules/main/sections/TableWrapper.vue new file mode 100644 index 000000000..bc38b22d7 --- /dev/null +++ b/src/modules/main/sections/TableWrapper.vue @@ -0,0 +1,71 @@ + + + diff --git a/src/pages/Context.vue b/src/pages/Context.vue index 4c562fd49..9f103cc16 100644 --- a/src/pages/Context.vue +++ b/src/pages/Context.vue @@ -1,123 +1,108 @@ - \ No newline at end of file + diff --git a/src/router.js b/src/router.js index 101682d72..0692d42f1 100644 --- a/src/router.js +++ b/src/router.js @@ -17,12 +17,12 @@ export default new Router({ component: Startpage, }, { - path: '/context/:contextId', + path: '/context/', component: Context, name: 'context', }, { - path: '/context/:contextId/row/:rowId', + path: '/context/row/:rowId', component: Context, name: 'contextRow', }, @@ -57,4 +57,4 @@ export default new Router({ name: 'viewRow', }, ], -}) \ No newline at end of file +}) diff --git a/src/shared/components/ncTable/partials/columnTypePartials/forms/MainForm.vue b/src/shared/components/ncTable/partials/columnTypePartials/forms/MainForm.vue index c3ce122ac..64ca16c14 100644 --- a/src/shared/components/ncTable/partials/columnTypePartials/forms/MainForm.vue +++ b/src/shared/components/ncTable/partials/columnTypePartials/forms/MainForm.vue @@ -116,7 +116,7 @@ export default { if (this.isView) { return this.views.filter(view => view.tableId === this.activeElement.tableId && view !== this.activeElement).filter(view => !this.localSelectedViews.includes(view)) } - return this.views.filter(view => view.tableId === this.activeElement.id).filter(view => !this.localSelectedViews.includes(view)) + return this.views.filter(view => view.tableId === this.activeElement?.id).filter(view => !this.localSelectedViews.includes(view)) }, }, From 170f68554d7f89c884b3e1692b94480be76bcf6d Mon Sep 17 00:00:00 2001 From: Cleopatra Enjeck M Date: Thu, 22 Feb 2024 20:10:42 +0100 Subject: [PATCH 08/28] feat: show contexts Signed-off-by: Cleopatra Enjeck M --- src/App.vue | 3 + src/pages/Context.vue | 108 ++++++++++++++++------------ src/pages/Contextpage.vue | 148 ++++++++++++++++++++++++++++++++++++++ src/router.js | 13 +++- src/store/store.js | 37 ++++++++++ 5 files changed, 261 insertions(+), 48 deletions(-) create mode 100644 src/pages/Contextpage.vue diff --git a/src/App.vue b/src/App.vue index 383b2b884..307abc1f9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -50,6 +50,7 @@ export default { }, async created() { await this.$store.dispatch('loadTablesFromBE') + await this.$store.dispatch('getAllContexts') await this.$store.dispatch('loadViewsSharedWithMeFromBE') this.routing(this.$router.currentRoute) this.observeAppContent() @@ -67,6 +68,8 @@ export default { } else if (currentRoute.path.startsWith('/view/')) { this.$store.commit('setActiveViewId', parseInt(currentRoute.params.viewId)) this.setPageTitle(this.$store.getters.activeView.title) + } else if (currentRoute.path.startsWith('/context/')) { + this.$store.commit('setActiveContextId', currentRoute.params.contextId) } }, setPageTitle(title) { diff --git a/src/pages/Context.vue b/src/pages/Context.vue index 9f103cc16..7bb876bb1 100644 --- a/src/pages/Context.vue +++ b/src/pages/Context.vue @@ -1,24 +1,25 @@ - + diff --git a/src/pages/Contextpage.vue b/src/pages/Contextpage.vue new file mode 100644 index 000000000..301384bfa --- /dev/null +++ b/src/pages/Contextpage.vue @@ -0,0 +1,148 @@ + + + + + diff --git a/src/router.js b/src/router.js index 0692d42f1..0d9f358e5 100644 --- a/src/router.js +++ b/src/router.js @@ -4,6 +4,7 @@ import { generateUrl } from '@nextcloud/router' import MainViewWrapper from './pages/View.vue' import MainDashboardWrapper from './pages/Table.vue' import Startpage from './pages/Startpage.vue' +import Contextpage from './pages/Contextpage.vue' import Context from './pages/Context.vue' Vue.use(Router) @@ -18,11 +19,21 @@ export default new Router({ }, { path: '/context/', - component: Context, + component: Contextpage, name: 'context', }, { path: '/context/row/:rowId', + component: Contextpage, + name: 'contextRow', + }, + { + path: '/context/:contextId', + component: Context, + name: 'context', + }, + { + path: '/context/:contextId/row/:rowId', component: Context, name: 'contextRow', }, diff --git a/src/store/store.js b/src/store/store.js index 8245baba1..83ef6819d 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -20,10 +20,12 @@ export default new Vuex.Store({ tablesLoading: false, tables: [], views: [], + contexts: [], activeViewId: null, activeTableId: null, activeRowId: null, activeElementIsView: false, + activeContextId: null, }, getters: { @@ -75,12 +77,20 @@ export default new Vuex.Store({ state.activeElementIsView = false } }, + setActiveContextId(state, contextId) { + if (state.activeContextId !== contextId) { + state.activeContextId = contextId + } + }, setTables(state, tables) { state.tables = tables }, setViews(state, views) { state.views = views }, + setContexts(state, contexts) { + state.contexts = contexts + }, setTable(state, table) { const index = state.tables.findIndex(t => t.id === table.id) state.tables[index] = table @@ -89,6 +99,10 @@ export default new Vuex.Store({ const index = state.views.findIndex(v => v.id === view.id) state.views[index] = view }, + setContext(state, context) { + const index = state.contexts.findIndex(c => c.id === context.id) + state.contexts[index] = context + }, setActiveRowId(state, rowId) { state.activeRowId = rowId }, @@ -309,6 +323,29 @@ export default new Vuex.Store({ commit('setTables', [...tables]) return true }, + + async getAllContexts({ commit, state }) { + try { + const res = await axios.get(generateOcsUrl('/apps/tables/api/3/contexts')) + commit('setContexts', res.data.ocs.data) + } catch (e) { + displayError(e, t('tables', 'Could not load contexts.')) + showError(t('tables', 'Could not fetch contexts')) + } + return true + }, + + async getContext({ state, commit, dispatch }, { id }) { + try { + const res = await axios.get(generateOcsUrl('/apps/tables/api/3/contexts/' + id)) + commit('setContext', res.data.ocs.data) + } catch (e) { + displayError(e, t('tables', 'Could not load contexts.')) + showError(t('tables', 'Could not fetch contexts')) + } + return true + }, + async removeTable({ state, commit }, { tableId }) { try { await axios.delete(generateUrl('/apps/tables/table/' + tableId)) From 41da9fc0a60a6d7fad3486a937eaac422b96d3c4 Mon Sep 17 00:00:00 2001 From: Cleopatra Enjeck M Date: Thu, 22 Feb 2024 20:19:32 +0100 Subject: [PATCH 09/28] check if nodes exist Signed-off-by: Cleopatra Enjeck M --- src/pages/Context.vue | 49 ++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/pages/Context.vue b/src/pages/Context.vue index 7bb876bb1..cce10f388 100644 --- a/src/pages/Context.vue +++ b/src/pages/Context.vue @@ -7,9 +7,8 @@

Context Tables

-
@@ -49,12 +48,14 @@ export default { ...mapState(['tables', 'contexts', 'activeContextId']), tableData() { const data = {} - for (const [key, node] of Object.entries(this.context.nodes)) { - if (node.node_type) { - const rowId = 'rows' + node.node_id - const colId = 'columns' + node.node_id - data[colId] = this.$store.state.data.columns[(node.node_id).toString()] - data[rowId] = this.$store.state.data.rows[(node.node_id).toString()] + if (this.context && this.context.nodes) { + for (const [key, node] of Object.entries(this.context.nodes)) { + if (node.node_type) { + const rowId = 'rows' + node.node_id + const colId = 'columns' + node.node_id + data[colId] = this.$store.state.data.columns[(node.node_id).toString()] + data[rowId] = this.$store.state.data.rows[(node.node_id).toString()] + } } } return data @@ -67,7 +68,7 @@ export default { }, }, - async mounted() { + async mounted() { await this.reload() }, @@ -77,18 +78,22 @@ export default { const index = this.contexts.findIndex(c => parseInt(c.id) === parseInt(this.activeContextId)) this.context = this.contexts[index] - for (const [key, node] of Object.entries(this.context.nodes)) { - if (node.node_type === 'table') { - const table = this.tables.find(table => table.id === node.node_id) - this.contextTables.push(table) - await this.$store.dispatch('loadColumnsFromBE', { - view: null, - tableId: node.node_id, - }) - await this.$store.dispatch('loadRowsFromBE', { - viewId: null, - tableId: node.node_id, - }) + console.log(this.contexts, this.activeContextId) + console.log(this.context) + if (this.context && this.context.nodes) { + for (const [key, node] of Object.entries(this.context.nodes)) { + if (node.node_type === 'table') { + const table = this.tables.find(table => table.id === node.node_id) + this.contextTables.push(table) + await this.$store.dispatch('loadColumnsFromBE', { + view: null, + tableId: node.node_id, + }) + await this.$store.dispatch('loadRowsFromBE', { + viewId: null, + tableId: node.node_id, + }) + } } } }, From cb7776668eceff87abb01a9da7d85e6187899edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 28 Feb 2024 08:32:56 +0100 Subject: [PATCH 10/28] fix: lint fixes and cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Hรคrtl --- src/pages/Context.vue | 15 ++++++--------- src/pages/Contextpage.vue | 14 +++++++++----- src/store/store.js | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/pages/Context.vue b/src/pages/Context.vue index cce10f388..0f3be2629 100644 --- a/src/pages/Context.vue +++ b/src/pages/Context.vue @@ -6,7 +6,7 @@

{{ context.description }}

Context Tables

-
+
@@ -18,11 +18,9 @@ + diff --git a/src/modules/modals/Modals.vue b/src/modules/modals/Modals.vue index c7cb90b25..2228fb1a7 100644 --- a/src/modules/modals/Modals.vue +++ b/src/modules/modals/Modals.vue @@ -1,6 +1,7 @@
@@ -76,6 +76,7 @@ +