Some new help functions, some cleanup.

This commit is contained in:
James Cole 2014-11-28 14:12:16 +01:00
parent 98993cfa9b
commit f6afb46f6f
12 changed files with 132 additions and 65 deletions

View File

@ -229,13 +229,16 @@ class AccountController extends BaseController
case 'Asset account':
case 'Default account':
$subTitleIcon = 'fa-money';
$what = 'asset';
break;
case 'Expense account':
case 'Beneficiary account':
$subTitleIcon = 'fa-shopping-cart';
$what = 'expense';
break;
case 'Revenue account':
$subTitleIcon = 'fa-download';
$what = 'revenue';
break;
}
@ -254,7 +257,7 @@ class AccountController extends BaseController
}
return View::make('accounts.show', compact('account', 'view', 'subTitleIcon', 'journals'))->with('account', $account)->with(
return View::make('accounts.show', compact('account', 'what', 'view', 'subTitleIcon', 'journals'))->with('account', $account)->with(
'subTitle', 'Details for ' . strtolower($account->accountType->type) . ' "' . $account->name . '"'
);
}

View File

@ -0,0 +1,46 @@
<?php
class HelpController extends BaseController
{
public function show($route)
{
// no valid route
if (!Route::has($route)) {
$helpText = '<p>There is no help for this route!</p>';
$helpTitle = 'Help';
return Response::json(['title' => $helpTitle, 'text' => $helpText]);
}
// content in cache
if (Cache::has('help.' . $route . '.title') && Cache::has('help.' . $route . '.text')) {
$helpText = Cache::get('help.' . $route . '.text');
$helpTitle = Cache::get('help.' . $route . '.title');
return Response::json(['title' => $helpTitle, 'text' => $helpText]);
}
// get the help-content from Github:
$URL = 'https://raw.githubusercontent.com/JC5/firefly-iii-help/master/' . e($route) . '.md';
try {
$content = file_get_contents($URL);
} catch (ErrorException $e) {
$content = '<p>There is no help for this route.</p>';
}
if (strlen($content) > 0) {
$helpText = \Michelf\Markdown::defaultTransform($content);
$helpTitle = $route;
Cache::put('help.' . $route . '.text', $helpText, 10080); // a week.
Cache::put('help.' . $route . '.title', $helpTitle, 10080);
return Response::json(['title' => $helpTitle, 'text' => $helpText]);
}
$helpText = '<p>There is no help for this route!</p>';
$helpTitle = 'Help';
return Response::json(['title' => $helpTitle, 'text' => $helpText]);
}
}

View File

