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

(-)a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss (+4 lines)
Lines 2863-2868 td.bundle { Link Here
2863
    background: #FFF url( "../img/spinner-small.gif" ) right center no-repeat;
2863
    background: #FFF url( "../img/spinner-small.gif" ) right center no-repeat;
2864
}
2864
}
2865
2865
2866
.patron-detail-autocomplete-selection {
2867
    padding: 0.3em;
2868
}
2869
2866
.toptabs {
2870
.toptabs {
2867
    margin: 1rem 0;
2871
    margin: 1rem 0;
2868
}
2872
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicate_orders.tt (-24 / +5 lines)
Lines 323-329 Link Here
323
            $("input[name='ordernumbers']").val(ordernumbers.join(','));
323
            $("input[name='ordernumbers']").val(ordernumbers.join(','));
324
        }
324
        }
325
325
326
        var MSG_REMOVE_PATRON = _("Remove");
327
        var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
326
        var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
328
        var MSG_NO_FUND_SELECTED = _("No fund selected.");
327
        var MSG_NO_FUND_SELECTED = _("No fund selected.");
329
        $(document).ready(function() {
328
        $(document).ready(function() {
Lines 333-366 Link Here
333
            });
332
            });
334
333
335
            [% IF op == 'search' OR op == 'select' %]
334
            [% IF op == 'search' OR op == 'select' %]
336
                function AddPatron( patron_name, value, container, input_name ) {
337
                    div = "<div id='borrower_" + value + "'>" + patron_name + " ( <a href='#' class='removePatron'><i class='fa fa-trash-can' aria-hidden='true'></i> " + MSG_REMOVE_PATRON + " </a> ) <input type='hidden' name='" + input_name + "' value='" + value + "' /></div>";
338
                    $(container).append( div );
339
340
                    $(container).parent().show( 800 );
341
                }
342
                function RemovePatron( cardnumber, container ) {
343
                    $( '#borrower_' + cardnumber ).remove();
344
345
                    if ( ! $(container).html() ) {
346
                        $(container).parent("fieldset").hide( 800 );
347
                    }
348
                }
349
                patron_autocomplete($("#find_patron"), {
335
                patron_autocomplete($("#find_patron"), {
350
                    'on-select-callback': function( event, ui ) {
336
                    "on-select-add-to": {
351
                        var field = ui.item.patron_id;
337
                        container: $("#basket_creators"),
352
                        AddPatron( ui.item.firstname + " " + ( ui.item.middle_name || "" ) + " " + ui.item.surname, field, $("#basket_creators"), 'created_by' );
338
                        input_name: 'created_by'
339
                    },
340
                    "on-select-callback": function( event, ui ) {
353
                        $("#find_patron").val('').focus();
341
                        $("#find_patron").val('').focus();
354
                        return false;
342
                        return false;
355
                    }
343
                    }
356
                });
344
                });
357
                $("body").on("click",".removePatron",function(e){
358
                    e.preventDefault();
359
                    var divid = $(this).parent().attr("id");
360
                    var cardnumber = divid.replace("borrower_","");
361
                    RemovePatron(cardnumber, $("#basket_creators"));
362
                });
363
364
            [% END %]
345
            [% END %]
