Skip to content

Commit

Permalink
Update events feature and add full schedule CRUD
Browse files Browse the repository at this point in the history
  • Loading branch information
themightychris committed Apr 11, 2018
1 parent c899763 commit 26aa7aa
Show file tree
Hide file tree
Showing 11 changed files with 374 additions and 88 deletions.
175 changes: 99 additions & 76 deletions html-templates/events/event.tpl
@@ -1,107 +1,130 @@
{extends "designs/site.tpl"} {extends "designs/site.tpl"}


{block title}{_ 'Event'} — {$dwoo.parent}{/block} {block title}{$data->Title|escape} — {$dwoo.parent}{/block}

{block css}
{$dwoo.parent}

<style>
.event-description p:last-child {
margin-bottom: 0;
}
.event-details dt {
font-size: 130%;
}
.event-details dd {
margin-bottom: 1em;
}
.event-segments h4 {
margin-top: 0;
}
.event-segments dl {
margin-bottom: 0;
}
.event-segments dd {
margin-bottom: 0.5em;
}
.event-segments .event-location {
display: block;
margin-top: 1em;
margin-bottom: 1em;
}
.event-segments .event-location dt {
font-size: 200%;
}
</style>
{/block}


{block content} {block content}
{$Event = $data} {$Event = $data}
{load_templates "subtemplates.tpl"}


<div class="page-header"> <div class="page-header">
{*
<ol class="breadcrumb"> <ol class="breadcrumb">
<li><a href="/events">{_ "Events"}</a></li> <li><a href="/events">{_ "Events"}</a></li>
<li><a href="{$Event->getUrl()}">{$Event->Title|escape}</a></li> <li>{tif $Event->EndTime > $.now ? 'Upcoming' : 'Past'}</li>
</ol> </ol>
*}
<div class="btn-toolbar pull-right"> <div class="btn-toolbar pull-right">
{if $.User} {if $.User}
<form action="{$Event->getUrl(edit)}"> <a class="btn btn-success" href="{$Event->getUrl(edit)}">{glyph "pencil"}&nbsp;{_ "Edit Event"}</a>
<button class="btn btn-success" type="submit">{glyph "pencil"}&nbsp;{_ "Edit Event&hellip;"}</button> <a class="btn btn-success" href="{$Event->getUrl('segments/*create')}">{glyph "plus"}&nbsp;{_ "Add Segment"}</a>
</form>
{/if} {/if}
</div> </div>
<h1>{$Event->Title|escape}</h1> <h1>{$Event->Title|escape}</h1>
</div> </div>
<div class="row">
<div class="col-md-3">
<ul class="row list-unstyled">
{if $Event->Status != 'published'}
<li class="col-sm-3 col-md-12">
<p>
<b>Status</b><br/>
{$Event->Status}
</p>
</li>
{/if}

<li class="col-sm-3 col-md-12">
<p>
<b>Start time</b><br/>
{timestamp $Event->StartTime time=yes}
</p>
</li>

{if $Event->EndTime}
<li class="col-sm-3 col-md-12">
<p>
<b>End time</b><br/>
{timestamp $Event->EndTime time=yes}
</p>
</li>
{/if}

{if $Event->Location}
<li class="col-sm-3 col-md-12">
<p>
<b>Location</b><br/>
<a href="https://www.google.com/maps?q={$Event->Location|escape:url}">{$Event->Location|escape}</a>
</p>
</li>
{/if}
</ul>
</div>


<div class="row">
<div class="col-md-9"> <div class="col-md-9">
{if $Event->Description} {if $Event->Description}
<div class="well"> <div class="content-markdown event-description well">{$Event->Description|escape|markdown}</div>
<div class="content-markdown event-description">{$Event->Description|truncate:600|escape|markdown}</div>
</div>
{/if} {/if}


{if $Event->Segments} {if $Event->Segments}
<h2>Segments</h2> <section class="event-segments">
<h2>Schedule</h2>


{$lastDate = null} {$lastDate = null}
{$lastLocationName = null}
{$lastLocationAddress = null}


{foreach item=Segment from=$Event->Segments} {foreach item=Segment from=$Event->Segments}
{$thisDate = date("l, F jS", $Segment->StartTime)} {$thisDate = date("l, F jS", $Segment->StartTime)}


