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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt (-17 / +1 lines)
Lines 322-347 Link Here
322
322
323
[% MACRO jsinclude BLOCK %]
323
[% MACRO jsinclude BLOCK %]
324
    [% Asset.js("js/tools-menu.js") | $raw %]
324
    [% Asset.js("js/tools-menu.js") | $raw %]
325
    [% Asset.js("js/marc_modification_templates.js") | $raw %]
325
    <script>
326
    <script>
326
        var MSG_MMT_SUBFIELDS_MATCH = _("Both subfield values should be filled or empty.");
327
        var MSG_MMT_DESTINATION_REQUIRED = _("The destination should be filled.");
328
        var MSG_MMT_CONTROL_FIELD_EMPTY = _("If the field is a control field, the subfield should be empty");
329
        var MSG_MMT_CONTROL_FIELD = _("A control field cannot be used with a regular field.");
330
        var MSG_MMT_SOURCE_SUBFIELD = _("The source subfield should be filled for update.");
331
        var MSG_MMT_SOURCE_FIELD = _("The source field should be filled.");
332
        var MSG_MMT_EVERY = _("Every");
333
        var MSG_MMT_ALL = _("All");
334
        var MSG_MMT_CONFIRM_DEL_TEMPLATE = _("Are you sure you wish to delete this template?");
335
        var MSG_MMT_CONFIRM_DEL_TEMPLATE_ACTION = _("Are you sure you wish to delete this template action?");
336
        var MSG_MMT_EDIT_ACTION = _("Edit action %s");
337
        var MSG_MMT_UPDATE_ACTION = _("Update action");
338
        var MSG_MMT_CONDITIONAL_FIELD_REQUIRED = _("The conditional field should be filled.");
339
        var MSG_MMT_CONDITIONAL_COMPARISON_REQUIRED = _("The conditional comparison operator should be filled.");
340
        var MSG_MMT_CONDITIONAL_VALUE_REQUIRED = _("The conditional value should be filled.");
341
        var MSG_MMT_CONDITIONAL_VALUE_REGEX_REQUIRED = _("The conditional regular expression should be filled.");
342
        var mmtas = [% ActionsLoop.json | $raw %]
327
        var mmtas = [% ActionsLoop.json | $raw %]
343
    </script>
328
    </script>
344
    [% Asset.js("js/marc_modification_templates.js") | $raw %]
