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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/display_ticket.inc (+31 lines)
Line 0 Link Here
1
<!-- Display updates concern modal -->
2
<div class="modal" id="ticketDetailsModal" tabindex="-1" role="dialog" aria-labelledby="ticketDetailsLabel">
3
    <div class="modal-dialog modal-lg" role="document">
4
        <div class="modal-content">
5
            <div class="modal-header">
6
                <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
7
                <h4 class="modal-title" id="displayUpdateLabel">Ticket details</h4>
8
            </div>
9
            <div class="modal-body">
10
                <div id="concern-details"></div>
11
                <fieldset class="rows">
12
                    <ol>
13
                        <li>
14
                            <label for="message">Update: </label>
15
                            <textarea id="update_message" name="message"></textarea>
16
                        </li>
17
                        <li>
18
                            <label for="public">Notify: </label>
19
                            <input type="checkbox" name="public" id="public">
20
                        </li>
21
                    </ol>
22
                </fieldset>
23
            </div> <!-- /.modal-body -->
24
            <div class="modal-footer">
25
                <input type="hidden" name="ticket_id" id="ticket_id">
26
                <button type="button" class="btn btn-default" id="resolveTicket">Resolve <i id="resolve-spinner" class="fa fa-spinner pa-pulse fa-fw" style="display:none"></i></button>
27
                <button type="submit" class="btn btn-primary" id="updateTicket">Comment <i id="comment-spinner" class="fa fa-spinner pa-pulse fa-fw" style="display:none"></i></button>
28
            </div> <!-- /.modal-footer -->
29
        </div> <!-- /.modal-content -->
30
    </div> <!-- /.modal-dialog -->
31
</div> <!-- /#displayUpdateModal -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (+177 lines)
Lines 299-304 Link Here
299
[% IF Koha.Preference('AcquisitionDetails') %]<li role="presentation"><a href="#acq_details"  aria-controls="acq_details" role="tab" data-toggle="tab">Acquisition details</a></li>[% END %]
299
[% IF Koha.Preference('AcquisitionDetails') %]<li role="presentation"><a href="#acq_details"  aria-controls="acq_details" role="tab" data-toggle="tab">Acquisition details</a></li>[% END %]
300
[% IF suggestions.count %]<li role="presentation"><a href="#suggestion_details"  aria-controls="suggestion_details" role="tab" data-toggle="tab">Suggestion details</a></li>[% END %]
300
[% IF suggestions.count %]<li role="presentation"><a href="#suggestion_details"  aria-controls="suggestion_details" role="tab" data-toggle="tab">Suggestion details</a></li>[% END %]
301
[% IF ( FRBRizeEditions ) %][% IF ( XISBNS ) %]<li role="presentation"><a href="#editions"  aria-controls="editions" role="tab" data-toggle="tab">Editions</a></li>[% END %][% END %]
301
[% IF ( FRBRizeEditions ) %][% IF ( XISBNS ) %]<li role="presentation"><a href="#editions"  aria-controls="editions" role="tab" data-toggle="tab">Editions</a></li>[% END %][% END %]
302
[% IF ( Koha.Preference('CatalogConcerns') || Koha.Preference('OpacCatalogConcerns') ) %]<li role="presentation"><a href="#concerns" aria-controls="concerns" role="tab" data-toggle="tab">Concerns ([% biblio.tickets.count | html %])</a></li>[% END %]
302
[% IF ( LocalCoverImages ) %]
303
[% IF ( LocalCoverImages ) %]
303
    <li role="presentation">
304
    <li role="presentation">
304
        <a href="#images"  aria-controls="images" role="tab" data-toggle="tab">Images ([% localimages.count || 0 | html %])</a>
305
        <a href="#images"  aria-controls="images" role="tab" data-toggle="tab">Images ([% localimages.count || 0 | html %])</a>
Lines 1000-1005 Note that permanent location is a code, and location may be an authval. Link Here
1000
</table></div>[% END %]
1001
</table></div>[% END %]
1001
[% END %]
1002
[% END %]
1002
1003
1004
[% IF ( Koha.Prefernce('CatalogConcerns') || Koha.Preference('OpacCatalogConcerns') ) %]
1005
<div role="tabpanel" class="tab-pane" id="concerns">
1006
    <fieldset class="action" style="cursor:pointer;">
1007
        <a id="hideResolved"><i class="fa fa-minus-square"></i> Hide resolved</a>
