Bugzilla – Attachment 165743 Details for
Bug 36374
Some of our JS files should stay tidy
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36374: Also tidy ticket and concern modals js
Bug-36374-Also-tidy-ticket-and-concern-modals-js.patch (text/plain), 14.99 KB, created by
Martin Renvoize (ashimema)
on 2024-04-29 11:55:47 UTC
(
hide
)
Description:
Bug 36374: Also tidy ticket and concern modals js
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-04-29 11:55:47 UTC
Size:
14.99 KB
patch
obsolete
>From cab0828d72448e80270b9a3718e0451ce4350901 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 21 Mar 2024 09:31:38 +0000 >Subject: [PATCH] Bug 36374: Also tidy ticket and concern modals js > >This patch does the promised follow-up to tidy the two other recently >added js files for modals. As I'm the main maintainer of those to date >I'm happy to rebase any patches already submitted atop this bug. > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> >--- > .../prog/js/modals/add_catalog_concern.js | 65 +++--- > .../prog/js/modals/display_ticket.js | 191 +++++++++++------- > 2 files changed, 155 insertions(+), 101 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/add_catalog_concern.js b/koha-tmpl/intranet-tmpl/prog/js/modals/add_catalog_concern.js >index 61cb26d8c07..6fdd14a769d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/modals/add_catalog_concern.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/modals/add_catalog_concern.js >@@ -1,53 +1,62 @@ > /* keep tidy */ >-$(document).ready(function() { >- >+$(document).ready(function () { > // Pre-populate empty message with template >- $('#addConcernModal').on('show.bs.modal', function (e) { >- $('#addConfirm').prop('disabled', false); >- let concern_body = $('#concern_body'); >- if ( concern_body.val() === "" ) { >- let template = $('#concern_template').text(); >+ $("#addConcernModal").on("show.bs.modal", function (e) { >+ $("#addConfirm").prop("disabled", false); >+ let concern_body = $("#concern_body"); >+ if (concern_body.val() === "") { >+ let template = $("#concern_template").text(); > concern_body.val(template); > } > }); > >- $('#addConcernModal').on('click', '#addConfirm', function(e) { >- let concern_title = $('#concern_title').val(); >- let concern_body = $('#concern_body').val(); >- let biblio_id = $('#concern_biblio').val(); >- let reporter_id = $('#concern_reporter').val(); >+ $("#addConcernModal").on("click", "#addConfirm", function (e) { >+ let concern_title = $("#concern_title").val(); >+ let concern_body = $("#concern_body").val(); >+ let biblio_id = $("#concern_biblio").val(); >+ let reporter_id = $("#concern_reporter").val(); > > let params = { >- source: 'catalog', >+ source: "catalog", > title: concern_title, > body: concern_body, > biblio_id: biblio_id, > reporter_id: logged_in_user_borrowernumber, > }; > >- $('#concern-submit-spinner').show(); >- $('#addConfirm').prop('disabled', true); >+ $("#concern-submit-spinner").show(); >+ $("#addConfirm").prop("disabled", true); > > $.ajax({ >- url: '/api/v1/tickets', >- type: 'POST', >+ url: "/api/v1/tickets", >+ type: "POST", > data: JSON.stringify(params), >- success: function(data) { >- $('#concern-submit-spinner').hide(); >- $('#addConcernModal').modal('hide'); >- $('#concern_body').val(''); >- $('#concern_title').val(''); >- $('#toolbar').before('<div class="dialog message">' + __("Your concern was successfully submitted.") + '</div>'); >+ success: function (data) { >+ $("#concern-submit-spinner").hide(); >+ $("#addConcernModal").modal("hide"); >+ $("#concern_body").val(""); >+ $("#concern_title").val(""); >+ $("#toolbar").before( >+ '<div class="dialog message">' + >+ __("Your concern was successfully submitted.") + >+ "</div>" >+ ); > if ($.fn.dataTable.isDataTable("#table_concerns")) { > $("#table_concerns").DataTable().ajax.reload(); > } > }, >- error: function(data) { >- $('#concern-submit-spinner').hide(); >- $('#addConcernModal').modal('hide'); >- $('#toolbar').before('<div class="dialog alert">' + __("There was an error when submitting your concern, please contact a librarian.") + '</div>'); >+ error: function (data) { >+ $("#concern-submit-spinner").hide(); >+ $("#addConcernModal").modal("hide"); >+ $("#toolbar").before( >+ '<div class="dialog alert">' + >+ __( >+ "There was an error when submitting your concern, please contact a librarian." >+ ) + >+ "</div>" >+ ); > }, >- contentType: "json" >+ contentType: "json", > }); > }); > }); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js b/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js >index 0812d7fccb0..a4541bc8ca4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js >@@ -1,31 +1,31 @@ > /* keep tidy */ >-$(document).ready(function() { >- $('#ticketDetailsModal').on('show.bs.modal', function(event) { >+$(document).ready(function () { >+ $("#ticketDetailsModal").on("show.bs.modal", function (event) { > let modal = $(this); > let button = $(event.relatedTarget); >- let ticket_id = button.data('concern'); >- let resolved = button.data('resolved'); >- modal.find('.modal-footer input').val(ticket_id); >+ let ticket_id = button.data("concern"); >+ let resolved = button.data("resolved"); >+ modal.find(".modal-footer input").val(ticket_id); > >- if ( resolved ) { >- $('#resolveTicket').hide(); >+ if (resolved) { >+ $("#resolveTicket").hide(); > } else { >- $('#resolveTicket').show(); >+ $("#resolveTicket").show(); > } > >- let detail = $('#detail_' + ticket_id).text(); >+ let detail = $("#detail_" + ticket_id).text(); > > // Display ticket details > let display = '<div class="list-group">'; > display += '<div class="list-group-item">'; >- display += '<span class="wrapfix">' + detail + '</span>'; >- display += '</div>'; >+ display += '<span class="wrapfix">' + detail + "</span>"; >+ display += "</div>"; > display += '<div id="concern-updates" class="list-group-item">'; >- display += '<span>' + __("Loading updates . . .") + '</span>'; >- display += '</div>'; >- display += '</div>'; >+ display += "<span>" + __("Loading updates . . .") + "</span>"; >+ display += "</div>"; >+ display += "</div>"; > >- let details = modal.find('#concern-details'); >+ let details = modal.find("#concern-details"); > details.html(display); > > // Load any existing updates >@@ -33,89 +33,134 @@ $(document).ready(function() { > url: "/api/v1/tickets/" + ticket_id + "/updates", > method: "GET", > headers: { >- "x-koha-embed": "user" >+ "x-koha-embed": "user", > }, >- }).success(function(data) { >- let updates_display = $('#concern-updates'); >- let updates = ''; >- data.forEach(function(item, index) { >- if ( item.public ) { >- updates += '<div class="list-group-item list-group-item-success">'; >- updates += '<span class="pull-right">' + __("Public") + '</span>'; >- } >- else { >- updates += '<div class="list-group-item list-group-item-warning">'; >- updates += '<span class="pull-right">' + __("Private") + '</span>'; >- } >- updates += '<span class="wrapfix">' + item.message + '</span>'; >- updates += '<span class="clearfix">' + $patron_to_html(item.user, { >- display_cardnumber: false, >- url: true >- }) + ' (' + $datetime(item.date) + ')</span>'; >- updates += '</div>'; >- }); >- updates_display.html(updates); >- }).error(function() { >- >- }); >+ }) >+ .success(function (data) { >+ let updates_display = $("#concern-updates"); >+ let updates = ""; >+ data.forEach(function (item, index) { >+ if (item.public) { >+ updates += >+ '<div class="list-group-item list-group-item-success">'; >+ updates += >+ '<span class="pull-right">' + >+ __("Public") + >+ "</span>"; >+ } else { >+ updates += >+ '<div class="list-group-item list-group-item-warning">'; >+ updates += >+ '<span class="pull-right">' + >+ __("Private") + >+ "</span>"; >+ } >+ updates += >+ '<span class="wrapfix">' + item.message + "</span>"; >+ updates += >+ '<span class="clearfix">' + >+ $patron_to_html(item.user, { >+ display_cardnumber: false, >+ url: true, >+ }) + >+ " (" + >+ $datetime(item.date) + >+ ")</span>"; >+ updates += "</div>"; >+ }); >+ updates_display.html(updates); >+ }) >+ .error(function () {}); > > // Clear any previously entered update message >- $('#update_message').val(''); >- $('#public').prop( "checked", false ); >+ $("#update_message").val(""); >+ $("#public").prop("checked", false); > }); > >- $('#ticketDetailsModal').on('click', '#updateTicket', function(e) { >- let ticket_id = $('#ticket_id').val(); >+ $("#ticketDetailsModal").on("click", "#updateTicket", function (e) { >+ let ticket_id = $("#ticket_id").val(); > let params = { >- 'public': $('#public').is(":checked"), >- message: $('#update_message').val(), >- user_id: logged_in_user_borrowernumber >+ public: $("#public").is(":checked"), >+ message: $("#update_message").val(), >+ user_id: logged_in_user_borrowernumber, > }; > >- $('#comment-spinner').show(); >+ $("#comment-spinner").show(); > > $.ajax({ > url: "/api/v1/tickets/" + ticket_id + "/updates", > method: "POST", > data: JSON.stringify(params), >- ontentType: "application/json; charset=utf-8" >- }).success(function() { >- $('#comment-spinner').hide(); >- $('#ticketDetailsModal').modal('hide'); >- $('#table_concerns').DataTable().ajax.reload(function(data) { >- $("#concern_action_result_dialog").hide(); >- $("#concern_delete_success").html(__("Concern #%s updated successfully.").format(ticket_id)).show(); >+ ontentType: "application/json; charset=utf-8", >+ }) >+ .success(function () { >+ $("#comment-spinner").hide(); >+ $("#ticketDetailsModal").modal("hide"); >+ $("#table_concerns") >+ .DataTable() >+ .ajax.reload(function (data) { >+ $("#concern_action_result_dialog").hide(); >+ $("#concern_delete_success") >+ .html( >+ __("Concern #%s updated successfully.").format( >+ ticket_id >+ ) >+ ) >+ .show(); >+ }); >+ }) >+ .error(function () { >+ $("#concern_update_error") >+ .html( >+ __( >+ "Error resolving concern #%s. Check the logs for details." >+ ).format(ticket_id) >+ ) >+ .show(); > }); >- }).error(function() { >- $("#concern_update_error").html(__("Error resolving concern #%s. Check the logs for details.").format(ticket_id)).show(); >- }); > }); > >- $('#ticketDetailsModal').on('click', '#resolveTicket', function(e) { >- let ticket_id = $('#ticket_id').val(); >+ $("#ticketDetailsModal").on("click", "#resolveTicket", function (e) { >+ let ticket_id = $("#ticket_id").val(); > let params = { >- 'public': $('#public').is(":checked"), >- message: $('#update_message').val(), >+ public: $("#public").is(":checked"), >+ message: $("#update_message").val(), > user_id: logged_in_user_borrowernumber, >- state: 'resolved' >+ state: "resolved", > }; > >- $('#resolve-spinner').show(); >+ $("#resolve-spinner").show(); > > $.ajax({ > url: "/api/v1/tickets/" + ticket_id + "/updates", > method: "POST", > data: JSON.stringify(params), >- ontentType: "application/json; charset=utf-8" >- }).success(function() { >- $('#resolve-spinner').hide(); >- $("#ticketDetailsModal").modal('hide'); >- $('#table_concerns').DataTable().ajax.reload(function(data) { >- $("#concern_action_result_dialog").hide(); >- $("#concern_delete_success").html(__("Concern #%s updated successfully.").format(ticket_id)).show(); >+ ontentType: "application/json; charset=utf-8", >+ }) >+ .success(function () { >+ $("#resolve-spinner").hide(); >+ $("#ticketDetailsModal").modal("hide"); >+ $("#table_concerns") >+ .DataTable() >+ .ajax.reload(function (data) { >+ $("#concern_action_result_dialog").hide(); >+ $("#concern_delete_success") >+ .html( >+ __("Concern #%s updated successfully.").format( >+ ticket_id >+ ) >+ ) >+ .show(); >+ }); >+ }) >+ .error(function () { >+ $("#concern_update_error") >+ .html( >+ __( >+ "Error resolving concern #%s. Check the logs for details." >+ ).format(ticket_id) >+ ) >+ .show(); > }); >- }).error(function() { >- $("#concern_update_error").html(__("Error resolving concern #%s. Check the logs for details.").format(ticket_id)).show(); >- }); > }); > }); >-- >2.44.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36374
:
163555
|
163556
|
163558
|
163559
|
163560
|
163587
|
163588
|
163589
|
163591
|
163592
|
163593
|
163594
|
163595
|
163596
|
165732
|
165733
|
165734
|
165735
|
165736
|
165737
|
165738
|
165739
|
165740
|
165741
|
165742
| 165743