-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42f9b9f
commit 70cf646
Showing
9 changed files
with
990 additions
and
31 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
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,51 @@ | ||
{% extends "layout.html" %} | ||
|
||
{% block title %} | ||
Budget Created | ||
{% endblock %} | ||
|
||
{% block main %} | ||
<h1>Budget Created</h1> | ||
<br> | ||
<div class="alert alert-dismissible alert-success"> | ||
<button type="button" class="close" data-dismiss="alert">×</button> | ||
<strong>Well done! </strong>This budget will now appear in your <a href="/">Dashboard</a> and <a href="/reports">Reports</a> where you can monitor how well you're spending against your budget. | ||
</div> | ||
<div class="row"> | ||
<div class="col-sm-12"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<h5 class="card-title">Budget Details</h5> | ||
<p><strong>Name</strong>: {{ results["name"] }}</p> | ||
<p><strong>Amount</strong>: {{ results["amount"] | usd }}</p> | ||
<div class="table-responsive"> | ||
<table class="table table-hover"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Category</th> | ||
<th scope="col">%</th> | ||
<th scope="col">Amount</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for category in results["categories"] %} | ||
{% set amount = (results["amount"] * category["percent"]) %} | ||
<tr> | ||
<td>{{ category["name"] }}</td> | ||
<td>{{ ((category["percent"] * 100) | string)[:-2] }}%</td> | ||
<td>{{ amount | usd }} | ||
</tr> | ||
{% endfor %} | ||
<tr> | ||
<td></td> | ||
<td>100%</td> | ||
<td>{{ results["amount"] | usd }}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
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,102 @@ | ||
{% extends "layout.html" %} | ||
|
||
{% block title %} | ||
Manage Budgets | ||
{% endblock %} | ||
|
||
{% block main %} | ||
<h1>Manage Budgets</h1> | ||
<br> | ||
{% if deletedBudgetName != None %} | ||
<div class="alert alert-dismissible alert-danger"> | ||
<button type="button" class="close" data-dismiss="alert">×</button> | ||
<strong>POOF!</strong> You deleted the budget '<strong>{{ deletedBudgetName }}</strong>'. | ||
</div> | ||
{% endif %} | ||
<div class="row"> | ||
<div class="col-sm-6"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<h5 class="card-title">Create a new budget</h5> | ||
{% if (income - budgeted) > 0 %} | ||
<p>You currently have <strong>{{ (income - budgeted) | usd}}</strong> of unbudgeted income.</p> | ||
<a href="/createbudget" class="btn btn-success">Create a Budget</a> | ||
{% else %} | ||
<p>All of your income is budgeted for. Good job 👍</p> | ||
<a href="/createbudget" class="btn btn-success">Create a Budget</a> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-sm-6"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<h5 class="card-title">Update existing budgets</h5> | ||
{% if budgets %} | ||
{% for budget in budgets %} | ||
<div class="btn-group"> | ||
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | ||
{{ budget["name"] }} | ||
</button> | ||
<div class="dropdown-menu"> | ||
<a class="dropdown-item" href="/updatebudget/{{ budget['name'] }}">Update</a> | ||
<div class="dropdown-divider"></div> | ||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#deleteModal" data-budget="{{ budget['name'] }}" data-amount="{{ budget['amount'] | usd }}">Delete</a> | ||
</div> | ||
</div> | ||
<small class="form-text text-muted">Amount: {{ budget["amount"] | usd }}</a></small> | ||
<br> | ||
{% endfor %} | ||
{% else %} | ||
<p>You have not created any budgets yet 😢</p> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- Budget delete modal --> | ||
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true"> | ||
<div class="modal-dialog" role="document"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title" id="deleteModalLabel">Delete Budget</h5> | ||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="modal-body"> | ||
<form action="/budgets" id="deleteBudget" method="post"> | ||
<div class="form-group"> | ||
<input type="hidden" class="form-control" name="delete" id="delete" value="" readonly> | ||
</div> | ||
</form> | ||
<p class="text-danger"><strong>Are you sure you want to delete this budget?</strong></p> | ||
<ul class="text-danger" style="text-align:left"> | ||
<li class="text-danger small">The budget will no longer appear in your Dashboard or Reports</li> | ||
<li class="text-danger small" id="amountAlert"></li> | ||
</ul> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="submit" class="btn btn-danger" form="deleteBudget" id="btnDeleteBudget">Delete Budget</button> | ||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
// Set the title and fields of the delete modal on load/show | ||
$('#deleteModal').on('show.bs.modal', function (event) { | ||
var button = $(event.relatedTarget) // Button that triggered the modal | ||
var budget = button.data('budget') // Extract info from data-* attributes | ||
var amount = button.data('amount') | ||
var modal = $(this) | ||
modal.find('.modal-title').text("Delete budget '" + budget + "'") | ||
modal.find('#delete').val(budget) | ||
modal.find('#amountAlert').text(amount + " of your income will no longer be budgeted for") | ||
}) | ||
</script> | ||
|
||
{% endblock %} | ||
|
Oops, something went wrong.