Skip to content

Commit

Permalink
fixed new inits bug; expanded personnel table
Browse files Browse the repository at this point in the history
  • Loading branch information
katrina-cityofdetroit committed Jun 21, 2024
1 parent 5f44387 commit 0bb4077
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 22 deletions.
2 changes: 2 additions & 0 deletions data/law_dept_sample/services.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[
{ "id" : "",
"name" : "Select"},
{ "id" : "Appeals",
"name" : "Appeals"},
{ "id" : "FOIA",
Expand Down
14 changes: 9 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,40 +140,44 @@ <h6 id="section-header"><strong>Baseline</strong></h6>
<div class='sidebar-stat-line' id="target">
<span class="stat-label">FY26 target:</span>
<span class="stat"></span>
<div>
</div>
<div class='sidebar-stat-line' id="baseline-revenue">
<span class="stat-label">Projected revenue:</span>
<span class="stat"></span>
<div>
</div>
<div class='sidebar-stat-line' id="baseline-personnel">
<span class="stat-label">Personnel cost:</span>
<span class="stat"></span>
<div>
</div>
<div class='sidebar-stat-line' id="baseline-nonpersonnel">
<span class="stat-label">Non-personnel cost:</span>
<span class="stat"></span>
<div>
</div>
<div class='sidebar-stat-line' id="baseline-total">
<span class="stat-label">Total baseline:</span>
<span class="stat"></span>
<div>
</div>
</div>
<br>
<h6 id="section-header"><strong>Supplemental</strong></h6>
<div id="supp-stats">
<div class='sidebar-stat-line' id="supp-revenue">
<span class="stat-label">Revenue:</span>
<span class="stat"></span>
</div>
<div class='sidebar-stat-line' id="supp-personnel">
<span class="stat-label">Personnel cost:</span>
<span class="stat"></span>
</div>
<div class='sidebar-stat-line' id="supp-nonpersonnel">
<span class="stat-label">Non-personnel cost:</span>
<span class="stat"></span>
</div>
<div class='sidebar-stat-line' id="supp-total">
<span class="stat-label">Total supplemental:</span>
<span class="stat"></span>
</div>
</div>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { loadPersonnelPage } from './pages/04_personnel/main.js';
import { addTarget } from './components/sidebar/sidebar.js';

export let DATA_ROOT = '../../../data/law_dept_sample/'
export let REVENUE = 0;

document.addEventListener('DOMContentLoaded', function () {

Expand Down
27 changes: 15 additions & 12 deletions js/pages/02_new_initiatives/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,19 @@ export function handleFormSubmissions(event){
modal.addEventListener('submit', function(event) {
// get answers from form, hide form, show answers in table
const responses = fetchAllResponses(event);

// change page view
hideModal('main-modal');
hidePrompt();

// add data to table
addNewRow('main-table', responses);
showTable('main-table');
showAddButton();
// TODO: save table data
// TODO: edit cost to show currency correctly
});
// make sure it's not an empty response
if (Object.values(responses)[0] != ''){
// change page view
hideModal('main-modal');
hidePrompt();

// add data to table
addNewRow('main-table', responses);
showTable('main-table');
showAddButton();
// TODO: save table data
// TODO: edit cost to show currency correctly
}

})
}
4 changes: 3 additions & 1 deletion js/pages/03_revenue/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { showNavButtons } from '../../components/nav_buttons/nav_buttons.js'
import { loadNewInitiatives } from '../02_new_initiatives/main.js'
import { hideTable } from '../../components/table/table.js'
import { hideSideBar } from '../../components/sidebar/sidebar.js'
import { formatCurrency } from '../../utils/utils.js'

import { REVENUE } from '../../init.js'

export function loadRevenuePage() {

Expand All @@ -23,7 +25,7 @@ export function loadRevenuePage() {
// update page text
updateSubtitle('Revenue Projections');
// TODO: update to make dynamic
updatePrompt('Your revenue projection for FY26 is $0');
updatePrompt(`Your revenue projection for FY26 is ${formatCurrency(REVENUE, true)}`);
updatePromptButtons('Confirm and continue.', "This doesn't look right");

// clicking 'confirm and continue' will also take us to the next page
Expand Down
9 changes: 6 additions & 3 deletions js/pages/04_personnel/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,20 @@ function initializeConfirmButton(rowToEdit){
confirm_btn.addEventListener('click', function(event){
// get current row
const rowToEdit = event.target.closest('tr');
var textboxes = rowToEdit.querySelectorAll('input')
var textboxes = rowToEdit.querySelectorAll('input');
// save all text in textboxes
textboxes.forEach( textbox => {
var enteredValue = textbox.value;
var cell = textbox.parentElement;
cell.textContent = enteredValue;
cell.setAttribute('value', enteredValue);
})

// set service selection
const serviceSelector = rowToEdit.querySelector('select');
var cell = serviceSelector.parentElement;
cell.textContent = serviceSelector.value;
//set service value


// update values in sidebar
updateDisplayandTotals();
Expand Down
5 changes: 4 additions & 1 deletion js/utils/utils.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
// Function to format number as currency
export const formatCurrency = (amount) => {
export const formatCurrency = (amount, return_zero = false) => {
var amount = parseFloat(amount);
if (amount == NaN){
return "$ -"
}
if (amount < 0){
return '($' + amount.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,') + ')';
} else if (amount == 0) {
if (return_zero){
return '$0';
}
return "$ -"
}
return '$' + amount.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
Expand Down

0 comments on commit 0bb4077

Please sign in to comment.