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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/display_ticket.inc (+2 lines)
Lines 20-25 Link Here
20
                        <li class="rows">
20
                        <li class="rows">
21
                            <label for="public">Notify: </label>
21
                            <label for="public">Notify: </label>
22
                            <input type="checkbox" name="public" id="public">
22
                            <input type="checkbox" name="public" id="public">
23
                            <label for="assignee_id">Change assignee: </label>
24
                            <select name="assignee_id" id="assignee_id"></select>
23
                        </li>
25
                        </li>
24
                    </ol>
26
                    </ol>
25
                </fieldset>
27
                </fieldset>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt (-1 / +8 lines)
Lines 182-187 Link Here
182
                                } else {
182
                                } else {
183
                                    result += _("Open");
183
                                    result += _("Open");
184
                                }
184
                                }
185
                                if (row.assignee) {
186
                                    result += '<span class="clearfix">' + _("Assigned to: ") + $patron_to_html(row.assignee, {
187
                                        display_cardnumber: false,
188
                                        url: true
189
                                    }) + '</span>';
190
                                }
185
                            }
191
                            }
186
                            return result;
192
                            return result;
187
                        },
193
                        },
Lines 191-197 Link Here
191
                    {
197
                    {
192
                        "data": function(row, type, val, meta) {
198
                        "data": function(row, type, val, meta) {
193
                            let resolved = ( row.resolved_date ) ? true : false;
199
                            let resolved = ( row.resolved_date ) ? true : false;
194
                            let result = '<a class="btn btn-default btn-xs" role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '" data-resolved="'+resolved+'"><i class="fa-solid fa-eye" aria-hidden="true"></i> ' + _("Details") + '</a>';
200
                            let result = '<a class="btn btn-default btn-xs" role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '" data-resolved="'+resolved+'" data-assignee="'+$patron_to_html(row.assignee, { display_cardnumber: false, url: false })+'"><i class="fa-solid fa-eye" aria-hidden="true"></i> ' + _("Details") + '</a>';
195
                            return result;
201
                            return result;
196
                        },
202
                        },
197
                        "searchable": false,
203
                        "searchable": false,
Lines 245-250 Link Here
245
            [% END %]
251
            [% END %]
246
        });
252
        });
247
    </script>
253
    </script>
254
    [% INCLUDE 'select2.inc' %]
248
    [% Asset.js("js/modals/display_ticket.js") | $raw %]
255
    [% Asset.js("js/modals/display_ticket.js") | $raw %]