345
[% END %]
329
[% END %]
346
330
347
[% INCLUDE 'intranet-bottom.inc' %]
331
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js (-20 / +20 lines)
Lines 1-3 Link Here
1
/* global __ */
1
$(document).ready(function() {
2
$(document).ready(function() {
2
    window.modaction_legend_innerhtml = $("#modaction_legend").text();
3
    window.modaction_legend_innerhtml = $("#modaction_legend").text();
3
    window.action_submit_value = $("#action_submit").val();
4
    window.action_submit_value = $("#action_submit").val();
Lines 13-62 $(document).ready(function() { Link Here
13
        var action = $("#action").val();
14
        var action = $("#action").val();
14
        if ( action == 'move_field' || action == 'copy_field' || action == 'copy_and_replace_field') {
15
        if ( action == 'move_field' || action == 'copy_field' || action == 'copy_and_replace_field') {
15
            if ( $("#from_subfield").val().length != $("#to_subfield").val().length ) {
16
            if ( $("#from_subfield").val().length != $("#to_subfield").val().length ) {
16
                alert( MSG_MMT_SUBFIELDS_MATCH );
17
                alert( __("Both subfield values should be filled or empty.") );
17
                return false;
18
                return false;
18
            }
19
            }
19
            if ( $("#to_field").val().length <= 0 ) {
20
            if ( $("#to_field").val().length <= 0 ) {
20
                alert( MSG_MMT_DESTINATION_REQUIRED );
21
                alert( __("The destination should be filled.") );
21
                return false;
22
                return false;
22
            }
23
            }
23
            if ( ( $("#to_field").val()   < 10 && $("#to_subfield").val().length   > 0 ) ||
24
            if ( ( $("#to_field").val()   < 10 && $("#to_subfield").val().length   > 0 ) ||
24
                 ( $("#from_field").val() < 10 && $("#from_subfield").val().length > 0 ) ) {
25
                ( $("#from_field").val() < 10 && $("#from_subfield").val().length > 0 ) ) {
25
                 alert( MSG_MMT_CONTROL_FIELD_EMPTY );
26
                alert( __("If the field is a control field, the subfield should be empty") );
26
                 return false;
27
                return false;
27
            }
28
            }
28
            if ( ( $("#from_field").val() < 10 && $("#to_field").val()   >= 10 ) ||
29
            if ( ( $("#from_field").val() < 10 && $("#to_field").val()   >= 10 ) ||
29
                 ( $("#to_field").val()   < 10 && $("#from_field").val() >= 10 ) ) {
30
                 ( $("#to_field").val()   < 10 && $("#from_field").val() >= 10 ) ) {
30
                alert( MSG_MMT_CONTROL_FIELD );
31
                alert( __("A control field cannot be used with a regular field.") );
31
                return false;
32
                return false;
32
             }
33
            }
33
        }
34
        }
34
        if ( action == 'update_field' ) {
35
        if ( action == 'update_field' ) {
35
            if ( $("#from_subfield").val().length <= 0 ) {
36
            if ( $("#from_subfield").val().length <= 0 ) {
36
                alert( MSG_MMT_SOURCE_SUBFIELD );
37
                alert( __("The source subfield should be filled for update.") );
37
                return false;
38
                return false;
38
            }
39
            }
39
        }
40
        }
40
        if ( $("#from_field").val().length <= 0 ) {
41
        if ( $("#from_field").val().length <= 0 ) {
41
            alert( MSG_MMT_SOURCE_FIELD );
42
            alert( __("The source field should be filled.") );
42
            return false;
43
            return false;
43
        }
44
        }
44
        if ( $("#conditional").val() == 'if' || $("#conditional").val() == 'unless' ) {
45
        if ( $("#conditional").val() == 'if' || $("#conditional").val() == 'unless' ) {
45
            if ( $("#conditional_field").val() == '' ) {
46
            if ( $("#conditional_field").val() == '' ) {
46
                alert( MSG_MMT_CONDITIONAL_FIELD_REQUIRED );
47
                alert( __("The conditional field should be filled.") );
47
                return false;
48
                return false;
48
            }
49
            }
49
            if ( $("#conditional_comparison").val() == '' ) {
50
            if ( $("#conditional_comparison").val() == '' ) {
50
                alert( MSG_MMT_CONDITIONAL_COMPARISON_REQUIRED );
51
                alert( __("The conditional comparison operator should be filled.") );
51
                return false
52
                return false
52
            }
53
            }
53
            if ( $("#conditional_value").val() == '' &&
54
            if ( $("#conditional_value").val() == '' &&
54
                 ( $("#conditional_comparison").val() == 'equals' || $("#conditional_comparison").val() == 'not_equals' ) ) {
55
                 ( $("#conditional_comparison").val() == 'equals' || $("#conditional_comparison").val() == 'not_equals' ) ) {
55
                if ( document.getElementById('conditional_regex').checked == true ) {
56
                if ( document.getElementById('conditional_regex').checked == true ) {
56
                    alert( MSG_MMT_CONDITIONAL_VALUE_REGEX_REQUIRED );
57
                    alert( __("The conditional regular expression should be filled.") );
57
                    return false;
58
                    return false;
58
                } else {
59
                } else {
59
                    alert( MSG_MMT_CONDITIONAL_VALUE_REQUIRED );
60
                    alert( __("The conditional value should be filled.") );
60
                    return false;
61
                    return false;
61
                }
62
                }
62
            }
63
            }
Lines 112-120 $(document).ready(function() { Link Here
112
function updateAllEvery(){
113
function updateAllEvery(){
113
    if ( $("#conditional_field").is(":visible") ) {
114
    if ( $("#conditional_field").is(":visible") ) {
114
        if ( $("#conditional_field").val() == $("#from_field").val() && $("#from_field").val().length > 0 ) {
115
        if ( $("#conditional_field").val() == $("#from_field").val() && $("#from_field").val().length > 0 ) {
115
            $("#field_number option[value='0']").html( MSG_MMT_EVERY );
116
            $("#field_number option[value='0']").html( __("Every") );
116
        } else {
117
        } else {
117
            $("#field_number option[value='0']").html( MSG_MMT_ALL );
118
            $("#field_number option[value='0']").html( __("All") );
118
        }
119
        }
119
    }
120
    }
120
}
121
}
Lines 256-266 function clearFormElements(divId) { Link Here
256
}
257
}
257
258
258
function confirmDeleteAction() {
259
function confirmDeleteAction() {
259
    return confirm( MSG_MMT_CONFIRM_DEL_TEMPLATE_ACTION );
260
    return confirm( __("Are you sure you wish to delete this template action?") );
260
}
261
}
261
262
262
function confirmDelete() {
263
function confirmDelete() {
263
    return confirm( MSG_MMT_CONFIRM_DEL_TEMPLATE );
264
    return confirm( __("Are you sure you wish to delete this template?") );
264
}
265
}
265
266
266
var modaction_legend_innerhtml;
267
var modaction_legend_innerhtml;
Lines 306-315 function editAction( mmta ) { Link Here
306
    document.getElementById('description').value = mmta['description'];
307
    document.getElementById('description').value = mmta['description'];
307
308
308
    window.modaction_legend_innerhtml = document.getElementById('modaction_legend').innerHTML;
309
    window.modaction_legend_innerhtml = document.getElementById('modaction_legend').innerHTML;
309
    document.getElementById('modaction_legend').innerHTML = MSG_MMT_EDIT_ACTION.format(mmta['ordering']);
310
    document.getElementById('modaction_legend').innerHTML = __("Edit action %s").format(mmta['ordering']);
310
311
311
    window.action_submit_value = document.getElementById('action_submit').value;
312
    window.action_submit_value = document.getElementById('action_submit').value;
312
    document.getElementById('action_submit').value = MSG_MMT_UPDATE_ACTION;
313
    document.getElementById('action_submit').value = __("Update action");
313
}
314
}
314
315
315
function cancelEditAction() {
316
function cancelEditAction() {
316
- 

Return to bug 26065