diff --git a/app/Models/AccountType.php b/app/Models/AccountType.php index 2bb17e3400..88bc502ff6 100644 --- a/app/Models/AccountType.php +++ b/app/Models/AccountType.php @@ -21,13 +21,11 @@ use Illuminate\Database\Eloquent\Relations\HasMany; * @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $updated_at * @property string $type - * @property boolean $editable * @property-read \Illuminate\Database\Eloquent\Collection|Account[] $accounts * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereUpdatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereType($value) - * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereEditable($value) * @mixin \Eloquent */ class AccountType extends Model diff --git a/app/Support/Binder/AccountList.php b/app/Support/Binder/AccountList.php index de024c609d..e1b351a459 100644 --- a/app/Support/Binder/AccountList.php +++ b/app/Support/Binder/AccountList.php @@ -42,7 +42,6 @@ class AccountList implements BinderInterface /** @var \Illuminate\Support\Collection $object */ $object = Account::leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id') - ->where('account_types.editable', 1) ->whereIn('accounts.id', $ids) ->where('user_id', Auth::user()->id) ->get(['accounts.*']); diff --git a/public/js/ff/reports/default/year.js b/public/js/ff/reports/default/year.js index 79a3b50faa..54627fc29d 100644 --- a/public/js/ff/reports/default/year.js +++ b/public/js/ff/reports/default/year.js @@ -1,8 +1,10 @@ /* globals google, startDate ,reportURL, endDate , reportType ,accountIds , picker:true, minDate, expenseRestShow:true, incomeRestShow:true, year, month, hideTheRest, showTheRest, showTheRestExpense, hideTheRestExpense, columnChart, lineChart, stackedColumnChart */ - +var chartDrawn; +var budgetChart; $(function () { "use strict"; + chartDrawn = false; drawChart(); // click open the top X income list: @@ -26,9 +28,68 @@ function clickBudgetChart(e) { "use strict"; var link = $(e.target); var budgetId = link.data('budget'); - console.log('Budget id is ' + budgetId); - $('#budget_chart').empty(); - columnChart('chart/budget/period/' + budgetId + '/' + reportType + '/' + startDate + '/' + endDate + '/' + accountIds, 'budget_chart'); + var URL = 'chart/budget/period/' + budgetId + '/' + reportType + '/' + startDate + '/' + endDate + '/' + accountIds; + var container = 'budget_chart'; + // if chart drawn is false, draw the first one, then + // set to true + if (chartDrawn == false) { + // do new chart: + + + $.getJSON(URL).done(function (data) { + console.log('Will draw new columnChart(' + URL + ')'); + + var ctx = document.getElementById(container).getContext("2d"); + var newData = {}; + newData.datasets = []; + + for (var i = 0; i < data.count; i++) { + newData.labels = data.labels; + var dataset = data.datasets[i]; + dataset.backgroundColor = fillColors[i]; + newData.datasets.push(dataset); + } + // completely new chart. + budgetChart = new Chart(ctx, { + type: 'bar', + data: data, + options: defaultColumnOptions + }); + + }).fail(function () { + $('#' + container).addClass('general-chart-error'); + }); + console.log('URL for column chart : ' + URL); + chartDrawn = true; + } else { + console.log('Will now handle remove data and add new!'); + $.getJSON(URL).done(function (data) { + console.log('Will draw updated columnChart(' + URL + ')'); + var newData = {}; + newData.datasets = []; + + for (var i = 0; i < data.count; i++) { + newData.labels = data.labels; + var dataset = data.datasets[i]; + dataset.backgroundColor = fillColors[i]; + newData.datasets.push(dataset); + } + // update the chart + console.log('Now update chart thing.'); + budgetChart.data.datasets = newData.datasets; + budgetChart.update(); + + }).fail(function () { + $('#' + container).addClass('general-chart-error'); + }); + + + } + + // if chart drawn is true, add new data to existing chart. + // console.log('Budget id is ' + budgetId); + // $('#budget_chart').empty(); + // columnChart('chart/budget/period/' + budgetId + '/' + reportType + '/' + startDate + '/' + endDate + '/' + accountIds, 'budget_chart'); return false; }