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

(-)a/koha-tmpl/intranet-tmpl/prog/js/modals/add_catalog_concern.js (-27 / +36 lines)
Lines 1-21 Link Here
1
/* keep tidy */
1
/* keep tidy */
2
$(document).ready(function() {
2
$(document).ready(function () {
3
4
    // Pre-populate empty message with template
3
    // Pre-populate empty message with template
5
    $('#addConcernModal').on('show.bs.modal', function (e) {
4
    $("#addConcernModal").on("show.bs.modal", function (e) {
6
        $('#addConfirm').prop('disabled', false);
5
        $("#addConfirm").prop("disabled", false);
7
        let concern_body = $('#concern_body');
6
        let concern_body = $("#concern_body");
8
        if ( concern_body.val() === "" ) {
7
        if (concern_body.val() === "") {
9
            let template = $('#concern_template').text();
8
            let template = $("#concern_template").text();
10
            concern_body.val(template);
9
            concern_body.val(template);
11
        }
10
        }
12
    });
11
    });
13
12
14
    $('#addConcernModal').on('click', '#addConfirm', function(e) {
13
    $("#addConcernModal").on("click", "#addConfirm", function (e) {
15
        let concern_title = $('#concern_title').val();
14
        let concern_title = $("#concern_title").val();
16
        let concern_body = $('#concern_body').val();
15
        let concern_body = $("#concern_body").val();
17
        let biblio_id = $('#concern_biblio').val();
16
        let biblio_id = $("#concern_biblio").val();
18
        let reporter_id = $('#concern_reporter').val();
17
        let reporter_id = $("#concern_reporter").val();
19
18
20
        let params = {
19
        let params = {
21
            source: 'catalog',
20
            source: 'catalog',
Lines 25-53 $(document).ready(function() { Link Here
25
            reporter_id: logged_in_user_borrowernumber,
24
            reporter_id: logged_in_user_borrowernumber,
26
        };
25
        };
27
26
28
        $('#concern-submit-spinner').show();
27
        $("#concern-submit-spinner").show();
29
        $('#addConfirm').prop('disabled', true);
28
        $("#addConfirm").prop("disabled", true);
30
29
31
        $.ajax({
30
        $.ajax({
32
            url: '/api/v1/tickets',
31
            url: "/api/v1/tickets",
33
            type: 'POST',
32
            type: "POST",
34
            data: JSON.stringify(params),
33
            data: JSON.stringify(params),
35
            success: function(data) {
34
            success: function (data) {
36
                $('#concern-submit-spinner').hide();
35
                $("#concern-submit-spinner").hide();
37
                $('#addConcernModal').modal('hide');
36
                $("#addConcernModal").modal("hide");
38
                $('#concern_body').val('');
37
                $("#concern_body").val("");
39
                $('#concern_title').val('');
38
                $("#concern_title").val("");
40
                $('#toolbar').before('<div class="dialog message">' + __("Your concern was successfully submitted.") + '</div>');
39
                $("#toolbar").before(
40
                    '<div class="dialog message">' +
41
                        __("Your concern was successfully submitted.") +
42
                        "</div>",
43
                );
41
                if ($.fn.dataTable.isDataTable("#table_concerns")) {
44
                if ($.fn.dataTable.isDataTable("#table_concerns")) {
42
                    $("#table_concerns").DataTable().ajax.reload();
45
                    $("#table_concerns").DataTable().ajax.reload();
43
                }
46
                }
44
            },
47
            },
45
            error: function(data) {
48
            error: function (data) {
46
                $('#concern-submit-spinner').hide();
49
                $("#concern-submit-spinner").hide();
47
                $('#addConcernModal').modal('hide');
50
                $("#addConcernModal").modal("hide");
48
                $('#toolbar').before('<div class="dialog alert">' + __("There was an error when submitting your concern, please contact a librarian.") + '</div>');
51
                $("#toolbar").before(
52
                    '<div class="dialog alert">' +
53
                        __(
54
                            "There was an error when submitting your concern, please contact a librarian.",
55
                        ) +
56
                        "</div>",
57
                );
49
            },
58
            },
50
            contentType: "json"
59
            contentType: "json",
51
        });
60
        });
52
    });
61
    });
53
});
62
});
(-)a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js (-74 / +118 lines)
Lines 1-31 Link Here
1
/* keep tidy */
1
/* keep tidy */
2
$(document).ready(function() {
2
$(document).ready(function () {
3
    $('#ticketDetailsModal').on('show.bs.modal', function(event) {
3
    $("#ticketDetailsModal").on("show.bs.modal", function (event) {
4
        let modal = $(this);
4
        let modal = $(this);
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
        modal.find('.modal-footer input').val(ticket_id);
8
        modal.find(".modal-footer input").val(ticket_id);
9
9
10
        if ( resolved ) {
10
        if (resolved) {
11
            $('#resolveTicket').hide();
11
            $("#resolveTicket").hide();
12
        } else {
12
        } else {
13
            $('#resolveTicket').show();
13
            $("#resolveTicket").show();
14
        }
14
        }
15
15
16
        let detail = $('#detail_' + ticket_id).text();
16
        let detail = $("#detail_" + ticket_id).text();
17
17
18
        // Display ticket details
18
        // Display ticket details
19
        let display = '<div class="list-group">';
19
        let display = '<div class="list-group">';
20
        display += '<div class="list-group-item">';
20
        display += '<div class="list-group-item">';
21
        display += '<span class="wrapfix">' + detail + '</span>';
21
        display += '<span class="wrapfix">' + detail + "</span>";
22
        display += '</div>';
22
        display += "</div>";
23
        display += '<div id="concern-updates" class="list-group-item">';
23
        display += '<div id="concern-updates" class="list-group-item">';
24
        display += '<span>' + __("Loading updates . . .") + '</span>';
24
        display += "<span>" + __("Loading updates . . .") + "</span>";
25
        display += '</div>';
25
        display += "</div>";
26
        display += '</div>';
26
        display += "</div>";
27
27
28
        let details = modal.find('#concern-details');
28
        let details = modal.find("#concern-details");
29
        details.html(display);
29
        details.html(display);
30
30
31
        // Load any existing updates
31
        // Load any existing updates
Lines 33-121 $(document).ready(function() { Link Here
33
            url: "/api/v1/tickets/" + ticket_id + "/updates",
33
            url: "/api/v1/tickets/" + ticket_id + "/updates",
34
            method: "GET",
34
            method: "GET",
35
            headers: {
35
            headers: {
36
                "x-koha-embed": "user"
36
                "x-koha-embed": "user",
37
            },
37
            },
38
        }).success(function(data) {
38
        })
39
            let updates_display = $('#concern-updates');
39
            .success(function (data) {
40
            let updates = '';
40
                let updates_display = $("#concern-updates");
41
            data.forEach(function(item, index) {
41
                let updates = "";
42
                if ( item.public ) {
42
                data.forEach(function (item, index) {
43
                    updates += '<div class="list-group-item list-group-item-success">';
43
                    if (item.public) {
44
                    updates += '<span class="pull-right">' + __("Public") + '</span>';
44
                        updates +=
45
                }
45
                            '<div class="list-group-item list-group-item-success">';
46
                else {
46
                        updates +=
47
                    updates += '<div class="list-group-item list-group-item-warning">';
47
                            '<span class="pull-right">' +
48
                    updates += '<span class="pull-right">' + __("Private") + '</span>';
48
                            __("Public") +
49
                }
49
                            "</span>";
50
                updates += '<span class="wrapfix">' + item.message + '</span>';
50
                    } else {
51
                updates += '<span class="clearfix">' + $patron_to_html(item.user, {
51
                        updates +=
52
                    display_cardnumber: false,
52
                            '<div class="list-group-item list-group-item-warning">';
53
                    url: true
53
                        updates +=
54
                }) + ' (' + $datetime(item.date) + ')</span>';
54
                            '<span class="pull-right">' +
55
                updates += '</div>';
55
                            __("Private") +
56
            });
56
                            "</span>";
57
            updates_display.html(updates);
57
                    }
58
        }).error(function() {
58
                    updates +=
59
59
                        '<span class="wrapfix">' + item.message + "</span>";
60
        });
60
                    updates +=
61
                        '<span class="clearfix">' +
62
                        $patron_to_html(item.user, {
63
                            display_cardnumber: false,
64
                            url: true,
65
                        }) +
66
                        " (" +
67
                        $datetime(item.date) +
68
                        ")</span>";
69
                    updates += "</div>";
70
                });
71
                updates_display.html(updates);
72
            })
73
            .error(function () {});
61
74
62
        // Clear any previously entered update message
75
        // Clear any previously entered update message
63
        $('#update_message').val('');
76
        $("#update_message").val("");
64
        $('#public').prop( "checked", false );
77
        $("#public").prop("checked", false);
65
    });
78
    });
66
79
67
    $('#ticketDetailsModal').on('click', '#updateTicket', function(e) {
80
    $("#ticketDetailsModal").on("click", "#updateTicket", function (e) {
68
        let ticket_id = $('#ticket_id').val();
81
        let ticket_id = $("#ticket_id").val();
69
        let params = {
82
        let params = {
70
            'public': $('#public').is(":checked"),
83
            public: $("#public").is(":checked"),
71
            message: $('#update_message').val(),
84
            message: $("#update_message").val(),
72
            user_id: logged_in_user_borrowernumber
85
            user_id: logged_in_user_borrowernumber,
73
        };
86
        };
74
87
75
        $('#comment-spinner').show();
88
        $("#comment-spinner").show();
76
89
77
        $.ajax({
90
        $.ajax({
78
            url: "/api/v1/tickets/" + ticket_id + "/updates",
91
            url: "/api/v1/tickets/" + ticket_id + "/updates",
79
            method: "POST",
92
            method: "POST",
80
            data: JSON.stringify(params),
93
            data: JSON.stringify(params),
81
            ontentType: "application/json; charset=utf-8"
94
            ontentType: "application/json; charset=utf-8",
82
        }).success(function() {
95
        })
83
            $('#comment-spinner').hide();
96
            .success(function () {
84
            $('#ticketDetailsModal').modal('hide');
97
                $("#comment-spinner").hide();
85
            $('#table_concerns').DataTable().ajax.reload(function(data) {
98
                $("#ticketDetailsModal").modal("hide");
86
                $("#concern_action_result_dialog").hide();
99
                $("#table_concerns")
87
                $("#concern_delete_success").html(__("Concern #%s updated successfully.").format(ticket_id)).show();
100
                    .DataTable()
101
                    .ajax.reload(function (data) {
102
                        $("#concern_action_result_dialog").hide();
103
                        $("#concern_delete_success")
104
                            .html(
105
                                __("Concern #%s updated successfully.").format(
106
                                    ticket_id,
107
                                ),
108
                            )
109
                            .show();
110
                    });
111
            })
112
            .error(function () {
113
                $("#concern_update_error")
114
                    .html(
115
                        __(
116
                            "Error resolving concern #%s. Check the logs for details.",
117
                        ).format(ticket_id),
118
                    )
119
                    .show();
88
            });
120
            });
89
        }).error(function() {
90
            $("#concern_update_error").html(__("Error resolving concern #%s. Check the logs for details.").format(ticket_id)).show();
91
        });
92
    });
121
    });
93
122
94
    $('#ticketDetailsModal').on('click', '#resolveTicket', function(e) {
123
    $("#ticketDetailsModal").on("click", "#resolveTicket", function (e) {
95
        let ticket_id = $('#ticket_id').val();
124
        let ticket_id = $("#ticket_id").val();
96
        let params = {
125
        let params = {
97
            'public': $('#public').is(":checked"),
126
            public: $("#public").is(":checked"),
98
            message: $('#update_message').val(),
127
            message: $("#update_message").val(),
99
            user_id: logged_in_user_borrowernumber,
128
            user_id: logged_in_user_borrowernumber,
100
            state: 'resolved'
129
            state: "resolved",
101
        };
130
        };
102
131
103
        $('#resolve-spinner').show();
132
        $("#resolve-spinner").show();
104
133
105
        $.ajax({
134
        $.ajax({
106
            url: "/api/v1/tickets/" + ticket_id + "/updates",
135
            url: "/api/v1/tickets/" + ticket_id + "/updates",
107
            method: "POST",
136
            method: "POST",
108
            data: JSON.stringify(params),
137
            data: JSON.stringify(params),
109
            ontentType: "application/json; charset=utf-8"
138
            ontentType: "application/json; charset=utf-8",
110
        }).success(function() {
139
        })
111
            $('#resolve-spinner').hide();
140
            .success(function () {
112
            $("#ticketDetailsModal").modal('hide');
141
                $("#resolve-spinner").hide();
113
            $('#table_concerns').DataTable().ajax.reload(function(data) {
142
                $("#ticketDetailsModal").modal("hide");
114
                $("#concern_action_result_dialog").hide();
143
                $("#table_concerns")
115
                $("#concern_delete_success").html(__("Concern #%s updated successfully.").format(ticket_id)).show();
144
                    .DataTable()
145
                    .ajax.reload(function (data) {
146
                        $("#concern_action_result_dialog").hide();
147
                        $("#concern_delete_success")
148
                            .html(
149
                                __("Concern #%s updated successfully.").format(
150
                                    ticket_id,
151
                                ),
152
                            )
153
                            .show();
154
                    });
155
            })
156
            .error(function () {
157
                $("#concern_update_error")
158
                    .html(
159
                        __(
160
                            "Error resolving concern #%s. Check the logs for details.",
161
                        ).format(ticket_id),
162
                    )
163
                    .show();
116
            });
164
            });
117
        }).error(function() {
118
            $("#concern_update_error").html(__("Error resolving concern #%s. Check the logs for details.").format(ticket_id)).show();
119
        });
120
    });
165
    });
121
});
166
});
122
- 

Return to bug 36374