From 37c1d4e2cf7e8219d6f3630b30d20ffdc213f751 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 19 Aug 2024 14:50:20 -0300 Subject: [PATCH] Bug 37513: Add a way for KohaTable to decide if a button should be displayed This patch adds, for the case of object parameters in the actions config entry for the KohaTable Vue component, a check for a function on the current row, that will be used to determine if a button needs to be displayed or not. It checks for the function to be defined, and uses it for checking displayability. Signed-off-by: David Nind --- .../prog/js/vue/components/KohaTable.vue | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 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 b988a2c7df..d3a03bd974 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/KohaTable.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/KohaTable.vue @@ -94,9 +94,21 @@ export default { this.actions["-1"].forEach(action => { if (typeof action === "object") { let action_name = Object.keys(action)[0] - content.push( - ` ${action[action_name].text}` - ) + let should_display = true + + if ( + typeof action[action_name] + .should_display === "function" + ) { + should_display = + action[action_name].should_display(row) + } + + if (should_display) { + content.push( + ` ${action[action_name].text}` + ) + } } else if (action == "edit") { content.push( ' ' + -- 2.39.2