File: /home/timetracker.panomity.com/tm.old/Resources/views/actions.html.twig
{% macro tasks(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set event = actions(app.user, 'tasks', view) %}
{{ widgets.page_actions(event.actions) }}
{% endmacro %}
{% macro task(task, view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {} %}
{% if task.id is not empty %}
{% if view != 'details' and is_granted('task_details', task) %}
{% set actions = actions|merge({'details': path('tasks_detail', {'id': task.id})}) %}
{% endif %}
{% if is_granted('task_edit', task) %}
{% set class = '' %}
{% if view != 'edit' %}
{% set class = 'modal-ajax-form' %}
{% endif %}
{% set actions = actions|merge({'edit': {'url': path('tasks_edit', {'id': task.id}), 'class': class}}) %}
{% set actions = actions|merge({'copy': {'icon': 'copy'|icon, 'url': path('tasks_duplicate', {'id' : task.id}), 'class': 'modal-ajax-form'}}) %}
{% endif %}
{% if actions|length > 0 %}
{% set actions = actions|merge({'divider': null}) %}
{% endif %}
{% if task.activeRecord(app.user) is not null %}
{% set actions = actions|merge({'stop.task': {'icon': 'fas fa-pause', 'url': path('stop_task', {'id' : task.id}), 'class': 'api-link', 'attr': {'data-event': 'kimai.taskUpdate kimai.taskStop kimai.timesheetUpdate kimai.timesheetStop', 'data-method': 'PATCH', 'data-msg-error': 'action.update.error', 'data-msg-success': 'action.update.success'}}}) %}
{% elseif is_granted('task_start', task) %}
{% set actions = actions|merge({'start.task': {'icon': 'fas fa-play', 'url': path('start_task', {'id' : task.id}), 'class': 'api-link', 'attr': {'data-event': 'kimai.taskUpdate kimai.taskStart kimai.timesheetUpdate kimai.timesheetStart', 'data-method': 'PATCH', 'data-msg-error': 'action.update.error', 'data-msg-success': 'action.update.success'}}}) %}
{% endif %}
{% if is_granted('task_assign', task) %}
{% if task.user is not null %}
{% set actions = actions|merge({'unassign.task': {'icon': 'fas fa-user-minus', 'url': path('unassign_task', {'id' : task.id}), 'class': 'api-link', 'attr': {'data-event': 'kimai.taskUpdate kimai.taskUnassign', 'data-question': 'task.unassign'|trans, 'data-method': 'PATCH', 'data-msg-error': 'action.update.error', 'data-msg-success': 'action.update.success'}}}) %}
{% else %}
{% set actions = actions|merge({'assign.task': {'icon': 'fas fa-user-check', 'url': path('assign_task', {'id' : task.id}), 'class': 'api-link', 'attr': {'data-event': 'kimai.taskUpdate kimai.taskAssign', 'data-question': 'task.assign'|trans, 'data-method': 'PATCH', 'data-msg-error': 'action.update.error', 'data-msg-success': 'action.update.success'}}}) %}
{% endif %}
{% endif %}
{% if is_granted('task_close', task) %}
{% if task.closed %}
{% set actions = actions|merge({'reopen.task': {'icon': 'fas fa-lock', 'url': path('reopen_task', {'id' : task.id}), 'class': 'api-link', 'attr': {'data-event': 'kimai.taskUpdate kimai.taskReopen', 'data-question': 'task.reopen'|trans, 'data-method': 'PATCH', 'data-msg-error': 'action.update.error', 'data-msg-success': 'action.update.success'}}}) %}
{% else %}
{% set actions = actions|merge({'close.task': {'icon': 'fas fa-lock-open', 'url': path('close_task', {'id' : task.id}), 'class': 'api-link', 'attr': {'data-event': 'kimai.taskUpdate kimai.taskClose', 'data-question': 'task.close'|trans, 'data-method': 'PATCH', 'data-msg-error': 'action.update.error', 'data-msg-success': 'action.update.success'}}}) %}
{% endif %}
{% endif %}
{% if view == 'index' and is_granted('task_delete', task) %}
{% set actions = actions|merge({'trash': {'url': path('delete_task', {'id' : task.id}), 'class': 'api-link', 'attr': {'data-event': 'kimai.taskUpdate kimai.taskDelete kimai.userTaskDelete', 'data-method': 'DELETE', 'data-question': 'confirm.delete', 'data-msg-error': 'action.delete.error', 'data-msg-success': 'action.delete.success'}}}) %}
{% endif %}
{% endif %}
{% set event = actions(app.user, 'task', view, {'actions': actions, 'task': task}) %}
{% if view == 'index' %}
{{ widgets.table_actions(event.actions) }}
{% else %}
{{ widgets.page_actions(event.actions) }}
{% endif %}
{% endmacro %}