Skip to content

Commit fe4c1d8

Browse files
Update events feature and add full schedule CRUD
1 parent 749aa7e commit fe4c1d8

File tree

11 files changed

+374
-88
lines changed

11 files changed

+374
-88
lines changed

html-templates/events/event.tpl

Lines changed: 99 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,130 @@
11
{extends "designs/site.tpl"}
22

3-
{block title}{_ 'Event'} — {$dwoo.parent}{/block}
3+
{block title}{$data->Title|escape} — {$dwoo.parent}{/block}
4+
5+
{block css}
6+
{$dwoo.parent}
7+
8+
<style>
9+
.event-description p:last-child {
10+
margin-bottom: 0;
11+
}
12+
13+
.event-details dt {
14+
font-size: 130%;
15+
}
16+
.event-details dd {
17+
margin-bottom: 1em;
18+
}
19+
20+
.event-segments h4 {
21+
margin-top: 0;
22+
}
23+
.event-segments dl {
24+
margin-bottom: 0;
25+
}
26+
.event-segments dd {
27+
margin-bottom: 0.5em;
28+
}
29+
.event-segments .event-location {
30+
display: block;
31+
margin-top: 1em;
32+
margin-bottom: 1em;
33+
}
34+
.event-segments .event-location dt {
35+
font-size: 200%;
36+
}
37+
</style>
38+
{/block}
439

540
{block content}
641
{$Event = $data}
42+
{load_templates "subtemplates.tpl"}
743

844
<div class="page-header">
9-
{*
1045
<ol class="breadcrumb">
1146
<li><a href="/events">{_ "Events"}</a></li>
12-
<li><a href="{$Event->getUrl()}">{$Event->Title|escape}</a></li>
47+
<li>{tif $Event->EndTime > $.now ? 'Upcoming' : 'Past'}</li>
1348
</ol>
14-
*}
1549
<div class="btn-toolbar pull-right">
1650
{if $.User}
17-
<form action="{$Event->getUrl(edit)}">
18-
<button class="btn btn-success" type="submit">{glyph "pencil"}&nbsp;{_ "Edit Event&hellip;"}</button>
19-
</form>
51+
<a class="btn btn-success" href="{$Event->getUrl(edit)}">{glyph "pencil"}&nbsp;{_ "Edit Event"}</a>
52+
<a class="btn btn-success" href="{$Event->getUrl('segments/*create')}">{glyph "plus"}&nbsp;{_ "Add Segment"}</a>
2053
{/if}
2154
</div>
2255
<h1>{$Event->Title|escape}</h1>
2356
</div>
24-
<div class="row">
25-
<div class="col-md-3">
26-
<ul class="row list-unstyled">
27-
{if $Event->Status != 'published'}
28-
<li class="col-sm-3 col-md-12">
29-
<p>
30-
<b>Status</b><br/>
31-
{$Event->Status}
32-
</p>
33-
</li>
34-
{/if}
35-
36-
<li class="col-sm-3 col-md-12">
37-
<p>
38-
<b>Start time</b><br/>
39-
{timestamp $Event->StartTime time=yes}
40-
</p>
41-
</li>
42-
43-
{if $Event->EndTime}
44-
<li class="col-sm-3 col-md-12">
45-
<p>
46-
<b>End time</b><br/>
47-
{timestamp $Event->EndTime time=yes}
48-
</p>
49-
</li>
50-
{/if}
51-
52-
{if $Event->Location}
53-
<li class="col-sm-3 col-md-12">
54-
<p>
55-
<b>Location</b><br/>
56-
<a href="https://www.google.com/maps?q={$Event->Location|escape:url}">{$Event->Location|escape}</a>
57-
</p>
58-
</li>
59-
{/if}
60-
</ul>
61-
</div>
6257

58+
<div class="row">
6359
<div class="col-md-9">
6460
{if $Event->Description}
65-
<div class="well">
66-
<div class="content-markdown event-description">{$Event->Description|truncate:600|escape|markdown}</div>
67-
</div>
61+
<div class="content-markdown event-description well">{$Event->Description|escape|markdown}</div>
6862
{/if}
6963

7064
{if $Event->Segments}
71-
<h2>Segments</h2>
65+
<section class="event-segments">
66+
<h2>Schedule</h2>
7267