365
346
366
            $("#show_orders_filters, #hide_orders_filters").on('click', function(e) {
347
            $("#show_orders_filters, #hide_orders_filters").on('click', function(e) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt (-22 / +1 lines)
Lines 168-174 Link Here
168
    [% INCLUDE 'calendar.inc' %]
168
    [% INCLUDE 'calendar.inc' %]
169
    [% INCLUDE 'datatables.inc' %]
169
    [% INCLUDE 'datatables.inc' %]
170
    <script>
170
    <script>
171
        var MSG_REMOVE_PATRON = _("Remove");
172
        $(document).ready(function() {
171
        $(document).ready(function() {
173
            var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'histsearch', 'histsearcht', 'json' ) | $raw %];
172
            var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'histsearch', 'histsearcht', 'json' ) | $raw %];
174
            $("#histsearcht").kohaTable(
173
            $("#histsearcht").kohaTable(
Lines 178-210 Link Here
178
                table_settings
177
                table_settings
179
            );
178
            );
180
179
181
            function AddPatron( patron_name, value, container, input_name ) {
182
                div = "<div id='borrower_" + value + "'>" + patron_name + " ( <a href='#' class='removePatron'><i class='fa fa-trash-can' aria-hidden='true'></i> " + MSG_REMOVE_PATRON + " </a> ) <input type='hidden' name='" + input_name + "' value='" + value + "' /></div>";
183
                $(container).append( div );
184
185
                $(container).parent().show( 800 );
186
            }
187
            function RemovePatron( cardnumber, container ) {
188
                $( '#borrower_' + cardnumber ).remove();
189
190
                if ( ! $(container).html() ) {
191
                    $(container).parent("fieldset").hide( 800 );
192
                }
193
            }
194
            patron_autocomplete($("#find_patron"), {
180
            patron_autocomplete($("#find_patron"), {
181
                'on-select-add-to': {container: $("#basket_creators"), input_name: 'created_by' },
195
                'on-select-callback': function( event, ui ) {
182
                'on-select-callback': function( event, ui ) {
196
                    var field = ui.item.patron_id;
197
                    AddPatron( ui.item.firstname + " " + ( ui.item.middle_name || "" ) + " " + ui.item.surname, field, $("#basket_creators"), 'created_by' );
198
                    $("#find_patron").val('').focus();
183
                    $("#find_patron").val('').focus();
199
                    return false;
184
                    return false;
200
                }
185
                }
201
            });
186
            });
202
            $("body").on("click",".removePatron",function(e){
203
                e.preventDefault();
204
                var divid = $(this).parent().attr("id");
205
                var cardnumber = divid.replace("borrower_","");
206
                RemovePatron(cardnumber, $("#basket_creators"));
207
            });
208
187
209
        });
188
        });
210
    </script>
189
    </script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt (-42 / +7 lines)
Lines 19-27 Link Here
19
    #course_instructors {
19
    #course_instructors {
20
        float: left;
20
        float: left;
21
    }
21
    }
22
    .instructor_line {
23
        padding: 0.3em;
24
    }
