diff --git a/js/components/table/table.js b/js/components/table/table.js index b4621c5..ef36ba8 100644 --- a/js/components/table/table.js +++ b/js/components/table/table.js @@ -4,7 +4,6 @@ import Columns from './subcomponents/columns.js' import Header from './subcomponents/headers.js' import Rows from './subcomponents/rows.js' import Data from './subcomponents/data.js' -import { unformatCurrency } from '../../utils/common_utils.js' import { saveTableData } from '../../utils/data_utils/local_storage_handlers.js' function adjustTableWidth(width_pct){ diff --git a/js/utils/data_utils/local_storage_handlers.js b/js/utils/data_utils/local_storage_handlers.js index 53d2e45..224c42f 100644 --- a/js/utils/data_utils/local_storage_handlers.js +++ b/js/utils/data_utils/local_storage_handlers.js @@ -42,8 +42,7 @@ export function saveTableData() { var save_as = CurrentPage.load(); } localStorage.setItem(save_as, convertToJSON(table, ['Edit'])); - console.log('uncomment this line'); - //Sidebar.updateTotals(); + Sidebar.updateTotals(); } function deleteTable(name){ @@ -93,12 +92,12 @@ class StoredTable { } getSum() { // fill with zero until there is something saved in storage - return colSum(this.table, this.totalCol()); + return colSum(this.table, this.totalCol(), this.name); } } -function colSum(table, colName) { +function colSum(table, colName, name) { // fill with zero until there is something saved in storage if(!table || table == ''){ return 0; @@ -106,12 +105,12 @@ function colSum(table, colName) { const headers = Object.keys(table[0]); if (headers.includes(colName)) { let sum = 0; - for (let i = 1; i < table.length; i++){ + for (let i = 0; i < table.length; i++){ sum += Math.round(parseFloat(table[i][colName])); } return sum; } else { - console.error('Could not find expected total column in saved data. See StoredTable.totalCol() switch.'); + console.error(`Could not find expected total column in saved data for ${name}. Returning 0. See StoredTable.totalCol() switch.`); return 0; } diff --git a/js/views/04_personnel/helpers.js b/js/views/04_personnel/helpers.js index 5ffef41..18af98c 100644 --- a/js/views/04_personnel/helpers.js +++ b/js/views/04_personnel/helpers.js @@ -9,6 +9,9 @@ import Prompt from "../../components/prompt/prompt.js"; import Table from '../../components/table/table.js' import Sidebar from "../../components/sidebar/sidebar.js"; import { Services } from "../../utils/data_utils/budget_data_handlers.js"; +import { convertToJSON } from "../../utils/data_utils/JSON_data_handlers.js"; + +import { Baseline, loadTableData } from "../../utils/data_utils/local_storage_handlers.js"; export function preparePageView(){ // prepare page view @@ -54,7 +57,6 @@ export async function initializePersonnelTable(){ await Table.Data.load(); //after table is loaded, show it Table.show(); - Table.Columns.addAtEnd('0', 'Total Cost'); Table.Columns.addAtEnd(Table.Buttons.edit_confirm_btns, 'Edit'); assignClasses(); // add up the baseline costs and update sidebar @@ -87,8 +89,12 @@ function updateDisplayandTotals(){ // update total column Table.Cell.updateValue(rows[i], 'total-baseline', total_baseline_cost); + } + + // Save the table after all updates are done Table.save(); + } diff --git a/js/views/05_nonpersonnel/helpers.js b/js/views/05_nonpersonnel/helpers.js index 295f503..7fd9e0e 100644 --- a/js/views/05_nonpersonnel/helpers.js +++ b/js/views/05_nonpersonnel/helpers.js @@ -5,9 +5,24 @@ import Body from "../../components/body/body.js"; import NavButtons from "../../components/nav_buttons/nav_buttons.js"; import Subtitle from "../../components/header/header.js"; +// "Vendor": "Law Firm LLC", +// "CPA #" : "765421", +// "Account String": "1000-29320-320010", +// "Object Name": "Consulting", +// "End of Contract": "12/31/2024", +// "Amount Remaining" : 50000, +// "FY26 Request": 100000 + const nonPersonnelColumns = [ { title: 'FY26 Request', className: 'request', isCost: true }, - { title: 'Amount Remaining', className: 'remaining', isCost: true }, + { title: 'Amount Remaining on Contract', className: 'remaining', isCost: true }, + { title: 'Service', className : 'service' }, + { title: 'Edit', className : 'edit' }, + { title : 'Account String', className : 'account-string'}, + { title : 'CPA #', className : 'cpa'}, + { title : 'End of Contract', className : 'contract-end'}, + { title: 'Recurring or One-Time', className: 'recurring'} + ]; export function preparePageView(){ @@ -30,7 +45,7 @@ export async function initializeNonpersonnelTable(){ await Table.Data.load(); //after table is loaded, fill it Table.show(); - Table.Columns.addAtEnd(Table.Buttons.edit_confirm_btns, " "); + Table.Columns.addAtEnd(Table.Buttons.edit_confirm_btns, "Edit"); // assign cost classes Table.Columns.assignClasses(nonPersonnelColumns); // enable editing @@ -40,5 +55,6 @@ export async function initializeNonpersonnelTable(){ function nonPersonnelRowOnEdit(){ // make it editable Table.Cell.createTextbox('request'); + Table.Cell.createServiceDropdown(); }