73-
{$lastDate = null}
68+
{$lastDate = null}
69+
{$lastLocationName = null}
70+
{$lastLocationAddress = null}
7471

75-
{foreach item=Segment from=$Event->Segments}
76-
{$thisDate = date("l, F jS", $Segment->StartTime)}
72+
{foreach item=Segment from=$Event->Segments}
73+
{$thisDate = date("l, F jS", $Segment->StartTime)}
7774

78-
{if $lastDate != $thisDate}
79-
{if $lastDate}
80-
</dl>
75+
{if $lastDate != $thisDate}
76+
{if $lastDate}
77+
</dl>
78+
{/if}
79+
<h3>{$thisDate}</h3>
80+
<dl class="dl-horizontal">
81+
{$lastDate = $thisDate}
82+
{$lastLocationName = null}
83+
{$lastLocationAddress = null}
8184
{/if}
82-
<h3>{$thisDate}</h3>
83-
<dl class="dl-horizontal">
84-
{$lastDate = $thisDate}
85-
{/if}
86-
<dt>{time_range $Segment->StartTime $Segment->EndTime}</dt>
87-
<dd>
88-
<a href="{$Event->getUrl("segments/$Segment->Handle")}">{$Segment->Title|escape}</a>
89-
{if $Segment->LocationName || $Segment->LocationAddress}
90-
<p>
91-
<strong>Location</strong>
92-
<a target="_blank" href="https://maps.google.com?q={implode(', ', array_filter(array($Segment->LocationName, $Segment->LocationAddress)))|escape:url}">
93-
{if $Segment->LocationName && $Segment->LocationAddress}
94-
{$Segment->LocationName|escape} ({$Segment->LocationAddress|escape})
95-
{else}
96-
{$Segment->LocationName|default:$Segment->LocationAddress|escape}
97-
{/if}
98-
</a>
99-
</p>
85+
{if
86+
(
87+
$Segment->LocationName != $lastLocationName
88+
|| $Segment->LocationAddress != $lastLocationAddress
89+
)
90+
&& ($Segment->LocationName || $Segment->LocationAddress)
91+
}
92+
<div class="event-location">
93+
<dt>{icon "map-marker"}</dt>
94+
<dd>{eventLocation name=$Segment->LocationName address=$Segment->LocationAddress}</dd>
95+
</div>
10096
{/if}
101-
<div class="content-markdown event-segment-description">{$Segment->Description|escape|markdown}</div>
102-
</dd>
103-
{/foreach}
97+
<dt>{time_range $Segment->StartTime $Segment->EndTime}</dt>
98+
<dd>
99+
<h4><a href="{$Segment->getUrl()}">{$Segment->Title|escape}</a></h4>
100+
<div class="content-markdown event-segment-description">{$Segment->Description|escape|markdown}</div>
101+
</dd>
102+
103+
{$lastLocationName = $Segment->LocationName}
104+
{$lastLocationAddress = $Segment->LocationAddress}
105+
{/foreach}
106+
</foreach>
104107
{/if}
105108
</div>
109+
110+
<dl class="event-details col-md-3">
111+
{if $Event->Status != 'published'}
112+
<dt>Status</dt>
113+
<dd>{$Event->Status}</dd>
114+
{/if}
115+
116+
<dt>Starts</dt>
117+
<dd>{timestamp $Event->StartTime time='auto'}</dd>
118+
119+
{if $Event->EndTime}
120+
<dt>Ends</dt>
121+
<dd>{timestamp $Event->EndTime time='auto'}</dd>
122+
{/if}
123+
124+
{if $Event->LocationName || $Event->LocationAddress}
125+
<dt>Location</dt>
126+
<dd>{eventLocation name=$Event->LocationName address=$Event->LocationAddress}</dd>
127+
{/if}
128+
</dl>
106129
</div>
107130
{/block}

