From d36ee2538311254dbc370af0e345d90f928300b7 Mon Sep 17 00:00:00 2001 From: Katrina Wheelan Date: Tue, 16 Jul 2024 10:29:36 -0400 Subject: [PATCH] fixed some bugs with data entry on edit --- js/components/table/subcomponents/cells.js | 14 ++++++++++---- js/init.js | 2 +- js/utils/common_utils.js | 2 +- js/utils/data_utils/local_storage_handlers.js | 2 +- js/views/04.5_OT/helpers.js | 6 +++--- js/views/05_nonpersonnel/helpers.js | 4 ++-- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/js/components/table/subcomponents/cells.js b/js/components/table/subcomponents/cells.js index 526adb8..122c1be 100644 --- a/js/components/table/subcomponents/cells.js +++ b/js/components/table/subcomponents/cells.js @@ -21,13 +21,19 @@ function updateTableCell(row, col_class, new_value){ cell.textContent = formatCurrency(new_value); } -function createEditableCell(cellClass){ +function createEditableCell(cellClass, isCost){ // get cell const cell = document.querySelector(`.active-editing td.${cellClass}`); // Create an input element to edit the value var textbox = document.createElement('input'); textbox.type = 'text'; - textbox.value = displayWithCommas(cell.textContent); + if (isCost){ + var value = cell.getAttribute('value'); + console.log(value); + } else { + var value = cell.textContent; + } + textbox.value = displayWithCommas(value); // Clear the current content and append the textbox to the cell cell.innerHTML = ''; cell.appendChild(textbox); @@ -55,8 +61,8 @@ const Cell = { updateValue: function(row, col_class, new_value) { updateTableCell(row, col_class, new_value); }, - createTextbox : function(className) { - createEditableCell(className) + createTextbox : function(className, isCost) { + createEditableCell(className, isCost) }, createServiceDropdown : createServiceDropdown }; diff --git a/js/init.js b/js/init.js index 0eaa8da..d7264c9 100644 --- a/js/init.js +++ b/js/init.js @@ -8,7 +8,7 @@ export let DATA_ROOT = '../../../data/law_dept_sample/' // export let DATA_ROOT = '../../budget-request-demo/data/law_dept_sample/' export let REVENUE = 0; -export let TARGET = 2000000; +export let TARGET = 20000000; export var FISCAL_YEAR = '26'; export var OT_FRINGE = 0.0765; diff --git a/js/utils/common_utils.js b/js/utils/common_utils.js index 65076da..17e13a4 100644 --- a/js/utils/common_utils.js +++ b/js/utils/common_utils.js @@ -26,7 +26,7 @@ export const unformatCurrency = (formattedAmount) => { }; export function displayWithCommas(value) { - if (value == '$ -'){ + if (value == 0){ return 0; } return formatCurrency(value).replace('$', ''); diff --git a/js/utils/data_utils/local_storage_handlers.js b/js/utils/data_utils/local_storage_handlers.js index 224c42f..83af012 100644 --- a/js/utils/data_utils/local_storage_handlers.js +++ b/js/utils/data_utils/local_storage_handlers.js @@ -110,7 +110,7 @@ function colSum(table, colName, name) { } return sum; } else { - console.error(`Could not find expected total column in saved data for ${name}. Returning 0. 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.5_OT/helpers.js b/js/views/04.5_OT/helpers.js index 3a4767f..d3e22d6 100644 --- a/js/views/04.5_OT/helpers.js +++ b/js/views/04.5_OT/helpers.js @@ -44,8 +44,8 @@ function assignClasses() { } function OTRowOnEdit(){ - Table.Cell.createTextbox('OT-wages'); - Table.Cell.createTextbox('OT-salary'); + Table.Cell.createTextbox('OT-wages', true); + Table.Cell.createTextbox('OT-salary', true); Table.Cell.createServiceDropdown(Services.list()); } @@ -56,7 +56,7 @@ export async function initializeOTTable(){ Table.show(); Table.Columns.addAtEnd( '0', 'Hourly Employee Overtime (Wages)'); Table.Columns.addAtEnd( '0', 'Salaried Employee Overtime (Salary)'); - Table.Columns.addAtEnd( '0', 'Total Cost (including benefits)'); + // Table.Columns.addAtEnd( '0', 'Total Cost (including benefits)'); Table.Columns.addAtEnd(Table.Buttons.edit_confirm_btns, 'Edit');; assignClasses(); // add up the baseline costs and update sidebar diff --git a/js/views/05_nonpersonnel/helpers.js b/js/views/05_nonpersonnel/helpers.js index 7fd9e0e..0939b9d 100644 --- a/js/views/05_nonpersonnel/helpers.js +++ b/js/views/05_nonpersonnel/helpers.js @@ -20,7 +20,7 @@ const nonPersonnelColumns = [ { title: 'Edit', className : 'edit' }, { title : 'Account String', className : 'account-string'}, { title : 'CPA #', className : 'cpa'}, - { title : 'End of Contract', className : 'contract-end'}, + { title : 'Contract End Date', className : 'contract-end'}, { title: 'Recurring or One-Time', className: 'recurring'} ]; @@ -54,7 +54,7 @@ export async function initializeNonpersonnelTable(){ function nonPersonnelRowOnEdit(){ // make it editable - Table.Cell.createTextbox('request'); + Table.Cell.createTextbox('request', true); Table.Cell.createServiceDropdown(); }