Skip to content

Commit

Permalink
fixed some bugs with data entry on edit
Browse files Browse the repository at this point in the history
  • Loading branch information
katrina-cityofdetroit committed Jul 16, 2024
1 parent e87470c commit d36ee25
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
14 changes: 10 additions & 4 deletions js/components/table/subcomponents/cells.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
};
Expand Down
2 changes: 1 addition & 1 deletion js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion js/utils/common_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const unformatCurrency = (formattedAmount) => {
};

export function displayWithCommas(value) {
if (value == '$ -'){
if (value == 0){
return 0;
}
return formatCurrency(value).replace('$', '');
Expand Down
2 changes: 1 addition & 1 deletion js/utils/data_utils/local_storage_handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions js/views/04.5_OT/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions js/views/05_nonpersonnel/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'}

];
Expand Down Expand Up @@ -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();
}

0 comments on commit d36ee25

Please sign in to comment.