Implement copying of events.

Fixes #17
This commit is contained in:
Tim Schumacher 2014-09-17 17:50:24 +02:00
parent e8c94262d0
commit 9562a8d3a3
4 changed files with 41 additions and 7 deletions

View file

@ -305,4 +305,33 @@ class EventController extends Controller
);
}
/**
* Copies a Event entity.
*
* @Route("/termine/{slug}/kopieren", name="_copy")
* @Method("GET")
* @Template("CalciferBundle:Event:new.html.twig")
*/
public function copyAction(Request $request, $slug) {
/** @var EntityManager $em */
$em = $this->getDoctrine()->getManager();
/** @var EntityRepository $repo */
$repo = $em->getRepository('CalciferBundle:Event');
/** @var Event $entity */
$entity = $repo->findOneBy(['slug' => $slug]);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Event entity.');
}
$entity->id = null;
return array(
'entity' => $entity,
);
}
}

View file

@ -6,7 +6,7 @@
}
}
.startdate,.location,.url,.edit,.delete {
.startdate,.location,.url,.action {
display: inline;
margin: 0;
margin-right: 0.5rem;

View file

@ -4,8 +4,7 @@
{% stylesheets filter="compass"
"@CalciferBundle/Resources/assets/css/jquery.datetimepicker.scss"
"@CalciferBundle/Resources/assets/css/events.scss"
"@CalciferBundle/Resources/assets/css/leaflet.scss"
%}
"@CalciferBundle/Resources/assets/css/leaflet.scss" %}
<link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %}
{% endblock %}
@ -14,8 +13,7 @@
{% javascripts
"@CalciferBundle/Resources/assets/js/jquery.datetimepicker.js"
"@CalciferBundle/Resources/assets/js/events.js"
"@CalciferBundle/Resources/assets/js/leaflet.js"
%}
"@CalciferBundle/Resources/assets/js/leaflet.js" %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock %}

View file

@ -5,17 +5,24 @@
</h2>
{% if (detail|default(false)) %}
<p class="edit">
<p class="action">
<a href="{{ path('_edit', {'slug' : entity.slug }) }}"><i
class="circular icon edit green inverted link"></i>Bearbeiten</a>
</p>
<p class="delete">
<p class="action">
<a href="{{ path('_delete', {'slug' : entity.slug }) }}">
<i class="circular icon delete green inverted link"></i>
Löschen
</a>
</p>
<p class="action">
<a href="{{ path('_copy', {'slug' : entity.slug }) }}">
<i class="circular icon copy green inverted link"></i>
Kopieren
</a>
</p>
{% endif %}
<p class="startdate ">