Fixing issue where campaigns aren't showing up in the archived tab if they have been marked as completed.

Fixes #1892
pull/1914/head
Jordan Wright 2020-07-25 14:47:16 -05:00
parent 65f06c138f
commit b684fb4ebd
2 changed files with 18 additions and 14 deletions

File diff suppressed because one or more lines are too long

View File

@ -343,7 +343,7 @@ $(document).ready(function () {
$("#campaignTable").show() $("#campaignTable").show()
$("#campaignTableArchive").show() $("#campaignTableArchive").show()
campaignTableOriginal = $("#campaignTable").DataTable({ activeCampaignsTable = $("#campaignTable").DataTable({
columnDefs: [{ columnDefs: [{
orderable: false, orderable: false,
targets: "no-sort" targets: "no-sort"
@ -352,7 +352,7 @@ $(document).ready(function () {
[1, "desc"] [1, "desc"]
] ]
}); });
campaignTableArchive = $("#campaignTableArchive").DataTable({ archivedCampaignsTable = $("#campaignTableArchive").DataTable({
columnDefs: [{ columnDefs: [{
orderable: false, orderable: false,
targets: "no-sort" targets: "no-sort"
@ -361,13 +361,11 @@ $(document).ready(function () {
[1, "desc"] [1, "desc"]
] ]
}); });
campaignRows = [] rows = {
$.each(campaigns, function (i, campaign) { 'active': [],
campaignTable = campaignTableOriginal 'archived': []
if (campaign.status === "Completed") {
campaignTable = campaignTableArchive
} }
$.each(campaigns, function (i, campaign) {
label = labels[campaign.status] || "label-default"; label = labels[campaign.status] || "label-default";
//section for tooltips on the status of a campaign to show some quick stats //section for tooltips on the status of a campaign to show some quick stats
@ -377,10 +375,10 @@ $(document).ready(function () {
var quickStats = launchDate + "<br><br>" + "Number of recipients: " + campaign.stats.total var quickStats = launchDate + "<br><br>" + "Number of recipients: " + campaign.stats.total
} else { } else {
launchDate = "Launch Date: " + moment(campaign.launch_date).format('MMMM Do YYYY, h:mm:ss a') launchDate = "Launch Date: " + moment(campaign.launch_date).format('MMMM Do YYYY, h:mm:ss a')
var quickStats = launchDate + "<br><br>" + "Number of recipients: " + campaign.stats.total + "<br><br>" + "Emails opened: " + campaign.stats.opened + "<br><br>" + "Emails clicked: " + campaign.stats.clicked + "<br><br>" + "Submitted Credentials: " + campaign.stats.submitted_data + "<br><br>" + "Errors : " + campaign.stats.error + "Reported : " + campaign.stats.reported var quickStats = launchDate + "<br><br>" + "Number of recipients: " + campaign.stats.total + "<br><br>" + "Emails opened: " + campaign.stats.opened + "<br><br>" + "Emails clicked: " + campaign.stats.clicked + "<br><br>" + "Submitted Credentials: " + campaign.stats.submitted_data + "<br><br>" + "Errors : " + campaign.stats.error + "<br><br>" + "Reported : " + campaign.stats.email_reported
} }
campaignRows.push([ var row = [
escapeHtml(campaign.name), escapeHtml(campaign.name),
moment(campaign.created_date).format('MMMM Do YYYY, h:mm:ss a'), moment(campaign.created_date).format('MMMM Do YYYY, h:mm:ss a'),
"<span class=\"label " + label + "\" data-toggle=\"tooltip\" data-placement=\"right\" data-html=\"true\" title=\"" + quickStats + "\">" + campaign.status + "</span>", "<span class=\"label " + label + "\" data-toggle=\"tooltip\" data-placement=\"right\" data-html=\"true\" title=\"" + quickStats + "\">" + campaign.status + "</span>",
@ -393,10 +391,16 @@ $(document).ready(function () {
<button class='btn btn-danger' onclick='deleteCampaign(" + i + ")' data-toggle='tooltip' data-placement='left' title='Delete Campaign'>\ <button class='btn btn-danger' onclick='deleteCampaign(" + i + ")' data-toggle='tooltip' data-placement='left' title='Delete Campaign'>\
<i class='fa fa-trash-o'></i>\ <i class='fa fa-trash-o'></i>\
</button></div>" </button></div>"
]) ]
$('[data-toggle="tooltip"]').tooltip() if (campaign.status == 'Completed') {
rows['archived'].push(row)
} else {
rows['active'].push(row)
}
}) })
campaignTable.rows.add(campaignRows).draw() activeCampaignsTable.rows.add(rows['active']).draw()
archivedCampaignsTable.rows.add(rows['archived']).draw()
$('[data-toggle="tooltip"]').tooltip()
} else { } else {
$("#emptyMessage").show() $("#emptyMessage").show()
} }