added delete timesheet records action for users #67 (#72)

This commit is contained in:
Kevin Papst
2018-01-09 21:47:32 +01:00
committed by GitHub
parent 03896e3a1a
commit 42bf4f41f7
6 changed files with 39 additions and 6 deletions

View File

@@ -30,6 +30,10 @@
<source>create</source>
<target>Erstellen</target>
</trans-unit>
<trans-unit id="confirm.delete">
<source>confirm.delete</source>
<target>Wollen Sie das wirklich löschen?</target>
</trans-unit>
<!--
Login / Security

View File

@@ -93,7 +93,7 @@
<script type="text/javascript">
$(document).ready(function () {
$('.dropdown-toggle').dropdown();
$(document).kimai({imagePath: '{{ asset('images') }}'});
$(document).kimai({imagePath: '{{ asset('images') }}', confirmDelete: '{{ 'confirm.delete'|trans }}'});
//$(document).kimai('pauseRecord', 'li.messages-menu ul.menu li');
});
</script>

View File

@@ -167,7 +167,7 @@
{% endmacro %}
{% macro button_action(icon, url) %}
<a href="{{ url }}" class="btn btn-default">
<a href="{{ url }}" class="btn btn-default btn-{{ icon }}">
<i class="fa fa-{{ icon }}"></i>
</a>
{% endmacro %}

View File

@@ -144,6 +144,26 @@ class TimesheetController extends AbstractController
return $this->create($request, 'timesheet', 'TimesheetBundle:timesheet:edit.html.twig');
}
/**
* The route to delete an existing entry.
*
* @Route("/{id}/delete", name="timesheet_delete")
* @Method({"GET", "POST"})
* @Security("is_granted('delete', entry)")
*
* @param Timesheet $entry
* @param Request $request
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
public function deleteAction(Timesheet $entry, Request $request)
{
$entityManager = $this->getDoctrine()->getManager();
$entityManager->remove($entry);
$entityManager->flush();
return $this->redirectToRoute('timesheet_paginated', ['page' => $request->get('page')]);
}
/**
* @param Timesheet $entry
* @return \Symfony\Component\Form\FormInterface

View File

@@ -38,11 +38,14 @@
<td class="hidden-xs hidden-sm">{{ widgets.label_activity(entry.activity) }}</td>
<td class="hidden-xs hidden-sm">{{ entry.description }}</td>
<td>
{% set actionButtons = {'repeat': path('timesheet_start', {'id' : entry.activity.id}), 'edit': path('timesheet_edit', {'id' : entry.id, 'page': page})} %}
{% if entry.end %}
{{ widgets.button_group({'repeat': path('timesheet_start', {'id' : entry.activity.id}), 'edit': path('timesheet_edit', {'id' : entry.id, 'page': page}), 'trash': '#'}) }}
{% else %}
{{ widgets.button_group({'stop': path('timesheet_stop', {'id' : entry.id}), 'edit': path('timesheet_edit', {'id' : entry.id, 'page': page}), 'trash': '#'}) }}
{% set actionButtons = {'stop': path('timesheet_stop', {'id' : entry.id}), 'edit': path('timesheet_edit', {'id' : entry.id, 'page': page})} %}
{% endif %}
{% if is_granted('delete', entry) %}
{% set actionButtons = actionButtons|merge({'trash': path('timesheet_delete', {'id' : entry.id, 'page': page})}) %}
{% endif %}
{{ widgets.button_group(actionButtons) }}
</td>
</tr>
{% endfor %}

View File

@@ -7,6 +7,11 @@ $(document).ready(function() {
var methods = {
init : function(options) {
$.fn.kimai.settings = $.extend( {}, $.fn.kimai.defaults, options );
// ask before a delete call is executed
$('a.btn-trash').click(function (event) {
return confirm($.fn.kimai.settings['confirmDelete']);
});
},
hook: function(name) {
alert('Hook: ' + name);
@@ -45,7 +50,8 @@ $(document).ready(function() {
// default values
$.fn.kimai.defaults = {
baseUrl: '/',
imagePath: '/images'
imagePath: '/images',
confirmDelete: 'Really delete?'
};
// once initialized, here are all values