249
[% END %]
256
[% END %]
250
[% INCLUDE 'intranet-bottom.inc' %]
257
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js (-3 / +106 lines)
Lines 5-10 $(document).ready(function () { Link Here
5
        let button = $(event.relatedTarget);
5
        let button = $(event.relatedTarget);
6
        let ticket_id = button.data("concern");
6
        let ticket_id = button.data("concern");
7
        let resolved = button.data("resolved");
7
        let resolved = button.data("resolved");
8
        let assignee = button.data("assignee");
8
        modal.find(".modal-footer input").val(ticket_id);
9
        modal.find(".modal-footer input").val(ticket_id);
9
10
10
        if (resolved) {
11
        if (resolved) {
Lines 18-23 $(document).ready(function () { Link Here
18
        // Display ticket details
19
        // Display ticket details
19
        let display = '<div class="list-group">';
20
        let display = '<div class="list-group">';
20
        display += '<div class="list-group-item">';
21
        display += '<div class="list-group-item">';
22
        if (assignee) {
23
            display +=
24
                '<span class="pull-right"><span class="label">' +
25
                __("Assignee") +
26
                "</span>: " +
27
                assignee +
28
                "</span>";
29
        }
21
        display += '<span class="wrapfix">' + detail + "</span>";
30
        display += '<span class="wrapfix">' + detail + "</span>";
22
        display += "</div>";
31
        display += "</div>";
23
        display += '<div id="concern-updates" class="list-group-item">';
32
        display += '<div id="concern-updates" class="list-group-item">';
Lines 33-39 $(document).ready(function () { Link Here
33
            url: "/api/v1/tickets/" + ticket_id + "/updates",
42
            url: "/api/v1/tickets/" + ticket_id + "/updates",
34
            method: "GET",
43
            method: "GET",
35
            headers: {
44
            headers: {
36
                "x-koha-embed": ["user", "+strings"],
45
                "x-koha-embed": ["user", "assignee", "+strings"],
37
            },
46
            },
38
        })
47
        })
39
            .success(function (data) {
48
            .success(function (data) {
Lines 67-78 $(document).ready(function () { Link Here
67
                        $datetime(item.date) +
76
                        $datetime(item.date) +
68
                        ")";
77
                        ")";
69
                    if (item.status) {
78
                    if (item.status) {
70
                        updates += '<span class="wrapfix pull-right">';
79
                        updates += '<span class="clearfix pull-right">';
71
                        updates += item._strings.status
80
                        updates += item._strings.status
72
                            ? escape_str(item._strings.status.str)
81
                            ? escape_str(item._strings.status.str)
73
                            : "";
82
                            : "";
74
                        updates += "</span>";
83
                        updates += "</span>";
75
                    }
84
                    }
85
                    if (item.assignee) {
86
                        updates += '<span class="clearfix pull-right">';
87
                        updates += $patron_to_html(item.assignee, {
88
                            display_cardnumber: false,
89
                            url: true,
90
                        });
91
                        updates += "</span>";
92
                    }
76
                    updates += "</span>";
93
                    updates += "</span>";
77
                    updates += "</div>";
94
                    updates += "</div>";
78
                });
95
                });
Lines 83-98 $(document).ready(function () { Link Here
83
        // Clear any previously entered update message
100
        // Clear any previously entered update message
84
        $("#update_message").val("");
101
        $("#update_message").val("");
85
        $("#public").prop("checked", false);
102
        $("#public").prop("checked", false);
103
104
        // Patron select2
105
        $("#assignee_id").kohaSelect({
106
            dropdownParent: $(".modal-content", "#ticketDetailsModal"),
107
            width: "50%",
108
            dropdownAutoWidth: true,
109
            allowClear: true,
110
            minimumInputLength: 3,
111
            ajax: {
112
                url: "/api/v1/patrons",
113
                delay: 250,
114
                dataType: "json",
115
                headers: {
116
                    "x-koha-embed": "library",
117
                },
118
                data: function (params) {
119
                    let q = buildPatronSearchQuery(params.term);
120
                    let query = {
121
                        q: JSON.stringify(q),
122
                        _page: params.page,
123
                        _order_by: "+me.surname,+me.firstname",
124
                    };
125
                    return query;
126
                },
127
                processResults: function (data, params) {
128
                    let results = [];
129
                    data.results.forEach(function (patron) {
130
                        patron.id = patron.patron_id;
131
                        results.push(patron);
132
                    });
133
                    return {
134
                        results: results,
135
                        pagination: { more: data.pagination.more },
136
                    };
137
                },
138
            },
139
            templateResult: function (patron) {
140
                if (patron.library_id == loggedInLibrary) {
141
                    loggedInClass = "ac-currentlibrary";
142
                } else {
143
                    loggedInClass = "";
144
                }
145
146
                let $patron = $("<span></span>")
147
                    .append(
148
                        "" +
149
                            (patron.surname
150
                                ? escape_str(patron.surname) + ", "
151
                                : "") +
152
                            (patron.firstname
153
                                ? escape_str(patron.firstname) + " "
154
                                : "") +
155
                            (patron.cardnumber
156
                                ? " (" + escape_str(patron.cardnumber) + ")"
157
                                : "") +
158
                            "<small>" +
159
                            (patron.date_of_birth
160
                                ? ' <span class="age_years">' +
161
                                  $get_age(patron.date_of_birth) +
162
                                  " " +
163
                                  __("years") +
164
                                  "</span>"
165
                                : "") +
166
                            (patron.library
167
                                ? ' <span class="ac-library">' +
168
                                  escape_str(patron.library.name) +
169
                                  "</span>"
170
                                : "") +
171
                            "</small>"
172
                    )
173
                    .addClass(loggedInClass);
174
                return $patron;
175
            },
176
            templateSelection: function (patron) {
177
                if (!patron.surname) {
178
                    return patron.text;
179
                }
180
                return (
181
                    escape_str(patron.surname) +
182
                    ", " +
183
                    escape_str(patron.firstname)
184
                );
185
            },
186
            placeholder: "Search for a patron",
187
        });
86
    });
188
    });
87
189
88
    $("#ticketDetailsModal").on("click", ".updateSubmit", function (e) {
190
    $("#ticketDetailsModal").on("click", ".updateSubmit", function (e) {
89
        let clicked = $(this);
191
        let clicked = $(this);
90
        let ticket_id = $("#ticket_id").val();
192
        let ticket_id = $("#ticket_id").val();
193
        let assignee_id = $("#assignee_id").val();
91
        let params = {
194
        let params = {
92
            public: $("#public").is(":checked"),
195
            public: $("#public").is(":checked"),
93
            message: $("#update_message").val(),
196
            message: $("#update_message").val(),
94
            user_id: logged_in_user_borrowernumber,
197
            user_id: logged_in_user_borrowernumber,
95
            status: clicked.data("status"),
198
            status: clicked.data("status"),
199
            assignee_id: assignee_id,
96
        };
200
        };
97
201
98
        $("#comment-spinner").show();
202
        $("#comment-spinner").show();
99
- 

Return to bug 35657