From bb93a922b07ddad464e63d62167504f7d7fc1aca Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 9 Feb 2023 16:18:10 +0000 Subject: [PATCH] Bug_32932: Update router to use object references - agreements This patch updates the Vue files for ERM to use router object links rather than urls - this will make it much simpler to maintain the router if urls need to be updated. This first patch only updates the files in the agreements section of ERM as a first step to introduce the topic for discussion. Test plan: 1) Apply patch 2) Navigate to the Agreements section of ERM and click on different navigation links/buttons 3) The links/buttons should all work as normal 4) Review the code to see that the component files now refer back to the router using objects rather than url strings --- .../vue/components/ERM/AgreementsFormAdd.vue | 6 +-- .../ERM/AgreementsFormConfirmDelete.vue | 4 +- .../js/vue/components/ERM/AgreementsList.vue | 25 +++++----- .../js/vue/components/ERM/AgreementsShow.vue | 48 ++++++++++++++++--- .../vue/components/ERM/AgreementsToolbar.vue | 4 +- .../prog/js/vue/components/ERM/Main.vue | 2 +- .../intranet-tmpl/prog/js/vue/routes/erm.js | 28 +++++++++++ 7 files changed, 90 insertions(+), 27 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue index 71dfa09b862..6d4f466c50c 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue @@ -171,7 +171,7 @@
{{ $__("Cancel") }} { setMessage(this.$__("Agreement updated")) - this.$router.push("/cgi-bin/koha/erm/agreements") + this.$router.push({ name: "AgreementsList" }) }, error => {} ) @@ -388,7 +388,7 @@ export default { client.agreements.create(agreement).then( success => { setMessage(this.$__("Agreement created")) - this.$router.push("/cgi-bin/koha/erm/agreements") + this.$router.push({ name: "AgreementsList" }) }, error => {} ) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue index 991c4a8770f..eb0d3b603b7 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue @@ -20,7 +20,7 @@
{{ $__("No, do not delete") }} { setMessage(this.$__("Agreement deleted")) - this.$router.push("/cgi-bin/koha/erm/agreements") + this.$router.push({ name: "AgreementsList" }) }, error => {} ) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue index 9394f1c08d3..d5a79030d72 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue @@ -103,17 +103,22 @@ export default { ) }, show_agreement: function (agreement_id) { - this.$router.push("/cgi-bin/koha/erm/agreements/" + agreement_id) + this.$router.push({ + name: "AgreementsShow", + params: { agreement_id: agreement_id }, + }) }, edit_agreement: function (agreement_id) { - this.$router.push( - "/cgi-bin/koha/erm/agreements/edit/" + agreement_id - ) + this.$router.push({ + name: "AgreementsFormAddEdit", + params: { agreement_id: agreement_id }, + }) }, delete_agreement: function (agreement_id) { - this.$router.push( - "/cgi-bin/koha/erm/agreements/delete/" + agreement_id - ) + this.$router.push({ + name: "AgreementsFormConfirmDelete", + params: { agreement_id: agreement_id }, + }) }, select_agreement: function (agreement_id) { this.$emit("select-agreement", agreement_id) @@ -121,10 +126,8 @@ export default { }, filter_table: async function () { if (this.before_route_entered) { - let new_route = build_url( - "/cgi-bin/koha/erm/agreements", - this.filters - ) + let { href } = this.$router.resolve({ name: "AgreementsList" }) + let new_route = build_url(href, this.filters) this.$router.push(new_route) } if (this.filters.by_expired) { diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsShow.vue index b249bb8738f..f6f80264109 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsShow.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsShow.vue @@ -5,13 +5,19 @@ {{ $__("Agreement #%s").format(agreement.agreement_id) }} @@ -159,7 +165,13 @@ > {{ agreement_license.license.name }} @@ -196,7 +208,15 @@ > {{ relationship.related_agreement.name }} {{ agreement_package.package.name }} {{ agreement_package.package.name }}
{{ $__("Close") }}
- {{ $__("New agreement") }} diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue index 03c914bd866..24f7c886f7f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue @@ -21,7 +21,7 @@
  • {{ $__("Agreements") }} [breadcrumbs.home, breadcrumbs.erm_home], @@ -135,6 +136,7 @@ export const routes = [ children: [ { path: "", + name: "AgreementsList", component: AgreementsList, meta: { breadcrumb: () => breadcrumb_paths.agreements, @@ -142,6 +144,7 @@ export const routes = [ }, { path: ":agreement_id", + name: "AgreementsShow", component: AgreementsShow, meta: { breadcrumb: () => @@ -153,6 +156,7 @@ export const routes = [ }, { path: "delete/:agreement_id", + name: "AgreementsFormConfirmDelete", component: AgreementsFormConfirmDelete, meta: { breadcrumb: () => @@ -164,6 +168,7 @@ export const routes = [ }, { path: "add", + name: "AgreementsFormAdd", component: AgreementsFormAdd, meta: { breadcrumb: () => @@ -175,6 +180,7 @@ export const routes = [ }, { path: "edit/:agreement_id", + name: "AgreementsFormAddEdit", component: AgreementsFormAdd, meta: { breadcrumb: () => @@ -212,6 +218,7 @@ export const routes = [ children: [ { path: "", + name: "EHoldingsLocalPackagesList", component: EHoldingsLocalPackagesList, meta: { breadcrumb: () => @@ -224,6 +231,7 @@ export const routes = [ }, { path: ":package_id", + name: "EHoldingsLocalPackagesShow", component: EHoldingsLocalPackagesShow, meta: { breadcrumb: () => @@ -239,6 +247,7 @@ export const routes = [ }, { path: "delete/:package_id", + name: "EHoldingsLocalPackagesFormConfirmDelete", component: EHoldingsLocalPackagesFormConfirmDelete, meta: { @@ -255,6 +264,7 @@ export const routes = [ }, { path: "add", + name: "EHoldingsLocalPackagesFormAdd", component: EHoldingsLocalPackagesFormAdd, meta: { breadcrumb: () => @@ -270,6 +280,7 @@ export const routes = [ }, { path: "edit/:package_id", + name: "EHoldingsLocalPackagesFormAddEdit", component: EHoldingsLocalPackagesFormAdd, meta: { breadcrumb: () => @@ -290,6 +301,7 @@ export const routes = [ children: [ { path: "", + name: "EHoldingsLocalTitlesList", component: EHoldingsLocalTitlesList, meta: { breadcrumb: () => @@ -301,6 +313,7 @@ export const routes = [ }, { path: ":title_id", + name: "EHoldingsLocalTitlesShow", component: EHoldingsLocalTitlesShow, meta: { breadcrumb: () => @@ -316,6 +329,7 @@ export const routes = [ }, { path: "delete/:title_id", + name: "EHoldingsLocalTitlesFormConfirmDelete", component: EHoldingsLocalTitlesFormConfirmDelete, meta: { @@ -332,6 +346,7 @@ export const routes = [ }, { path: "add", + name: "EHoldingsLocalTitlesFormAdd", component: EHoldingsLocalTitlesFormAdd, meta: { breadcrumb: () => @@ -347,6 +362,7 @@ export const routes = [ }, { path: "edit/:title_id", + name: "EHoldingsLocalTitlesFormAddEdit", component: EHoldingsLocalTitlesFormAdd, meta: { breadcrumb: () => @@ -362,6 +378,7 @@ export const routes = [ }, { path: "import", + name: "EHoldingsLocalTitlesFormImport", component: EHoldingsLocalTitlesFormImport, meta: { breadcrumb: () => @@ -379,6 +396,7 @@ export const routes = [ }, { path: "resources/:resource_id", + name: "EHoldingsLocalResourcesShow", component: EHoldingsLocalResourcesShow, meta: { breadcrumb: () => @@ -407,6 +425,7 @@ export const routes = [ children: [ { path: "", + name: "EHoldingsEBSCOPackagesList", component: EHoldingsEBSCOPackagesList, meta: { breadcrumb: () => @@ -419,6 +438,7 @@ export const routes = [ }, { path: ":package_id", + name: "EHoldingsEBSCOPackagesShow", component: EHoldingsEBSCOPackagesShow, meta: { breadcrumb: () => @@ -439,6 +459,7 @@ export const routes = [ children: [ { path: "", + name: "EHoldingsEBSCOTitlesList", component: EHoldingsEBSCOTitlesList, meta: { breadcrumb: () => @@ -450,6 +471,7 @@ export const routes = [ }, { path: ":title_id", + name: "EHoldingsEBSCOTitlesShow", component: EHoldingsEBSCOTitlesShow, meta: { breadcrumb: () => @@ -467,6 +489,7 @@ export const routes = [ }, { path: "resources/:resource_id", + name: "EHoldingsEBSCOResourcesShow", component: EHoldingsEBSCOResourcesShow, meta: { breadcrumb: () => @@ -488,6 +511,7 @@ export const routes = [ children: [ { path: "", + name: "LicensesList", component: LicensesList, meta: { breadcrumb: () => breadcrumb_paths.licenses, @@ -495,6 +519,7 @@ export const routes = [ }, { path: ":license_id", + name: "LicensesShow", component: LicensesShow, meta: { breadcrumb: () => @@ -506,6 +531,7 @@ export const routes = [ }, { path: "delete/:license_id", + name: "LicensesFormConfirmDelete", component: LicensesFormConfirmDelete, meta: { breadcrumb: () => @@ -517,6 +543,7 @@ export const routes = [ }, { path: "add", + name: "LicensesFormAdd", component: LicensesFormAdd, meta: { breadcrumb: () => @@ -528,6 +555,7 @@ export const routes = [ }, { path: "edit/:license_id", + name: "LicensesFormAddEdit", component: LicensesFormAdd, meta: { breadcrumb: () => -- 2.37.1 (Apple Git-137.1)