-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from kwheelan/55-adjust-target-logic
55 adjust target logic
- Loading branch information
Showing
9 changed files
with
195 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,6 @@ jspm_packages/ | |
.env | ||
.env.test | ||
node_modules | ||
|
||
# excel temp files | ||
~$* |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
src/js/components/sidebar/subcomponents/baseline_section.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { FISCAL_YEAR } from "../../../constants"; | ||
import { Baseline, FundLookupTable, Fund, CurrentFund } from "../../../models"; | ||
import { formatCurrency } from "../../../utils/common_utils"; | ||
import { visitPage } from "../../../views/view_logic"; | ||
|
||
export const BaselineSection = { | ||
_data: new Baseline(), | ||
_genFund : new Fund(1000), | ||
|
||
get data() { | ||
this._data = new Baseline(); | ||
return this._data; | ||
}, | ||
|
||
set data(newData) { | ||
this._data = newData; | ||
}, | ||
|
||
get genFund() { | ||
this._genFund = new Fund(1000); | ||
return this._genFund; | ||
}, | ||
|
||
set genFund(newFund) { | ||
this._genFund = newFund; | ||
}, | ||
|
||
target_html() { | ||
return ` | ||
<div class='sidebar-stat-line' id="baseline-total"> | ||
<span class="stat-label">Baseline total:</span> | ||
<span class="stat">${formatCurrency(this.data.total())}</span> | ||
</div> | ||
<div class='sidebar-stat-line' id="target"> | ||
<span class="stat-label">FY${FISCAL_YEAR} GF target:</span> | ||
<span class="stat">${formatCurrency(Baseline.target())}</span> | ||
</div> | ||
<div class='sidebar-stat-line' id="GF-total"> | ||
<span class="stat-label">Current GF total:</span> | ||
<span class="stat">${formatCurrency(this.genFund.getTotal())}</span> | ||
</div> | ||
<br>`; | ||
}, | ||
|
||
fund_html(fund) { | ||
return ` | ||
<h6>${FundLookupTable.getName(fund.fund)}</h6> | ||
<hr> | ||
<div class='sidebar-stat-line revenue'> | ||
<span class="stat-label">Projected revenues:</span> | ||
<span class="stat">${formatCurrency(fund.getRevenue())}</span> | ||
<i class="fas fa-edit edit-icon" title="Edit"></i> | ||
</div> | ||
<div class='sidebar-stat-line personnel'> | ||
<span class="stat-label">Personnel cost:</span> | ||
<span class="stat">${formatCurrency(fund.getPersonnelCost())}</span> | ||
<i class="fas fa-edit edit-icon" title="Edit"></i> | ||
</div> | ||
<div class='sidebar-stat-line nonpersonnel'> | ||
<span class="stat-label">Non-personnel cost:</span> | ||
<span class="stat">${formatCurrency(fund.getNonPersonnelCost())}</span> | ||
<i class="fas fa-edit edit-icon" title="Edit"></i> | ||
</div> | ||
<div class='sidebar-stat-line fund-total'> | ||
<span class="stat-label">Fund total:</span> | ||
<span class="stat">${formatCurrency(fund.getTotal())}</span> | ||
</div> | ||
<br>`; | ||
}, | ||
|
||
linkEditBtns() { | ||
let btns = document.querySelectorAll('.edit-icon'); | ||
btns.forEach((btn) => { | ||
// Get the fund from the div the button is in | ||
let fund = btn.closest('.fund-div').id.replace('fund_', ''); | ||
let page = btn.closest('.sidebar-stat-line').classList[1]; | ||
|
||
btn.addEventListener('click', function(event) { | ||
CurrentFund.update(fund); | ||
visitPage(page); | ||
}); | ||
}); | ||
}, | ||
|
||
update() { | ||
const baselineDiv = document.querySelector('#baseline-stats'); | ||
baselineDiv.innerHTML = this.target_html(); | ||
|
||
this.data.funds.forEach((fund) => { | ||
var fundDiv = document.createElement('div'); | ||
fundDiv.id = `fund_${fund.fund}`; | ||
fundDiv.classList.add('fund-div'); | ||
fundDiv.innerHTML = this.fund_html(fund); | ||
baselineDiv.appendChild(fundDiv); | ||
}); | ||
|
||
if(this.genFund.getTotal() <= Baseline.target()){ | ||
document.querySelector('#GF-total .stat').style.color = "green"; | ||
document.querySelector('#fund_100 sidebar-stat-line.fund-total .stat').style.color = "green"; | ||
} else { | ||
document.querySelector('#GF-total .stat').style.color = "red"; | ||
document.querySelector('#fund_1000 .sidebar-stat-line:last-of-type .stat').style.color = "red"; | ||
} | ||
this.linkEditBtns(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Supplemental } from "../../../models"; | ||
import { formatCurrency } from "../../../utils/common_utils"; | ||
|
||
export const SuppSection = { | ||
html() { | ||
var supp = new Supplemental; | ||
return ` | ||
<div class='sidebar-stat-line' id="supp-revenue"> | ||
<span class="stat-label">Estimated revenues:</span> | ||
<span class="stat">${formatCurrency(supp.revenue())}</span> | ||
</div> | ||
<div class='sidebar-stat-line' id="supp-expenses"> | ||
<span class="stat-label">Esimated expenditures:</span> | ||
<span class="stat">${formatCurrency(supp.expenses())}</span> | ||
</div> | ||
<div class='sidebar-stat-line' id="supp-total"> | ||
<span class="stat-label">Total supplemental:</span> | ||
<span class="stat">${formatCurrency(supp.total())}</span> | ||
</div>` | ||
}, | ||
|
||
update() { | ||
const suppDiv = document.querySelector('#supp-stats'); | ||
suppDiv.innerHTML = this.html(); | ||
} | ||
} | ||
|
||
export default SuppSection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters