From cac809024a6e6d305eccf02f010ec4c2d6f0de6b Mon Sep 17 00:00:00 2001
From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Date: Wed, 14 Aug 2024 14:56:09 +0000
Subject: [PATCH] Bug 10190: Add letter names to tables

Sponsored-by: Glasgow Colleges Library Group
---
 .../CirculationTriggersFormAdd.vue            |  1 +
 .../CirculationTriggersList.vue               |  7 ++++++-
 .../CirculationTriggers/TriggersTable.vue     | 19 +++++++++++++------
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersFormAdd.vue
index ac331a26c00..fac7b534fc3 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersFormAdd.vue
+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersFormAdd.vue
@@ -19,6 +19,7 @@
                         :triggerNumber="newTriggerNumber - 1"
                         :modal="true"
                         :ruleBeingEdited="ruleBeingEdited"
+                        :letters="letters"
                     />
                 </div>
                 <fieldset class="rows">
diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersList.vue
index f464cbb8833..27c0511c8a5 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersList.vue
+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersList.vue
@@ -92,6 +92,7 @@
                         :triggerNumber="number"
                         :categories="categories"
                         :itemTypes="itemTypes"
+                        :letters="letters"
                     />
                 </div>
             </template>
@@ -113,13 +114,17 @@ import ToolbarButton from "../../ToolbarButton.vue"
 import { APIClient } from "../../../fetch/api-client.js"
 import TriggersTable from "./TriggersTable.vue"
 import { inject } from "vue"
+import { storeToRefs } from "pinia"
 
 export default {
     setup() {
-        const { splitCircRulesByTriggerNumber } = inject("circRulesStore")
+        const circRulesStore = inject("circRulesStore")
+        const { splitCircRulesByTriggerNumber } = circRulesStore
+        const { letters } = storeToRefs(circRulesStore)
 
         return {
             splitCircRulesByTriggerNumber,
+            letters,
         }
     },
     data() {
diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/TriggersTable.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/TriggersTable.vue
index 69f0df003a6..da01a45e943 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/TriggersTable.vue
+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/TriggersTable.vue
@@ -9,7 +9,7 @@
                     {{ $__("Item type") }}
                 </th>
                 <th v-if="modal">
-                    {{ $__("Notice") }}
+                    {{ $__("Rule") }}
                 </th>
                 <th>
                     {{ $__("Delay") }}
@@ -114,11 +114,13 @@
                         "
                     >
                         {{
-                            rule[
-                                "overdue_" +
-                                    (modal ? i + 1 : triggerNumber) +
-                                    "_notice"
-                            ]
+                            handleNotice(
+                                rule[
+                                    "overdue_" +
+                                        (modal ? i + 1 : triggerNumber) +
+                                        "_notice"
+                                ]
+                            )
                         }}
                     </td>
                     <td
@@ -224,6 +226,7 @@ export default {
         "ruleBeingEdited",
         "categories",
         "itemTypes",
+        "letters",
     ],
     methods: {
         handleContext(value, data, type, displayProperty = "name") {
@@ -251,6 +254,10 @@ export default {
                         rule[`overdue_${number}_restrict`])
             )
         },
+        handleNotice(notice) {
+            const letter = this.letters.find(letter => letter.code === notice)
+            return letter ? letter.name : notice
+        },
     },
 }
 </script>
-- 
2.47.0