View | Details | Raw Unified | Return to bug 10190
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersFormAdd.vue (-18 / +35 lines)
Lines 5-34 Link Here
5
    <div v-if="initialized" class="modal-content">
5
    <div v-if="initialized" class="modal-content">
6
        <form @submit="addCircRule($event)">
6
        <form @submit="addCircRule($event)">
7
            <div class="modal-header">
7
            <div class="modal-header">
8
                <h1 v-if="!editMode">{{ $__("Add circulation trigger") }}</h1>
8
                <h1 class="modal-title" v-if="!editMode">
9
                <h1 v-else>{{ $__("Edit circulation trigger") }}</h1>
9
                    {{ $__("Circulation triggers") }}
10
                </h1>
11
                <h1 class="modal-title" v-else>
12
                    {{ $__("Edit circulation trigger") }}
13
                </h1>
10
            </div>
14
            </div>
11
            <div class="modal-body">
15
            <div class="modal-body">
12
                <div class="page-section bg-info" v-if="circRules.length">
16
                <div class="page-section bg-info" v-if="circRules.length">
13
                    <h2>{{ $__("Trigger context") }}</h2>
17
                    <h2>{{ $__("Circulation context") }}</h2>
14
                    <TriggerContext :ruleInfo="ruleInfo" />
18
                    <TriggerContext :ruleInfo="ruleInfo" />
15
                    <h2 v-if="ruleInfo.numberOfTriggers > 0">
16
                        {{ $__("Existing rules") }}
17
                    </h2>
18
                    <p v-if="ruleInfo.numberOfTriggers > 0">
19
                        {{ $__("Notice") }} {{ " " + newTriggerNumber - 1 }}
20
                    </p>
21
                    <TriggersTable
22
                        v-if="ruleInfo.numberOfTriggers > 0"
23
                        :circRules="circRules"
24
                        :triggerNumber="newTriggerNumber - 1"
25
                        :modal="true"
26
                        :ruleBeingEdited="ruleBeingEdited"
27
                        :triggerBeingEdited="triggerBeingEdited"
28
                        :letters="letters"
29
                    />
30
                </div>
19
                </div>
20
31
                <fieldset class="rows">
21
                <fieldset class="rows">
22
                    <legend>{{ $__("Select trigger context") }}</legend>
32
                    <ol>
23
                    <ol>
33
                        <li>
24
                        <li>
34
                            <label for="library_id" class="required"
25
                            <label for="library_id" class="required"
Lines 102-107 Link Here
102
                            </v-select>
93
                            </v-select>
103
                            <span class="required">{{ $__("Required") }}</span>
94
                            <span class="required">{{ $__("Required") }}</span>
104
                        </li>
95
                        </li>
96
                    </ol>
97
98
                    <div
99
                        class="page-section bg-warning-subtle"
100
                        v-if="circRules.length"
101
                    >
102
                        <TriggersTable
103
                            :circRules="circRules"
104
                            :triggerNumber="newTriggerNumber - 1"
105
                            :modal="true"
106
                            :ruleBeingEdited="ruleBeingEdited"
107
                            :triggerBeingEdited="triggerBeingEdited"
108
                            :letters="letters"
109
                        />
110
                    </div>
111
                </fieldset>
112
113
                <fieldset class="rows" v-if="editMode">
114
                    <legend v-if="ruleInfo.numberOfTriggers < newTriggerNumber">
115
                        {{ $__("Add new trigger") }}
116
                        {{ " " + newTriggerNumber }}
117
                    </legend>
118
                    <legend v-else>
119
                        {{ $__("Edit trigger") }} {{ " " + newTriggerNumber }}
120
                    </legend>
121
                    <ol>
105
                        <li>
122
                        <li>
106
                            <label for="overdue_delay"
123
                            <label for="overdue_delay"
107
                                >{{ $__("Delay") }}:
124
                                >{{ $__("Delay") }}:
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/TriggersTable.vue (-5 / +42 lines)
Lines 1-6 Link Here
1
<template>
1
<template>
2
    <div class="page-section">
2
    <div class="page-section">
