mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Clean up some report code.
Signed-off-by: James Cole <thegrumpydictator@gmail.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* globals startDate, showOnlyTop, showFullList, endDate, reportType, accountIds, inOutReportUrl, accountReportUrl */
|
||||
/* globals startDate, showOnlyTop, showFullList, endDate, reportType, expenseReportUri, accountIds, incExpReportUri,accountReportUri, incomeReportUri */
|
||||
/*
|
||||
* all.js
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
@@ -13,23 +13,19 @@ $(function () {
|
||||
|
||||
|
||||
// load the account report, which this report shows:
|
||||
loadAccountReport();
|
||||
loadAjaxPartial('accountReport', accountReportUri);
|
||||
|
||||
// load income / expense / difference:
|
||||
loadInOutReport();
|
||||
|
||||
// trigger info click
|
||||
triggerInfoClick();
|
||||
|
||||
// trigger list length things:
|
||||
listLengthInitial();
|
||||
// load income and expense reports:
|
||||
loadAjaxPartial('incomeReport',incomeReportUri);
|
||||
loadAjaxPartial('expenseReport',expenseReportUri);
|
||||
loadAjaxPartial('incomeVsExpenseReport',incExpReportUri);
|
||||
|
||||
});
|
||||
|
||||
function triggerInfoClick() {
|
||||
"use strict";
|
||||
// find the little info buttons and respond to them.
|
||||
$('.firefly-info-button').unbind('clicl').click(clickInfoButton);
|
||||
$('.firefly-info-button').unbind('click').click(clickInfoButton);
|
||||
}
|
||||
|
||||
function listLengthInitial() {
|
||||
@@ -58,44 +54,6 @@ function triggerList(e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function loadInOutReport() {
|
||||
"use strict";
|
||||
console.log('Going to grab ' + inOutReportUrl);
|
||||
$.get(inOutReportUrl).done(placeInOutReport).fail(failInOutReport);
|
||||
}
|
||||
|
||||
function placeInOutReport(data) {
|
||||
"use strict";
|
||||
$('#incomeReport').removeClass('loading').html(data.income);
|
||||
$('#expenseReport').removeClass('loading').html(data.expenses);
|
||||
$('#incomeVsExpenseReport').removeClass('loading').html(data.incomes_expenses);
|
||||
listLengthInitial();
|
||||
triggerInfoClick();
|
||||
}
|
||||
|
||||
function failInOutReport() {
|
||||
"use strict";
|
||||
console.log('Fail in/out report data!');
|
||||
$('#incomeReport').removeClass('loading').addClass('general-chart-error');
|
||||
$('#expenseReport').removeClass('loading').addClass('general-chart-error');
|
||||
$('#incomeVsExpenseReport').removeClass('loading').addClass('general-chart-error');
|
||||
}
|
||||
|
||||
function loadAccountReport() {
|
||||
"use strict";
|
||||
$.get(accountReportUrl).done(placeAccountReport).fail(failAccountReport);
|
||||
}
|
||||
|
||||
function placeAccountReport(data) {
|
||||
"use strict";
|
||||
$('#accountReport').removeClass('loading').html(data);
|
||||
}
|
||||
|
||||
function failAccountReport(data) {
|
||||
"use strict";
|
||||
$('#accountReport').removeClass('loading').addClass('general-chart-error');
|
||||
}
|
||||
|
||||
function clickInfoButton(e) {
|
||||
"use strict";
|
||||
// find all data tags, regardless of what they are:
|
||||
@@ -125,8 +83,7 @@ function respondInfoButton(data) {
|
||||
"use strict";
|
||||
// remove wait cursor
|
||||
$('body').removeClass('waiting');
|
||||
$('#defaultModal').empty().html(data.html);
|
||||
$('#defaultModal').modal('show');
|
||||
$('#defaultModal').empty().html(data.html).modal('show');
|
||||
|
||||
}
|
||||
|
||||
@@ -150,6 +107,12 @@ function displayAjaxPartial(data, holder) {
|
||||
|
||||
// find a sortable table and make it sortable:
|
||||
$.bootstrapSortable(true);
|
||||
|
||||
// find the info click things and respond to them:
|
||||
triggerInfoClick();
|
||||
|
||||
// trigger list thing
|
||||
listLengthInitial();
|
||||
}
|
||||
|
||||
function failAjaxPartial(uri, holder) {
|
||||
|
@@ -1,74 +1,15 @@
|
||||
/* globals google, budgetReportUrl, startDate ,reportURL, endDate , reportType ,accountIds, lineChart, categoryReportUrl, balanceReportUrl */
|
||||
/* globals google, categoryReportUri, budgetReportUri, balanceReportUri */
|
||||
|
||||
|
||||
$(function () {
|
||||
"use strict";
|
||||
drawChart();
|
||||
|
||||
loadCategoryReport();
|
||||
loadBalanceReport();
|
||||
loadBudgetReport();
|
||||
loadAjaxPartial('categoryReport', categoryReportUri);
|
||||
loadAjaxPartial('budgetReport', budgetReportUri);
|
||||
loadAjaxPartial('balanceReport',balanceReportUri);
|
||||
});
|
||||
|
||||
function loadCategoryReport() {
|
||||
"use strict";
|
||||
console.log('Going to grab ' + categoryReportUrl);
|
||||
$.get(categoryReportUrl).done(placeCategoryReport).fail(failCategoryReport);
|
||||
}
|
||||
|
||||
function loadBudgetReport() {
|
||||
"use strict";
|
||||
console.log('Going to grab ' + budgetReportUrl);
|
||||
$.get(budgetReportUrl).done(placeBudgetReport).fail(failBudgetReport);
|
||||
}
|
||||
|
||||
|
||||
function loadBalanceReport() {
|
||||
"use strict";
|
||||
console.log('Going to grab ' + categoryReportUrl);
|
||||
$.get(balanceReportUrl).done(placeBalanceReport).fail(failBalanceReport);
|
||||
}
|
||||
|
||||
function placeBudgetReport(data) {
|
||||
"use strict";
|
||||
$('#budgetReport').removeClass('loading').html(data);
|
||||
listLengthInitial();
|
||||
triggerInfoClick();
|
||||
}
|
||||
|
||||
function placeBalanceReport(data) {
|
||||
"use strict";
|
||||
$('#balanceReport').removeClass('loading').html(data);
|
||||
listLengthInitial();
|
||||
triggerInfoClick();
|
||||
}
|
||||
|
||||
function placeCategoryReport(data) {
|
||||
"use strict";
|
||||
$('#categoryReport').removeClass('loading').html(data);
|
||||
listLengthInitial();
|
||||
triggerInfoClick();
|
||||
}
|
||||
|
||||
function failBudgetReport() {
|
||||
"use strict";
|
||||
console.log('Fail budget report data!');
|
||||
$('#budgetReport').removeClass('loading').addClass('general-chart-error');
|
||||
}
|
||||
|
||||
function failBalanceReport() {
|
||||
"use strict";
|
||||
console.log('Fail balance report data!');
|
||||
$('#balanceReport').removeClass('loading').addClass('general-chart-error');
|
||||
}
|
||||
|
||||
function failCategoryReport() {
|
||||
"use strict";
|
||||
console.log('Fail category report data!');
|
||||
$('#categoryReport').removeClass('loading').addClass('general-chart-error');
|
||||
}
|
||||
|
||||
|
||||
function drawChart() {
|
||||
"use strict";
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* globals google, accountIds, budgetYearOverviewUrl */
|
||||
/* globals google, accountIds, budgetYearOverviewUri */
|
||||
|
||||
var chartDrawn;
|
||||
var budgetChart;
|
||||
@@ -7,30 +7,9 @@ $(function () {
|
||||
chartDrawn = false;
|
||||
drawChart();
|
||||
|
||||
//
|
||||
loadBudgetOverview();
|
||||
loadAjaxPartial('budgetOverview',budgetYearOverviewUri);
|
||||
});
|
||||
|
||||
function loadBudgetOverview() {
|
||||
"use strict";
|
||||
console.log('Going to grab ' + budgetYearOverviewUrl);
|
||||
$.get(budgetYearOverviewUrl).done(placeBudgetOverview).fail(failBudgetOverview);
|
||||
}
|
||||
|
||||
function placeBudgetOverview(data) {
|
||||
"use strict";
|
||||
$('#budgetOverview').removeClass('loading').html(data);
|
||||
$('.budget-chart-activate').on('click', clickBudgetChart);
|
||||
}
|
||||
|
||||
function failBudgetOverview() {
|
||||
"use strict";
|
||||
console.log('Fail budget overview data!');
|
||||
$('#budgetOverview').removeClass('loading').addClass('general-chart-error');
|
||||
}
|
||||
|
||||
|
||||
|
||||
function drawChart() {
|
||||
"use strict";
|
||||
|
||||
|
Reference in New Issue
Block a user