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>
12
                    <ol>
13
                        <li class="form-group">
14
                            <label for="message">Update: </label>
15
                            <textarea id="update_message" class="form-control" name="message"></textarea>
16
                        </li>
17
                        <li class="rows">
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 fa-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 fa-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 (+125 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') ) && CAN_user_editcatalogue_edit_catalogue ) %]<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 1005-1010 Note that permanent location is a code, and location may be an authval. Link Here
1005
</table></div>[% END %]
1006
</table></div>[% END %]
1006
[% END %]
1007
[% END %]
1007
1008
1009
[% IF ( ( Koha.Preference('CatalogConcerns') || Koha.Preference('OpacCatalogConcerns') ) && CAN_user_editcatalogue_edit_catalogue ) %]
1010
<div role="tabpanel" class="tab-pane" id="concerns">
1011
    <fieldset class="action" style="cursor:pointer;">
1012
        <a id="hideResolved"><i class="fa fa-minus-square"></i> Hide resolved</a>
1013
        | <a id="showAll"><i class="fa fa-bars"></i> Show all</a>
1014
    </fieldset>
1015
1016
    <table id="table_concerns" width="100%">
1017
        <thead>
1018
            <tr>
1019
                <th>Reported</th>
1020
                <th>Details</th>
1021
                <th>Status</th>
1022
                <th data-class-name="actions noExport">Actions</th>
1023
            </tr>
1024
        </thead>
1025
    </table>
1026
</div>
1027
[% END %]
1028
1008
[% IF ( LocalCoverImages ) %]
1029
[% IF ( LocalCoverImages ) %]
1009
    <div role="tabpanel" class="tab-pane" id="images">
1030
    <div role="tabpanel" class="tab-pane" id="images">
1010
        [% IF localimages.count %]
1031
        [% IF localimages.count %]
Lines 1308-1313 Note that permanent location is a code, and location may be an authval. Link Here
1308
    [% INCLUDE 'modals/add_catalog_concern.inc' %]
1329
    [% INCLUDE 'modals/add_catalog_concern.inc' %]
1309
    [% END %]
1330
    [% END %]
1310
1331
1332
    [% IF ( ( Koha.Preference('CatalogConcerns') || Koha.Preference('OpacCatalogConcerns') ) && CAN_user_editcatalogue_edit_catalogue ) %]
1333
    [% INCLUDE 'modals/display_ticket.inc' %]
1334
    [% END %]
1335
1311
[% MACRO jsinclude BLOCK %]
1336
[% MACRO jsinclude BLOCK %]
1312
    [% INCLUDE 'catalog-strings.inc' %]
1337
    [% INCLUDE 'catalog-strings.inc' %]
1313
    [% Asset.js("js/catalog.js") | $raw %]
1338
    [% Asset.js("js/catalog.js") | $raw %]
Lines 1320-1325 Note that permanent location is a code, and location may be an authval. Link Here
1320
            var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";
1345
            var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";
1321
        </script>
1346
        </script>
1322
        [% Asset.js("js/modals/add_catalog_concern.js") | $raw %]
1347
        [% Asset.js("js/modals/add_catalog_concern.js") | $raw %]
1348
     [% END %]
1349
     [% IF ( ( Koha.Preference('CatalogConcerns') || Koha.Preference('OpacCatalogConcerns') ) && CAN_user_editcatalogue_edit_catalogue ) %]
1350
         <script>
1351
            $(document).ready(function() {
1352
                var table_settings = [% TablesSettings.GetTableSettings( 'cataloguing', 'concerns', 'table_concerns', 'json' ) | $raw %];
1353
1354
                var tickets_url = '/api/v1/tickets';
1355
                var tickets = $("#table_concerns").kohaTable({
1356
                    "ajax": {
1357
                        "url": tickets_url
1358
                    },
1359
                    "embed": [
1360
                        "reporter",
1361
                        "resolver",
1362
                        "updates+count",
1363
                    ],
1364
                    'emptyTable': '<div class="dialog message">' + _("Congradulations, there are no catalog concerns.") + '</div>',
1365
                    "columnDefs": [ {
1366
                        "targets": [0,1,2],
1367
                        "render": function (data, type, row, meta) {
1368
                            if ( type == 'display' ) {
1369
                                if ( data != null ) {
1370
                                    return data.escapeHtml();
1371
                                }
1372
                                else {
1373
                                    return "";
1374
                                }
1375
                            }
1376
                            return data;
1377
                        }
1378
                    } ],
1379
                    "columns": [
1380
                        {
1381
                            "data": "reported_date:reporter.firstname",
1382
                            "render": function(data, type, row, meta) {
1383
                                let reported = '<span class="date clearfix">' + $datetime(row.reported_date) + '</span>';
1384
                                reported += '<span class="reporter clearfix">' + $patron_to_html(row.reporter, {
1385
                                    display_cardnumber: false,
1386
                                    url: true
1387
                                }) + '</span>';
1388
                                return reported;
1389
                            },
1390
                            "searchable": true,
1391
                            "orderable": true
1392
                        },
1393
                        {
1394
                            "data": "title:body",
1395
                            "render": function(data, type, row, meta) {
1396
                                let resolved = ( row.resolved_date ) ? true : false;
1397
                                let result = '<a role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '" data-resolved="' + resolved + '">' + row.title + '</a>';
1398
                                if (row.updates_count) {
1399
                                    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>';
1400
                                }
1401
                                result += '<div id="detail_' + row.ticket_id + '" class="hidden">' + row.body + '</div>';
1402
                                return result;
1403
                            },
1404
                            "searchable": true,
1405
                            "orderable": true
1406
                        },
1407
                        {
1408
                            "data": "resolved_date",
1409
                            "render": function(data, type, row, meta) {
1410
                                let result = '';
1411
                                if (row.resolved_date) {
1412
                                    result += _("Resolved by:") + ' <span>' + $patron_to_html(row.resolver, {
1413
                                        display_cardnumber: false,
1414
                                        url: true
1415
                                    }) + '</span>';
1416
                                    result += '<span class="clearfix">' + $datetime(row.resolved_date) + '</span>';
1417
                                } else {
1418
                                    result += _("Open");
1419
                                }
1420
                                return result;
1421
                            },
1422
                            "searchable": true,
1423
                            "orderable": true
1424
                        },
1425
                        {
1426
                            "data": function(row, type, val, meta) {
1427
                                let resolved = ( row.resolved_date ) ? true : false;
1428
                                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>';
1429
                                return result;
1430
                            },
1431
                            "searchable": false,
1432
                            "orderable": false
1433
                        },
1434
                    ]
1435
                }, table_settings, 0, { biblio_id: [% biblionumber | uri %]});
1436
1437
                $('#hideResolved').on( "click", function() {
1438
                    // It would be great if we could pass null here but it gets stringified
1439
                    concerns.DataTable().columns('3').search('special:undefined').draw();
1440
                });
1441
1442
                $('#showAll').on( "click", function() {
1443
                    concerns.DataTable().columns('3').search('').draw();
1444
                });
1445
            });
1446
        </script>
1447
        [% Asset.js("js/modals/display_ticket.js") | $raw %]
1323
    [% END %]
1448
    [% END %]
1324
    <script>
1449
    <script>
1325
        var interface = "[% interface | html %]";
1450
        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/en/modules/intranet-main.tt (-1 / +1 lines)
Lines 177-183 Link Here
177
                <div class="row">
177
                <div class="row">
178
                    <div class="col-sm-12">
178
                    <div class="col-sm-12">
179
                        [%# Following statement must be in one line for translatability %]
179
                        [%# Following statement must be in one line for translatability %]
180
                        [% IF ( CAN_user_tools_moderate_comments  && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) || ( CAN_user_borrowers_edit_borrowers && pending_borrower_modifications ) || ( CAN_user_suggestions_suggestions_manage && ( pendingsuggestions || all_pendingsuggestions )) || ( CAN_user_borrowers_edit_borrowers && pending_discharge_requests ) || pending_article_requests || ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes.count ) || ( ( Koha.preference('OpacCatalogConcerns') || Koha.Preference('CatalogConcerns') ) && pending_biblio_tickets && CAN_user_editcatalogue_edit_catalogue ) || ( Koha.Preference('OPACReportProblem') && CAN_user_problem_reports && pending_problem_reports.count ) || already_ran_jobs || new_curbside_pickups.count %]
180
                        [% IF ( CAN_user_tools_moderate_comments  && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) || ( CAN_user_borrowers_edit_borrowers && pending_borrower_modifications ) || ( CAN_user_suggestions_suggestions_manage && ( pendingsuggestions || all_pendingsuggestions )) || ( CAN_user_borrowers_edit_borrowers && pending_discharge_requests ) || pending_article_requests || ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes.count ) || ( ( Koha.Preference('OpacCatalogConcerns') || Koha.Preference('CatalogConcerns') ) && pending_biblio_tickets && CAN_user_editcatalogue_edit_catalogue ) || ( Koha.Preference('OPACReportProblem') && CAN_user_problem_reports && pending_problem_reports.count ) || already_ran_jobs || new_curbside_pickups.count %]
181
                            <div id="area-pending" class="page-section">
181
                            <div id="area-pending" class="page-section">
182
                                [% IF pending_article_requests %]
182
                                [% IF pending_article_requests %]
183
                                <div class="pending-info" id="article_requests_pending">
183
                                <div class="pending-info" id="article_requests_pending">
(-)a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js (-1 / +120 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
        if ( resolved ) {
10
            $('#resolveTicket').hide();
11
        } else {
12
            $('#resolveTicket').show();
13
        }
14
15
        let detail = $('#detail_' + ticket_id).text();
16
17
        // Display ticket details
18
        let display = '<div class="list-group">';
19
        display += '<div class="list-group-item">';
20
        display += '<span class="wrapfix">' + detail + '</span>';
21
        display += '</div>';
22
        display += '<div id="concern-updates" class="list-group-item">';
23
        display += '<span>' + __("Loading updates . . .") + '</span>';
24
        display += '</div>';
25
        display += '</div>';
26
27
        let details = modal.find('#concern-details');
28
        details.html(display);
29
30
        // Load any existing updates
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
                if ( item.public ) {
42
                    updates += '<div class="list-group-item list-group-item-success">';
43
                    updates += '<span class="pull-right">' + __("Public") + '</span>';
44
                }
45
                else {
46
                    updates += '<div class="list-group-item list-group-item-warning">';
47
                    updates += '<span class="pull-right">' + __("Private") + '</span>';
48
                }
49
                updates += '<span class="wrapfix">' + item.message + '</span>';
50
                updates += '<span class="clearfix">' + $patron_to_html(item.user, {
51
                    display_cardnumber: false,
52
                    url: true
53
                }) + ' (' + $datetime(item.date) + ')</span>';
54
                updates += '</div>';
55
            });
