From 9268321170ea6278d37fc5377cc076492159a358 Mon Sep 17 00:00:00 2001 From: Katrina Wheelan Date: Fri, 26 Jul 2024 16:44:02 -0400 Subject: [PATCH] fix detail bug on new init page --- src/js/components/table/subcomponents/rows.js | 4 +--- src/js/components/table/table.js | 2 +- src/js/utils/data_utils/local_storage_handlers.js | 1 + src/js/views/04_personnel/helpers.js | 1 - src/js/views/07_new_initiatives/helpers.js | 15 +++++++++------ src/js/views/view_logic.js | 6 ++++++ 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/js/components/table/subcomponents/rows.js b/src/js/components/table/subcomponents/rows.js index 67d6491..512bdb6 100644 --- a/src/js/components/table/subcomponents/rows.js +++ b/src/js/components/table/subcomponents/rows.js @@ -2,9 +2,7 @@ import Header from "./headers.js"; import { formatCurrency } from "../../../utils/common_utils.js"; async function addNewRow(data_dictionary, columns = []){ - - console.log(data_dictionary); - + // Get the table element by its ID const table = document.getElementById('main-table'); diff --git a/src/js/components/table/table.js b/src/js/components/table/table.js index 5b9fb97..94f29dd 100644 --- a/src/js/components/table/table.js +++ b/src/js/components/table/table.js @@ -45,7 +45,7 @@ const Table = { clear : clearTable, hide : hideTable, show : showTable, - save : function() { + save : async function() { // remove the detail text Tooltip.unlink(); saveTableData(); diff --git a/src/js/utils/data_utils/local_storage_handlers.js b/src/js/utils/data_utils/local_storage_handlers.js index 04e1d90..dd5e9b1 100644 --- a/src/js/utils/data_utils/local_storage_handlers.js +++ b/src/js/utils/data_utils/local_storage_handlers.js @@ -42,6 +42,7 @@ export function saveTableData() { var save_as = CurrentPage.load(); } localStorage.setItem(save_as, convertToJSON(table, ['Edit'])); + console.log('saved'); Sidebar.updateTotals(); } diff --git a/src/js/views/04_personnel/helpers.js b/src/js/views/04_personnel/helpers.js index a97915d..d63fb8d 100644 --- a/src/js/views/04_personnel/helpers.js +++ b/src/js/views/04_personnel/helpers.js @@ -129,7 +129,6 @@ function handleSubmitNewJob(event){ // edit inputs from modal responses['avg-salary'] = unformatCurrency(responses['avg-salary']); responses['fringe'] = parseFloat(responses['fringe']) / 100; - console.log(responses['approp-name']); responses['account-string'] = AccountString.build(responses['approp-name'], responses['cc-name']) responses['approp'] = AccountString.getNumber(responses['approp-name']); responses['cc'] = AccountString.getNumber(responses['cc-name']); diff --git a/src/js/views/07_new_initiatives/helpers.js b/src/js/views/07_new_initiatives/helpers.js index 7b4ebbf..a3d1723 100644 --- a/src/js/views/07_new_initiatives/helpers.js +++ b/src/js/views/07_new_initiatives/helpers.js @@ -19,10 +19,10 @@ const initiativesCols = [ { title: 'Initiative Name', className: 'init-name' }, { title: 'Account String', className: 'account-string' }, { title: 'Ballpark Total Expenses', className: 'total', isCost: true }, - { title: 'Revenue', className: 'revenue', isCost: true }, { title: 'Personnel Cost', className: 'personnel', isCost: true }, { title: 'Non-personnel Cost', className: 'nonpersonnel', isCost: true }, - { title: 'One-time v. Recurring', className: 'rev-type' }, + { title: 'Revenue', className: 'revenue', isCost: true }, + { title: 'Revenue Type', className: 'rev-type' }, { title: 'Edit', className : 'edit' }, // hide the explanation columns @@ -110,16 +110,19 @@ function assignClasses() { } export async function initializeInitTable(){ + // load table data from storage if(await Table.Data.load()) { // after table is loaded, fill it Table.Columns.addAtEnd(Table.Buttons.edit_confirm_btns, "Edit"); assignClasses(); - // enable editing - Table.Buttons.Edit.init(rowOnEdit, Table.save); // show table - Table.save(); Table.show(); + // enable editing + Table.Buttons.Edit.init(rowOnEdit, Table.save); + } else { + Table.clear(); + console.log('no data'); } } @@ -128,7 +131,6 @@ function rowOnEdit(){ Table.Cell.createTextbox('revenue', true); Table.Cell.createTextbox('personnel', true); Table.Cell.createTextbox('nonpersonnel', true); - Table.Cell.createTextbox('account-string'); Table.Cell.createTextbox('init-name'); Table.Cell.createDropdown('rev-type', dropdownOptions); } @@ -136,6 +138,7 @@ function rowOnEdit(){ function submitNewRow(event){ // get answers from form, hide form, show answers in table const responses = Form.fetchAllResponses(event); + console.log(responses); // create account string columns responses['approp'] = AccountString.getNumber(responses['approp-name']); diff --git a/src/js/views/view_logic.js b/src/js/views/view_logic.js index 48febd6..4d20432 100644 --- a/src/js/views/view_logic.js +++ b/src/js/views/view_logic.js @@ -85,6 +85,12 @@ export function lastPage(){ // clean up current page if (CLEANUP[page_state]) { CLEANUP[page_state]() }; + + // if on new-inits, circle back to fund selection + if (CurrentPage.load() == 'new-inits'){ + visitPage('baseline-landing'); + return; + } // Check if there is a next key if (currentIndex >= 1) {