-
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 #48 from kwheelan/4-revenue-table
4 revenue table
- Loading branch information
Showing
14 changed files
with
186 additions
and
125 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,65 @@ | ||
import Prompt from '../../components/prompt/prompt.js' | ||
import { formatCurrency } from '../../utils/common_utils.js' | ||
import { REVENUE } from '../../init.js' | ||
import Body from '../../components/body/body.js' | ||
import NavButtons from '../../components/nav_buttons/nav_buttons.js' | ||
import { nextPage } from '../view_logic.js' | ||
import Subtitle from '../../components/header/header.js' | ||
import Modal from '../../components/modal/modal.js' | ||
import Form from '../../components/form/form.js' | ||
import Sidebar from '../../components/sidebar/sidebar.js' | ||
import Table from '../../components/table/table.js' | ||
import Tooltip from '../../components/tooltip/tooltip.js' | ||
|
||
const revenueColumns = [ | ||
{ title: 'Edit', className : 'edit' }, | ||
{ title : 'Account String', className : 'account-string'}, | ||
{ title: 'Recurring or One-Time', className: 'recurring'}, | ||
{ title: 'Object Category', className: 'object-category'}, | ||
{ title: 'Departmental Request Total', className: 'request', isCost: true}, | ||
{ title: 'Departmental Request Notes', className: 'notes'}, | ||
|
||
// hidden columns used for calcs and info boxes | ||
{ title: 'Appropriation Name', className: 'approp-name', hide: true }, | ||
{ title: 'Cost Center Name', className: 'cc-name', hide: true }, | ||
{ title: 'Object Name', className: 'object-name', hide: true} | ||
]; | ||
|
||
export function preparePageView(){ | ||
// prepare page view | ||
Body.reset(); | ||
NavButtons.show(); | ||
Sidebar.show(); | ||
Table.adjustWidth('100%'); | ||
|
||
// update page text | ||
Subtitle.update('Revenue Projections'); | ||
// TODO: update to make dynamic | ||
Prompt.Text.update(`Your revenue projection for FY26 is ${formatCurrency(REVENUE, true)}`); | ||
Prompt.Buttons.Left.updateText('Confirm'); | ||
Prompt.Buttons.Right.updateText("This doesn't look right"); | ||
} | ||
Subtitle.update('Revenues'); | ||
|
||
export function setUpNavButtons(){ | ||
// clicking 'confirm' will also take us to the next page | ||
Prompt.Buttons.Left.addAction(nextPage); | ||
// TODO: allow user to edit revenue here | ||
Modal.Link.add('option2'); | ||
handleErrorComment(); | ||
} | ||
// set up table | ||
initializeRevTable() | ||
|
||
export function removeButtonEvents(){ | ||
// remove event listeners on prompt buttons | ||
Prompt.Buttons.Left.removeAction(nextPage); | ||
Modal.Link.remove('option2'); | ||
} | ||
// enable continue button | ||
NavButtons.Next.enable(); | ||
|
||
Prompt.Text.update('Review and edit revenue line items.'); | ||
|
||
function handleErrorComment(){ | ||
var fund = localStorage.getItem("fund"); | ||
Modal.clear(); | ||
Modal.Title.update(`Comment on ${fund} Revenue`); | ||
Form.new('modal-body'); | ||
Form.NewField.longText('Explain your concerns here. Someone from the revenue team will follow up with you.', | ||
'revenue-comment', true); | ||
Form.SubmitButton.add(); | ||
// save comment on submission | ||
Modal.Submit.init(handleRevenueCommentSubmission); | ||
} | ||
|
||
function handleRevenueCommentSubmission(event){ | ||
// get data from form in modal | ||
const responses = Form.fetchAllResponses(event); | ||
// TODO: save comment here | ||
export async function initializeRevTable(){ | ||
// load table data from storage | ||
if(await Table.Data.load()) { | ||
//after table is loaded, fill it | ||
Table.show(); | ||
Table.Columns.addAtEnd(Table.Buttons.edit_confirm_btns, "Edit"); | ||
// assign cost classes | ||
Table.Columns.assignClasses(revenueColumns); | ||
// enable editing | ||
Table.Buttons.Edit.init(revRowOnEdit, Table.save); | ||
// show info boxes on click | ||
Tooltip.linkAllRevenue(); | ||
} else { | ||
Prompt.Text.update('No revenues for this fund.') | ||
} | ||
} | ||
|
||
// hide modal, update page, and enable continue | ||
Modal.hide(); | ||
Prompt.Buttons.hide(); | ||
Prompt.Text.update('Your comment has been received.'); | ||
NavButtons.Next.enable(); | ||
function revRowOnEdit(){ | ||
// make it editable | ||
Table.Cell.createTextbox('request', true); | ||
Table.Cell.createTextbox('notes'); | ||
Table.Cell.createDropdown('recurring', ['One-Time', 'Recurring']); | ||
} |
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 |
---|---|---|
@@ -1,14 +1,10 @@ | ||
import { CurrentPage } from '../../utils/data_utils/local_storage_handlers.js' | ||
import { preparePageView, removeButtonEvents, setUpNavButtons } from './helpers.js' | ||
import { preparePageView } from './helpers.js' | ||
|
||
export function loadRevenuePage() { | ||
|
||
//update page state | ||
CurrentPage.update('revenue'); | ||
preparePageView(); | ||
setUpNavButtons(); | ||
} | ||
|
||
export function cleanupRevenuePage() { | ||
removeButtonEvents(); | ||
}; |
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
Oops, something went wrong.