Clean up code after changing routes.

This commit is contained in:
James Cole
2016-12-06 07:48:41 +01:00
parent 02257e3887
commit d8f291be6e
15 changed files with 138 additions and 92 deletions

View File

@@ -0,0 +1,4 @@
$(function () {
"use strict";
columnChart(specific, 'period-specific-period');
});

View File

@@ -1,19 +1,5 @@
/* globals $, categoryID, columnChart, categoryDate */
$(function () {
"use strict";
if (typeof categoryID !== 'undefined') {
// more splits:
if ($('#all').length > 0) {
columnChart('chart/category/' + categoryID + '/all', 'all');
}
if ($('#period').length > 0) {
columnChart('chart/category/' + categoryID + '/period', 'period');
}
}
if (typeof categoryID !== 'undefined' && typeof categoryDate !== 'undefined') {
columnChart('chart/category/' + categoryID + '/period/' + categoryDate, 'period-specific-period');
}
columnChart(all, 'all');
columnChart(current, 'period');
});

View File

@@ -1,19 +0,0 @@
/* globals $, categoryID, columnChart, categoryDate */
$(function () {
"use strict";
if (typeof categoryID !== 'undefined') {
// more splits:
if ($('#all').length > 0) {
columnChart('chart/category/' + categoryID + '/all', 'all');
}
if ($('#period').length > 0) {
columnChart('chart/category/' + categoryID + '/period', 'period');
}
}
if (typeof categoryID !== 'undefined' && typeof categoryDate !== undefined) {
columnChart('chart/category/' + categoryID + '/period/' + categoryDate, 'period-specific-period');
}
});

View File

@@ -8,31 +8,25 @@
* See the LICENSE file for details.
*/
// it's hard coded, but what you're gonna do?
var catInUri = 'chart/category/' + accountIds + '/' + categoryIds + '/' + startDate + '/' + endDate + '/OTHERS/income';
var catOutUri = 'chart/category/' + accountIds + '/' + categoryIds + '/' + startDate + '/' + endDate + '/OTHERS/expense';
var accInUri = 'chart/account/' + accountIds + '/' + categoryIds + '/' + startDate + '/' + endDate + '/OTHERS/income';
var accOutUri = 'chart/account/' + accountIds + '/' + categoryIds + '/' + startDate + '/' + endDate + '/OTHERS/expense';
$(function () {
"use strict";
drawChart();
$('#categories-in-pie-chart-checked').on('change', function () {
redrawPieChart('categories-in-pie-chart', catInUri);
redrawPieChart('categories-in-pie-chart', categoryIncomeUri);
});
$('#categories-out-pie-chart-checked').on('change', function () {
redrawPieChart('categories-out-pie-chart', catOutUri);
redrawPieChart('categories-out-pie-chart', categoryExpenseUri);
});
$('#accounts-in-pie-chart-checked').on('change', function () {
redrawPieChart('accounts-in-pie-chart', accInUri);
redrawPieChart('accounts-in-pie-chart', accountIncomeUri);
});
$('#accounts-out-pie-chart-checked').on('change', function () {
redrawPieChart('accounts-out-pie-chart', accOutUri);
redrawPieChart('accounts-out-pie-chart', accountExpenseUri);
});
});
@@ -42,13 +36,13 @@ function drawChart() {
"use strict";
// month view:
stackedColumnChart('chart/category-report-in-out/' + accountIds + '/' + categoryIds + '/' + startDate + '/' + endDate, 'in-out-chart');
stackedColumnChart(mainUri, 'in-out-chart');
// draw pie chart of income, depending on "show other transactions too":
redrawPieChart('categories-in-pie-chart', catInUri);
redrawPieChart('categories-out-pie-chart', catOutUri);
redrawPieChart('accounts-in-pie-chart', accInUri);
redrawPieChart('accounts-out-pie-chart', accOutUri);
redrawPieChart('categories-in-pie-chart', categoryIncomeUri);
redrawPieChart('categories-out-pie-chart', categoryExpenseUri);
redrawPieChart('accounts-in-pie-chart', accountIncomeUri);
redrawPieChart('accounts-out-pie-chart', accountExpenseUri);
}

View File

@@ -108,8 +108,7 @@ function clickCategoryChart(e) {
var link = $(e.target);
var categoryId = link.data('category');
// this url is different from the one below. this is something that must be fixed
var URL = 'chart/category/' + categoryId + '/report-period/' + startDate + '/' + endDate + '/' + accountIds;
var URL = 'chart/category/report-period/' + categoryId + '/' + accountIds + '/' + startDate + '/' + endDate;
var container = 'category_chart';
columnChart(URL, container);
return false;

View File

@@ -5,7 +5,6 @@ $(function () {
drawChart();
loadAjaxPartial('budgetPeriodReport', budgetPeriodReportUri);
loadAjaxPartial('categoryExpense', categoryExpenseUri);
loadAjaxPartial('categoryIncome', categoryIncomeUri);
});