Optimize some views for category report

This commit is contained in:
James Cole
2016-11-12 12:12:11 +01:00
parent a294f757ff
commit c5d2fabfec
4 changed files with 24 additions and 6 deletions

View File

@@ -20,7 +20,6 @@ use FireflyIII\Helpers\Collector\JournalCollector;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log;
/** /**
* Class MonthReportGenerator * Class MonthReportGenerator
@@ -232,7 +231,6 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$transactions = $collector->getJournals(); $transactions = $collector->getJournals();
$transactions = self::filterExpenses($transactions, $accountIds); $transactions = self::filterExpenses($transactions, $accountIds);
return $transactions; return $transactions;
} }

View File

@@ -17,7 +17,6 @@ $(function () {
} }
); );
// set values from cookies, if any: // set values from cookies, if any:
if (readCookie('report-type') !== null) { if (readCookie('report-type') !== null) {
$('select[name="report_type"]').val(readCookie('report-type')); $('select[name="report_type"]').val(readCookie('report-type'));
@@ -26,7 +25,7 @@ $(function () {
if ((readCookie('report-accounts') !== null)) { if ((readCookie('report-accounts') !== null)) {
var arr = readCookie('report-accounts').split(','); var arr = readCookie('report-accounts').split(',');
arr.forEach(function (val) { arr.forEach(function (val) {
$('input[type="checkbox"][value="' + val + '"]').prop('checked', true); $('input[class="account-checkbox"][type="checkbox"][value="' + val + '"]').prop('checked', true);
}); });
} }
@@ -55,13 +54,24 @@ function getReportOptions() {
$('#extra-options').empty(); $('#extra-options').empty();
$('#extra-options').addClass('loading'); $('#extra-options').addClass('loading');
console.log('Changed report type to ' + reportType); console.log('Changed report type to ' + reportType);
$.getJSON('reports/options/' + reportType, function (data) { $.getJSON('reports/options/' + reportType, function (data) {
$('#extra-options').removeClass('loading').html(data.html); $('#extra-options').removeClass('loading').html(data.html);
setOptionalFromCookies();
}).fail(function () { }).fail(function () {
$('#extra-options').removeClass('loading').addClass('error'); $('#extra-options').removeClass('loading').addClass('error');
}); });
} }
function setOptionalFromCookies() {
if ((readCookie('report-categories') !== null)) {
var arr = readCookie('report-categories').split(',');
arr.forEach(function (val) {
$('input[class="category-checkbox"][type="checkbox"][value="' + val + '"]').prop('checked', true);
});
}
}
function catchSubmit() { function catchSubmit() {
"use strict"; "use strict";
// date, processed: // date, processed:
@@ -78,7 +88,15 @@ function catchSubmit() {
} }
}); });
// all category ids to come // all category ids:
//category-checkbox
var categories = [];
$.each($('.category-checkbox'), function (i, v) {
var c = $(v);
if (c.prop('checked')) {
categories.push(c.val());
}
});
// remember all // remember all
@@ -86,6 +104,7 @@ function catchSubmit() {
// set cookie to remember choices. // set cookie to remember choices.
createCookie('report-type', $('select[name="report_type"]').val(), 365); createCookie('report-type', $('select[name="report_type"]').val(), 365);
createCookie('report-accounts', accounts, 365); createCookie('report-accounts', accounts, 365);
createCookie('report-categories', categories, 365);
createCookie('report-start', moment(picker.startDate).format("YYYYMMDD"), 365); createCookie('report-start', moment(picker.startDate).format("YYYYMMDD"), 365);
createCookie('report-end', moment(picker.endDate).format("YYYYMMDD"), 365); createCookie('report-end', moment(picker.endDate).format("YYYYMMDD"), 365);
} }

View File

@@ -669,6 +669,7 @@ return [
'report_type' => 'Report type', 'report_type' => 'Report type',
'report_type_default' => 'Default financial report', 'report_type_default' => 'Default financial report',
'report_type_audit' => 'Transaction history overview (audit)', 'report_type_audit' => 'Transaction history overview (audit)',
'report_type_category' => 'Category report',
'report_type_meta-history' => 'Categories, budgets and bills overview', 'report_type_meta-history' => 'Categories, budgets and bills overview',
'more_info_help' => 'More information about these types of reports can be found in the help pages. Press the (?) icon in the top right corner.', 'more_info_help' => 'More information about these types of reports can be found in the help pages. Press the (?) icon in the top right corner.',
'report_included_accounts' => 'Included accounts', 'report_included_accounts' => 'Included accounts',

View File

@@ -3,6 +3,6 @@
</p> </p>
{% for category in categories %} {% for category in categories %}
<label class="checkbox-inline"> <label class="checkbox-inline">
<input type="checkbox" name="category[]" value="{{ category.id }}"> {{ category.name }} <input type="checkbox" class="category-checkbox" name="category[]" value="{{ category.id }}"> {{ category.name }}
</label> </label>
{% endfor %} {% endfor %}