html-templates/events/eventEdit.tpl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,20 @@
5454
</select>
5555
</div>
5656
<div class="form-group">
57-
<label for="field-time-start">{_ "StartTime"}:</label>
58-
<input type="date" name="StartTime" id="field-time-start" class="form-control" value="{refill field=StartTime default=$Event->StartTime}"/>
57+
<label for="field-time-start">{_ "Start time"}:</label>
58+
<input type="datetime-local" name="StartTime" id="field-time-start" class="form-control" value="{refill field=StartTime default=tif($Event->StartTime, date('Y-m-d\TH:i', $Event->StartTime))}"/>
5959
</div>
6060
<div class="form-group">
61-
<label for="field-time-end">{_ "EndTime"}:</label>
62-
<input type="date" name="EndTime" id="field-time-end" class="form-control" value="{refill field=EndTime default=$Event->EndTime}"/>
61+
<label for="field-time-end">{_ "End time"}:</label>
62+
<input type="datetime-local" name="EndTime" id="field-time-end" class="form-control" value="{refill field=EndTime default=tif($Event->EndTime, date('Y-m-d\TH:i', $Event->EndTime))}"/>
6363
</div>
6464
<div class="form-group">
65-
<label for="field-location">{_ "Location"}:</label>
66-
<input type="text" name="Location" id="field-location" class="form-control" placeholder="908 N 3rd St, Philadelphia PA" value="{refill field=Location default=$Event->Location}"/>
65+
<label for="field-location-name">{_ "Location name"}:</label>
66+
<input type="text" name="LocationName" id="field-location-name" class="form-control" placeholder="Localhost" value="{refill field=LocationName default=$Event->LocationName}"/>
67+
</div>
68+
<div class="form-group">
69+
<label for="field-location-address">{_ "Location address"}:</label>
70+
<input type="text" name="LocationAddress" id="field-location-address" class="form-control" placeholder="908 N 3rd St, Philadelphia PA" value="{refill field=LocationAddress default=$Event->LocationAddress}"/>
6771
</div>
6872

6973
<div class="form-group">

html-templates/events/eventSaved.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{capture assign=eventLink}<a href="{$Event->getUrl()|escape}">{$Event->getTitle()|escape}</a>{/capture}
99