{if $lastDate != $thisDate} {if $lastDate != $thisDate}
{if $lastDate} {if $lastDate}
</dl> </dl>
{/if}
<h3>{$thisDate}</h3>
<dl class="dl-horizontal">
{$lastDate = $thisDate}
{$lastLocationName = null}
{$lastLocationAddress = null}
{/if} {/if}
<h3>{$thisDate}</h3> {if
<dl class="dl-horizontal"> (
{$lastDate = $thisDate} $Segment->LocationName != $lastLocationName
{/if} || $Segment->LocationAddress != $lastLocationAddress
<dt>{time_range $Segment->StartTime $Segment->EndTime}</dt> )
<dd> && ($Segment->LocationName || $Segment->LocationAddress)
<a href="{$Event->getUrl("segments/$Segment->Handle")}">{$Segment->Title|escape}</a> }
{if $Segment->LocationName || $Segment->LocationAddress} <div class="event-location">
<p> <dt>{icon "map-marker"}</dt>
<strong>Location</strong> <dd>{eventLocation name=$Segment->LocationName address=$Segment->LocationAddress}</dd>
<a target="_blank" href="https://maps.google.com?q={implode(', ', array_filter(array($Segment->LocationName, $Segment->LocationAddress)))|escape:url}"> </div>
{if $Segment->LocationName && $Segment->LocationAddress}
{$Segment->LocationName|escape} ({$Segment->LocationAddress|escape})
{else}
{$Segment->LocationName|default:$Segment->LocationAddress|escape}
{/if}
</a>
</p>
{/if} {/if}
<div class="content-markdown event-segment-description">{$Segment->Description|escape|markdown}</div> <dt>{time_range $Segment->StartTime $Segment->EndTime}</dt>
</dd> <dd>
{/foreach} <h4><a href="{$Segment->getUrl()}">{$Segment->Title|escape}</a></h4>
<div class="content-markdown event-segment-description">{$Segment->Description|escape|markdown}</div>
</dd>

{$lastLocationName = $Segment->LocationName}
{$lastLocationAddress = $Segment->LocationAddress}
{/foreach}
</foreach>
{/if} {/if}
</div> </div>

<dl class="event-details col-md-3">
{if $Event->Status != 'published'}
<dt>Status</dt>
<dd>{$Event->Status}</dd>
{/if}

<dt>Starts</dt>
<dd>{timestamp $Event->StartTime time='auto'}</dd>

{if $Event->EndTime}
<dt>Ends</dt>
<dd>{timestamp $Event->EndTime time='auto'}</dd>
{/if}

{if $Event->LocationName || $Event->LocationAddress}
<dt>Location</dt>
<dd>{eventLocation name=$Event->LocationName address=$Event->LocationAddress}</dd>
{/if}
</dl>
</div> </div>
{/block} {/block}
16 changes: 10 additions & 6 deletions html-templates/events/eventEdit.tpl
Expand Up @@ -54,16 +54,20 @@
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="field-time-start">{_ "StartTime"}:</label> <label for="field-time-start">{_ "Start time"}:</label>
<input type="date" name="StartTime" id="field-time-start" class="form-control" value="{refill field=StartTime default=$Event->StartTime}"/> <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))}"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="field-time-end">{_ "EndTime"}:</label> <label for="field-time-end">{_ "End time"}:</label>
<input type="date" name="EndTime" id="field-time-end" class="form-control" value="{refill field=EndTime default=$Event->EndTime}"/> <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))}"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="field-location">{_ "Location"}:</label> <label for="field-location-name">{_ "Location name"}:</label>
<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}"/> <input type="text" name="LocationName" id="field-location-name" class="form-control" placeholder="Localhost" value="{refill field=LocationName default=$Event->LocationName}"/>
</div>
<div class="form-group">
<label for="field-location-address">{_ "Location address"}:</label>
<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}"/>
</div> </div>


<div class="form-group"> <div class="form-group">
Expand Down
2 changes: 1 addition & 1 deletion html-templates/events/eventSaved.tpl
Expand Up @@ -8,7 +8,7 @@
{capture assign=eventLink}<a href="{$Event->getUrl()|escape}">{$Event->getTitle()|escape}</a>{/capture} {capture assign=eventLink}<a href="{$Event->getUrl()|escape}">{$Event->getTitle()|escape}</a>{/capture}


<div class="page-header"> <div class="page-header">
<h1>Event Created</h1> <h1>Event Saved</h1>
</div> </div>
{if $Event->isNew} {if $Event->isNew}
<p>{_("Your event has been created: %s")|sprintf:$eventLink}</p> <p>{_("Your event has been created: %s")|sprintf:$eventLink}</p>
Expand Down
63 changes: 63 additions & 0 deletions html-templates/events/eventSegment.tpl
@@ -0,0 +1,63 @@
{extends "designs/site.tpl"}

{block title}{$data->Title|escape} @ {$data->Event->Title|escape} &mdash; {$dwoo.parent}{/block}

{block css}
{$dwoo.parent}

<style>
.event-segment-description p:last-child {
margin-bottom: 0;
}
.event-segment-details dt {
font-size: 130%;
}
.event-segment-details dd {
margin-bottom: 1em;
}
</style>
{/block}

