mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-03 19:16:51 +00:00
Allow report options to be pulled using AJAX. Ajax is cool.
This commit is contained in:
@@ -23,6 +23,7 @@ use FireflyIII\Models\Transaction;
|
|||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
|
use Response;
|
||||||
use Session;
|
use Session;
|
||||||
use Steam;
|
use Steam;
|
||||||
use View;
|
use View;
|
||||||
@@ -85,6 +86,23 @@ class ReportController extends Controller
|
|||||||
return view('reports.index', compact('months', 'accounts', 'start', 'accountList', 'customFiscalYear'));
|
return view('reports.index', compact('months', 'accounts', 'start', 'accountList', 'customFiscalYear'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $reportType
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function options(string $reportType)
|
||||||
|
{
|
||||||
|
$result = false;
|
||||||
|
switch ($reportType) {
|
||||||
|
default:
|
||||||
|
$result = $this->noReportOptions();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response::json($result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $reportType
|
* @param string $reportType
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
@@ -292,4 +310,12 @@ class ReportController extends Controller
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function noReportOptions(): array
|
||||||
|
{
|
||||||
|
return ['html' => view('reports.options.no-options')->render()];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,9 +44,24 @@ $(function () {
|
|||||||
|
|
||||||
$('.date-select').on('click', preSelectDate);
|
$('.date-select').on('click', preSelectDate);
|
||||||
$('#report-form').on('submit', catchSubmit);
|
$('#report-form').on('submit', catchSubmit);
|
||||||
|
$('select[name="report_type"]').on('change', getReportOptions);
|
||||||
|
getReportOptions();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function getReportOptions() {
|
||||||
|
"use strict";
|
||||||
|
var reportType = $('select[name="report_type"]').val();
|
||||||
|
$('#extra-options').empty();
|
||||||
|
$('#extra-options').addClass('loading');
|
||||||
|
console.log('Changed report type to ' + reportType);
|
||||||
|
$.getJSON('reports/options/' + reportType, function(data) {
|
||||||
|
$('#extra-options').removeClass('loading').html(data.html);
|
||||||
|
}).fail(function(){
|
||||||
|
$('#extra-options').removeClass('loading').addClass('error');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function catchSubmit() {
|
function catchSubmit() {
|
||||||
"use strict";
|
"use strict";
|
||||||
// default;20141201;20141231;4;5
|
// default;20141201;20141231;4;5
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
<select name="report_type" class="form-control" id="inputReportType">
|
<select name="report_type" class="form-control" id="inputReportType">
|
||||||
<option selected label="{{ 'report_type_default'|_ }}" value="default">{{ 'report_type_default'|_ }}</option>
|
<option selected label="{{ 'report_type_default'|_ }}" value="default">{{ 'report_type_default'|_ }}</option>
|
||||||
<option label="{{ 'report_type_audit'|_ }}" value="audit">{{ 'report_type_audit'|_ }}</option>
|
<option label="{{ 'report_type_audit'|_ }}" value="audit">{{ 'report_type_audit'|_ }}</option>
|
||||||
|
<option label="{{ 'report_type_category'|_ }}" value="category">{{ 'report_type_category'|_ }}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -86,10 +87,7 @@
|
|||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title">{{ 'reports_extra_options'|_ }}</h3>
|
<h3 class="box-title">{{ 'reports_extra_options'|_ }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body loading" id="extra-options">
|
||||||
<p id="no_extra_options">
|
|
||||||
<em>{{ 'report_has_no_extra_options'|_ }}</em>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
3
resources/views/reports/options/no-options.twig
Normal file
3
resources/views/reports/options/no-options.twig
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<p id="no_extra_options">
|
||||||
|
<em>{{ 'report_has_no_extra_options'|_ }}</em>
|
||||||
|
</p>
|
@@ -308,6 +308,7 @@ Route::group(
|
|||||||
*/
|
*/
|
||||||
Route::get('/reports', ['uses' => 'ReportController@index', 'as' => 'reports.index']);
|
Route::get('/reports', ['uses' => 'ReportController@index', 'as' => 'reports.index']);
|
||||||
Route::get('/reports/report/{reportType}/{start_date}/{end_date}/{accountList}', ['uses' => 'ReportController@report', 'as' => 'reports.report']);
|
Route::get('/reports/report/{reportType}/{start_date}/{end_date}/{accountList}', ['uses' => 'ReportController@report', 'as' => 'reports.report']);
|
||||||
|
Route::get('/reports/options/{reportType}', ['uses' => 'ReportController@options', 'as' => 'reports.options']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report AJAX data Controller:
|
* Report AJAX data Controller:
|
||||||
|
Reference in New Issue
Block a user