1010
<div class="page-header">
11-
<h1>Event Created</h1>
11+
<h1>Event Saved</h1>
1212
</div>
1313
{if $Event->isNew}
1414
<p>{_("Your event has been created: %s")|sprintf:$eventLink}</p>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{extends "designs/site.tpl"}
2+
3+
{block title}{$data->Title|escape} @ {$data->Event->Title|escape} &mdash; {$dwoo.parent}{/block}
4+
5+
{block css}
6+
{$dwoo.parent}
7+
8+
<style>
9+
.event-segment-description p:last-child {
10+
margin-bottom: 0;
11+
}
12+
13+
.event-segment-details dt {
14+
font-size: 130%;
15+
}
16+
.event-segment-details dd {
17+
margin-bottom: 1em;
18+
}
19+
</style>
20+
{/block}
21+
22+
{block content}
23+
{$Segment = $data}
24+
{$Event = $Segment->Event}
25+
{load_templates "subtemplates.tpl"}
26+
27+
<div class="page-header">
28+
<ol class="breadcrumb">
29+
<li><a href="/events">{_ "Events"}</a></li>
30+
<li><a href="{$Event->getUrl()}">{$Event->Title|escape}</a></li>
31+
<li>Schedule</li>
32+
</ol>
33+
<div class="btn-toolbar pull-right">
34+
{if $.User}
35+
<a class="btn btn-success" href="{$Segment->getUrl(edit)}">{glyph "pencil"}&nbsp;{_ "Edit Segment"}</a>
36+
{/if}
37+
</div>
38+
<h1>{$Segment->Title|escape}</h1>
39+
</div>
40+
41+
<div class="row">
42+
<div class="col-md-9">
43+
{if $Segment->Description}
44+
<div class="content-markdown event-segment-description well">{$Segment->Description|escape|markdown}</div>
45+
{/if}
46+
</div>
47+
48+
<dl class="event-segment-details col-md-3">
49+
<dt>Starts</dt>
50+
<dd>{timestamp $Segment->StartTime time='auto'}</dd>
51+
52+
{if $Segment->EndTime}
53+
<dt>Ends</dt>
54+
<dd>{timestamp $Segment->EndTime time='auto'}</dd>
55+
{/if}
56+
57+
{if $Segment->LocationName || $Segment->LocationAddress}
58+
<dt>Location</dt>
59+
<dd>{eventLocation name=$Segment->LocationName address=$Segment->LocationAddress}</dd>
60+
{/if}
61+
</dl>
62+
</div>
63+
{/block}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{extends designs/site.tpl}
2+
3+
{block title}{if $data->isPhantom}{_ 'Create'}{else}{_('Edit %s')|sprintf:$data->Title|escape}{/if} &mdash; {_ 'Events'} &mdash; {$dwoo.parent}{/block}
4+
5+
{block js-bottom}
6+
{$dwoo.parent}
7+
{jsmin "epiceditor.js"}
8+
{jsmin "pages/event-edit.js"}
9+
{/block}
10+
11+
{block content}
12+
{$Segment = $data}
13+
14+
<div class="container">
15+
<div class="row">
16+
<div class="col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
17+
<div class="page-header">
18+
<h1>
19+
{if $Segment->isPhantom}
20+
{_ "Create new event segment"}
21+
{else}
22+
{_("Edit event segment %s")|sprintf:$Segment->Title|escape}
23+
{/if}
24+
</h1>
25+
</div>
26+
27+
{if !$Segment->isValid}
28+
<div class="error well">
29+
<strong>{_ "There were problems with your entry:"}</strong>
30+
<ul class="errors">
31+
{foreach item=error key=field from=$Segment->validationErrors}
32+
<li>{$error}</li>
33+
{/foreach}
34+
</ul>
35+
</div>
36+
{/if}
37+
38+
<form method="POST">
39+
<div class="form-group">
40+
<label for="field-event">{_ "Event"}:</label>
41+
<select name="EventID" id="field-event" class="form-control">
42+
{foreach item=Event from=Emergence\Events\Event::getAll(array(Order=StartTime))}
43+
<option value="{$Event->ID}" {refill field=EventID default=$Segment->EventID selected=$Event->ID}>{date('Y-m-d', $Event->StartTime)}: {$Event->Title|escape}</option>
44+
{/foreach}
45+
</select>
46+
</div>
47+
<div class="form-group">
48+
<label for="field-title">{_ "Title"}:</label>
49+
<input name="Title" id="field-title" class="form-control" placeholder="{_ 'Opening Remarks'}" value="{refill field=Title default=$Segment->Title}" />
50+
</div>
51+
<div class="form-group">
52+
<label for="field-handle">{_ "Handle"} ({_ "optional"}):</label>
53+
<input name="Handle" id="field-handle" class="form-control" placeholder="{_ 'opening-remarks'}" value="{refill field=Handle default=$Segment->Handle}" />
54+
<p class="help-block">Must be unique &mdash; leave blank to auto-generate</p>
55+
</div>
56+
<div class="form-group">
57+
<label for="field-time-start">{_ "Start time"}:</label>
58+
<input type="datetime-local" name="StartTime" id="field-time-start" class="form-control" value="{refill field=StartTime default=tif($Segment->StartTime, date('Y-m-d\TH:i', $Segment->StartTime))}"/>
59+
</div>
60+
<div class="form-group">
61+
<label for="field-time-end">{_ "End time"}:</label>
62+
<input type="datetime-local" name="EndTime" id="field-time-end" class="form-control" value="{refill field=EndTime default=tif($Segment->EndTime, date('Y-m-d\TH:i', $Segment->EndTime))}"/>
63+
</div>
64+
<div class="form-group">
65+
<label for="field-location-name">{_ "Location name"}:</label>
66+
<input type="text" name="LocationName" id="field-location-name" class="form-control" placeholder="Localhost" value="{refill field=LocationName default=$Segment->LocationName}"/>
67+
</div>
68+
<div class="form-group">
69+
<label for="field-location-address">{_ "Location address"}:</label>
70+
<input type="text" name="LocationAddress" id="field-location-address" class="form-control" placeholder="908 N 3rd St, Philadelphia PA" value="{refill field=LocationAddress default=$Segment->LocationAddress}"/>
71+
</div>
72+
73+
<div class="form-group">
74+
<label for="field-description">{_ 'Description(.md)'}</label>
75+
<div class="controls">
76+
<textarea name="Description" class="input-block-level" rows="10">{refill field=Description default=$Segment->Description}</textarea>
77+
</div>
78+
</div>
79+
80+
<button type="submit" class="btn btn-primary">{if $Segment->isPhantom}{_ 'Create Event Segment'}{else}{_ 'Save Changes'}{/if}</button>
81+
</form>
82+
</div>
83+
</div>
84+
</div>
85+
{/block}

0 commit comments

Comments
 (0)