1008
        | <a id="showAll"><i class="fa fa-bars"></i> Show all</a>
1009
    </fieldset>
1010
1011
    <table id="table_concerns" width="100%">
1012
        <thead>
1013
            <tr>
1014
                <th>Reported</th>
1015
                <th>Details</th>
1016
                <th>Status</th>
1017
                <th data-class-name="actions noExport">Actions</th>
1018
            </tr>
1019
        </thead>
1020
    </table>
1021
1022
    <!-- Resolve concern modal -->
1023
    <div class="modal" id="resolveConcernModal" tabindex="-1" role="dialog" aria-labelledby="resolveConcernLabel">
1024
        <div class="modal-dialog" role="document">
1025
            <div class="modal-content">
1026
                <div class="modal-header">
1027
                    <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
1028
                    <h4 class="modal-title" id="resolveConcernLabel">Resolve concern</h4>
1029
                </div>
1030
                <div class="modal-body">
1031
                    <fieldset class="rows">
1032
                        <ol>
1033
                            <li>
1034
                                <label for="notify">Notify: </label>
1035
                                <input type="checkbox" name="notify" id="resolve_notify">
1036
                            </li>
1037
                            <li>
1038
                                <label for="message">Resolution: </label>
1039
                                <textarea id="resolve_message" name="message"></textarea>
1040
                                <p id="helpBlock" class="help-block">Optional message to include with the notification to the reporter</p>
1041
1042
                            </li>
1043
                        </ol>
1044
                    </fieldset>
1045
                </div> <!-- /.modal-body -->
1046
                <div class="modal-footer">
1047
                    <input type="hidden" name="concern_id" id="concern_id">
1048
                    <button type="submit" class="btn btn-default" id="resolveConfirm">Confirm</button>
1049
                    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
1050
                </div> <!-- /.modal-footer -->
1051
            </div> <!-- /.modal-content -->
1052
        </div> <!-- /.modal-dialog -->
1053
    </div> <!-- /#resolveConcernModal -->
1054
</div>
1055
[% END %]
1056
1003
[% IF ( LocalCoverImages ) %]
1057
[% IF ( LocalCoverImages ) %]
1004
    <div role="tabpanel" class="tab-pane" id="images">
1058
    <div role="tabpanel" class="tab-pane" id="images">
1005
        [% IF localimages.count %]
1059
        [% IF localimages.count %]
Lines 1301-1306 Note that permanent location is a code, and location may be an authval. Link Here
1301
1355
1302
    [% IF ( Koha.Preference('CatalogConcerns') ) %]
1356
    [% IF ( Koha.Preference('CatalogConcerns') ) %]
1303
    [% INCLUDE 'modals/add_catalog_concern.inc' %]
1357
    [% INCLUDE 'modals/add_catalog_concern.inc' %]
1358
    [% INCLUDE 'modals/display_ticket.inc' %]
1304
    [% END %]
1359
    [% END %]
1305
1360
1306
[% MACRO jsinclude BLOCK %]
1361
[% MACRO jsinclude BLOCK %]
Lines 1313-1320 Note that permanent location is a code, and location may be an authval. Link Here
1313
        <script>
1368
        <script>
1314
            /* Set a variable needed by add_catalog_concern.js */
1369
            /* Set a variable needed by add_catalog_concern.js */
1315
            var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";
1370
            var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";
