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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/str/cataloging_additem.inc (+16 lines)
Line 0 Link Here
1
<script>
2
    var searchid = '[% searchid | html %]';
3
    var biblionumber = '[% biblionumber | html %]';
4
    var frameworkcode = '[% frameworkcode | html %]';
5
    var popup = '[% popup | html %]';
6
    var opisadd = '[% opisadd | html %]';
7
    var LABEL_EDIT_ITEM = _("Edit item");
8
    var LABEL_DELETE_ITEM = _("Delete item");
9
    var MSG_FORM_NOT_SUBMITTED = _("Form not submitted because of the following problem(s)");
10
    var MSG_MANDATORY_FIELDS_EMPTY = _("%s mandatory fields empty (highlighted)");
11
    var MSG_ADD_MULTIPLE_ITEMS = _("You are about to add %s items. Continue?");
12
    var MSG_ENTER_NUM_ITEMS = _("Please enter a number of items to create.");
13
    var MSG_CONFIRM_DELETE_ITEM = _("Are you sure you want to delete this item?");
14
    var MSG_CONFIRM_ADD_ITEM = _("Are you sure you want to add a new item? Any changes made on this page will be lost.");
15
    var columns_settings = [% ColumnsSettings.GetColumns( 'cataloguing', 'additem', 'itemst', 'json' ) | $raw %];
