From 6c08f5ecc7a7205ddcf26639de4446a78fad0b92 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Wed, 31 Jul 2024 10:25:39 -0400 Subject: [PATCH] Implement front-end routing #18 --- CHANGELOG.md | 5 +- .../plugins/controlled-list-manager.js | 15 +++ .../components/ControlledListsMain.vue | 109 ++++++++++++------ .../components/tree/AddDeleteControls.vue | 32 +---- .../components/tree/ListTree.vue | 8 +- .../components/tree/ListTreeControls.vue | 98 +++++++++++++++- .../components/tree/MoveRow.vue | 26 ++--- .../components/tree/TreeRow.vue | 7 +- .../src/arches-references/constants.ts | 6 + .../plugins/ControlledListManager.vue | 14 +-- .../src/arches-references/utils.ts | 20 +++- 11 files changed, 233 insertions(+), 107 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4ef1c9..959b805 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,10 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added -- Added compatibility with PrimeVue 4 [#16](https://github.com/archesproject/arches-references/pull/16) +- Add compatibility with PrimeVue 4 [#16](https://github.com/archesproject/arches-references/pull/16) +- Add front-end routing [#18](https://github.com/archesproject/arches-references/pull/18) ### Changed -- Generate URIs when not supplied [#17](https://github.com/archesproject/arches-references/pull/17) +- Generate URIs when not supplied [#17](https://github.com/archesproject/arches-references/pull/17) ### Fixed diff --git a/arches_references/media/js/views/components/plugins/controlled-list-manager.js b/arches_references/media/js/views/components/plugins/controlled-list-manager.js index b4e25e8..0d23956 100644 --- a/arches_references/media/js/views/components/plugins/controlled-list-manager.js +++ b/arches_references/media/js/views/components/plugins/controlled-list-manager.js @@ -1,4 +1,5 @@ import ko from 'knockout'; +import ControlledListsMain from '@/arches-references/components/ControlledListsMain.vue'; import { definePreset } from '@primevue/themes'; import Aura from '@primevue/themes/aura'; @@ -6,6 +7,19 @@ import ControlledListManager from '@/arches-references/plugins/ControlledListMan import createVueApplication from 'utils/create-vue-application'; import ControlledListManagerTemplate from 'templates/views/components/plugins/controlled-list-manager.htm'; +import { createRouter, createWebHistory } from 'vue-router'; + +const routes = [ + { path: '/plugins/controlled-list-manager', name: 'splash', component: ControlledListsMain }, + { path: '/plugins/controlled-list-manager/list/:id', name: 'list', component: ControlledListsMain }, + { path: '/plugins/controlled-list-manager/item/:id', name: 'item', component: ControlledListsMain }, +]; + +const router = createRouter({ + history: createWebHistory(), + routes, +}); + // Much of this might get merged upstream to core arches in 8.0? const ControlledListsPreset = definePreset(Aura, { primitive: { @@ -65,6 +79,7 @@ const controlledListsTheme = { ko.components.register('controlled-list-manager', { viewModel: function() { createVueApplication(ControlledListManager, controlledListsTheme).then((vueApp) => { + vueApp.use(router); vueApp.mount('#controlled-list-manager-mounting-point'); }); }, diff --git a/arches_references/src/arches-references/components/ControlledListsMain.vue b/arches_references/src/arches-references/components/ControlledListsMain.vue index 798d917..1c95915 100644 --- a/arches_references/src/arches-references/components/ControlledListsMain.vue +++ b/arches_references/src/arches-references/components/ControlledListsMain.vue @@ -1,13 +1,17 @@