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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt (-45 / +65 lines)
Lines 207-258 Link Here
207
                                    <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
207
                                    <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
208
208
209
                                    <label for="sortfield">Sort by: </label>
209
                                    <label for="sortfield">Sort by: </label>
210
                                    <select name="sortfield" id="sortfield" class="resort" onchange="$('#sorting-form').submit()">
210
                                    <select name="sortfield" id="sortfield" class="resort">
211
                                        <option value="">Default sorting</option>
211
                                        <option value="">Default sorting</option>
212
212
                                        <optgroup label="Author">
213
                                        [% IF sortfield == 'author' %]
213
                                            [% IF sortfield == 'author' && direction == 'asc' %]
214
                                            <option value="author" selected="selected">Author</option>
214
                                                <option value="author:asc" selected="selected">Author (A-Z)</option>
215
                                        [% ELSE %]
215
                                            [% ELSE %]
216
                                            <option value="author">Author</option>
216
                                                <option value="author:asc">Author (A-Z)</option>
217
                                        [% END %]
217
                                            [% END %]
218
218
                                            [% IF sortfield == 'author' && direction == 'desc' %]
219
                                        [% IF sortfield == 'title' %]
219
                                                <option value="author:desc" selected="selected">Author (Z-A)</option>
220
                                            <option value="title" selected="selected">Title</option>
220
                                            [% ELSE %]
221
                                        [% ELSE %]
221
                                                <option value="author:desc">Author (Z-A)</option>
222
                                            <option value="title">Title</option>
222
                                            [% END %]
223
                                        [% END %]
223
                                        </optgroup>
224
224
                                        <optgroup label="Title">
225
                                        [% IF sortfield == 'itemcallnumber' %]
225
                                            [% IF sortfield == 'title' && direction == 'asc' %]
226
                                            <option value="itemcallnumber" selected="selected">Call number</option>
226
                                                <option value="title:asc" selected="selected">Title (A-Z)</option>
227
                                        [% ELSE %]
227
                                            [% ELSE %]
228
                                            <option value="itemcallnumber">Call number</option>
228
                                                <option value="title:asc">Title (A-Z)</option>
229
                                        [% END %]
229
                                            [% END %]
230
230
                                            [% IF sortfield == 'title' && direction == 'desc' %]
231
                                        [% IF sortfield == 'copyrightdate' %]
231
                                                <option value="title:desc" selected="selected">Title (Z-A)</option>
232
                                            <option value="copyrightdate" selected="selected">Copyright date</option>
232
                                            [% ELSE %]
233
                                        [% ELSE %]
233
                                                <option value="title:desc">Title (Z-A)</option>
234
                                            <option value="copyrightdate">Copyright date</option>
234
                                            [% END %]
235
                                        [% END %]
235
                                        </optgroup>
236
236
                                        <optgroup label="Call number">
237
                                        [% IF sortfield == "dateadded" %]
237
                                            [% IF sortfield == 'itemcallnumber' && direction == 'asc' %]
238
                                            <option value="dateadded" selected="selected">Date added</option>
238
                                                <option value="itemcallnumber:asc" selected="selected">Call number (A-Z)</option>
239
                                        [% ELSE %]
239
                                            [% ELSE %]
240
                                            <option value="dateadded">Date added</option>
240
                                                <option value="itemcallnumber:asc">Call number (A-Z)</option>
241
                                        [% END %]
241
                                            [% END %]
242
                                    </select>
242
                                            [% IF sortfield == 'itemcallnumber' && direction == 'desc' %]
243
243
                                                <option value="itemcallnumber:desc" selected="selected">Call number (Z-A)</option>
244
                                    <select name="direction" class="resort" onchange="$('#sorting-form').submit()">
244
                                            [% ELSE %]
245
                                        [% IF direction == 'asc' %]
245
                                                <option value="itemcallnumber:desc">Call number (Z-A)</option>
246
                                            <option value="asc" selected="selected">Ascending</option>
246
                                            [% END %]
247
                                        [% ELSE %]
247
                                        </optgroup>
