From 4f930461c3ff5dd27c0836ec50219d3dfbbb007c Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 9 Jul 2024 14:30:40 +0000 Subject: [PATCH] Bug 37301: [PoC] DRY ToolbarButton This is only a PoC applied to Agreements for discussion. This is a continuation of bug 37274. Bug 37274 applied the ToolbarButton to missing components but it was mostly replacing WET for WET. This is DRYer: - All mark-up related to toolbar buttons is now written once (css class, icons, elements) - All labels are now written once (except 'Add' for translatability) --- .../js/vue/components/ERM/AgreementsList.vue | 9 ++++-- .../js/vue/components/ERM/AgreementsShow.vue | 29 ++++++++----------- .../prog/js/vue/components/ToolbarButton.vue | 26 +++++++++++++++-- 3 files changed, 43 insertions(+), 21 deletions(-) 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 e57b7a00b9..ea50ea92f9 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 @@ -3,8 +3,8 @@
@@ -223,6 +223,11 @@ export default { }) }) }, + add_agreement: function () { + this.$router.push({ + name: "AgreementsFormAdd", + }) + }, doShow: function ({ agreement_id }, dt, event) { event.preventDefault() this.$router.push({ 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 7b49fe88d6..f0745ca7db 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 @@ -2,22 +2,8 @@
{{ $__("Loading") }}
- - {{ $__("Delete") }} + +

@@ -406,7 +392,16 @@ export default { error => {} ) }, - delete_agreement: function (agreement_id, agreement_name) { + edit_agreement: function () { + this.$router.push({ + name: "AgreementsFormAddEdit", + params: { agreement_id: this.agreement.agreement_id }, + }) + }, + delete_agreement: function () { + let agreement_id = this.agreement.agreement_id + let agreement_name = this.agreement.name + this.setConfirmationDialog( { title: this.$__( diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ToolbarButton.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ToolbarButton.vue index 4cfada715c..84cec0d11f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ToolbarButton.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ToolbarButton.vue @@ -1,12 +1,22 @@ -- 2.39.5