From a1f058b900508d5f8cf892bbf4595e71acc41729 Mon Sep 17 00:00:00 2001 From: Chloe Zermatten Date: Fri, 7 Nov 2025 12:03:26 +0000 Subject: [PATCH] Bug 10190: (follow-up) Complete Vue.js rewrite of Circulation Triggers administration interface This patch aims to resolve the following issues as reported by comment 193: - missing atomic update for overde_X_has_rules: - existing delays being overwritten by the client when a rule set is displayed - inability to save circulation overdue rule sets for context for which circulations rules where already set --- .../atomicupdate/bug_10190-mynewcircrule.pl | 37 +++++++++++++++++++ .../CirculationTriggersFormAdd.vue | 26 +++++++------ .../prog/js/vue/stores/circulation-rules.js | 5 ++- 3 files changed, 55 insertions(+), 13 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_10190-mynewcircrule.pl diff --git a/installer/data/mysql/atomicupdate/bug_10190-mynewcircrule.pl b/installer/data/mysql/atomicupdate/bug_10190-mynewcircrule.pl new file mode 100755 index 00000000000..afed04f5c27 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_10190-mynewcircrule.pl @@ -0,0 +1,37 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "10190", + description => "Add overdue_X_has_rules to pre-existing overdue rule sets in the circulation_rules table", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + if ( !column_exists( 'borrower_modifications', 'relationship' ) ) { + $dbh->do( + q{ + INSERT INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value) + SELECT DISTINCT + branchcode, + categorycode, + itemtype, + CONCAT('overdue_', CAST(REGEXP_REPLACE(rule_name, '[^0-9]', '') AS UNSIGNED), '_has_rules' AS rule_name, + 1 AS rule_value + FROM circulation_rules c + WHERE rule_name LIKE 'overdue\_%' + AND rule_name NOT LIKE '%has\_rules' + AND NOT EXISTS ( + SELECT 1 + FROM circulation_rules r + WHERE r.branchcode <=> circulation_rules.branchcode + AND r.categorycode <=> circulation_rules.categorycode + AND r.itemtype <=> circulation_rules.itemtype + AND r.rule_name = CONCAT('overdue_', CAST(REGEXP_REPLACE(circulation_rules.rule_name, '[^0-9]', '') AS UNSIGNED), '_has_rules') + ); + } + ); + } + }, +}; + 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 136fd55a0ee..87f2978f91b 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 @@ -638,7 +638,7 @@ export default { if (this.ruleSetToSubmit === null) { this.ruleSetToSubmit = { context: this.context, - [`overdue_${this.triggerNumber}_delay`]: this.minDelay, + [`overdue_${this.triggerNumber}_delay`]: `${this.minDelay}`, [`overdue_${this.triggerNumber}_notice`]: null, [`overdue_${this.triggerNumber}_mtt`]: null, [`overdue_${this.triggerNumber}_restrict`]: null, @@ -742,8 +742,6 @@ export default { this.currentRuleSet[`overdue_${priorTriggerNumber}_delay`] ) + 1 : 0; - this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`] = - this.minDelay; }, setMaxDelay() { const nextTriggerNumber = parseInt(this.triggerNumber) + 1; @@ -791,16 +789,18 @@ export default { null ) { this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`] = - min; + `${min}`; } // Increment within the valid range else { this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`] = Math.min( - this.ruleSetToSubmit[ - `overdue_${this.triggerNumber}_delay` - ] + 1, + parseInt( + this.ruleSetToSubmit[ + `overdue_${this.triggerNumber}_delay` + ] + ) + 1, max ); } @@ -809,12 +809,14 @@ export default { decrementDelay() { // Check for minDelay const min = this.minDelay !== undefined ? this.minDelay : 1; + let delay = parseInt( + this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`] + ); // Decrement only if greater than minDelay - if ( - this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`] > - min - ) { - this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`]--; + if (delay > min) { + delay--; + this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`] = + `${delay}`; } this.setAllowSubmission(); }, diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/circulation-rules.js b/koha-tmpl/intranet-tmpl/prog/js/vue/stores/circulation-rules.js index 53d21f1f562..a6d743d684c 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/circulation-rules.js +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/stores/circulation-rules.js @@ -87,7 +87,10 @@ export const useCircRulesStore = defineStore("circRules", { return value.includes(type) ? $__("Yes") : $__("No"); }, hasConflict(oldRuleSet, newRuleSet, triggerNumber) { - if (!oldRuleSet) { + if ( + !oldRuleSet || + oldRuleSet[`overdue_${triggerNumber}_has_rules`] === null + ) { return false; } return ( -- 2.39.5