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

(-)a/koha-tmpl/opac-tmpl/bootstrap/css/src/_common.scss (-5 / +10 lines)
Lines 647-663 table { Link Here
647
    display: flex;
647
    display: flex;
648
648
649
    .dataTables_filter {
649
    .dataTables_filter {
650
        label {
650
        label + label {
651
            input {
651
            margin-left: 5px;
652
                margin-left: 5px;
653
            }
654
        }
652
        }
655
653
656
        input {
654
        input,
655
        select {
657
            @extend .form-control;
656
            @extend .form-control;
658
            @extend .form-control-sm;
657
            @extend .form-control-sm;
659
658
660
            display: inline-block;
659
            display: inline-block;
660
            margin-left: 5px;
661
            width: auto;
661
            width: auto;
662
662
663
            &:focus {
663
            &:focus {
Lines 667-672 table { Link Here
667
    }
667
    }
668
}
668
}
669
669
670
.dataTables_info {
671
    font-size: 0.875rem;
672
    margin: 5px;
673
}
674
670
.table_entries {
675
.table_entries {
671
    color: #797979;
676
    color: #797979;
672
    font-size: 90%;
677
    font-size: 90%;
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt (-48 / +60 lines)
Lines 337-374 Link Here
337
337
338
                            [% IF ( deleted ) %]<div class="alert alert-info">The selected suggestions have been deleted.</div>[% END %]
338
                            [% IF ( deleted ) %]<div class="alert alert-info">The selected suggestions have been deleted.</div>[% END %]
339
339
340
                            [% IF (Koha.Preference( 'OPACViewOthersSuggestions' ) || loggedinusername) && (suggestions.size > 0 OR title_filter) %]
341
                                [% SET can_delete_suggestion = 0 %]
342
                                <form action="/cgi-bin/koha/opac-suggestions.pl" class="form-inline" id="search_suggestions_form" method="get">
343
                                    <div class="form-row">
344
                                        <div class="col-auto my-1">
345
                                            <label for="title_filter">Search for:</label>
346
                                        </div>
347
                                        <div class="col-auto my-1">
348
                                            <input type="text" name="title_filter" id="title_filter" value="[% title_filter | html %]" size="30" class="form-control form-control-sm" />
349
                                        </div>
350
                                        [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) %]
351
                                            [% IF loggedinusername %]
352
                                                <div class="col-auto my-1">
353
                                                    <label class="sr-only" for="suggested_by_anyone">Suggested by:</label>
354
                                                    <select class="form-control form-control-sm" name="suggested_by_anyone" id="suggested_by_anyone">
355
                                                        [% IF suggested_by_anyone %]
356
                                                            <option value="0">Suggested by me</option>
357
                                                            <option value="1" selected="selected">Suggested by anyone</option>
358
                                                        [% ELSE %]
359
                                                            <option value="0" selected="selected">Suggested by me</option>
360
                                                            <option value="1">Suggested by anyone</option>
361
                                                        [% END %]
362
                                                    </select>
363
                                                </div>
364
                                            [% END %]
365
                                        [% END %]
366
                                        <div class="col-auto my-1">
367
                                            <button type="submit" class="btn btn-sm btn-primary">Go</button>
368
                                        </div>
369
                                    </div>
370
                                </form>
371
                            [% END %]
372
                            [% IF suggestions.size > 0 %]
340
                            [% IF suggestions.size > 0 %]
373
                                [% SET can_delete_suggestion = 0 %]
341
                                [% SET can_delete_suggestion = 0 %]
374
                                <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="delete_suggestions">
342
                                <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="delete_suggestions">
Lines 401-414 Link Here
401
369
402
                                    [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 || loggedinusername %]
370
                                    [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 || loggedinusername %]
403
                                    <table id="suggestt" class="table table-bordered tabled">
371
                                    <table id="suggestt" class="table table-bordered tabled">
404
                                        <caption class="sr-only">Your purchase suggestions<caption>
372
                                        <caption class="sr-only">Your purchase suggestions</caption>
405
                                        <thead>
373
                                        <thead>
406
                                            <tr>
374
                                            <tr>
407
                                                [% IF ( loggedinusername ) %]<th>&nbsp;</th>[% END %]
375
                                                [% IF ( loggedinusername ) %]<th class="NoSort">&nbsp;</th>[% END %]
408
                                                <th class="all">Summary</th>
376
                                                <th class="all">Summary</th>
409
                                                <th>Suggested on</th>
377
                                                <th>Suggested on</th>
410
                                                <th>Note</th>
378
                                                <th>Note</th>
411
                                                [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]<th>Suggested for</th>[% END %]
379
                                                [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
380
                                                    <th>Suggested for</th>
381
                                                    <th class="hidden"></th>
382
                                                [% END %]
412
                                                [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]<th>Managed by</th>[% END %]
383
                                                [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]<th>Managed by</th>[% END %]
413
                                                <th>Status</th>
384
                                                <th>Status</th>
414
                                                <th></th>
385
                                                <th></th>
Lines 425-431 Link Here
425
                                                            [% END %]
396
                                                            [% END %]
426
                                                        </td>
397
                                                        </td>
427
                                                    [% END %]
398
                                                    [% END %]
428
                                                    <td>
399
                                                    <td class="anti-the">
429
                                                        <p>
400
                                                        <p>
430
                                                            <label for="id[% suggestions_loo.suggestionid | html %]">
401
                                                            <label for="id[% suggestions_loo.suggestionid | html %]">
431
                                                                [% IF suggestion.biblionumber %]
402
                                                                [% IF suggestion.biblionumber %]
Lines 459-464 Link Here
459
                                                                [% Branches.GetName(suggestion.branchcode) | html %]
430
                                                                [% Branches.GetName(suggestion.branchcode) | html %]
460
                                                            [% END %]
431
                                                            [% END %]
461
                                                        </td>
432
                                                        </td>
433
                                                        <td>
434
                                                            [% IF logged_in_user.borrowernumber == suggestion.suggester.borrowernumber %]
435
                                                                1
436
                                                            [% ELSE %]
437
                                                                0
438
                                                            [% END %]
439
                                                        </td>
462
                                                    [% END %]
440
                                                    [% END %]
463
                                                    [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]
441
                                                    [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]
464
                                                    <td>
442
                                                    <td>
Lines 567-597 Link Here
567
    [% END %]
545
    [% END %]
568
546
569
    $(function() {
547
    $(function() {
570
        $("#suggestt").dataTable($.extend(true, {}, dataTablesDefaults, {
548
        dataTablesDefaults.buttons.splice(1,3); // Remove copy, print, csv from button set
549
        var suggestions_table = $("#suggestt").DataTable($.extend(true, {}, dataTablesDefaults, {
571
            "order": [[ 1, "asc" ]],
550
            "order": [[ 1, "asc" ]],
572
            "autoWidth": false,
551
            "autoWidth": false,
552
            "dom": '<"top"<"table_entries"i><"table_controls"fB>>t',
573
            "columnDefs": [
553
            "columnDefs": [
574
              [% IF ( loggedinusername ) %]{ "targets": [ 0 ], "sortable": false, "searchable": false }[% END %],
554
                { "targets": ["NoSort"], "sortable": false, "searchable": false },
555
                { "visible": false, "targets" : [ "hidden" ] },
575
                { "className": 'dtr-control', "orderable": false, "targets": -1 },
556
                { "className": 'dtr-control', "orderable": false, "targets": -1 },
557
                { "type": "anti-the", "targets" : [ "anti-the" ] },
576
                { responsivePriority: 1, targets: 1 }
558
                { responsivePriority: 1, targets: 1 }
577
            ],
559
            ],
578
            "columns": [
560
            "language": {
579
                [% IF ( loggedinusername ) %]null,[% END %]
561
                "search": "_INPUT_",
580
                { "type": "anti-the" },
562
                "searchPlaceholder": _("Search")
581
                null,
563
            },
582
                null,
583
                [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]null,[% END %]
584
                [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]null,[% END %]
585
                null,
586
                null
587
            ],
588
            "responsive": {
564
            "responsive": {
589
                details: {
565
                details: {
590
                    type: 'column',
566
                    type: 'column',
591
                    target: -1
567
                    target: -1
592
                }
568
                }
593
            },
569
            },
570
            initComplete: function (settings, json) {
571
                var tableId = settings.nTable.id;
572
                [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 && loggedinusername %]
573
                    // Add select filter
574
                    $('#suggestt_filter').append('<label for="suggested_by_user" class="sr-only">Filter:</label>').append('<select class="form-control form-control-sm" name="suggested_by_user" id="suggested_by_user"><option value="1" selected="selected">Suggested by me</option><option value="0">Suggested by anyone</option></select>');
575
                    // Filter results on select change
576
                    let suggested_by_user = $("#suggested_by_user");
577
                    suggested_by_user.on('change', function () {
578
                        suggestions_table.columns(5).search($(this).val()).draw();
579
                    });
580
                    $("body").on( 'search.dt', "#" + tableId, function ( e, settings ) {
581
                        if( settings.oPreviousSearch.sSearch == "" && suggested_by_user.val() == "1" ){
582
                            $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").addClass("disabled");
583
                        } else {
584
                            $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").removeClass("disabled");
585
                        }
586
                    });
587
                [% ELSE %]
588
                    $("body").on( 'search.dt', "#" + tableId, function ( e, settings ) {
589
                        if( settings.oPreviousSearch.sSearch == "" ){
590
                            $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").addClass("disabled");
591
                        } else {
592
                            $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").removeClass("disabled");
593
                        }
594
                    });
595
                [% END %]
596
            }
594
        }));
597
        }));
598
        $("#usersuggestions").on("click", ".dt_button_clear_filter",function(){
599
            suggestions_table.search("").columns().search("").draw();
600
            $("#suggested_by_user").val(1).change();
601
            $(this).addClass("disabled");
602
        });
603
        [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 && loggedinusername %]
604
            suggestions_table.columns(5).search( 1 ).draw();
605
        [% END %]
606
595
        [% IF ( loggedinusername ) %]$("span.clearall").html("<a id=\"CheckNone\" class=\"btn btn-link btn-sm\" href=\"#\">"+_("Clear all")+"<\/a>");
607
        [% IF ( loggedinusername ) %]$("span.clearall").html("<a id=\"CheckNone\" class=\"btn btn-link btn-sm\" href=\"#\">"+_("Clear all")+"<\/a>");
596
        $("span.checkall").html("<a id=\"CheckAll\" class=\"btn btn-link btn-sm\" href=\"#\">"+_("Select all")+"<\/a>");
608
        $("span.checkall").html("<a id=\"CheckAll\" class=\"btn btn-link btn-sm\" href=\"#\">"+_("Select all")+"<\/a>");
597
        $("#CheckAll").on("click",function(e){
609
        $("#CheckAll").on("click",function(e){
(-)a/opac/opac-suggestions.pl (-9 / +2 lines)
Lines 105-114 my $suggested_by; Link Here
105
if ( $op eq 'else' ) {
105
if ( $op eq 'else' ) {
106
    if ( C4::Context->preference("OPACViewOthersSuggestions") ) {
106
    if ( C4::Context->preference("OPACViewOthersSuggestions") ) {
107
        if ( $borrowernumber ) {
107
        if ( $borrowernumber ) {
108
            # A logged in user is able to see suggestions from others
108
            $suggested_by = undef;
109
            $suggested_by = $suggested_by_anyone
110
                ? undef
111
                : $borrowernumber;
112
        }
109
        }
113
        # else: Non logged in user is able to see all suggestions
110
        # else: Non logged in user is able to see all suggestions
114
    }
111
    }
Lines 136-142 $suggestion = { Link Here
136
        ( defined $p && $p ne '' ? ( $_ => $p ) : () )
133
        ( defined $p && $p ne '' ? ( $_ => $p ) : () )
137
    } keys %$suggestion
134
    } keys %$suggestion
138
};
135
};
139
$suggestion->{suggestedby} = $borrowernumber;
136
$suggestion->{suggestedby} = $suggested_by;
140
137
141
if ( $op eq "add_validate" && not $biblionumber ) { # If we are creating the suggestion from an existing record we do not want to search for duplicates
138
if ( $op eq "add_validate" && not $biblionumber ) { # If we are creating the suggestion from an existing record we do not want to search for duplicates
142
    $op = 'add_confirm';
139
    $op = 'add_confirm';
Lines 226-234 my $suggestions = [ Koha::Suggestions->search_limited( Link Here
226
        $suggestion->{suggestedby}
223
        $suggestion->{suggestedby}
227
        ? ( suggestedby => $suggestion->{suggestedby} )
224
        ? ( suggestedby => $suggestion->{suggestedby} )
228
        : (),
225
        : (),
229
        $title_filter
230
        ? ( title       => $title_filter )
231
        : (),
232
    }
226
    }
233
)->as_list ];
227
)->as_list ];
234
228
235
- 

Return to bug 36045