Skip to content

Commit

Permalink
#53 add edit button for each table row on inits view
Browse files Browse the repository at this point in the history
  • Loading branch information
katrina-cityofdetroit committed Jul 24, 2024
1 parent 5d2e4a5 commit 743e889
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/js/components/table/subcomponents/cells.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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;
16 changes: 13 additions & 3 deletions src/js/views/07_new_initiatives/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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){
Expand Down

0 comments on commit 743e889

Please sign in to comment.