From 491dd947a86c37d35084718044dca8bd06e654f9 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Tue, 21 Mar 2023 16:14:45 -0300 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 Signed-off-by: Agustin Moyano Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi (cherry picked from commit a53351b4a0e2b32d589fea3f74b350f5100a2e72) Signed-off-by: Matt Blenkinsop --- .../vue/components/ERM/AgreementsFormAdd.vue | 6 +-- .../js/vue/components/ERM/AgreementsList.vue | 24 +++++----- .../js/vue/components/ERM/AgreementsShow.vue | 45 ++++++++++++++++--- .../vue/components/ERM/AgreementsToolbar.vue | 4 +- .../ERM/EHoldingsEBSCOPackageAgreements.vue | 7 ++- .../ERM/EHoldingsEBSCOPackageTitlesList.vue | 10 ++--- .../ERM/EHoldingsEBSCOPackagesList.vue | 26 +++++------ .../ERM/EHoldingsEBSCOPackagesShow.vue | 2 +- .../ERM/EHoldingsEBSCOResourcesShow.vue | 10 ++++- .../ERM/EHoldingsEBSCOTitlePackagesList.vue | 16 ++++--- .../ERM/EHoldingsEBSCOTitlesList.vue | 25 ++++++----- .../ERM/EHoldingsEBSCOTitlesShow.vue | 2 +- .../ERM/EHoldingsLocalPackageTitlesList.vue | 10 ++--- .../ERM/EHoldingsLocalPackagesFormAdd.vue | 14 +++--- .../ERM/EHoldingsLocalPackagesList.vue | 20 ++++----- .../ERM/EHoldingsLocalPackagesShow.vue | 22 ++++++--- .../ERM/EHoldingsLocalPackagesToolbar.vue | 2 +- .../ERM/EHoldingsLocalResourcesShow.vue | 10 ++++- .../ERM/EHoldingsLocalTitlePackagesList.vue | 16 ++++--- .../ERM/EHoldingsLocalTitlesFormAdd.vue | 14 +++--- .../ERM/EHoldingsLocalTitlesList.vue | 19 ++++---- .../ERM/EHoldingsLocalTitlesShow.vue | 13 +++--- .../ERM/EHoldingsLocalTitlesToolbar.vue | 4 +- .../js/vue/components/ERM/LicensesFormAdd.vue | 6 +-- .../js/vue/components/ERM/LicensesList.vue | 15 +++---- .../js/vue/components/ERM/LicensesShow.vue | 9 ++-- .../js/vue/components/ERM/LicensesToolbar.vue | 2 +- .../prog/js/vue/components/ERM/Main.vue | 4 +- .../intranet-tmpl/prog/js/vue/routes/erm.js | 24 ++++++++++ 29 files changed, 238 insertions(+), 143 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 d491250a8b..e551a94532 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 @@ -159,7 +159,7 @@
{{ $__("Cancel") }} { setMessage(this.$__("Agreement updated")) - this.$router.push("/cgi-bin/koha/erm/agreements") + this.$router.push({ name: "AgreementsList" }) }, error => {} ) @@ -383,7 +383,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/AgreementsList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue index 7d8df42c1a..54414fd050 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 @@ -165,16 +165,18 @@ export default { error => {} ) }, - doShow: function (agreement, dt, event) { + doShow: function ({ agreement_id }, dt, event) { event.preventDefault() - this.$router.push( - "/cgi-bin/koha/erm/agreements/" + agreement.agreement_id - ) + this.$router.push({ + name: "AgreementsShow", + params: { agreement_id }, + }) }, - doEdit: function (agreement, dt, event) { - this.$router.push( - "/cgi-bin/koha/erm/agreements/edit/" + agreement.agreement_id - ) + doEdit: function ({ agreement_id }, dt, event) { + this.$router.push({ + name: "AgreementsFormAddEdit", + params: { agreement_id }, + }) }, doDelete: function (agreement, dt, event) { this.setConfirmationDialog( @@ -228,10 +230,8 @@ export default { if (!this.filters.by_expired) { this.filters.max_expiration_date = "" } - 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) } this.$refs.table.redraw(this.table_url()) 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 81d49a4158..34e77e98b8 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,7 +5,10 @@ {{ $__("Agreement #%s").format(agreement.agreement_id) }} @@ -161,7 +164,13 @@ > {{ agreement_license.license.name }} @@ -198,7 +207,15 @@ > {{ relationship.related_agreement.name }} {{ agreement_package.package.name }} {{ agreement_package.package.name }}
{{ $__("Close") }} {} ) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsToolbar.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsToolbar.vue index 035c326683..b61ceec2fc 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsToolbar.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsToolbar.vue @@ -1,8 +1,6 @@