248
                                            <option value="asc">Ascending</option>
248
                                        <optgroup label="Copyright date">
249
                                        [% END %]
249
                                            [% IF sortfield == 'copyrightdate' && direction == 'asc' %]
250
250
                                                <option value="copyrightdate:asc" selected="selected">Copyright date (newest to oldest)</option>
251
                                        [% IF direction == 'desc' %]
251
                                            [% ELSE %]
252
                                            <option value="desc" selected="selected">Descending</option>
252
                                                <option value="copyrightdate:asc">Copyright date (newest to oldest)</option>
253
                                        [% ELSE %]
253
                                            [% END %]
254
                                            <option value="desc">Descending</option>
254
                                            [% IF sortfield == 'copyrightdate' && direction == 'desc' %]
255
                                        [% END %]
255
                                                <option value="copyrightdate:desc" selected="selected">Copyright date (oldest to newest)</option>
256
                                            [% ELSE %]
257
                                                <option value="copyrightdate:desc">Copyright date (oldest to newest)</option>
258
                                            [% END %]
259
                                        </optgroup>
260
                                        <optgroup label="Date added">
261
                                            [% IF sortfield == "dateadded" && direction == 'asc' %]
262
                                                <option value="dateadded:asc" selected="selected">Date added (newest to oldest)</option>
263
                                            [% ELSE %]
264
                                                <option value="dateadded:asc">Date added (newest to oldest)</option>
265
                                            [% END %]
266
                                            [% IF sortfield == "dateadded" && direction == 'desc' %]
267
                                                <option value="dateadded:desc" selected="selected">Date added (oldest to newest)</option>
268
                                            [% ELSE %]
269
                                                <option value="dateadded:desc">Date added (oldest to newest)</option>
270
                                            [% END %]
271
                                        </optgroup>
256
                                    </select>
272
                                    </select>
257
273
258
                                    <input type="submit" class="btn btn-small" id="sort-submit" value="Resort list" />
274
                                    <input type="submit" class="btn btn-small" id="sort-submit" value="Resort list" />
Lines 977-982 $(function() { Link Here
977
        stickyClass: "floating"
993
        stickyClass: "floating"
978
    });
994
    });
979
995
996
    $("#sortfield").on("change", function(){
997
        $('#sorting-form').submit();
998
    });
999
980
}); // document.ready
1000
}); // document.ready
981
1001
982
function AdjustRemark() {
1002
function AdjustRemark() {
(-)a/opac/opac-shelves.pl (-3 / +7 lines)
Lines 234-242 if ( $op eq 'view' ) { Link Here
234
    if ( $shelf ) {
234
    if ( $shelf ) {
235
        if ( $shelf->can_be_viewed( $loggedinuser ) ) {
235
        if ( $shelf->can_be_viewed( $loggedinuser ) ) {
236
            $category = $shelf->category;
236
            $category = $shelf->category;
237
            my $sortfield = $query->param('sortfield') || $shelf->sortfield;    # Passed in sorting overrides default sorting
237
            my( $sortfield, $direction );
238
            if( defined( $query->param('sortfield') ) ){ # Passed in sorting overrides default sorting
239
                ( $sortfield, $direction ) = split /:/, $query->param('sortfield');
240
            } else {
241
                $sortfield = $shelf->sortfield;
242
                $direction = 'asc';
243
            }
238
            $sortfield = 'title' unless grep $_ eq $sortfield, qw( title author copyrightdate itemcallnumber dateadded );
244
            $sortfield = 'title' unless grep $_ eq $sortfield, qw( title author copyrightdate itemcallnumber dateadded );
239
            my $direction = $query->param('direction') || 'asc';
240
            $direction = 'asc' if $direction ne 'asc' and $direction ne 'desc';
245
            $direction = 'asc' if $direction ne 'asc' and $direction ne 'desc';
241
            my ( $page, $rows );
246
            my ( $page, $rows );
242
            unless ( $query->param('print') or $query->param('rss') ) {
247
            unless ( $query->param('print') or $query->param('rss') ) {
243
- 

Return to bug 23913