1371
1372
            $(document).ready(function() {
1373
                var table_settings = [% TablesSettings.GetTableSettings( 'cataloguing', 'concerns', 'table_concerns', 'json' ) | $raw %];
1374
1375
                var tickets_url = '/api/v1/tickets';
1376
                var tickets = $("#table_concerns").kohaTable({
1377
                    "ajax": {
1378
                        "url": tickets_url
1379
                    },
1380
                    "embed": [
1381
                        "reporter",
1382
                        "resolver",
1383
                        "updates+count",
1384
                    ],
1385
                    'emptyTable': '<div class="dialog message">' + _("Congradulations, there are no catalog concerns.") + '</div>',
1386
                    "columnDefs": [ {
1387
                        "targets": [0,1,2],
1388
                        "render": function (data, type, row, meta) {
1389
                            if ( type == 'display' ) {
1390
                                if ( data != null ) {
1391
                                    return data.escapeHtml();
1392
                                }
1393
                                else {
1394
                                    return "";
1395
                                }
1396
                            }
1397
                            return data;
1398
                        }
1399
                    } ],
1400
                    "columns": [
1401
                        {
1402
                            "data": "reported_date:reporter.firstname",
1403
                            "render": function(data, type, row, meta) {
1404
                                let reported = '<span class="date clearfix">' + $datetime(row.reported_date) + '</span>';
1405
                                reported += '<span class="reporter clearfix">' + $patron_to_html(row.reporter, {
1406
                                    display_cardnumber: false,
1407
                                    url: true
1408
                                }) + '</span>';
1409
                                return reported;
1410
                            },
1411
                            "searchable": true,
1412
                            "orderable": true
1413
                        },
1414
                        {
1415
                            "data": "title:body",
1416
                            "render": function(data, type, row, meta) {
1417
                                let result = '<a role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '">' + row.title + '</a>';
1418
                                if (row.updates_count) {
1419
                                    result += '<span class="pull-right"><a role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '"><i class="fa fa-comment" aria-hidden="true"></i> ' + row.updates_count + '</a></span>';
1420
                                }
1421
                                result += '<div id="detail_' + row.ticket_id + '" class="hidden">' + row.body + '</div>';
1422
                                return result;
1423
                            },
1424
                            "searchable": true,
1425
                            "orderable": true
1426
                        },
1427
                        {
1428
                            "data": "resolved_date",
1429
                            "render": function(data, type, row, meta) {
1430
                                let result = '';
1431
                                if (row.resolved_date) {
1432
                                    result += _("Resolved by:") + ' <span>' + $patron_to_html(row.resolver, {
1433
                                        display_cardnumber: false,
1434
                                        url: true
1435
                                    }) + '</span>';
1436
                                    result += '<span class="clearfix">' + $datetime(row.resolved_date) + '</span>';
1437
                                } else {
1438
                                    result += _("Open");
1439
                                }
1440
                                return result;
1441
                            },
1442
                            "searchable": true,
1443
                            "orderable": true
1444
                        },
1445
                        {
1446
                            "data": function(row, type, val, meta) {
1447
                                let result = '<a class="btn btn-default btn-xs" role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '"><i class="fa fa-eye" aria-hidden="true"></i> ' + _("Details") + '</a>';
1448
                                return result;
1449
                            },
1450
                            "searchable": false,
1451
                            "orderable": false
1452
                        },
1453
                    ]
1454
                }, table_settings, 0, { biblio_id: [% biblionumber | uri %]});
1455
1456
                $('#hideResolved').on( "click", function() {
1457
                    // It would be great if we could pass null here but it gets stringified
1458
                    concerns.DataTable().columns('3').search('special:undefined').draw();
1459
                });
1460
1461
                $('#showAll').on( "click", function() {
1462
                    concerns.DataTable().columns('3').search('').draw();
1463
                });
1464
1465
                $('#resolveConcernModal').on('show.bs.modal', function (event) {
1466
                      let modal = $(this);
1467
                      let button = $(event.relatedTarget);
1468
                      let concern = button.data('concern');
1469
1470
                      modal.find('.modal-footer input').val(concern)
1471
                });
1472
1473
                $('#resolveConcernModal').on('click', '#resolveConfirm', function(e) {
1474
                    let concern_id = $('#concern_id').val();
1475
                    let params = { notify: $('#resolve_notify').is(":checked"), message: $('#resolve_message').val() };
1476
1477
                    $.ajax({
1478
                        url: "/api/v1/tickets/"+concern_id+"/resolve",
1479
                        method: "POST",
1480
                        data: JSON.stringify(params)
1481
                    }).success(function() {
1482
                        $("#resolveConcernModal").modal('hide');
1483
                        concerns.DataTable().ajax.reload(function (data) {
1484
                            $("#concern_action_result_dialog").hide();
1485
                            $("#concern_delete_success").html(_("Concern #%s deleted successfully.").format(concern_id)).show();
1486
                        });
1487
                    }).error(function () {
1488
                        $("#concern_resolve_error").html(_("Error resolving concern #%s. Check the logs.").format(concern_id)).show();
1489
                    });
1490
                });
1491
            });
1316
        </script>
1492
        </script>
1317
        [% Asset.js("js/modals/add_catalog_concern.js") | $raw %]
1493
        [% Asset.js("js/modals/add_catalog_concern.js") | $raw %]
1494
        [% Asset.js("js/modals/display_ticket.js") | $raw %]
1318
    [% END %]
1495
    [% END %]
1319
    <script>
