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

(-)a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss (+20 lines)
Lines 2213-2218 li { Link Here
2213
    }
2213
    }
2214
}
2214
}
2215
2215
2216
#patron_search_selected {
2217
    background-color: #F9FEFF;
2218
    border: 1px solid #B9D8D9;
2219
    border-color: #A2CBCC #CEE0E3 #CEE0E3 #A2CBCC;
2220
    border-radius: 3px;
2221
    color: #333;
2222
    display: inline-block;
2223
    font-size: 11px;
2224
    line-height: 1.5;
2225
    padding: 5px 10px;
2226
    text-align: center;
2227
    vertical-align: middle;
2228
    white-space: nowrap;
2229
}
2230
2231
#clear-patron-selection {
2232
    display: inline-block;
2233
    margin-left: 1em;
2234
}
2235
2216
#search-facets {
2236
#search-facets {
2217
    border: 1px solid #B9D8D9;
2237
    border: 1px solid #B9D8D9;
2218
    border-radius: 5px 5px 0 0;
2238
    border-radius: 5px 5px 0 0;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-1 / +4 lines)
Lines 369-375 Link Here
369
                        return json.data;
369
                        return json.data;
370
                    }
370
                    }
371
                },
371
                },
372
                [% IF open_on_row_click OR preview_on_name_click %]
372
                [% IF open_on_row_click OR preview_on_name_click OR remember_selections %]
373
                "drawCallback": function( settings ) {
373
                "drawCallback": function( settings ) {
374
                    var api = this.api();
374
                    var api = this.api();
375
                    var data = api.data();
375
                    var data = api.data();
Lines 389-394 Link Here
389
                        $(tr).find("a.patron_name").addClass("patron_preview");
389
                        $(tr).find("a.patron_name").addClass("patron_preview");
390
                    });
390
                    });
391
                    [% END %]
391
                    [% END %]
392
                    [% IF remember_selections %]
393
                        prepSelections();
394
                    [% END %]
392
                },
395
                },
393
                [% END %]
396
                [% END %]
394
                "iDeferLoading": defer_loading,
397
                "iDeferLoading": defer_loading,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt (-36 / +92 lines)
Lines 95-100 Link Here
95
                    [% IF CAN_user_borrowers_edit_borrowers %]
95
                    [% IF CAN_user_borrowers_edit_borrowers %]
96
                          <button id="merge-patrons" class="btn btn-sm btn-default disabled" disabled="disabled" type="submit"><i class="fa fa-compress" aria-hidden="true"></i> Merge selected patrons</button>
96
                          <button id="merge-patrons" class="btn btn-sm btn-default disabled" disabled="disabled" type="submit"><i class="fa fa-compress" aria-hidden="true"></i> Merge selected patrons</button>
97
                    [% END %]
97
                    [% END %]
98
                    <div id="patron_search_selected" class="btn-group" style="display:none;">
99
                        <span></span>
100
                        <a href="#" id="clear-patron-selection"><i class="fa fa-remove"></i> Clear</a>
101
                    </div>
98
                  </div>
102
                  </div>
99
                </div>
103
                </div>
100
            [% END %]
104
            [% END %]
Lines 147-161 Link Here
147
    [% INCLUDE 'str/members-menu.inc' %]
151
    [% INCLUDE 'str/members-menu.inc' %]
148
    [% Asset.js("js/members-menu.js") | $raw %]
152
    [% Asset.js("js/members-menu.js") | $raw %]
149
    <script>
153
    <script>
154
        function showPatronSelections( number ){
155
            $("#patron_search_selected").show().find("span").text(_("Patrons selected: " + number ) );
156
        }
