Skip to content

Commit 1335c4f

Browse files
author
Jared King
committed
moved templating to twig - resolves #3
1 parent 9b5acea commit 1335c4f

File tree

107 files changed

+1945
-1948
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+1945
-1948
lines changed

app/Admin/Controller.php

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,12 @@ class Controller
2828

2929
const PER_PAGE = 10;
3030

31-
public static $viewsDir;
32-
3331
static $sectionModels = [
34-
'volunteers' => 'App\Volunteers\Models\Volunteer',
35-
'hours' => 'App\Volunteers\Models\VolunteerHour',
36-
'places' => 'App\Volunteers\Models\VolunteerPlace',
32+
'volunteers' => Volunteer::class,
33+
'hours' => VolunteerHour::class,
34+
'places' => VolunteerPlace::class,
3735
];
3836

39-
public function __construct()
40-
{
41-
self::$viewsDir = __DIR__.'/views';
42-
}
43-
4437
/*
4538
--- Admin: Dashboard ---
4639
*/
@@ -74,7 +67,7 @@ public function index($req, $res)
7467
$periods[$k]['topVolunteer'] = (count($topVolunteers) == 1) ? $topVolunteers[0] : false;
7568
}
7669

77-
return new View('dashboard', [
70+
return new View('@admin/dashboard', [
7871
'org' => $org,
7972
'title' => 'Pulse',
8073
'periods' => $periods,
@@ -161,7 +154,7 @@ public function volunteersBrowse($req, $res)
161154
$this->app['errors']->add('As a volunteer coordinator, you cannot remove yourself.');
162155
}
163156

164-
return new View('volunteers/browse', [
157+
return new View('@admin/volunteers/browse', [
165158
'org' => $org,
166159
'title' => 'Volunteers',
167160
'volunteersPage' => true,
@@ -191,7 +184,7 @@ public function addVolunteerForm($req, $res)
191184
return;
192185
}
193186

194-
return new View('volunteers/add', [
187+
return new View('@admin/volunteers/add', [
195188
'org' => $org,
196189
'title' => 'Add Volunteers',
197190
'volunteersPage' => true,
@@ -327,7 +320,7 @@ public function addVolunteerImportForm($req, $res)
327320
return;
328321
}
329322

330-
return new View('volunteers/import', [
323+
return new View('@admin/volunteers/import', [
331324
'org' => $org,
332325
'title' => 'Import Volunteers',
333326
'volunteersPage' => true,
@@ -367,7 +360,7 @@ public function volunteersView($req, $res)
367360
}
368361
}
369362

370-
return new View('volunteers/view', [
363+
return new View('@admin/volunteers/view', [
371364
'org' => $org,
372365
'volunteer' => $volunteer->toArray(),
373366
'user' => $user,
@@ -469,7 +462,7 @@ public function hoursBrowse($req, $res)
469462
$count = $query->count();
470463
$numPages = ceil($count / $perPage);
471464

472-
return new View('hours/browse', [
465+
return new View('@admin/hours/browse', [
473466
'org' => $org,
474467
'title' => 'Volunteer Hours',
475468
'hoursPage' => true,
@@ -510,7 +503,7 @@ public function recordHoursStep1($req, $res)
510503
->sort('name ASC')
511504
->all();
512505

513-
return new View('hours/add1', [
506+
return new View('@admin/hours/add1', [
514507
'org' => $org,
515508
'title' => 'Add Volunteer Hours',
516509
'hoursPage' => true,
@@ -578,7 +571,7 @@ public function recordHoursStep2($req, $res)
578571
->limit(10)
579572
->column();
580573

581-
return new View('hours/add2', [
574+
return new View('@admin/hours/add2', [
582575
'org' => $org,
583576
'title' => 'Add Volunteer Hours',
584577
'hoursPage' => true,
@@ -662,7 +655,7 @@ public function recordHoursStep3($req, $res)
662655
}
663656
}
664657

665-
return new View('hours/add3', [
658+
return new View('@admin/hours/add3', [
666659
'org' => $org,
667660
'title' => 'Confirm Volunteer Hours',
668661
'hoursPage' => true,
@@ -754,7 +747,7 @@ public function hoursView($req, $res)
754747

755748
list($org, $hour, $section) = $lookup;
756749

757-
return new View('hours/view', [
750+
return new View('@admin/hours/view', [
758751
'org' => $org,
759752
'hour' => $hour->toArray(),
760753
'tags' => $hour->tags(),
@@ -830,7 +823,7 @@ public function placesBrowse($req, $res)
830823
$count = $query->count();
831824
$numPages = ceil($count / $perPage);
832825

833-
return new View('places/browse', [
826+
return new View('@admin/places/browse', [
834827
'org' => $org,
835828
'title' => 'Places',
836829
'placesPage' => true,
@@ -864,7 +857,7 @@ public function placesAddForm($req, $res)
864857
'place_type' => VolunteerPlace::INTERNAL,
865858
'address' => '', ], $req->request());
866859

867-
return new View('places/modify', [
860+
return new View('@admin/places/modify', [
868861
'org' => $org,
869862
'title' => 'Add Volunteer Places',
870863
'placesPage' => true,
@@ -909,7 +902,7 @@ public function placesView($req, $res)
909902
->where('place', $place->id());
910903
$hours = $query->first(10);
911904

912-
return new View('places/view', [
905+
return new View('@admin/places/view', [
913906
'org' => $org,
914907
'title' => $place->name.' :: Places',
915908
'placesPage' => true,
@@ -929,7 +922,7 @@ public function placesEditForm($req, $res)
929922

930923
list($org, $place, $section) = $lookup;
931924

932-
return new View('places/modify', [
925+
return new View('@admin/places/modify', [
933926
'org' => $org,
934927
'title' => $place->name.' :: Places',
935928
'placesPage' => true,
@@ -1011,7 +1004,7 @@ public function reports($req, $res)
10111004
return;
10121005
}
10131006

1014-
return new View('reports', [
1007+
return new View('@admin/reports', [
10151008
'org' => $org,
10161009
'title' => 'Reports',
10171010
'reportsPage' => true,

app/Admin/views/dashboard.tpl

Lines changed: 0 additions & 53 deletions
This file was deleted.

app/Admin/views/dashboard.twig

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{% extends "@admin/parent.twig" %}
2+
{% block content %}
3+
4+
<h1>Welcome, {{ org.name }}!</h1>
5+
6+
<div class="btn-toolbar dashboard hidden-xs">
7+
<a href="{{ org.manageUrl() }}/volunteers/add" class="btn btn-link">
8+
<span class="glyphicon glyphicon-user"></span>
9+
Add Volunteers
10+
</a>
11+
<a href="{{ org.manageUrl() }}/places/add" class="btn btn-link">
12+
<span class="glyphicon glyphicon-map-marker"></span>
13+
New Volunteer Place
14+
</a>
15+
</div>
16+
<br/>
17+
18+
{% for period in periods %}
19+
<div class="stat-group-title">{{ period.title }}</div>
20+
<div class="row well">
21+
<div class="col-md-4 stat">
22+
<div class="number">{{ period.hoursVolunteered|number_format }}</div>
23+
<div class="title">
24+
{{ app.locale.p(period.hoursVolunteered,'Hour','Hours') }} Volunteered
25+
</div>
26+
</div>
27+
<div class="col-md-4 stat">
28+
<div class="number">{{ period.volunteers|number_format }}</div>
29+
<div class="title">
30+
{% if period.title != 'All Time' %}New {% endif %}{{ app.locale.p(period.volunteers,'Volunteer','Volunteers') }}
31+
</div>
32+
</div>
33+
<div class="col-md-4 stat">
34+
{% if period.topVolunteer %}
35+
<div class="name">
36+
<a href="{{ org.manageUrl() }}/volunteers/{{ period.topVolunteer.user.id() }}">
37+
{{ period.topVolunteer.user.name() }}</strong>
38+
</a>:
39+
{{ period.topVolunteer.hours|number_format }} {{ app.locale.p(period.topVolunteer.hours,'hour','hours') }}
40+
</div>
41+
{% else %}
42+
<div class="name">
43+
N/A
44+
</div>
45+
{% endif %}
46+
<div class="title">
47+
Top Volunteer
48+
</div>
49+
</div>
50+
</div>
51+
{% endfor %}
52+
53+
{% endblock %}

app/Admin/views/hours/add1.tpl

Lines changed: 0 additions & 36 deletions
This file was deleted.

app/Admin/views/hours/add1.twig

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{% extends "@admin/parent.twig" %}
2+
{% block content %}
3+
4+
<h1>Add Volunteer Hours <small>step 1 of 3</small></h1>
5+
6+
<p class="lead">
7+
Which place did the volunteer hours happen for {{ volunteer.relation('uid').name(true) }}?
8+
</p>
9+
<br/>
10+
11+
<div class="well clearfix">
12+
<form action="{{ org.manageUrl() }}/hours/add/2" method="get" role="form">
13+
<input type="hidden" name="user" value="{{ volunteer.uid }}" />
14+
<div class="form-group">
15+
<h4>Select Place</h4>
16+
{% if places|length == 0 %}
17+
<div class="alert alert-danger">
18+
First you must create a place. <a href="{{ org.manageUrl() }}/places/add">Add one</a>
19+
</div>
20+
{% else %}
21+
<div class="col-md-4">
22+
<select name="place" class="form-control">
23+
{% for place in places %}
24+
<option value="{{ place.id() }}">{{ place.name }}</option>
25+
{% endfor %}
26+
</select>
27+
</div>
28+
<div class="col-md-2">
29+
<button type="submit" class="btn btn-success">Go</button>
30+
</div>
31+
{% endif %}
32+
</div>
33+
</form>
34+
</div>
35+
36+
{% endblock %}

0 commit comments

Comments
 (0)