@ -23,6 +23,7 @@ Route::bind(
'user_id', Auth::user()->id
)->first();
}
return null;
}
);
@ -34,6 +35,7 @@ Route::bind(
return RecurringTransaction::
where('id', $value)->where('user_id', Auth::user()->id)->first();
}
return null;
}
);
@ -43,6 +45,7 @@ Route::bind(
return Budget::
where('id', $value)->where('user_id', Auth::user()->id)->first();
}
return null;
}
);
@ -53,6 +56,7 @@ Route::bind(
return Component::
where('id', $value)->where('user_id', Auth::user()->id)->first();
}
return null;
}
);
@ -63,6 +67,7 @@ Route::bind(
return Reminder::
where('id', $value)->where('user_id', Auth::user()->id)->first();
}
return null;
}
);
@ -73,6 +78,7 @@ Route::bind(
return Category::
where('id', $value)->where('user_id', Auth::user()->id)->first();
}
return null;
}
);
@ -83,6 +89,7 @@ Route::bind(
return TransactionJournal::
where('id', $value)->where('user_id', Auth::user()->id)->first();
}
return null;
}
);
@ -95,6 +102,7 @@ Route::bind(
'components', 'components.id', '=', 'limits.component_id'
)->where('components.class', 'Budget')->where('components.user_id', Auth::user()->id)->first(['limit_repetitions.*']);
}
return null;
}
);
@ -104,10 +112,11 @@ Route::bind(
if (Auth::check()) {
return Piggybank::
where('piggybanks.id', $value)
->leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')
->where('accounts.user_id', Auth::user()->id)
->where('repeats',0)->first(['piggybanks.*']);
->leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')
->where('accounts.user_id', Auth::user()->id)
->where('repeats', 0)->first(['piggybanks.*']);
}
return null;
}
);
@ -119,8 +128,9 @@ Route::bind(
where('piggybanks.id', $value)
->leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')
->where('accounts.user_id', Auth::user()->id)
->where('repeats',1)->first(['piggybanks.*']);
->where('repeats', 1)->first(['piggybanks.*']);
}
return null;
}
);
@ -172,11 +182,14 @@ Route::group(
Route::get('/chart/recurring/{recurring}', ['uses' => 'GoogleChartController@recurringOverview']);
Route::get('/chart/reports/budgets/{year}', ['uses' => 'GoogleChartController@budgetsReportChart']);
Route::get('/chart/budget/{budget}/{limitrepetition}', ['uses' => 'GoogleChartController@budgetLimitSpending']);
Route::get('/chart/piggyhistory/{piggybank}',['uses' => 'GoogleChartController@piggyBankHistory']);
Route::get('/chart/piggyhistory/{piggybank}', ['uses' => 'GoogleChartController@piggyBankHistory']);
// google chart for components (categories + budgets combined)
Route::get('/chart/component/{component}/spending/{year}', ['uses' => 'GoogleChartController@componentsAndSpending']);
// help controller
Route::get('/help/{route}', ['uses' => 'HelpController@show', 'as' => 'help.show']);
// home controller
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
Route::get('/flush', ['uses' => 'HomeController@flush', 'as' => 'flush']); # even though nothing is cached.
@ -224,10 +237,10 @@ Route::group(
Route::get('/reports/unbalanced/{year}/{month}', ['uses' => 'ReportController@unbalanced', 'as' => 'reports.unbalanced']);
// reminder controller
Route::get('/reminders/{reminder}',['uses' => 'ReminderController@show','as' => 'reminders.show']);
Route::get('/reminders/{reminder}/dismiss',['uses' => 'ReminderController@dismiss','as' => 'reminders.dismiss']);
Route::get('/reminders/{reminder}/notnow',['uses' => 'ReminderController@notnow','as' => 'reminders.notnow']);
Route::get('/reminders/{reminder}/act',['uses' => 'ReminderController@act','as' => 'reminders.act']);
Route::get('/reminders/{reminder}', ['uses' => 'ReminderController@show', 'as' => 'reminders.show']);
Route::get('/reminders/{reminder}/dismiss', ['uses' => 'ReminderController@dismiss', 'as' => 'reminders.dismiss']);
Route::get('/reminders/{reminder}/notnow', ['uses' => 'ReminderController@notnow', 'as' => 'reminders.notnow']);
Route::get('/reminders/{reminder}/act', ['uses' => 'ReminderController@act', 'as' => 'reminders.act']);
// search controller:
Route::get('/search', ['uses' => 'SearchController@index', 'as' => 'search']);

View File

@ -1,5 +1,6 @@
@extends('layouts.default')
@section('content')
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $what) }}
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="panel panel-default">

View File

@ -1,5 +1,6 @@
@extends('layouts.default')
@section('content')
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $what, $account) }}
<div class="row">
<div class="col-lg-8 col-md-6 col-sm-12">
<div class="panel panel-default">
@ -20,7 +21,6 @@
</div>
<div class="panel-body">
<p>
<!-- TODO clean up these methods and everything associated with them. -->
@if($view == 'all')
<a href="{{route('accounts.show',$account->id)}}/session" class="btn btn-default">Stick to date-range</a>
@else

View File

