Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Boxes will try to remember their state and auto-collapse.
James Coleb714eaac0643
diff --git a/public/js/ff/boxes.js b/public/js/ff/boxes.jsnew file mode 100644index 0000000000..ae787e7f5b--- /dev/null+++ b/public/js/ff/boxes.js@@ -0,0 +1,61 @@+/*+ * boxes.js+ * Copyright (C) 2016 [email protected]+ *+ * This software may be modified and distributed under the terms+ * of the MIT license. See the LICENSE file for details.+ */++$(function () {+ "use strict";+ $('button[data-widget="collapse"]').click(storeBoxState);++ // restore boxes to their original state:+ $.each($('.box'), function (i, v) {+ var box = $(v);+ if (box.attr('id')) {+ var state = getBoxState(box.attr('id'));+ console.log('Box ' + box.attr('id') + ' should be ' + state);+ if(state == 'closed') {+ $('button[data-widget="collapse"]', box).click();+ }+ }+ });+});++function storeBoxState(e) {+ "use strict";+ //Find the box parent+ var button = $(e.target);+ var box = button.parents(".box").first();+ var id = box.attr('id');+ if (id) {+ console.log('Box has id: ' + id);+ if (box.hasClass('collapsed-box')) {+ setBoxState(id, 'open');+ console.log('Box "' + id + '" is now opening / open.');+ } else {+ setBoxState(id, 'closed');+ console.log('Box "' + id + '" is now closing / closed.');+ }+ }+}++function setBoxState(id, state) {+ "use strict";+ var index = 'ff-box-state-' + id;+ if (typeof(Storage) !== "undefined") {+ localStorage.setItem(index, state);+ }+}+function getBoxState(id) {+ "use strict";+ var index = 'ff-box-state-' + id;+ if (typeof(Storage) !== "undefined") {+ var state = localStorage.getItem(index);+ if (state) {+ return state;+ }+ }+ return 'open';+}\ No newline at end of filediff --git a/public/js/ff/charts.js b/public/js/ff/charts.jsindex 83fa029dda..e6b00274cd 100644--- a/public/js/ff/charts.js+++ b/public/js/ff/charts.js@@ -285,6 +285,19 @@ function areaChart(URL, container, options) {function columnChart(URL, container, options) {"use strict";+ // find the parent box:+ var cont = $('#' + container);+ var box = cont.parents(".box").first();+ var boxId = box.attr('id');+ if (boxId) {+ var state = getBoxState(boxId);+ if (state == 'closed') {+ console.log('Will not draw columnChart(' + URL + ') because ' + boxId + ' is closed.');+ return;+ }+ }++options = options || {};$.getJSON(URL).done(function (data) {diff --git a/public/js/ff/firefly.js b/public/js/ff/firefly.jsindex 3130714722..cedeaf41f3 100644--- a/public/js/ff/firefly.js+++ b/public/js/ff/firefly.js@@ -96,19 +96,5 @@ function currencySelect(e) {return false;-- //var code = target.data('code');- //var fieldType = target.data('field');- //var menu = $('.' + fieldType + 'CurrencyDropdown');- //- //var symbolHolder = $('#' + fieldType + 'CurrentSymbol');- //symbolHolder.text(symbol);- //$('input[name="' + fieldType + '_currency_id"]').val(id);- //- // close dropdown (hack hack)- //menu.click();--- //return false;}diff --git a/resources/views/accounts/index.twig b/resources/views/accounts/index.twigindex a1b0377c75..2310652b71 100644--- a/resources/views/accounts/index.twig+++ b/resources/views/accounts/index.twig@@ -15,7 +15,7 @@</div><div class="row"><div class="col-lg-12 col-md-12 col-sm-12">- <div class="box">+ <div class="box" id="account-index-{{ what }}"><div class="box-header with-border"><h3 class="box-title">{{ subTitle }}</h3>diff --git a/resources/views/layout/default.twig b/resources/views/layout/default.twigindex 16ee742cef..eadf79b317 100644--- a/resources/views/layout/default.twig+++ b/resources/views/layout/default.twig@@ -195,6 +195,7 @@</script><script type="text/javascript" src="js/ff/firefly.js"></script>+<script type="text/javascript" src="js/ff/boxes.js"></script><script type="text/javascript" src="js/ff/help.js"></script>{% block scripts %}{% endblock %}diff --git a/resources/views/reports/default/year.twig b/resources/views/reports/default/year.twigindex f8d4040337..85f951869c 100644--- a/resources/views/reports/default/year.twig+++ b/resources/views/reports/default/year.twig@@ -8,7 +8,7 @@<div class="row"><div class="col-lg-8 col-md-8 col-sm-12">- <div class="box">+ <div class="box" id="year-inc-exp"><div class="box-header with-border"><h3 class="box-title">{{ 'incomeVsExpenses'|_ }}</h3></div>@@ -18,7 +18,7 @@</div></div><div class="col-lg-4 col-md-4 col-sm-12">- <div class="box">+ <div class="box" id="year-inc-exp-sum"><div class="box-header with-border"><h3 class="box-title">{{ 'incomeVsExpenses'|_ }}</h3></div>@@ -61,42 +61,17 @@</div></div>- <!--- <div class="row">- <div class="col-lg-12 col-md-12 col-sm-12">- <div class="box">- <div class="box-header with-border">- <h3 class="box-title">{{ 'categories_spent_in_year'|_ }}</h3>- </div>- <div class="box-body">- <canvas height="400" id="categories-spent-in-period" style="width:100%;height:400px;"></canvas>- </div>- </div>- </div>- </div>- -->-- <!--- <div class="row">- <div class="col-lg-12 col-md-12 col-sm-12">- <div class="box">- <div class="box-header with-border">- <h3 class="box-title">{{ 'categories_earned_in_year'|_ }}</h3>- </div>- <div class="box-body">- <canvas height="400" id="categories-earned-in-period" style="width:100%;height:400px;"></canvas>- </div>- </div>- </div>- </div>- -->-{% for category in categories %}<div class="row"><div class="col-lg-12 col-md-12 col-sm-12">- <div class="box">+ <div class="box" id="year-cat-{{ category.id }}"><div class="box-header with-border"><h3 class="box-title">{{ 'category'|_ }} {{ category.name }}</h3>++ <!-- ACTIONS MENU -->+ <div class="box-tools pull-right">+ <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>+ </div></div><div class="box-body"><canvas height="400" id="categories_{{ category.id }}" class="category_year_chart" data-category="{{ category.id }}"@@ -110,9 +85,14 @@{% for budget in budgets %}<div class="row"><div class="col-lg-12 col-md-12 col-sm-12">- <div class="box">+ <div class="box" id="year-budget-{{ budget.id }}"><div class="box-header with-border"><h3 class="box-title">{{ 'budget'|_ }} {{ budget.name }}</h3>++ <!-- ACTIONS MENU -->+ <div class="box-tools pull-right">+ <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>+ </div></div><div class="box-body"><canvas height="400" id="budgets_{{ budget.id }}" class="budget_year_chart" data-budget="{{ budget.id }}"