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