1496
    <script>
1320
        var interface = "[% interface | html %]";
1497
        var interface = "[% interface | html %]";
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt (-129 / +8 lines)
Lines 63-99 Link Here
63
            </div> <!-- /.col-sm-2.col-sm-pull-10 -->
63
            </div> <!-- /.col-sm-2.col-sm-pull-10 -->
64
        </div> <!-- /.row -->
64
        </div> <!-- /.row -->
65
65
66
        <!-- Display updates concern modal -->
66
        [% INCLUDE 'modals/display_ticket.inc' %]
67
        <div class="modal" id="ticketDetailsModal" tabindex="-1" role="dialog" aria-labelledby="ticketDetailsLabel">
68
            <div class="modal-dialog modal-lg" role="document">
69
                <div class="modal-content">
70
                    <div class="modal-header">
71
                        <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
72
                        <h4 class="modal-title" id="displayUpdateLabel">Ticket details</h4>
73
                    </div>
74
                    <div class="modal-body">
75
                        <div id="concern-details"></div>
76
                        <fieldset class="rows">
77
                            <ol>
78
                                <li>
79
                                    <label for="message">Update: </label>
80
                                    <textarea id="update_message" name="message"></textarea>
81
                                </li>
82
                                <li>
83
                                    <label for="public">Notify: </label>
84
                                    <input type="checkbox" name="public" id="public">
85
                                </li>
86
                            </ol>
87
                        </fieldset>
88
                    </div> <!-- /.modal-body -->
89
                    <div class="modal-footer">
90
                        <input type="hidden" name="ticket_id" id="ticket_id">
91
                        <button type="button" class="btn btn-default" id="resolveTicket">Resolve</button>
92
                        <button type="submit" class="btn btn-primary" id="updateTicket">Comment</button>
93
                    </div> <!-- /.modal-footer -->
94
                </div> <!-- /.modal-content -->
95
            </div> <!-- /.modal-dialog -->
96
        </div> <!-- /#displayUpdateModal -->
97
67
98
[% MACRO jsinclude BLOCK %]
68
[% MACRO jsinclude BLOCK %]
99
    [% INCLUDE 'datatables.inc' %]
69
    [% INCLUDE 'datatables.inc' %]
Lines 104-110 Link Here
104
    <script>
74
    <script>