150
157
151
        $(document).ready(function() {
158
        $(document).ready(function() {
152
            $('#merge-patrons').prop('disabled', true);
159
            $('#merge-patrons').prop('disabled', true);
153
            $('#memberresultst').on('change', 'input.selection', function() {
160
            $('#memberresultst').on('change', 'input.selection', function() {
154
                if ( $('.selection:checked').length > 1 ) {
161
                var patron_search_selections = JSON.parse( localStorage.getItem("patron_search_selections") ) || [];
162
                var borrowernumber = $(this).val();
163
                if( $(this).prop("checked") ){
164
                    patron_search_selections.push( $(this).val() );
165
                    localStorage.setItem('patron_search_selections', JSON.stringify( patron_search_selections ));
166
                    showPatronSelections( patron_search_selections.length );
167
                } else {
168
                    var filtered = patron_search_selections.filter(function( value ){
169
                        return value !== borrowernumber;
170
                    });
171
                    if( filtered.length > 0 ){
172
                        localStorage.setItem('patron_search_selections', JSON.stringify( filtered ));
173
                        patron_search_selections = filtered;
174
                        showPatronSelections( filtered.length );
175
                    } else {
176
                        patron_search_selections = [];
177
                        localStorage.removeItem('patron_search_selections');
178
                        $("#patron_search_selected").hide();
179
                    }
180
                }
181
                if ( patron_search_selections.length > 1 ) {
155
                    /* More than one checkbox has been checked */
182
                    /* More than one checkbox has been checked */
156
                    $('#merge-patrons').prop('disabled', false).removeClass("disabled");
183
                    $('#merge-patrons').prop('disabled', false).removeClass("disabled");
157
                    $("#patronlist-menu").removeClass("disabled").prop("disabled", false);
184
                    $("#patronlist-menu").removeClass("disabled").prop("disabled", false);
158
                } else if ( $('.selection:checked').length == 1 ) {
185
                } else if ( patron_search_selections.length == 1 ) {
159
                    /* At least one checkbox has been checked */
186
                    /* At least one checkbox has been checked */
160
                    $('#merge-patrons').prop('disabled', true).addClass("disabled");
187
                    $('#merge-patrons').prop('disabled', true).addClass("disabled");
161
                    $("#patronlist-menu").removeClass("disabled").prop("disabled", false);
188
                    $("#patronlist-menu").removeClass("disabled").prop("disabled", false);
Lines 167-183 Link Here
167
            });
194
            });
168
195
169
            $('#merge-patrons').on('click', function() {
196
            $('#merge-patrons').on('click', function() {
170
                var merge_patrons_url = 'merge-patrons.pl?' + $('.selection:checked')
197
                var patron_search_selections = JSON.parse( localStorage.getItem("patron_search_selections") ) || [];
171
                    .map(function() {
198
                var merge_patrons_url = 'merge-patrons.pl?id=' + patron_search_selections.join("&id=");
172
                       return "id=" + $(this).val()
173
                    }).get().join('&');
174
                window.location.href = merge_patrons_url;
199
                window.location.href = merge_patrons_url;
175
            });
200
            });
176
201
177
            $("#patronlist-dropdown").on("click", ".patron-list-add", function(e){
202
            $("#clear-patron-selection").on("click", function(e){
178
                e.preventDefault();
203
                e.preventDefault();
204
                $(".selection").prop("checked", false).change();
205
                localStorage.removeItem("patron_search_selections");
206
                $("#patron_search_selected").hide();
207
                $('#merge-patrons').prop('disabled', true).addClass("disabled");
208
                $("#patronlist-menu").addClass("disabled").prop("disabled", true);
209
            });
179
210
180
                if ( $("#memberresultst input:checkbox:checked").length == 0 ) {
211
            $("#patronlist-dropdown").on("click", ".patron-list-add", function(e){
212
                e.preventDefault();
213
                var patron_search_selections = JSON.parse( localStorage.getItem("patron_search_selections") ) || [];
214
                if ( patron_search_selections.length == 0 ) {
181
                    alert( _("You have not selected any patrons to add to a list!") );
215
                    alert( _("You have not selected any patrons to add to a list!") );
182
                    $(".btn-group").removeClass("open"); /* Close button menu */
216
                    $(".btn-group").removeClass("open"); /* Close button menu */
183
                    return false;
217
                    return false;
Lines 247-281 Link Here
247
        });
281
        });
248
282
249
        function patronListAdd(){
283
        function patronListAdd(){
250
            var borrowernumbers = [];
284
            var borrowernumbers = JSON.parse( localStorage.getItem("patron_search_selections") ) || [];
251
            $("#memberresultst").find("input:checkbox:checked").each(function(){
285
            if ( borrowernumbers.length > 0 ){
252
                borrowernumbers.push($(this).val());
286
                var data = {
253
            });
287
                    add_to_patron_list: $("#add_to_patron_list").val(),
254
            var data = {
288
                    new_patron_list: $("#new_patron_list").val(),
255
                add_to_patron_list: $("#add_to_patron_list").val(),
289
                    borrowernumbers: borrowernumbers
256
                new_patron_list: $("#new_patron_list").val(),
290
                };
257
                borrowernumbers: borrowernumbers
291
                $.ajax({
258
            };
292
                    data: data,
259
            $.ajax({
293
                    type: 'POST',
260
                data: data,
294
                    url: '/cgi-bin/koha/svc/members/add_to_list',
261
                type: 'POST',
295
                    success: function(data) {
262
                url: '/cgi-bin/koha/svc/members/add_to_list',
296
                        $("#patron_list_dialog").show();
263
                success: function(data) {
297
                        $("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list);
264
                    $("#patron_list_dialog").show();
298
                        $("#patron_list_dialog > a").attr("href", "/cgi-bin/koha/patron_lists/list.pl?patron_list_id=" + data.patron_list.patron_list_id);
265
                    $("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list);
299
                        $("#patron_list_dialog > a").html(data.patron_list.name);
266
                    $("#patron_list_dialog > a").attr("href", "/cgi-bin/koha/patron_lists/list.pl?patron_list_id=" + data.patron_list.patron_list_id);
300
267
                    $("#patron_list_dialog > a").html(data.patron_list.name);
301
                        if ( $('#add_to_patron_list').val() == 'new' ) {
268
302
                            /* Add a new entry to the menu */
269
                    if ( $('#add_to_patron_list').val() == 'new' ) {
303
                            $("#patronlist-dropdown .divider").before('<li><a class="patron-list-add" href="#" data-listid="' + data.patron_list.patron_list_id + '">' + data.patron_list.name + '</li>');
270
                        /* Add a new entry to the menu */
304
                        }
271
                        $("#patronlist-dropdown .divider").before('<li><a class="patron-list-add" href="#" data-listid="' + data.patron_list.patron_list_id + '">' + data.patron_list.name + '</li>');
305
                    },
306
                    error: function() {
307
                        alert( _("An error occurred. Patron list could not be updated.") );
308
                    }
309
                });
310
                return true;
311
            } else {
312
                alert( _("You have not selected any patrons to add to a list!") );
313
                return false;
314
            }
315
        }
316
317
        function prepSelections(){
318
            var selected_patrons = JSON.parse( localStorage.getItem("patron_search_selections") );
319
            if( selected_patrons && selected_patrons.length > 0 ){
320
                showPatronSelections( selected_patrons.length );
321
322
                $('#merge-patrons').prop('disabled', true);
323
                $("input.selection").each(function(){
324
                    var cardnumber = $(this).val();
325
                    if( selected_patrons.indexOf( cardnumber ) >= 0 ){
326
                        $(this).prop("checked", true );
272
                    }
327
                    }
273
                },
328
                });
274
                error: function() {
329
275
                    alert( _("An error occurred. Patron list could not be updated.") );
330
                if( selected_patrons.length > 1 ){
331
                    $('#merge-patrons').removeClass("disabled").prop('disabled', false);
332
                    $('#patronlist-menu').removeClass("disabled").prop('disabled', false);
276
                }
333
                }
277
            });
334
            }
278
            return true;
279
        }
335
        }
280
336
281
        $('#memberresultst tbody').on('click','td',function(e){
337
        $('#memberresultst tbody').on('click','td',function(e){
Lines 302-308 Link Here
302
    [% ELSE %]
358
    [% ELSE %]
303
        [% SET redirect_url = '/cgi-bin/koha/members/moremember.pl' %]
359
        [% SET redirect_url = '/cgi-bin/koha/members/moremember.pl' %]
304
    [% END %]
360
    [% END %]
305
    [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns,actions => ['edit', 'checkout'], redirect_if_one_result => 1, redirect_url => redirect_url, sticky_header => "searchheader", sticky_to => "searchresults", default_sort_column => 'name-address', display_search_description => 1 %]
361
    [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns,actions => ['edit', 'checkout'], redirect_if_one_result => 1, redirect_url => redirect_url, sticky_header => "searchheader", sticky_to => "searchresults", default_sort_column => 'name-address', display_search_description => 1, remember_selections => 1 %]
306
362
307
[% END %]
363
[% END %]
308
364
(-)a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js (-1 / +1 lines)
Lines 213-218 function logOut(){ Link Here
213
    localStorage.removeItem("sql_reports_activetab");
213
    localStorage.removeItem("sql_reports_activetab");
214
    localStorage.removeItem("searches");
214
    localStorage.removeItem("searches");
215
    localStorage.removeItem("bibs_selected");
215
    localStorage.removeItem("bibs_selected");
216
    localStorage.removeItem("patron_search_selections");
216
}
217
}
217
218
218
function openHelp(){
219
function openHelp(){
219
- 

Return to bug 29971