Bugzilla – Attachment 172612 Details for
Bug 10190
Overdue notice triggers based on item type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10190: Display effective values and highlight them
Bug-10190-Display-effective-values-and-highlight-t.patch (text/plain), 14.13 KB, created by
Martin Renvoize (ashimema)
on 2024-10-10 14:40:34 UTC
(
hide
)
Description:
Bug 10190: Display effective values and highlight them
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-10-10 14:40:34 UTC
Size:
14.13 KB
patch
obsolete
>From a83540d9c7f3c043bb83daef864f815a0aedd6df Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 5 Sep 2024 13:13:52 +0100 >Subject: [PATCH] Bug 10190: Display effective values and highlight them > >--- > .../CirculationTriggers/TriggersTable.vue | 287 +++++++++--------- > 1 file changed, 150 insertions(+), 137 deletions(-) > >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 c88951c356b..43ab5881e8d 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 >@@ -1,5 +1,6 @@ > <template> > <div class="page-section"> >+ <div class="page-section bg-info">{{ $__("Bolid italic values denote fallback values where an override has not been set for the context.") }}</div> > <table> > <thead> > <th v-if="!modal"> >@@ -39,15 +40,12 @@ > triggerNumber > )" > v-bind:key="'rule' + i" >+ :class="{ >+ selected_rule: >+ modal && i + 1 === parseInt(ruleBeingEdited), >+ }" > > >- <td >- v-if="!modal" >- :class=" >- modal && i + 1 === parseInt(ruleBeingEdited) >- ? 'selected_rule' >- : '' >- " >- > >+ <td v-if="!modal"> > {{ > handleContext( > rule.context.patron_category_id, >@@ -56,14 +54,7 @@ > ) > }} > </td> >- <td >- v-if="!modal" >- :class=" >- modal && i + 1 === parseInt(ruleBeingEdited) >- ? 'selected_rule' >- : '' >- " >- > >+ <td v-if="!modal"> > {{ > handleContext( > rule.context.item_type_id, >@@ -73,127 +64,97 @@ > ) > }} > </td> >- <td >- v-if="modal" >- :class=" >- modal && i + 1 === parseInt(ruleBeingEdited) >- ? 'selected_rule' >- : '' >- " >- > >- {{ i + 1 }} >- </td> >- <td >- :class=" >- modal && i + 1 === parseInt(ruleBeingEdited) >- ? 'selected_rule' >- : '' >- " >- > >- {{ >- rule[ >- "overdue_" + >- (modal ? i + 1 : triggerNumber) + >- "_delay" >- ] >- ? rule[ >- "overdue_" + >- (modal ? i + 1 : triggerNumber) + >- "_delay" >- ] + >- " " + >- $__("days") >- : 0 + " " + $__("days") >- }} >+ <td v-if="modal">{{ i + 1 }}</td> >+ >+ <!-- Delay --> >+ <td> >+ <span >+ :class="{ >+ fallback: findEffectiveRule(rule, `overdue_${modal ? i + 1 : triggerNumber}_delay`).isFallback, >+ }" >+ > >+ {{ >+ findEffectiveRule(rule, `overdue_${modal ? i + 1 : triggerNumber}_delay`).value + >+ " " + >+ $__("days") >+ }} >+ </span> > </td> >- <td >- :class=" >- modal && i + 1 === parseInt(ruleBeingEdited) >- ? 'selected_rule' >- : '' >- " >- > >- {{ >- handleNotice( >- rule[ >- "overdue_" + >- (modal ? i + 1 : triggerNumber) + >- "_notice" >- ] >- ) >- }} >+ >+ <!-- Notice --> >+ <td> >+ <span >+ :class="{ >+ fallback: findEffectiveRule(rule, `overdue_${modal ? i + 1 : triggerNumber}_notice`).isFallback, >+ }" >+ > >+ {{ handleNotice(findEffectiveRule(rule, `overdue_${modal ? i + 1 : triggerNumber}_notice`).value) }} >+ </span> > </td> >- <td >- :class=" >- modal && i + 1 === parseInt(ruleBeingEdited) >- ? 'selected_rule' >- : '' >- " >- > >- {{ >- handleTransport( >- rule[ >- "overdue_" + >- (modal ? i + 1 : triggerNumber) + >- "_mtt" >- ], >- "email" >- ) >- }} >+ >+ <!-- Email --> >+ <td> >+ <span >+ :class="{ >+ fallback: findEffectiveRule(rule, `overdue_${modal ? i + 1 : triggerNumber}_mtt`).isFallback, >+ }" >+ > >+ {{ >+ handleTransport( >+ findEffectiveRule(rule, `overdue_${modal ? i + 1 : triggerNumber}_mtt`).value, >+ "email" >+ ) >+ }} >+ </span> > </td> >- <td >- :class=" >- modal && i + 1 === parseInt(ruleBeingEdited) >- ? 'selected_rule' >- : '' >- " >- > >- {{ >- handleTransport( >- rule[ >- "overdue_" + >- (modal ? i + 1 : triggerNumber) + >- "_mtt" >- ], >- "print" >- ) >- }} >+ >+ <!-- Print --> >+ <td> >+ <span >+ :class="{ >+ fallback: findEffectiveRule(rule, `overdue_${modal ? i + 1 : triggerNumber}_mtt`).isFallback, >+ }" >+ > >+ {{ >+ handleTransport( >+ findEffectiveRule(rule, `overdue_${modal ? i + 1 : triggerNumber}_mtt`).value, >+ "print" >+ ) >+ }} >+ </span> > </td> >- <td >- :class=" >- modal && i + 1 === parseInt(ruleBeingEdited) >- ? 'selected_rule' >- : '' >- " >- > >- {{ >- handleTransport( >- rule[ >- "overdue_" + >- (modal ? i + 1 : triggerNumber) + >- "_mtt" >- ], >- "sms" >- ) >- }} >+ >+ <!-- SMS --> >+ <td> >+ <span >+ :class="{ >+ fallback: findEffectiveRule(rule, `overdue_${modal ? i + 1 : triggerNumber}_mtt`).isFallback, >+ }" >+ > >+ {{ >+ handleTransport( >+ findEffectiveRule(rule, `overdue_${modal ? i + 1 : triggerNumber}_mtt`).value, >+ "sms" >+ ) >+ }} >+ </span> > </td> >- <td >- :class=" >- modal && i + 1 === parseInt(ruleBeingEdited) >- ? 'selected_rule' >- : '' >- " >- > >- {{ >- handleRestrictions( >- rule[ >- "overdue_" + >- (modal ? i + 1 : triggerNumber) + >- "_restrict" >- ] >- ) >- }} >+ >+ <!-- Restricts Checkouts --> >+ <td> >+ <span >+ :class="{ >+ fallback: findEffectiveRule(rule, `overdue_${modal ? i + 1 : triggerNumber}_restrict`).isFallback, >+ }" >+ > >+ {{ >+ handleRestrictions( >+ findEffectiveRule(rule, `overdue_${modal ? i + 1 : triggerNumber}_restrict`).value >+ ) >+ }} >+ </span> > </td> >+ > <td v-if="!modal" class="actions"> > <router-link > :to="{ >@@ -238,7 +199,7 @@ export default { > ? value.includes(type) > ? this.$__("Yes") > : this.$__("No") >- : this.$__("Default") >+ : '' > }, > handleRestrictions(value) { > return value === "1" ? this.$__("Yes") : this.$__("No") >@@ -258,19 +219,71 @@ export default { > const letter = this.letters.find(letter => letter.code === notice) > return letter > ? letter.name >- ? letter.name >- : notice >- : this.$__("Default") >+ : notice >+ }, >+ findEffectiveRule(ruleSet, key) { >+ // Check if the current rule's value for the key is null >+ if (ruleSet[key] === null) { >+ // Filter rules to only those with non-null values for the specified key >+ const relevantRules = this.circRules.filter( >+ rule => rule[key] !== null >+ ) >+ >+ // Function to calculate specificity score >+ const getSpecificityScore = ruleContext => { >+ let score = 0 >+ if ( >+ ruleContext.library_id !== "*" && >+ ruleContext.library_id === ruleSet.library_id >+ ) >+ score += 4 >+ if ( >+ ruleContext.patron_category_id !== "*" && >+ ruleContext.patron_category_id === >+ ruleSet.patron_category_id >+ ) >+ score += 2 >+ if ( >+ ruleContext.item_type_id !== "*" && >+ ruleContext.item_type_id === ruleSet.item_type_id >+ ) >+ score += 1 >+ return score >+ } >+ >+ // Sort the rules based on specificity score, descending >+ const sortedRules = relevantRules.sort((a, b) => { >+ return ( >+ getSpecificityScore(b.context) - >+ getSpecificityScore(a.context) >+ ) >+ }) >+ >+ // If no rule found, return null >+ if (sortedRules.length === 0) { >+ return { value: null, isFallback: true } >+ } >+ >+ // Get the value from the most specific rule >+ const bestRule = sortedRules[0] >+ return { value: bestRule[key], isFallback: true } >+ } else { >+ // If the current rule's value is not null, use it directly >+ return { value: ruleSet[key], isFallback: false } >+ } > }, > }, > } > </script> > > <style scoped> >-.selected_rule { >+.selected_rule > td { > background-color: yellow !important; > } >- >+.fallback { >+ font-style: italic; >+ font-weight: bold; >+} > .actions a { > margin-right: 5px; > } >-- >2.47.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 10190
:
170357
|
170358
|
170359
|
170360
|
170361
|
170362
|
170363
|
170364
|
170365
|
170366
|
170367
|
170368
|
170369
|
170370
|
170371
|
170372
|
170373
|
170374
|
170375
|
170376
|
170380
|
170449
|
171727
|
171728
|
171729
|
171730
|
171731
|
171732
|
171733
|
171734
|
171735
|
171736
|
171737
|
171738
|
171739
|
171740
|
171741
|
171742
|
171743
|
171744
|
171745
|
171746
|
171747
|
171748
|
171749
|
171750
|
171751
|
171752
|
171753
|
171754
|
171755
|
172588
|
172589
|
172590
|
172591
|
172592
|
172593
|
172594
|
172595
|
172596
|
172597
|
172598
|
172599
|
172600
|
172601
|
172602
|
172603
|
172604
|
172605
|
172606
|
172607
|
172608
|
172609
|
172612
|
172614
|
172617
|
172619
|
172621
|
172622
|
172623
|
172624
|
172625
|
172626
|
172630
|
172631
|
172632
|
172633
|
172634
|
172635
|
172636
|
172637
|
172638
|
172639
|
172640
|
172641
|
172642
|
172643
|
172644
|
172645
|
172646
|
172647
|
172648
|
172649
|
172650
|
172651
|
172652
|
172653
|
172654
|
172655
|
172656
|
172657
|
172658
|
172659
|
172660
|
172661
|
172662
|
172663