Filter spam prevention #7
This commit is contained in:
parent
97141dec4d
commit
f6568230b1
@ -24,16 +24,19 @@ function updateItemsState(state) {
|
|||||||
case "content":
|
case "content":
|
||||||
$("#ticketsContainer .none-found").hide();
|
$("#ticketsContainer .none-found").hide();
|
||||||
$("#ticketsContainer .loading").hide();
|
$("#ticketsContainer .loading").hide();
|
||||||
|
$("#filterSidebar input").prop("disabled", false);
|
||||||
break;
|
break;
|
||||||
case "loading":
|
case "loading":
|
||||||
$("#ticketsContainer .content").empty();
|
$("#ticketsContainer .content").empty();
|
||||||
$("#ticketsContainer .none-found").hide();
|
$("#ticketsContainer .none-found").hide();
|
||||||
$("#ticketsContainer .loading").show();
|
$("#ticketsContainer .loading").show();
|
||||||
|
$("#filterSidebar input").prop("disabled", true);
|
||||||
break;
|
break;
|
||||||
case "no-content":
|
case "no-content":
|
||||||
$("#ticketsContainer .content").empty();
|
$("#ticketsContainer .content").empty();
|
||||||
$("#ticketsContainer .none-found").show();
|
$("#ticketsContainer .none-found").show();
|
||||||
$("#ticketsContainer .loading").hide();
|
$("#ticketsContainer .loading").hide();
|
||||||
|
$("#filterSidebar input").prop("disabled", false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Invalid Items State '${state}'`);
|
throw new Error(`Invalid Items State '${state}'`);
|
||||||
@ -220,11 +223,18 @@ function changeItemsPage(next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadTicketItems(page=1) {
|
function loadTicketItems(page=1) {
|
||||||
|
|
||||||
|
if (global_loadingTickets) {
|
||||||
|
alert("Spam prevention\nStopped loadTicketItems because already loading.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
global_loadingTickets = true;
|
||||||
|
|
||||||
updateItemsState("loading");
|
updateItemsState("loading");
|
||||||
filters["page"] = page;
|
filters["page"] = page;
|
||||||
|
|
||||||
var fetchFilters = { ...filters };
|
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) => {
|
fetchTicketsPromise(fetchFilters).then((response) => {
|
||||||
// Update the counts to show how many tickets were found
|
// 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
|
// Create a copy of the template using the ticket data
|
||||||
var template = $($("#ticketItemTemplate").html());
|
var template = $($("#ticketItemTemplate").html());
|
||||||
template.find(".ticket-item-author").text(`${ticket.author.forename} ${ticket.author.surname}`);
|
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-title").text(ticket.title);
|
||||||
template.find(".ticket-item-desc").html(ticket.short_description);
|
template.find(".ticket-item-desc").html(ticket.short_description);
|
||||||
template.find(".ticket-item-icon").attr("src", ticket.author.icon);
|
template.find(".ticket-item-icon").attr("src", ticket.author.icon);
|
||||||
@ -300,6 +310,7 @@ function loadTicketItems(page=1) {
|
|||||||
applyTicketClickFunction();
|
applyTicketClickFunction();
|
||||||
|
|
||||||
updateItemsState("content");
|
updateItemsState("content");
|
||||||
|
global_loadingTickets = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,6 +321,7 @@ function loadTicketContent(uuid) {
|
|||||||
console.debug("Spam prevention\nStopped loadTicketContent because already loading.");
|
console.debug("Spam prevention\nStopped loadTicketContent because already loading.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
global_loadingTickets = true;
|
||||||
|
|
||||||
$("#ticketContent .content").empty();
|
$("#ticketContent .content").empty();
|
||||||
|
|
||||||
@ -319,7 +331,7 @@ function loadTicketContent(uuid) {
|
|||||||
// Create a copy of the template using the ticket data
|
// Create a copy of the template using the ticket data
|
||||||
var template = $($("#ticketContentTemplate").html());
|
var template = $($("#ticketContentTemplate").html());
|
||||||
template.find(".ticket-content-author").text(`${ticket.author.forename} ${ticket.author.surname}`);
|
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-title").text(ticket.title);
|
||||||
template.find(".ticket-content-desc").html(ticket.description);
|
template.find(".ticket-content-desc").html(ticket.description);
|
||||||
template.find(".ticket-content-icon").attr("src", ticket.author.icon);
|
template.find(".ticket-content-icon").attr("src", ticket.author.icon);
|
||||||
@ -335,6 +347,7 @@ function loadTicketContent(uuid) {
|
|||||||
$("#ticketContent .content").append(template);
|
$("#ticketContent .content").append(template);
|
||||||
|
|
||||||
updateContentState("content");
|
updateContentState("content");
|
||||||
|
global_loadingTickets = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// $("#ticketContent").empty();
|
// $("#ticketContent").empty();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user