56
            updates_display.html(updates);
57
        }).error(function() {
58
59
        });
60
61
        // Clear any previously entered update message
62
        $('#update_message').val('');
63
        $('#public').prop( "checked", false );
64
    });
65
66
    $('#ticketDetailsModal').on('click', '#updateTicket', function(e) {
67
        let ticket_id = $('#ticket_id').val();
68
        let params = {
69
            'public': $('#public').is(":checked"),
70
            message: $('#update_message').val(),
71
            user_id: logged_in_user_borrowernumber
72
        };
73
74
        $('#comment-spinner').show();
75
76
        $.ajax({
77
            url: "/api/v1/tickets/" + ticket_id + "/updates",
78
            method: "POST",
79
            data: JSON.stringify(params),
80
            ontentType: "application/json; charset=utf-8"
81
        }).success(function() {
82
            $('#comment-spinner').hide();
83
            $('#ticketDetailsModal').modal('hide');
84
            $('#table_concerns').DataTable().ajax.reload(function(data) {
85
                $("#concern_action_result_dialog").hide();
86
                $("#concern_delete_success").html(__("Concern #%s updated successfully.").format(ticket_id)).show();
87
            });
88
        }).error(function() {
89
            $("#concern_update_error").html(__("Error resolving concern #%s. Check the logs.").format(ticket_id)).show();
90
        });
91
    });
92
93
    $('#ticketDetailsModal').on('click', '#resolveTicket', function(e) {
94
        let ticket_id = $('#ticket_id').val();
95
        let params = {
96
            'public': $('#public').is(":checked"),
97
            message: $('#update_message').val(),
98
            user_id: logged_in_user_borrowernumber,
99
            state: 'resolved'
100
        };
101
102
        $('#resolve-spinner').show();
103
104
        $.ajax({
105
            url: "/api/v1/tickets/" + ticket_id + "/updates",
106
            method: "POST",
107
            data: JSON.stringify(params),
108
            ontentType: "application/json; charset=utf-8"
109
        }).success(function() {
110
            $('#resolve-spinner').hide();
111
            $("#ticketDetailsModal").modal('hide');
112
            $('#table_concerns').DataTable().ajax.reload(function(data) {
113
                $("#concern_action_result_dialog").hide();
114
                $("#concern_delete_success").html(__("Concern #%s updated successfully.").format(ticket_id)).show();
115
            });
116
        }).error(function() {
117
            $("#concern_update_error").html(__("Error resolving concern #%s. Check the logs.").format(ticket_id)).show();
118
        });
119
    });
120
});

Return to bug 31028