Skip to content

Commit

Permalink
minor gui issues
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiku committed Apr 19, 2016
1 parent 49ce4eb commit 61fec78
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 26 deletions.
5 changes: 3 additions & 2 deletions app/Http/Controllers/Cspot/PlanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,20 @@ public function index(Request $request)
}
$heading .= Type::find($filtervalue)->name.'s';
}
// show all future plans
elseif ($filterby=='future') {
// get ALL future plans incl today
$plans = Plan::with(['type', 'leader', 'teacher'])
->whereDate('date', '>', Carbon::yesterday())
->orderBy($orderBy, $order);
$heading = 'Upcoming Service Plans';

// for an API call, return the raw data in json format (without pagination!)
if (isset($request->api)) {
return json_encode($plans->get());
}
}
// show only plans of the user (or all for an admin)
// show only plans of the current user (or all plans if it's an admin)
else
{
// show all plans for Admins and only their own for non-Admins
Expand Down
2 changes: 0 additions & 2 deletions app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
PLANS
*/

// show only upcoming service plans with optional sorting
Route::get('plans/future/{api?}', ['as'=>'future', 'uses'=>'Cspot\PlanController@future']);
// show next Sunday's Service plan
Route::get('plans/next', ['as'=>'next', 'uses'=>'Cspot\PlanController@nextSunday']);

Expand Down
51 changes: 34 additions & 17 deletions public/js/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,26 @@ $(document).ready(function() {
*/
function toogleAllorFuturePlans()
{
// get current url and each segment
var currUrl = window.location.href;
var segments = currUrl.split('/');
var count = segments.length;
// check for 'all' or 'future' segment
if (segments.indexOf('future') > -1 ) {
segments[segments.indexOf('future')] = 'all';
} else {
segments[segments.indexOf('all')] = 'future';
}
var newUrl = segments.join('/');
$('#show-spinner').modal({keyboard: false})
// get current url and query string
var currUrl = window.location.href.split('?');
var newUrl = currUrl[0];
if (currUrl.length > 1)
{
var queryStr = currUrl[1].split('&');
if (queryStr.length > 1) {
newUrl += '?';
for (var i = queryStr.length - 1; i >= 0; i--) {
parms = queryStr[i].split('=');
if (parms[0]=='show') {
parms[1]=='all' ? parms[1]='future' : parms[1]='all';
queryStr[i] = 'show='+parms[1];
}
newUrl += queryStr[i];
if (i > 0) newUrl += '&';
}
}
}
window.location.href = newUrl;
}

Expand All @@ -247,17 +256,20 @@ function reloadListOrderBy(field)
{
$('#show-spinner').modal({keyboard: false})
// get current url and query string
var currUrl = window.location.href.split('?');
var newUrl = currUrl[0];
var currUrl = window.location.href.split('?');
var newUrl = currUrl[0];
if (currUrl.length > 1)
{
var queryStr = currUrl[1].split('&');
var orderbyFound = false;
if (queryStr.length > 1) {
newUrl += '?';
for (var i = queryStr.length - 1; i >= 0; i--) {
parms = queryStr[i].split('=');
if (parms[0]=='orderby')
if (parms[0]=='orderby') {
queryStr[i] = 'orderby='+field;
orderbyFound = true;
}
if (parms[0]=='order') {
parms[1]=='desc' ? parms[1]='asc' : parms[1]='desc';
queryStr[i] = 'order='+parms[1];
Expand All @@ -267,11 +279,16 @@ function reloadListOrderBy(field)
}
}
}
else
{
newUrl += '?orderby='+field;
else {
newUrl += '?';
}
// check if existing query string already contained a orderby param
if (currUrl.length > 1 && ! orderbyFound) newUrl += '&';
if (currUrl.length < 2 || ! orderbyFound) {
newUrl += 'orderby='+field;
newUrl += '&order=asc';
}

window.location.href = newUrl;
}

Expand Down
2 changes: 1 addition & 1 deletion resources/views/admin/users.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class="link" onclick="location.href ='{{ url('admin/users/'.$user->id) }}/edit'"
@endif
@endif
@if( $user->hasRole('teacher') || $user->hasRole('leader') )
<a class="btn btn-secondary btn-sm" title="Show Upcoming Plans" href="{{ url('cspot/plans?filterby=user&filtervalue='.$user->id) }}/future"><i class="fa fa-filter"></i></a> @endif
<a class="btn btn-secondary btn-sm" title="Show Upcoming Plans" href="{{ url('cspot/plans?filterby=user&filtervalue='.$user->id) }}&show=future"><i class="fa fa-filter"></i></a> @endif
</td>
</tr>
@endforeach
Expand Down
10 changes: 6 additions & 4 deletions resources/views/cspot/plans.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@
</a>
@endif

<h2>{{ $heading }}</h2>
<h2 class="pull-xs-left">{{ $heading }}</h2>

@if( Request::is('*/by_user/*') || Request::is('*/by_type/*') )
<center>Page {{ $plans->currentPage() }} of {{ $plans->lastPage() }}</center>

@if( Request::has('show') )
<p>
<a href="#" onclick="toogleAllorFuturePlans()">
<input type="checkbox" {{Request::is('*/all*') ? '' : 'checked'}}>
<input type="checkbox" {{Request::get('show')=='all' ? '' : 'checked'}}>
show only upcoming service plans</a>
</p>
@endif


@if ( isset($plans) && count($plans) )
Total: {{ count($plans) }} Services
<center><small>(Total: {{ $plans->total() }} Service Plans)</small></center>

<table class="table table-striped table-bordered table-hover
@if(count($plans)>15)
Expand Down
2 changes: 2 additions & 0 deletions resources/views/cspot/songs.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

@if (count($songs))

<center><small>(Total: {{ $songs->total() }} Songs)</small></center>

<table class="table table-striped table-bordered
@if(count($songs)>15)
table-sm
Expand Down

0 comments on commit 61fec78

Please sign in to comment.