105
        $(document).ready(function() {
75
        $(document).ready(function() {
106
76
107
            var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";
77
            logged_in_user_borrowernumber = [% logged_in_user.borrowernumber | html %];
108
78
109
            var table_settings = [% TablesSettings.GetTableSettings('cataloguing', 'concerns', 'table_concerns', 'json') | $raw %];
79
            var table_settings = [% TablesSettings.GetTableSettings('cataloguing', 'concerns', 'table_concerns', 'json') | $raw %];
110
80
Lines 149-157 Link Here
149
                    {
119
                    {
150
                        "data": "title:body",
120
                        "data": "title:body",
151
                        "render": function(data, type, row, meta) {
121
                        "render": function(data, type, row, meta) {
152
                            let result = '<a role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '">' + row.title + '</a>';
122
                            let resolved = ( row.resolved_date ) ? true : false;
123
                            let result = '<a role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '" data-resolved="'+resolved+'">' + row.title + '</a>';
153
                            if (row.updates_count) {
124
                            if (row.updates_count) {
154
                                result += '<span class="pull-right"><a role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '"><i class="fa fa-comment" aria-hidden="true"></i> ' + row.updates_count + '</a></span>';
125
                                result += '<span class="pull-right"><a role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '" data-resolved="'+resolved+'"><i class="fa fa-comment" aria-hidden="true"></i> ' + row.updates_count + '</a></span>';
155
                            }
126
                            }
156
                            result += '<div id="detail_' + row.ticket_id + '" class="hidden">' + row.body + '</div>';
127
                            result += '<div id="detail_' + row.ticket_id + '" class="hidden">' + row.body + '</div>';
157
                            return result;
128
                            return result;
Lines 189-195 Link Here
189
                    },
160
                    },
190
                    {
161
                    {
191
                        "data": function(row, type, val, meta) {
162
                        "data": function(row, type, val, meta) {
192
                            let result = '<a class="btn btn-default btn-xs" role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '"><i class="fa fa-eye" aria-hidden="true"></i> ' + _("Details") + '</a>';
163
                            let resolved = ( row.resolved_date ) ? true : false;
164
                            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 fa-eye" aria-hidden="true"></i> ' + _("Details") + '</a>';
193
                            return result;
165
                            return result;
194
                        },
166
                        },
195
                        "searchable": false,
167
                        "searchable": false,
Lines 206-306 Link Here
206
            $('#showAll').on("click", function() {
178
            $('#showAll').on("click", function() {
207
                tickets.DataTable().columns('3').search('').draw();
179
                tickets.DataTable().columns('3').search('').draw();
208
            });
180
            });
209
210
            $('#ticketDetailsModal').on('show.bs.modal', function(event) {
211
                let modal = $(this);
212
                let button = $(event.relatedTarget);
213
                let ticket_id = button.data('concern');
214
                modal.find('.modal-footer input').val(ticket_id);
215
216
                let detail = $('#detail_' + ticket_id).text();
217
218
                let display = '<div class="list-group">';
219
                display += '<div class="list-group-item">';
220
                display += '<span class="wrapfix">' + detail + '</span>';
221
                display += '</div>';
222
                display += '<div id="concern-updates" class="list-group-item">';
223
                display += '<span>Loading updates . . .</span>';
224
                display += '</div>';
225
                display += '</div>';
226
227
                let details = modal.find('#concern-details');
228
                details.html(display);
229
230
                $.ajax({
231
                    url: "/api/v1/tickets/" + ticket_id + "/updates",
232
                    method: "GET",
233
                    headers: {
234
                        "x-koha-embed": "user"
235
                    },
236
                }).success(function(data) {
237
                    let updates_display = $('#concern-updates');
238
                    let updates = '';
239
                    data.forEach(function(item, index) {
240
                        updates += '<div class="list-group-item">';
241
                        updates += '<span class="wrapfix">' + item.message + '</span>';
242
                        updates += '<span class="clearfix">' + $patron_to_html(item.user, {
243
                            display_cardnumber: false,
244
                            url: true
245
                        }) + ' (' + $datetime(item.date) + ')</span>';
246
                        updates += '</div>';
247
                    });
248
                    updates_display.html(updates);
249
                }).error(function() {
250
251
                });
252
            });
253
254
            $('#ticketDetailsModal').on('click', '#updateTicket', function(e) {
255
                let ticket_id = $('#ticket_id').val();
256
                let params = {
257
                    'public': $('#public').is(":checked"),
258
                    message: $('#update_message').val(),
259
                    user_id: logged_in_user_borrowernumber
260
                };
261
262
                $.ajax({
263
                    url: "/api/v1/tickets/" + ticket_id + "/updates",
264
                    method: "POST",
265
                    data: JSON.stringify(params),
266
                    ontentType: "application/json; charset=utf-8"
267
                }).success(function() {
268
                    $("#ticketDetailsModal").modal('hide');
269
                    tickets.DataTable().ajax.reload(function(data) {
270
                        $("#concern_action_result_dialog").hide();
271
                        $("#concern_delete_success").html(_("Concern #%s updated successfully.").format(ticket_id)).show();
272
                    });
273
                }).error(function() {
274
                    $("#concern_update_error").html(_("Error resolving concern #%s. Check the logs.").format(ticket_id)).show();
275
                });
276
            });
277
278
            $('#ticketDetailsModal').on('click', '#resolveTicket', function(e) {
279
                let ticket_id = $('#ticket_id').val();
280
                let params = {
281
                    'public': $('#public').is(":checked"),
282
                    message: $('#update_message').val(),
283
                    user_id: logged_in_user_borrowernumber,
284
                    state: 'resolved'
285
                };
286
287
                $.ajax({
288
                    url: "/api/v1/tickets/" + ticket_id + "/updates",
289
                    method: "POST",
290
                    data: JSON.stringify(params),
291
                    ontentType: "application/json; charset=utf-8"
292
                }).success(function() {
293
                    $("#ticketDetailsModal").modal('hide');
294
                    tickets.DataTable().ajax.reload(function(data) {
295
                        $("#concern_action_result_dialog").hide();
296
                        $("#concern_delete_success").html(_("Concern #%s updated successfully.").format(ticket_id)).show();
297
                    });
298
                }).error(function() {
299
                    $("#concern_update_error").html(_("Error resolving concern #%s. Check the logs.").format(ticket_id)).show();
300
                });
301
            });
302
303
        });
181
        });
304
    </script>
182
    </script>
183
    [% Asset.js("js/modals/display_ticket.js") | $raw %]
305
[% END %]
184
[% END %]
306
[% INCLUDE 'intranet-bottom.inc' %]
185
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js (-1 / +109 lines)
Line 0 Link Here
0
- 
1
$(document).ready(function() {
2
    $('#ticketDetailsModal').on('show.bs.modal', function(event) {
3
        let modal = $(this);
4
        let button = $(event.relatedTarget);
5
        let ticket_id = button.data('concern');
6
        let resolved  = button.data('resolved');
7
        modal.find('.modal-footer input').val(ticket_id);
8
9
        console.log(resolved);
10
11
        if ( resolved ) {
12
            $('#resolveTicket').hide();
13
        } else {
14
            $('#resolveTicket').show();
15
        }
16
17
        let detail = $('#detail_' + ticket_id).text();
18
19
        let display = '<div class="list-group">';
20
        display += '<div class="list-group-item">';
21
        display += '<span class="wrapfix">' + detail + '</span>';
22
        display += '</div>';
23
        display += '<div id="concern-updates" class="list-group-item">';
24
        display += '<span>Loading updates . . .</span>';
25
        display += '</div>';
26
        display += '</div>';
27
28
        let details = modal.find('#concern-details');
29
        details.html(display);
30
31
        $.ajax({
32
            url: "/api/v1/tickets/" + ticket_id + "/updates",
33
            method: "GET",
34
            headers: {
35
                "x-koha-embed": "user"
36
            },
37
        }).success(function(data) {
38
            let updates_display = $('#concern-updates');
39
            let updates = '';
40
            data.forEach(function(item, index) {
41
                updates += '<div class="list-group-item">';
42
                updates += '<span class="wrapfix">' + item.message + '</span>';
43
                updates += '<span class="clearfix">' + $patron_to_html(item.user, {
44
                    display_cardnumber: false,
45
                    url: true
46
                }) + ' (' + $datetime(item.date) + ')</span>';
47
                updates += '</div>';
48
            });
49
            updates_display.html(updates);
50
        }).error(function() {
51
52
        });
53
    });
54
55
    $('#ticketDetailsModal').on('click', '#updateTicket', function(e) {
56
        let ticket_id = $('#ticket_id').val();
57
        let params = {
58
            'public': $('#public').is(":checked"),
59
            message: $('#update_message').val(),
60
            user_id: logged_in_user_borrowernumber
61
        };
62
63
        $('#comment-spinner').show();
64
65
        $.ajax({
66
            url: "/api/v1/tickets/" + ticket_id + "/updates",
67
            method: "POST",
68
            data: JSON.stringify(params),
69
            ontentType: "application/json; charset=utf-8"
70
        }).success(function() {
71
            $('#comment-spinner').hide();
72
            $("#ticketDetailsModal").modal('hide');
73
            $('#table_concerns').DataTable().ajax.reload(function(data) {
74
                $("#concern_action_result_dialog").hide();
75
                $("#concern_delete_success").html(_("Concern #%s updated successfully.").format(ticket_id)).show();
76
            });
77
        }).error(function() {
78
            $("#concern_update_error").html(_("Error resolving concern #%s. Check the logs.").format(ticket_id)).show();
79
        });
80
    });
81
82
    $('#ticketDetailsModal').on('click', '#resolveTicket', function(e) {
83
        let ticket_id = $('#ticket_id').val();
84
        let params = {
85
            'public': $('#public').is(":checked"),
86
            message: $('#update_message').val(),
87
            user_id: logged_in_user_borrowernumber,
88
            state: 'resolved'
89
        };
90
91
        $('#resolve-spinner').show();
92
93
        $.ajax({
94
            url: "/api/v1/tickets/" + ticket_id + "/updates",
95
            method: "POST",
96
            data: JSON.stringify(params),
97
            ontentType: "application/json; charset=utf-8"
98
        }).success(function() {
99
            $('#resolve-spinner').hide();
100
            $("#ticketDetailsModal").modal('hide');
101
            $('#table_concerns').DataTable().ajax.reload(function(data) {
102
                $("#concern_action_result_dialog").hide();
103
                $("#concern_delete_success").html(_("Concern #%s updated successfully.").format(ticket_id)).show();
104
            });
105
        }).error(function() {
106
            $("#concern_update_error").html(_("Error resolving concern #%s. Check the logs.").format(ticket_id)).show();
107
        });
108
    });
109
});

Return to bug 31028