3
        <div class="page-section bg-info">{{ $__("Bolid italic values denote fallback values where an override has not been set for the context.") }}</div>
3
        <div class="page-section bg-info" v-if="!modal">
4
            {{
5
                $__(
6
                    "Bolid italic values denote fallback values where an override has not been set for the context."
7
                )
8
            }}
9
        </div>
4
        <table>
10
        <table>
5
            <thead>
11
            <thead>
6
                <th v-if="!modal">
12
                <th v-if="!modal">
Lines 10-16 Link Here
10
                    {{ $__("Item type") }}
16
                    {{ $__("Item type") }}
11
                </th>
17
                </th>
12
                <th v-if="modal">
18
                <th v-if="modal">
13
                    {{ $__("Rule") }}
19
                    {{ $__("Trigger") }}
14
                </th>
20
                </th>
15
                <th>
21
                <th>
16
                    {{ $__("Delay") }}
22
                    {{ $__("Delay") }}
Lines 260-265 Link Here
260
                        >
266
                        >
261
                    </td>
267
                    </td>
262
                </tr>
268
                </tr>
269
                <tr v-if="modal">
270
                    <td colspan="7"></td>
271
                    <td class="actions">
272
                        <router-link
273
                            :to="{
274
                                name: 'CirculationTriggersFormEdit',
275
                                query: {
276
                                    library_id:
277
                                        ruleBeingEdited.context.library_id,
278
                                    item_type_id:
279
                                        ruleBeingEdited.context.item_type_id,
280
                                    patron_category_id:
281
                                        ruleBeingEdited.context
282
                                            .patron_category_id,
283
                                    triggerNumber: numberOfTriggers + 1,
284
                                },
285
                            }"
286
                            class="btn btn-default btn-xs"
287
                            ><i class="fa-solid fa-pencil"></i> Add</router-link
288
                        >
289
                    </td>
290
                </tr>
263
            </tbody>
291
            </tbody>
264
        </table>
292
        </table>
265
    </div>
293
    </div>
Lines 277-282 export default { Link Here
277
        "itemTypes",
305
        "itemTypes",
278
        "letters",
306
        "letters",
279
    ],
307
    ],
308
    data() {
309
        return {
310
            numberOfTriggers: 0,
311
        }
312
    },
280
    methods: {
313
    methods: {
281
        handleContext(value, data, type, displayProperty = "name") {
314
        handleContext(value, data, type, displayProperty = "name") {
282
            const item = data.find(item => item[type] === value)
315
            const item = data.find(item => item[type] === value)
Lines 304-315 export default { Link Here
304
337
305
            // Calculate the number of 'overdue_X_' triggers in the effectiveRule
338
            // Calculate the number of 'overdue_X_' triggers in the effectiveRule
306
            const regex = /overdue_(\d+)_delay/g
339
            const regex = /overdue_(\d+)_delay/g
307
            const numberOfTriggers = Object.keys(effectiveRule).filter(
340
            this.numberOfTriggers = Object.keys(effectiveRule).filter(
308
                key => regex.test(key) && effectiveRule[key] !== null
341
                key => regex.test(key) && effectiveRule[key] !== null
309
            ).length
342
            ).length
310
343
344
            // Shortcut for the case where no triggers exist yet
345
            if (this.numberOfTriggers === 0) {
346
                return undefined
347
            }
348
311
            // Ensure there is one contextRule per 'X' from 1 to numberOfTriggers
349
            // Ensure there is one contextRule per 'X' from 1 to numberOfTriggers
312
            for (let i = 1; i <= numberOfTriggers; i++) {
350
            for (let i = 1; i <= this.numberOfTriggers; i++) {
313
                // Check if there's already a rule for overdue_X_ in contextRules
351
                // Check if there's already a rule for overdue_X_ in contextRules
314
                const matchingRule = contextRules.find(
352
                const matchingRule = contextRules.find(
315
                    rule => rule[`overdue_${i}_delay`] !== undefined
353
                    rule => rule[`overdue_${i}_delay`] !== undefined
316
- 

Return to bug 10190