From c396b58412a5c5a37be89ba4391a2697d3902e9e 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 50305dc21a..577f43c6fa 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 @@
@@ -174,6 +174,11 @@ export default { error => {} ) }, + 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 27eee68c05..000614ef4c 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") }} + +

@@ -397,7 +383,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.2