From f6e221287cc498ee5d808ec5444221fb8e71bb9e Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 13 Apr 2023 15:44:23 +0000 Subject: [PATCH] Bug 33529: Update KohaTable to accept customised buttons This patch updates the KohaTable component to accept action buttons as objects rather than as hard coded strings. This allows buttons to be customised for different use cases Test plan: 1) Apply patch 2) Run yarn build 3) Navigate to Agreements - add an agreement if the table is empty 4) Test the buttons for editing and deleting agreements in the "Actions" column 5) Repeat for licenses 6) Repeat for local packages 7) Repeat for local titles --- .../prog/js/vue/components/KohaTable.vue | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/KohaTable.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/KohaTable.vue index 3e5d809ed0..c2cdeec0c0 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/KohaTable.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/KohaTable.vue @@ -86,19 +86,11 @@ export default { render: (data, type, row) => { let content = [] this.actions["-1"].forEach(a => { - if (a == "edit") { - content.push( - '' + - this.$__("Edit") + - "" - ) - } else if (a == "delete") { - content.push( - '' + - this.$__("Delete") + - "" - ) - } + content.push( + `` + + this.$__(a.title) + + "" + ) }) return content.join(" ") }, @@ -156,9 +148,9 @@ export default { .to$() .each(function (idx) { const data = dataSet[idx] - actions.forEach(action => { - $("." + action, this).on("click", e => { - self.$emit(action, data, dt, e) + actions.forEach(a => { + $("." + a.action, this).on("click", e => { + self.$emit(a.action, data, dt, e) }) }) }) -- 2.37.1 (Apple Git-137.1)