From a355470457ff568116f8069ecb07cf874638e673 Mon Sep 17 00:00:00 2001 From: Bennett Gillig Date: Sat, 24 Oct 2020 08:37:58 -0400 Subject: [PATCH] synthetic assignments don't show statistics anymore fixed how synthetic assignments show statistics. --- public/js/home.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/public/js/home.js b/public/js/home.js index a970f215..68c1cb9a 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -19,6 +19,9 @@ let currentTableData = tableData[currentTableDataIndex]; let selected_class_i; let termsReset = {}; +//variable for the number of synthetic assignments at the top +let total_synthetic_assignments = 0 + let tempCell; // When the user clicks anywhere outside of a modal or dropdown, close it window.addEventListener("click", function(event) { @@ -316,13 +319,13 @@ let assignmentsTable = new Tabulator("#assignmentsTable", { { title: "Stats", titleFormatter: () => '', - formatter: cell => - (!isNaN(cell.getRow().getData().score)) ? + formatter: cell => + (!isNaN(cell.getRow().getData().score) && cell.getRow().getPosition() >= total_synthetic_assignments) ? '' : "", width: 40, align: "center", cellClick: async function(e, cell) { - if (isNaN(cell.getRow().getData().score)) { + if (isNaN(cell.getRow().getData().score) || cell.getRow().getPosition() < total_synthetic_assignments) { return; } noStats(); @@ -516,11 +519,18 @@ let assignmentsTable = new Tabulator("#assignmentsTable", { { title: "Add", titleFormatter: () => '', - headerClick: newAssignment, + headerClick: function () { + total_synthetic_assignments++; + newAssignment(); + }, formatter: "buttonCross", width: 40, align: "center", cellClick: function(e, cell) { + //if the index is less than the total number of synthetic assignments it must be a synthetic assignment + if (cell.getRow().getPosition() < total_synthetic_assignments) + total_synthetic_assignments--; + cell.getRow().delete(); }, headerSort: false,