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

(-)a/koha-tmpl/intranet-tmpl/prog/js/holds.js (-76 / +41 lines)
Lines 791-804 $(document).ready(function () { Link Here
791
        }
791
        }
792
    });
792
    });
793
793
794
    // if (!patron_page) {
795
    //     $(".holds_table .select_hold_all").each(function () {
796
    //         var table = $(this).parents(".holds_table");
797
    //         var count = $(".select_hold:not(:checked)", table).length;
798
    //         $(".select_hold_all", table).prop("checked", !count);
799
    //     });
800
    // }
801
802
    function updateSelectedHoldsButtonCounters() {
794
    function updateSelectedHoldsButtonCounters() {
803
        $(".move_selected_holds").html(
795
        $(".move_selected_holds").html(
804
            MSG_MOVE_SELECTED.format(
796
            MSG_MOVE_SELECTED.format(
Lines 1639-1717 async function load_patron_holds_table(biblio_id, split_data) { Link Here
1639
                    orderable: false,
1631
                    orderable: false,
1640
                    searchable: false,
1632
                    searchable: false,
1641
                    render: function (data, type, row, meta) {
1633
                    render: function (data, type, row, meta) {
1634
                        const group_hold_message = row.hold_group_id
1635
                            ? `<div>(${__("part of")} <a href="/cgi-bin/koha/reserve/hold-group.pl?hold_group_id=${row.hold_group_id}" class="hold-group">${__("hold group")}</a>)</div>`
1636
                            : "";
1637
1638
                        // Handle status cases
1642
                        if (row.status) {
1639
                        if (row.status) {
1643
                            return (
1640
                            return `<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=${row.biblio_id}&itemnumber=${row.item_id}">${row.item.external_id}</a>${group_hold_message}`;
1644
                                '<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=' +
1641
                        }
1645
                                row.biblio_id +
1642
1646
                                "&itemnumber=" +
1643
                        // Handle item level holds
1647
                                row.item_id +
1644
                        if (row.item_level_holds) {
1648
                                '">' +
1645
                            const barcode =
1649
                                row.item.external_id +
1646
                                row.item.external_id || __("No barcode");
1650
                                "</a>"
1647
                            const itemLink = `<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=${row.biblio_id}&itemnumber=${row.item_id}">${barcode.escapeHtml ? barcode.escapeHtml() : barcode}</a>`;
1651
                            );
1648
1652
                        } else if (row.item_id && row.item_level) {
1653
                            let barcode = row.item.external_id
1654
                                ? row.item.external_id
1655
                                : __("No barcode");
1656
                            if (row.item_level_holds >= 2) {
1649
                            if (row.item_level_holds >= 2) {
1657
                                let link =
1650
                                return `${__("Only item")} ${itemLink}${group_hold_message}`;
1658
                                    '<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=' +
1659
                                    row.biblio_id +
1660
                                    "&itemnumber=" +
1661
                                    row.item_id +
1662
                                    '">' +
1663
                                    (row.item.external_id
1664
                                        ? row.item.external_id.escapeHtml()
1665
                                        : __("No barcode")) +
1666
                                    "</a>";
1667
                                return __("Only item") + " " + link;
1668
                            } else {
1669
                                let select =
1670
                                    '<select id="change_hold_type" class="change_hold_type ' +
1671
                                    table_class +
1672
                                    '" data-id="' +
1673
                                    row.hold_id +
1674
                                    '">';
1675
                                select +=
1676
                                    '<option value="" selected>' +
1677
                                    __("Only item") +
1678
                                    " " +
1679
                                    barcode +
1680
                                    "</option>";
1681
                                select +=
1682
                                    '<option value="">' +
1683
                                    __("Next available") +
1684
                                    "</option>";
1685
                                select += "</select>";
1686
                                return select;
1687
                            }
1651
                            }
1688
                        } else if (row.item_group_id) {
1652
1689
                            return __(
1653
                            return `<select id="change_hold_type" class="change_hold_type ${table_class}" data-id="${row.hold_id}">
1690
                                "Next available item from group <strong>%s</strong>"
1654
                                <option value="" selected>${__("Only item")} ${barcode}</option>
1691
                            ).format(row.item_group.description);
1655
                                <option value="">${__("Next available")}</option>
1692
                        } else if (row.hold_group_id) {
1656
                            </select>${group_hold_message}`;
1657
                        }
1658
1659
                        // Handle item group
1660
                        if (row.item_group_id) {
1693
                            return (
1661
                            return (
1694
                                "<div>(" +
1662
                                __(
1695
                                __("part of") +
1663
                                    "Next available item from group <strong>%s</strong>"
1696
                                ' <a href="/cgi-bin/koha/reserve/hold-group.pl?hold_group_id=' +
1664
                                ).format(row.item_group.description) +
1697
                                row.hold_group_id +
1665
                                group_hold_message
1698
                                '" class="hold-group">' +
1699
                                __("hold group") +
1700
                                "</a>)</div>"
1701
                            );
1666
                            );
1702
                        } else {
1703
                            if (row.non_priority) {
1704
                                return (
1705
                                    "<em>" +
1706
                                    __("Next available") +
1707
                                    "</em><br/><i>" +
1708
                                    __("Non priority hold") +
1709
                                    "</i>"
1710
                                );
1711
                            } else {
1712
                                return "<em>" + __("Next available") + "</em>";
1713
                            }
1714
                        }
1667
                        }
1668
1669
                        // Default: Next available
1670
                        let message = __("Next available");
1671
                        if (row.non_priority) {
1672
                            message += `<br/><i>${__("Non priority hold")}</i>`;
1673
                        }
1674
                        return message + group_hold_message;
1715
                    },
1675
                    },
1716
                },
1676
                },
1717
                {
1677
                {
Lines 2297-2302 async function load_patron_holds_table(biblio_id, split_data) { Link Here
2297
            let priority = $(this).attr("data-priority");
2257
            let priority = $(this).attr("data-priority");
2298
            var res_id = $(this).attr("reserve_id");
2258
            var res_id = $(this).attr("reserve_id");
2299
            var moveTo;
2259
            var moveTo;
2260
            const $spinner = $(
2261
                '<img class="rank-spinner" src="/intranet-tmpl/prog/img/spinner-small.gif" alt="Loading..." style="display:block;margin:0 auto;vertical-align:middle;">'
2262
            );
2300
            if (toPosition == "up") {
2263
            if (toPosition == "up") {
2301
                moveTo = parseInt(priority) - 1;
2264
                moveTo = parseInt(priority) - 1;
2302
            }
2265
            }
Lines 2309-2323 async function load_patron_holds_table(biblio_id, split_data) { Link Here
2309
            if (toPosition == "bottom") {
2272
            if (toPosition == "bottom") {
2310
                moveTo = totalHolds;
2273
                moveTo = totalHolds;
2311
            }
2274
            }
2275
            $(this).parent().html($spinner);
2312
            $.ajax({
2276
            $.ajax({
2313
                method: "PUT",
2277
                method: "PUT",
2314
                url:
2278
                url:
2315
                    "/api/v1/holds/" + encodeURIComponent(res_id) + "/priority",
2279
                    "/api/v1/holds/" + encodeURIComponent(res_id) + "/priority",
2316
                data: JSON.stringify(moveTo),
2280
                data: JSON.stringify(moveTo),
2317
                success: function (data) {
2281
                success: function (data) {
2282
                    $spinner.remove();
2318
                    holdsQueueTable.api().ajax.reload(null, false);
2283
                    holdsQueueTable.api().ajax.reload(null, false);
2319
                },
2284
                },
2320
                error: function (jqXHR, textStatus, errorThrown) {
2285
                error: function (jqXHR, textStatus, errorThrown) {
2286
                    $spinner.remove();
2321
                    alert(
2287
                    alert(
2322
                        "There was an error:" + textStatus + " " + errorThrown
2288
                        "There was an error:" + textStatus + " " + errorThrown
2323
                    );
2289
                    );
2324
- 

Return to bug 23269