{block content}
{$Segment = $data}
{$Event = $Segment->Event}
{load_templates "subtemplates.tpl"}

<div class="page-header">
<ol class="breadcrumb">
<li><a href="/events">{_ "Events"}</a></li>
<li><a href="{$Event->getUrl()}">{$Event->Title|escape}</a></li>
<li>Schedule</li>
</ol>
<div class="btn-toolbar pull-right">
{if $.User}
<a class="btn btn-success" href="{$Segment->getUrl(edit)}">{glyph "pencil"}&nbsp;{_ "Edit Segment"}</a>
{/if}
</div>
<h1>{$Segment->Title|escape}</h1>
</div>

<div class="row">
<div class="col-md-9">
{if $Segment->Description}
<div class="content-markdown event-segment-description well">{$Segment->Description|escape|markdown}</div>
{/if}
</div>

<dl class="event-segment-details col-md-3">
<dt>Starts</dt>
<dd>{timestamp $Segment->StartTime time='auto'}</dd>

{if $Segment->EndTime}
<dt>Ends</dt>
<dd>{timestamp $Segment->EndTime time='auto'}</dd>
{/if}

{if $Segment->LocationName || $Segment->LocationAddress}
<dt>Location</dt>
<dd>{eventLocation name=$Segment->LocationName address=$Segment->LocationAddress}</dd>
{/if}
</dl>
</div>
{/block}
85 changes: 85 additions & 0 deletions html-templates/events/eventSegmentEdit.tpl
@@ -0,0 +1,85 @@
{extends designs/site.tpl}

{block title}{if $data->isPhantom}{_ 'Create'}{else}{_('Edit %s')|sprintf:$data->Title|escape}{/if} &mdash; {_ 'Events'} &mdash; {$dwoo.parent}{/block}

{block js-bottom}
{$dwoo.parent}
{jsmin "epiceditor.js"}
{jsmin "pages/event-edit.js"}
{/block}

{block content}
{$Segment = $data}

<div class="container">
<div class="row">
<div class="col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
<div class="page-header">
<h1>
{if $Segment->isPhantom}
{_ "Create new event segment"}
{else}
{_("Edit event segment %s")|sprintf:$Segment->Title|escape}
{/if}
</h1>
</div>

{if !$Segment->isValid}
<div class="error well">
<strong>{_ "There were problems with your entry:"}</strong>
<ul class="errors">
{foreach item=error key=field from=$Segment->validationErrors}
<li>{$error}</li>
{/foreach}
</ul>
</div>
{/if}

<form method="POST">
<div class="form-group">
<label for="field-event">{_ "Event"}:</label>
<select name="EventID" id="field-event" class="form-control">
{foreach item=Event from=Emergence\Events\Event::getAll(array(Order=StartTime))}
<option value="{$Event->ID}" {refill field=EventID default=$Segment->EventID selected=$Event->ID}>{date('Y-m-d', $Event->StartTime)}: {$Event->Title|escape}</option>
{/foreach}
</select>
</div>
<div class="form-group">
<label for="field-title">{_ "Title"}:</label>
<input name="Title" id="field-title" class="form-control" placeholder="{_ 'Opening Remarks'}" value="{refill field=Title default=$Segment->Title}" />
</div>
<div class="form-group">
<label for="field-handle">{_ "Handle"} ({_ "optional"}):</label>
<input name="Handle" id="field-handle" class="form-control" placeholder="{_ 'opening-remarks'}" value="{refill field=Handle default=$Segment->Handle}" />
<p class="help-block">Must be unique &mdash; leave blank to auto-generate</p>
</div>
<div class="form-group">
<label for="field-time-start">{_ "Start time"}:</label>
<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))}"/>
</div>
<div class="form-group">
<label for="field-time-end">{_ "End time"}:</label>
<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))}"/>
</div>
<div class="form-group">
<label for="field-location-name">{_ "Location name"}:</label>
<input type="text" name="LocationName" id="field-location-name" class="form-control" placeholder="Localhost" value="{refill field=LocationName default=$Segment->LocationName}"/>
</div>
<div class="form-group">
<label for="field-location-address">{_ "Location address"}:</label>
<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}"/>
</div>

<div class="form-group">
<label for="field-description">{_ 'Description(.md)'}</label>
<div class="controls">
<textarea name="Description" class="input-block-level" rows="10">{refill field=Description default=$Segment->Description}</textarea>
</div>
</div>

<button type="submit" class="btn btn-primary">{if $Segment->isPhantom}{_ 'Create Event Segment'}{else}{_ 'Save Changes'}{/if}</button>
</form>
</div>
</div>
</div>
{/block}

0 comments on commit 26aa7aa

Please sign in to comment.