@ -130,55 +130,6 @@
</div>
</div>
@foreach($budgets as $budget)
{{--
<div class="row">
<div class="col-lg-9 col-sm-8 col-md-8">
<div class="row">
<div class="col-lg-3 col-md-4 col-sm-4">
{{$budget->name}}
</div>
<div class="col-lg-7 col-md-4 col-sm-4">
</div>
<div class="col-lg-2 col-md-4 col-sm-3">
<span id="budget-range-display-{{$budget->id}}" data-id="{{$budget->id}}"></span>
</div>
</div>
<div class="row">
<div class="col-lg-7 col-lg-offset-3 col-md-4 col-md-offset-4 col-sm-4 col-sm-offset-4">
@if($budget->pct > 0)
<!-- display a progress bar. -->
<div class="progress" id="budget-progress-{{$budget->id}}" data-spent="{{$budget->spent}}" data-amount="{{$budget->limit}}">
</div>
@else
<!-- do NOT display a progress bar. -->
<div style="display:none;" class="progress" id="budget-progress-{{$budget->id}}" data-spent="{{$budget->spent}}" data-amount="{{$budget->limit}}">
</div>
@endif
<!--
@if($budget->currentRep)
@if($budget->currentRep->amount <= $budget->spent)
Overspent on budget (budgeted: {{$budget->currentRep->amount}}, spent: {{$budget->spent}}).
@else
NOT overspent on budget (budgeted: {{$budget->currentRep->amount}}, spent: {{$budget->spent}}).
@endif
@else
No limit.
@endif
-->
</div>
</div>
</div>
</div>
--}}
@endforeach
<!-- DIALOG -->
<div class="modal fade" id="monthlyBudgetModal">
</div><!-- /.modal -->

View File

@ -0,0 +1,14 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="helpTitle">{{$helpTitle}}</h4>
</div>
<div class="modal-body" id="helpBody">
{{$helpText}}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>

View File

@ -1,6 +1,6 @@
@extends('layouts.default')
@section('content')
{{ Breadcrumbs::render('home') }}
{{ Breadcrumbs::renderIfExists() }}
@if($count == 0)
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">

View File

@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<?php $r = Route::getCurrentRoute()->getName();?>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
@ -47,7 +48,7 @@
{{$subTitle}}
</small>
@endif
<small class="pull-right"><a href="#"><i class="fa fa-question-circle"></i></a></small>
<small class="pull-right"><a href="#" id="help" data-route="{{{Route::getCurrentRoute()->getName()}}}"><i data-route="{{{Route::getCurrentRoute()->getName()}}}" class="fa fa-question-circle"></i></a></small>
</h1>
</div>
@ -55,9 +56,26 @@
</div>
@include('partials.flashes')
@yield('content')
<!-- this modal will contain the help-text -->
<div class="modal fade" id="helpModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="helpTitle">Please hold...</h4>
</div>
<div class="modal-body" id="helpBody">
<i class="fa fa-refresh fa-spin"></i>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div><!-- /.modal -->
</div>
</div>
@ -65,6 +83,7 @@
{{HTML::script('assets/javascript/bootstrap/bootstrap.min.js')}}
{{HTML::script('assets/javascript/metisMenu/jquery.metisMenu.min.js')}}
{{HTML::script('assets/javascript/sb-admin/sb-admin-2.js')}}
{{HTML::script('assets/javascript/firefly/help.js')}}
@yield('scripts')
</body>
</html>

View File

@ -64,7 +64,6 @@
<!-- /.dropdown -->
</ul>
<!-- /.navbar-top-links -->
<?php $r = Route::getCurrentRoute()->getName();?>
<div class="navbar-default sidebar" role="navigation">
<div class="sidebar-nav navbar-collapse">
<ul class="nav" id="side-menu">

View File

@ -12,7 +12,7 @@
All instructions will be sent to you.
</p>
{{Form::open(['id' => 'register'])}}
<div class="form-group">
<div class="form-group"> <!-- {{App::environment()}} -->
<label for="inputEmail">Email address</label>
<input type="email" class="form-control" id="inputEmail" name="email" placeholder="Enter email">
</div>

View File

@ -0,0 +1,21 @@
$(function () {
$('#help').click(showHelp);
});
function showHelp(e) {
target = $(e.target);
route = target.data('route');
//
$('#helpBody').html('<i class="fa fa-refresh fa-spin"></i>');
$('#helpTitle').html('Please hold...');
$('#helpModal').modal('show');
$.getJSON('help/' + encodeURI(route)).success(function (data) {
$('#helpBody').html(data.text);
$('#helpTitle').html(data.title);
}).fail(function () {
$('#helpBody').html('<p class="text-danger">No help text could be found.</p>');
$('#helpTitle').html('Sorry...');
});
return false;
}