mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
A basic box for #786
This commit is contained in:
76
public/js/ff/budgets/index.js
vendored
76
public/js/ff/budgets/index.js
vendored
@@ -10,6 +10,37 @@
|
||||
|
||||
/** global: spent, budgeted, available, currencySymbol, budgetIndexUri, updateIncomeUri, periodStart, periodEnd, budgetAmountUri, accounting */
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
$(function () {
|
||||
"use strict";
|
||||
|
||||
$('.updateIncome').on('click', updateIncome);
|
||||
$('.infoIncome').on('click', infoIncome);
|
||||
|
||||
/*
|
||||
On start, fill the "spent"-bar using the content from the page.
|
||||
*/
|
||||
drawSpentBar();
|
||||
drawBudgetedBar();
|
||||
|
||||
/*
|
||||
When the input changes, update the percentages for the budgeted bar:
|
||||
*/
|
||||
$('input[type="number"]').on('input', updateBudgetedAmounts);
|
||||
|
||||
//
|
||||
$('.selectPeriod').change(function (e) {
|
||||
var sel = $(e.target).val();
|
||||
if (sel !== "x") {
|
||||
var newUri = budgetIndexUri.replace("REPLACE", sel);
|
||||
window.location.assign(newUri);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function drawSpentBar() {
|
||||
"use strict";
|
||||
if ($('.spentBar').length > 0) {
|
||||
@@ -55,6 +86,10 @@ function drawBudgetedBar() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param e
|
||||
*/
|
||||
function updateBudgetedAmounts(e) {
|
||||
"use strict";
|
||||
var target = $(e.target);
|
||||
@@ -90,7 +125,7 @@ function updateBudgetedAmounts(e) {
|
||||
|
||||
// send a post to Firefly to update the amount:
|
||||
var newUri = budgetAmountUri.replace("REPLACE", id);
|
||||
$.post(newUri, {amount: value,start: periodStart, end: periodEnd}).done(function (data) {
|
||||
$.post(newUri, {amount: value, start: periodStart, end: periodEnd}).done(function (data) {
|
||||
// update the link if relevant:
|
||||
if (data.repetition > 0) {
|
||||
$('.budget-link[data-id="' + id + '"]').attr('href', 'budgets/show/' + id + '/' + data.repetition);
|
||||
@@ -101,33 +136,10 @@ function updateBudgetedAmounts(e) {
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
"use strict";
|
||||
|
||||
$('.updateIncome').on('click', updateIncome);
|
||||
|
||||
/*
|
||||
On start, fill the "spent"-bar using the content from the page.
|
||||
*/
|
||||
drawSpentBar();
|
||||
drawBudgetedBar();
|
||||
|
||||
/*
|
||||
When the input changes, update the percentages for the budgeted bar:
|
||||
*/
|
||||
$('input[type="number"]').on('input', updateBudgetedAmounts);
|
||||
|
||||
//
|
||||
$('.selectPeriod').change(function (e) {
|
||||
var sel = $(e.target).val();
|
||||
if (sel !== "x") {
|
||||
var newUri = budgetIndexUri.replace("REPLACE", sel);
|
||||
window.location.assign(newUri);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function updateIncome() {
|
||||
"use strict";
|
||||
$('#defaultModal').empty().load(updateIncomeUri, function () {
|
||||
@@ -136,3 +148,11 @@ function updateIncome() {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function infoIncome() {
|
||||
$('#defaultModal').empty().load(infoIncomeUri, function () {
|
||||
$('#defaultModal').modal('show');
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user