16
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-133 / +7 lines)
Lines 2-149 Link Here
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Koha %]
3
[% USE Koha %]
4
[% USE ColumnsSettings %]
4
[% USE ColumnsSettings %]
5
6
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
7
<title>Koha &rsaquo; Cataloging &rsaquo; [% title | html %] [% IF ( author ) %] by [% author | html %][% END %] (Record #[% biblionumber | html %]) &rsaquo; Items</title>
6
<title>Koha &rsaquo; Cataloging &rsaquo; [% title | html %] [% IF ( author ) %] by [% author | html %][% END %] (Record #[% biblionumber | html %]) &rsaquo; Items</title>
8
[% Asset.css("css/datatables.css") | $raw %]
9
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'doc-head-close.inc' %]
8
[% Asset.css("css/datatables.css") | $raw %]
9
[% Asset.css("css/addbiblio.css") | $raw %]
10
[% INCLUDE 'datatables.inc' %]
10
[% INCLUDE 'datatables.inc' %]
11
[% Asset.js("js/cataloging.js") | $raw %]
11
[% Asset.js("js/cataloging.js") | $raw %]
12
[% INCLUDE 'columns_settings.inc' %]
12
[% INCLUDE 'columns_settings.inc' %]
13
[% INCLUDE 'browser-strings.inc' %]
13
[% INCLUDE 'browser-strings.inc' %]
14
[% Asset.js("js/browser.js") | $raw %]
14
[% Asset.js("js/browser.js") | $raw %]
15
<script type="text/javascript">
16
//<![CDATA[
17
    var browser = KOHA.browser('[% searchid | html %]', parseInt('[% biblionumber | html %]', 10));
18
    browser.show();
19
20
$(document).ready(function(){
21
22
    // Remove the onclick event defined in browser.js,
23
    // otherwise the deletion confirmation will not work correctly
24
    $('a[href*="biblionumber="]').off('click');
25
26
    [% IF (popup) %]
27
        [% IF (opisadd) %]
28
            window.close();
29
        [% END %]
30
    [% END %]
31
            $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit");
32
            /* Inline edit/delete links */
33
            var biblionumber = $("input[name='biblionumber']").attr("value");
34
            $("tr.editable").each(function(){
35
                $(this).find("td:not(:first)").on('click', function(){
36
                    var rowid = $(this).parent().attr("id");
37
                    num_rowid = rowid.replace("row","");
38
                    $(".linktools").remove();
39
                    var edit_link = $('<a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&frameworkcode=[% frameworkcode | uri %]&biblionumber=[% biblionumber | uri %]&itemnumber='+num_rowid+'&searchid=[% searchid | uri %]#edititem"></a>');
40
                    $(edit_link).text(_("Edit item"));
41
                    var delete_link = $('<a href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&frameworkcode=[% frameworkcode | uri %]&biblionumber=[% biblionumber | uri %]&itemnumber='+num_rowid+'&searchid=[% searchid | uri %]"></a>');
42
                    $(delete_link).text(_("Delete item"));
43
                    $(delete_link).on('click', function(e) {
44
                        return confirm_deletion();
45
                    });
46
                    var tools_node = $('<span class="linktools"></span>');
47
                    $(tools_node).append(edit_link);
48
                    $(tools_node).append(delete_link);
49
                    $(this).append(tools_node);
50
                });
51
            });
52
53
    $("#addnewitem").click(function(){
54
        if ( confirm(_("Are you sure you want to add a new item? Any changes made on this page will be lost.")) ){
55
            window.location.href = "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber | html %]";
56
        }
57
    });
58
59
    var columns_settings = [% ColumnsSettings.GetColumns( 'cataloguing', 'additem', 'itemst', 'json' ) | $raw %]
60
    // Skip the first column
61
    columns_settings.unshift( { cannot_be_toggled: "1" } );
62
63
    var itemst = KohaTable("itemst", {
64
        "aoColumnDefs": [
65
          { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
66
        ],
67
        'bPaginate': false,
68
        'bInfo': false,
69
        "bAutoWidth": false,
70
        "bKohaColumnsUseNames": true
71
    }, columns_settings);
72
73
    var multiCopyControl = $("#add_multiple_copies_span");
74
    var addMultipleBlock = $("#addmultiple");
75
    var addSingleBlock = $("#addsingle");
76
    multiCopyControl.hide();
77
    $("#add_multiple_copies").on("click",function(e){
78
        e.preventDefault;
79
        addMultipleBlock.toggle();
80
        addSingleBlock.toggle();
81
        multiCopyControl.toggle();
82
        $('body,html').animate({ scrollTop: $('body').height() }, 100);
83
    });
84
    $("#cancel_add_multiple").on("click",function(e){
85
        e.preventDefault();
86
        addMultipleBlock.toggle();
87
        addSingleBlock.toggle();
88
        multiCopyControl.toggle();
89
    });
90
});
91
92
function Check(f) {
93
    var total_errors = CheckMandatorySubfields(f);
94
    if (total_errors==0) {
95
        // Explanation about this line:
96
        // In case of limited edition permission, we have to prevent user from modifying some fields.
97
        // But there is no such thing as readonly attribute for select elements.
98
        // So we use disabled instead. But disabled prevent values from being passed through the form at submit.
99
        // So we "un-disable" the elements just before submitting.
100
        // That's a bit clumsy, and if someone comes up with a better solution, feel free to improve that.
101
        $("select[name=field_value]").prop('disabled', false);
102
        return true;
103
    } else {
104
        var alertString2 = _("Form not submitted because of the following problem(s)");
105
        alertString2 += "\n------------------------------------------------------------------------------------\n";
106
        alertString2 += "\n- " + _("%s mandatory fields empty (highlighted)").format(total_errors);
107
        alert(alertString2);
108
        return false;
109
    }
110
    return true;
111
}
112
function CheckMultipleAdd(f) {
113
114
    if (!f || isNaN(f) || !parseInt(f) == f || f <= 0) {
115
        alert(_("Please enter a number of items to create."));
116
        return false;
117
    }
118
    <!-- Add a soft-limit of 99 with a reminder about potential data entry error -->
119
    if (f>99) {
120
        return confirm(_("You are about to add %s items. Continue?").format(f));
121
    }
122
}
123
function Dopop(link,i) {
124
    defaultvalue=document.forms[0].field_value[i].value;
125
    newin=window.open(link+"&result="+defaultvalue,"valuebuilder",'width=500,height=400,toolbar=false,scrollbars=yes');
126
}
127
128
function confirm_deletion() {
129
    return confirm(_("Are you sure you want to delete this item?"));
130
}
131
132
//]]>
133
</script>
134
[% Asset.css("css/addbiblio.css") | $raw %]
135
136
[% INCLUDE 'select2.inc' %]
15
[% INCLUDE 'select2.inc' %]
137
<script type="text/javascript">
16
[% INCLUDE 'str/cataloging_additem.inc' %]
138
  $(document).ready(function() {
17
[% Asset.js("js/cataloging_additem.js") | $raw %]
139
    $('.subfield_line select').select2();
140
  });
141
</script>
142
143
[% IF ( bidi ) %]
144
   [% Asset.css("css/right-to-left.css") | $raw %]
145
[% END %]
146
</head>
18
</head>
19
147
<body id="cat_additem" class="cat">
20
<body id="cat_additem" class="cat">
148
[% INCLUDE 'header.inc' %]
21
[% INCLUDE 'header.inc' %]
149
[% INCLUDE 'cataloging-search.inc' %]
22
[% INCLUDE 'cataloging-search.inc' %]
Lines 364-370 function confirm_deletion() { Link Here
364
    <input type="button" id="addnewitem" value="Add a new item">
237
    <input type="button" id="addnewitem" value="Add a new item">
365
    <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]">Cancel</a>
238
    <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]">Cancel</a>
366
    [% END %]</fieldset>
239
    [% END %]</fieldset>
367
    
240
368
    [%# Fields for fast cataloging %]
241
    [%# Fields for fast cataloging %]
369
    <input type="hidden" name="circborrowernumber" value="[% circborrowernumber | html %]" />
242
    <input type="hidden" name="circborrowernumber" value="[% circborrowernumber | html %]" />
370
    <input type="hidden" name="stickyduedate" value="[% stickyduedate | html %]" />
243
    <input type="hidden" name="stickyduedate" value="[% stickyduedate | html %]" />
Lines 380-383 function confirm_deletion() { Link Here
380
253
381
</div>
254
</div>
382
</div>
255
</div>
256
383
[% INCLUDE 'intranet-bottom.inc' %]
257
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js (-1 / +119 lines)
Line 0 Link Here
0
- 
1
/* global KOHA searchid biblionumber frameworkcode popup opisadd LABEL_EDIT_ITEM LABEL_DELETE_ITEM MSG_FORM_NOT_SUBMITTED MSG_MANDATORY_FIELDS_EMPTY MSG_ADD_MULTIPLE_ITEMS MSG_ENTER_NUM_ITEMS MSG_CONFIRM_DELETE_ITEM MSG_CONFIRM_ADD_ITEM columns_settings CheckMandatorySubfields CheckMultipleAdd */
2
3
var browser = KOHA.browser(searchid, parseInt(biblionumber, 10));
4
browser.show();
5
6
$(document).ready(function(){
7
8
    // Remove the onclick event defined in browser.js,
9
    // otherwise the deletion confirmation will not work correctly
10
    $('a[href*="biblionumber="]').off('click');
11
12
    if( popup ){
13
        if( opisadd ){
14
            window.close();
15
        }
16
    }
17
18
    $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit");
19
    /* Inline edit/delete links */
20
    var biblionumber = $("input[name='biblionumber']").attr("value");
21
    $("tr.editable").each(function(){
22
        $(this).find("td:not(:first)").on('click', function(){
23
            var rowid = $(this).parent().attr("id");
24
            var num_rowid = rowid.replace("row","");
25
            $(".linktools").remove();
26
            var edit_link = $('<a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&frameworkcode=' + frameworkcode + '&biblionumber=' + biblionumber + '&itemnumber=' + num_rowid + '&searchid=' + searchid + '#edititem"></a>');
27
            $(edit_link).text( LABEL_EDIT_ITEM );
28
            var delete_link = $('<a href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&frameworkcode=' + frameworkcode + '&biblionumber=' + biblionumber + '&itemnumber=' + num_rowid + '&searchid=' + searchid + '"></a>');
29
            $(delete_link).text( LABEL_DELETE_ITEM );
30
            $(delete_link).on('click', function() {
31
                return confirm_deletion();
32
            });
33
            var tools_node = $('<span class="linktools"></span>');
34
            $(tools_node).append(edit_link);
35
            $(tools_node).append(delete_link);
36
            $(this).append(tools_node);
37
        });
38
    });
39
40
    $("#addnewitem").click(function(){
41
        if ( confirm( MSG_CONFIRM_ADD_ITEM ) ){
42
            window.location.href = "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=" + biblionumber;
43
        }
44
    });
45
46
    // Skip the first column
47
    columns_settings.unshift( { cannot_be_toggled: "1" } );
48
49
    var itemst = KohaTable("itemst", {
50
        "aoColumnDefs": [
51
            { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
52
        ],
53
        'bPaginate': false,
54
        'bInfo': false,
55
        "bAutoWidth": false,
56
        "bKohaColumnsUseNames": true
57
    }, columns_settings);
58
59
    var multiCopyControl = $("#add_multiple_copies_span");
60
    var addMultipleBlock = $("#addmultiple");
61
    var addSingleBlock = $("#addsingle");
62
    multiCopyControl.hide();
63
    $("#add_multiple_copies").on("click",function(e){
64
        e.preventDefault;
65
        addMultipleBlock.toggle();
66
        addSingleBlock.toggle();
67
        multiCopyControl.toggle();
68
        $('body,html').animate({ scrollTop: $('body').height() }, 100);
69
    });
70
    $("#cancel_add_multiple").on("click",function(e){
71
        e.preventDefault();
72
        addMultipleBlock.toggle();
73
        addSingleBlock.toggle();
74
        multiCopyControl.toggle();
75
    });
76
77
    $('.subfield_line select').select2();
78
});
79
80
function Check(f) {
81
    var total_errors = CheckMandatorySubfields(f);
82
    if (total_errors==0) {
83
        // Explanation about this line:
84
        // In case of limited edition permission, we have to prevent user from modifying some fields.
85
        // But there is no such thing as readonly attribute for select elements.
86
        // So we use disabled instead. But disabled prevent values from being passed through the form at submit.
87
        // So we "un-disable" the elements just before submitting.
88
        // That's a bit clumsy, and if someone comes up with a better solution, feel free to improve that.
89
        $("select[name=field_value]").prop('disabled', false);
90
        return true;
91
    } else {
92
        var alertString2 = MSG_FORM_NOT_SUBMITTED;
93
        alertString2 += "\n------------------------------------------------------------------------------------\n";
94
        alertString2 += "\n- " + "%s " + MSG_MANDATORY_FIELDS_EMPTY.format(total_errors);
95
        alert(alertString2);
96
        return false;
97
    }
98
}
99
100
function CheckMultipleAdd(f) {
101
102
    if (!f || isNaN(f) || !parseInt(f) == f || f <= 0) {
103
        alert( MSG_ENTER_NUM_ITEMS );
104
        return false;
105
    }
106
    // Add a soft-limit of 99 with a reminder about potential data entry error
107
    if (f>99) {
108
        return confirm( MSG_ADD_MULTIPLE_ITEMS.format(f));
109
    }
110
}
111
112
function Dopop(link,i) {
113
    var defaultvalue=document.forms[0].field_value[i].value;
114
    var newin=window.open(link+"&result=" + defaultvalue,"valuebuilder",'width=500,height=400,toolbar=false,scrollbars=yes');
115
}
116
117
function confirm_deletion() {
118
    return confirm( MSG_CONFIRM_DELETE_ITEM );
119
}

Return to bug 21091