From 743e88914023c53e24965459a1b1f74a66563ad4 Mon Sep 17 00:00:00 2001 From: Katrina Wheelan Date: Wed, 24 Jul 2024 12:36:35 -0400 Subject: [PATCH] #53 add edit button for each table row on inits view --- src/js/components/table/subcomponents/cells.js | 12 ++++++------ src/js/views/07_new_initiatives/helpers.js | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/js/components/table/subcomponents/cells.js b/src/js/components/table/subcomponents/cells.js index 93bd50a..73e8eec 100644 --- a/src/js/components/table/subcomponents/cells.js +++ b/src/js/components/table/subcomponents/cells.js @@ -43,16 +43,15 @@ function createEditableCell(cellClass, isCost){ cell.appendChild(textbox); } -function createServiceDropdown(){ +function createDropdown(cellClass, optionArray){ // get cell - var cellClass = 'service'; const cell = document.querySelector(`.active-editing td.${cellClass}`); // add service dropdown - const serviceDropdown = Dropdown.create(Services.list()); - serviceDropdown.value = cell.textContent; + const dropdown = Dropdown.create(optionArray); + dropdown.value = cell.textContent; // Clear the current content and append the textbox to the cell cell.innerHTML = ''; - cell.appendChild(serviceDropdown); + cell.appendChild(dropdown); } const Cell = { @@ -68,7 +67,8 @@ const Cell = { createTextbox : function(className, isCost) { createEditableCell(className, isCost) }, - createServiceDropdown : createServiceDropdown + createServiceDropdown : () => { createDropdown('service', Services.list()) }, + createDropdown : createDropdown }; export default Cell; \ No newline at end of file diff --git a/src/js/views/07_new_initiatives/helpers.js b/src/js/views/07_new_initiatives/helpers.js index a3e060e..183b83a 100644 --- a/src/js/views/07_new_initiatives/helpers.js +++ b/src/js/views/07_new_initiatives/helpers.js @@ -12,6 +12,8 @@ import Sidebar from '../../components/sidebar/sidebar.js' const explanation = `New initiative submissions will count as supplemental line items and will be the starting point for a conversation with both OB and ODFS, who will help with the details.` +const dropdownOptions = ['N/A', 'One-Time', 'Recurring'] + export function initializePageView() { // Prepare page view Body.reset(); @@ -61,11 +63,13 @@ export function setUpForm() { Form.NewField.shortText('Relevant account string (if known)?', 'Account String', false); // Numbers - Form.NewField.numericInput('What is your ballpark estimate of TOTAL ADDITONAL expenses associated with this initiative?', 'Ballpark Total Expenses', false); + Form.NewField.numericInput('What is your ballpark estimate of TOTAL ADDITONAL expenses associated with this initiative?', + 'Ballpark Total Expenses', false); Form.NewField.numericInput('Estimate of ADDITONAL personnel cost?', 'Personnel Cost', false); Form.NewField.numericInput('Estimate of ADDITONAL nonpersonnel cost?', 'Non-personnel Cost', false); Form.NewField.numericInput('Estimate of ADDITONAL revenue (if applicable)?', 'Revenue', false); - Form.NewField.dropdown(`If there will be revenue, is it one-time or recurring?`, 'One-time v. Recurring', ['N/A', 'One-Time', 'Recurring']); + Form.NewField.dropdown(`If there will be revenue, is it one-time or recurring?`, + 'One-time v. Recurring', dropdownOptions); Form.SubmitButton.add(); @@ -110,7 +114,13 @@ export async function initializeInitTable(){ } function rowOnEdit(){ - return; + Table.Cell.createTextbox('total', true); + 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); } function handleNewInitSubmission(event){