25
    fieldset.rows label[for="find_instructor"] {
22
    fieldset.rows label[for="find_instructor"] {
26
        text-align: left;
23
        text-align: left;
27
        margin: 0;
24
        margin: 0;
Lines 131-143 Link Here
131
                        <div id="course_instructors">
128
                        <div id="course_instructors">
132
                            <div id="instructors">
129
                            <div id="instructors">
133
                                [% FOREACH i IN instructors %]
130
                                [% FOREACH i IN instructors %]
134
                                    <div class="instructor_line" id="borrower_[% i.borrowernumber | html %]">
131
                                    <div class="patron-detail-autocomplete-selection" id="patron-detail-[% i.borrowernumber | html %]">
135
                                        [% INCLUDE 'patron-title.inc' patron=i no_cardnumber=1 %] (<a href="#" class="removeInstructor"><i class="fa fa-trash-can"></i> Remove </a>)
132
                                        [% INCLUDE 'patron-title.inc' patron=i no_cardnumber=1 %] (<a href="#" class="removePatron"><i class="fa fa-trash-can"></i> Remove </a>)
136
                                        <input type="hidden" name="instructors" value="[% i.borrowernumber | html %]" />
133
                                        <input type="hidden" name="instructors" value="[% i.borrowernumber | html %]" />
137
                                    </div>
134
                                    </div>
138
                                [% END %]
135
                                [% END %]
139
                            </div>
136
                            </div>
140
                            <div id="instructor_search" class="instructor_line">
137
                            <div id="instructor_search" class="patron-detail-autocomplete-selection">
141
                                <label for="find_instructor">Instructor search:</label>
138
                                <label for="find_instructor">Instructor search:</label>
142
                                <input autocomplete="off" id="find_instructor" type="text" style="width:150px" class="noEnterSubmit" />
139
                                <input autocomplete="off" id="find_instructor" type="text" style="width:150px" class="noEnterSubmit" />
143
                            </div>
140
                            </div>
Lines 199-246 Link Here
199
        <script>
196
        <script>
200
            $(document).ready(function () {
197
            $(document).ready(function () {
201
                patron_autocomplete($("#find_instructor"), {
198
                patron_autocomplete($("#find_instructor"), {
199
                    "on-select-add-to": { container: $("#instructors"), input_name: "instructors" },
202
                    "on-select-callback": function (event, ui) {
200
                    "on-select-callback": function (event, ui) {
203
                        AddInstructor($patron_to_html(ui.item, { display_cardnumber: false }), ui.item.patron_id);
201
                        $("#find_instructor").val("").focus();
204
                        return false;
205
                    },
202
                    },
206
                });
203
                });
207
204
                $(".removePatron").on("click", function (e) {
208
                if (!$("#instructors").html()) {
209
                    $("#course_instructors").hide();
210
                }
211
212
                $("body").on("click", ".removeInstructor", function (e) {
213
                    e.preventDefault();
205
                    e.preventDefault();
214
                    var divid = $(this).parent().attr("id");
206
                    $(this).closest('div[id^="patron-detail-"]').remove();
215
                    var borrowernumber = divid.replace("borrower_", "");
216
                    RemoveInstructor(borrowernumber);
217
                });
207
                });
218
            });
208
            });
219
220
            function AddInstructor(name, borrowernumber) {
221
                div =
222
                    "<div class='instructor_line' id='borrower_" +
223
                    borrowernumber +
224
                    "'>" +
225
                    (name ? name.escapeHtml() : "") +
226
                    " ( <a href='#' class='removeInstructor'><i class='fa fa-trash-can'></i> " +
227
                    _("Remove") +
228
                    " </a> ) <input type='hidden' name='instructors' value='" +
229
                    borrowernumber +
230
                    "' /></div>";
231
                $("#instructors").append(div);
232
233
                $("#find_instructor").val("").focus();
234
                $("#course_instructors").show();
235
            }
236
237
            function RemoveInstructor(borrowernumber) {
238
                $("#borrower_" + borrowernumber).remove();
239
240
                if (!$("#instructors").html()) {
241
                    $("#course_instructors").hide(800);
242
                }
243
            }
244
        </script>
209
        </script>
245
    [% END %]
210
    [% END %]
246
[% END %]
211
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt (-16 / +5 lines)
Lines 235-241 Link Here
235
    [% Asset.js("js/tools-menu.js") | $raw %]
235
    [% Asset.js("js/tools-menu.js") | $raw %]
236
    [% INCLUDE 'datatables.inc' %]
236
    [% INCLUDE 'datatables.inc' %]
237
    <script>
237
    <script>
238
        var MSG_REMOVE_PATRON = _("Remove");
239
        $(document).ready(function() {
238
        $(document).ready(function() {
240
            $('#patrons_to_add_fieldset').hide();
239
            $('#patrons_to_add_fieldset').hide();
241
240
Lines 247-258 Link Here
247
                    table_settings
246
                    table_settings
248
                );
247
                );
249
248
250
            function AddPatron( patron_name, value, container, input_name ) {
251
                div = "<div id='borrower_" + value + "'>" + patron_name + " ( <a href='#' class='removePatron'><i class='fa fa-trash-can' aria-hidden='true'></i> " + MSG_REMOVE_PATRON + " </a> ) <input type='hidden' name='" + input_name + "' value='" + value + "' /></div>";
252
                $(container).append( div );
253
254
                $(container).parent().show( 800 );
255
            }
256
            function RemovePatron( cardnumber, container ) {
249
            function RemovePatron( cardnumber, container ) {
257
                $( '#borrower_' + cardnumber ).remove();
250
                $( '#borrower_' + cardnumber ).remove();
258
251
Lines 261-279 Link Here
261
                }
254
                }
262
            }
255
            }
263
            patron_autocomplete($("#find_patron"), {
256
            patron_autocomplete($("#find_patron"), {
264
                'on-select-callback': function( event, ui ) {
257
                "on-select-add-to": {
265
                    var field = ui.item.cardnumber;
258
                    container: $("#patrons_to_add"),
266
                    AddPatron( ( ui.item.firstname || "" ) + " " + ( ui.item.middle_name || "" ) + " " + ( ui.item.surname || "" ), field, $("#patrons_to_add"), 'patrons_to_add' );
259
                    input_name: 'patrons_to_add',
260
                },
261
                "on-select-callback": function( event, ui ) {
267
                    $("#find_patron").val('').focus();
262
                    $("#find_patron").val('').focus();
268
                    return false;
263
                    return false;
269
                }
264
                }
270
            });
265
            });
271
            $("body").on("click",".removePatron",function(e){
272
                e.preventDefault();
273
                var divid = $(this).parent().attr("id");
274
                var cardnumber = divid.replace("borrower_","");
275
                RemovePatron(cardnumber, $("#patrons_to_add"));
276
            });
277
266
278
            $("body").on("click", "#CheckAll", function(e){
267
            $("body").on("click", "#CheckAll", function(e){
279
                e.preventDefault();
268
                e.preventDefault();
(-)a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js (-2 / +28 lines)
Lines 692-697 function patron_autocomplete(node, options) { Link Here
692
    let link_to;
692
    let link_to;
693
    let url_params;
693
    let url_params;
694
    let on_select_callback;
694
    let on_select_callback;
695
    let on_select_add_to;
695
696
696
    if (options) {
697
    if (options) {
697
        if (options["link-to"]) {
698
        if (options["link-to"]) {
Lines 703-708 function patron_autocomplete(node, options) { Link Here
703
        if (options["on-select-callback"]) {
704
        if (options["on-select-callback"]) {
704
            on_select_callback = options["on-select-callback"];
705
            on_select_callback = options["on-select-callback"];
705
        }
706
        }
707
        if (options["on-select-add-to"]) {
708
            on_select_add_to = options["on-select-add-to"];
709
        }
706
    }
710
    }
707
    return (node
711
    return (node
708
        .autocomplete({
712
        .autocomplete({
Lines 739-747 function patron_autocomplete(node, options) { Link Here
739
            },
743
            },
740
            minLength: 3,
744
            minLength: 3,
741
            select: function (event, ui) {
745
            select: function (event, ui) {
742
                if (ui.item.link) {
746
                if (on_select_add_to) {
747
                    let container = on_select_add_to.container;
748
749
                    const patron_name =
750
                        `${ui.item.firstname} ${ui.item.middle_name || ""} ${ui.item.surname}`.trim();
751
                    const node = `
752
                      <div id='patron-detail-${ui.item.patron_id}' class='patron-detail-autocomplete-selection'>
753
                        ${patron_name}
754
                        (<a href='#' class='removePatron'>
755
                          <i class='fa fa-trash-can' aria-hidden='true'></i> ${__("Remove")}
756
                        </a>)
757
                        <input type='hidden' name='${on_select_add_to.input_name}' value='${ui.item.patron_id}' />
758
                      </div>
759
                    `;
760
761
                    $(container).append(node).parent().show(800);
762
763
                    $(container).on("click", ".removePatron", function (e) {
764
                        e.preventDefault();
765
                        $(this).closest('div[id^="patron-detail-"]').remove();
766
                    });
767
                } else if (ui.item.link) {
743
                    window.location.href = ui.item.link;
768
                    window.location.href = ui.item.link;
744
                } else if (on_select_callback) {
769
                }
770
                if (on_select_callback) {
745
                    return on_select_callback(event, ui);
771
                    return on_select_callback(event, ui);
746
                }
772
                }
747
            },
773
            },
(-)a/patron_lists/list.pl (-2 / +1 lines)
Lines 74-80 if ( $op eq 'cud-add' && $patrons_by_id ) { Link Here
74
74
75
my @patrons_to_add = $cgi->multi_param('patrons_to_add');
75
my @patrons_to_add = $cgi->multi_param('patrons_to_add');
76
if ( $op eq 'cud-add' && @patrons_to_add ) {
76
if ( $op eq 'cud-add' && @patrons_to_add ) {
77
    AddPatronsToList( { list => $list, cardnumbers => \@patrons_to_add } );
77
    AddPatronsToList( { list => $list, borrowernumbers => \@patrons_to_add } );
78
}
78
}
79
79
80
my @patrons_to_remove = $cgi->multi_param('patrons_to_remove');
80
my @patrons_to_remove = $cgi->multi_param('patrons_to_remove');
81
- 

Return to bug 32176