diff --git a/apps/static/js/tickets.js b/apps/static/js/tickets.js index fd9a835..bbab738 100644 --- a/apps/static/js/tickets.js +++ b/apps/static/js/tickets.js @@ -24,16 +24,19 @@ function updateItemsState(state) { case "content": $("#ticketsContainer .none-found").hide(); $("#ticketsContainer .loading").hide(); + $("#filterSidebar input").prop("disabled", false); break; case "loading": $("#ticketsContainer .content").empty(); $("#ticketsContainer .none-found").hide(); $("#ticketsContainer .loading").show(); + $("#filterSidebar input").prop("disabled", true); break; case "no-content": $("#ticketsContainer .content").empty(); $("#ticketsContainer .none-found").show(); $("#ticketsContainer .loading").hide(); + $("#filterSidebar input").prop("disabled", false); break; default: throw new Error(`Invalid Items State '${state}'`); @@ -220,11 +223,18 @@ function changeItemsPage(next) { } function loadTicketItems(page=1) { + + if (global_loadingTickets) { + alert("Spam prevention\nStopped loadTicketItems because already loading."); + return; + } + global_loadingTickets = true; + updateItemsState("loading"); filters["page"] = page; var fetchFilters = { ...filters }; - fetchFilters["only_fields"] = "uuid,title,short_description,author,priority,tags,timestamp,is_edited,author__forename,author__surname,author__department,author__icon,string_datetime"; + fetchFilters["only_fields"] = "uuid,title,short_description,author,priority,tags,timestamp,is_edited,author__forename,author__surname,author__department,author__icon,display_datetime"; fetchTicketsPromise(fetchFilters).then((response) => { // Update the counts to show how many tickets were found @@ -263,7 +273,7 @@ function loadTicketItems(page=1) { // Create a copy of the template using the ticket data var template = $($("#ticketItemTemplate").html()); template.find(".ticket-item-author").text(`${ticket.author.forename} ${ticket.author.surname}`); - template.find(".ticket-item-datetime").text(ticket.string_datetime); + template.find(".ticket-item-datetime").text(ticket.display_datetime); template.find(".ticket-item-title").text(ticket.title); template.find(".ticket-item-desc").html(ticket.short_description); template.find(".ticket-item-icon").attr("src", ticket.author.icon); @@ -300,6 +310,7 @@ function loadTicketItems(page=1) { applyTicketClickFunction(); updateItemsState("content"); + global_loadingTickets = false; }); } @@ -310,6 +321,7 @@ function loadTicketContent(uuid) { console.debug("Spam prevention\nStopped loadTicketContent because already loading."); return; } + global_loadingTickets = true; $("#ticketContent .content").empty(); @@ -319,7 +331,7 @@ function loadTicketContent(uuid) { // Create a copy of the template using the ticket data var template = $($("#ticketContentTemplate").html()); template.find(".ticket-content-author").text(`${ticket.author.forename} ${ticket.author.surname}`); - template.find(".ticket-content-datetime").text(ticket.string_datetime); + template.find(".ticket-content-datetime").text(ticket.display_datetime); template.find(".ticket-content-title").text(ticket.title); template.find(".ticket-content-desc").html(ticket.description); template.find(".ticket-content-icon").attr("src", ticket.author.icon); @@ -335,6 +347,7 @@ function loadTicketContent(uuid) { $("#ticketContent .content").append(template); updateContentState("content"); + global_loadingTickets = false; }); // $("#ticketContent").empty();