enhanced plugin support (#634)

- refactored admin controller and templates
- plugin support for entity actions
- changed column mail to email in customer table
- refactored theme events
This commit is contained in:
Kevin Papst
2019-03-11 14:46:30 +01:00
committed by GitHub
parent 519be2d5a2
commit 3ac72a5c89
104 changed files with 1878 additions and 976 deletions

View File

@@ -1,9 +1,11 @@
{% extends 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}
{% import "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'admin_activity.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_activity.subtitle'|trans }}{% endblock %}
{% block page_actions %}{{ actions.activity(activity, 'delete') }}{% endblock %}
{% block main %}

View File

@@ -1,7 +1,10 @@
{% extends app.request.xmlHttpRequest ? 'form.html.twig' : 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'admin_activity.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_activity.subtitle'|trans }}{% endblock %}
{% block page_actions %}{{ actions.activity(activity, 'edit') }}{% endblock %}
{% block main %}
{{ include(app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig', {

View File

@@ -2,16 +2,11 @@
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}
{% import "macros/toolbar.html.twig" as toolbar %}
{% import "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'admin_activity.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_activity.subtitle'|trans }} {{ 'subtitle.amount'|trans({'%count%': entries.count}) }}{% endblock %}
{% block page_actions %}
{% set actions = {'filter': '#collapseActivityAdmin', 'visibility': '#modal_activity_admin'} %}
{% if is_granted('create_activity') %}
{% set actions = actions|merge({'create': path('admin_activity_create')}) %}
{% endif %}
{{ widgets.page_actions(actions) }}
{% endblock %}
{% block page_actions %}{{ actions.activities('index') }}{% endblock %}
{% block main_before %}
{{ toolbar.toolbar(toolbarForm, 'collapseActivityAdmin', showFilter) }}
@@ -55,14 +50,7 @@
<td class="{{ tables.data_table_column_class(tableName, columns, 'comment') }}">{{ entry.comment }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'visible') }}">{{ widgets.label_visible(entry.visible) }}</td>
<td>
{% set actionButtons = {} %}
{% if is_granted('edit', entry) %}
{% set actionButtons = {'edit': path('admin_activity_edit', {'id': entry.id})}|merge(actionButtons) %}
{% endif %}
{% if is_granted('delete', entry) %}
{% set actionButtons = actionButtons|merge({'trash': path('admin_activity_delete', {'id': entry.id})}) %}
{% endif %}
{{ widgets.button_group(actionButtons) }}
{{ actions.activity(entry, 'index') }}
</td>
</tr>
{% endfor %}

View File

@@ -1,12 +0,0 @@
{% extends app.request.xmlHttpRequest ? 'form.html.twig' : 'base.html.twig' %}
{% block page_title %}{{ 'timesheet.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'timesheet.subtitle'|trans }}{% endblock %}
{% block main %}
{{ include(app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig', {
'title': (entry.id ? 'timesheet.edit'|trans : 'create'|trans),
'form': form,
'back': path('admin_timesheet')
}) }}
{% endblock %}

View File

@@ -76,7 +76,7 @@
{% block avanzu_navbar_notifications %}
{% if app.user is not null and is_granted('IS_AUTHENTICATED_REMEMBERED') %}
{{ render(controller('App\\Controller\\ActivityController::recentActivitiesAction')) }}
{{ render(controller('App\\Controller\\NavbarController::recentActivitiesAction')) }}
{% endif %}
{% endblock %}
@@ -95,14 +95,16 @@
{% block stylesheets %}
{# we do not call parent() as we use a custom built for the frontend assets and don't want the default <stylesheet> #}
<link rel="stylesheet" href="{{ asset('build/app.css') }}">
{{ render(controller('App\\Controller\\EventController::trigger', {'request':app.request, 'event':constant('App\\Event\\ThemeEvent::STYLESHEET')})) }}
{% set event = trigger(constant('App\\Event\\ThemeEvent::STYLESHEET')) %}
{{ event.content|raw }}
{% endblock %}
{% block head %}
{{ parent() }}
<script src="{{ asset('build/app.js') }}"></script>
{% include 'partials/head.html.twig' %}
{{ render(controller('App\\Controller\\EventController::trigger', {'request':app.request, 'event':constant('App\\Event\\ThemeEvent::HTML_HEAD')})) }}
{% set event = trigger(constant('App\\Event\\ThemeEvent::HTML_HEAD')) %}
{{ event.content|raw }}
{% endblock %}
{% block javascripts %}
@@ -128,5 +130,6 @@
{# $.kimai.pauseRecord('li.messages-menu ul.menu li'); #}
});
</script>
{{ render(controller('App\\Controller\\EventController::trigger', {'request':app.request, 'event':constant('App\\Event\\ThemeEvent::JAVASCRIPT')})) }}
{% set event = trigger(constant('App\\Event\\ThemeEvent::JAVASCRIPT')) %}
{{ event.content|raw }}
{% endblock %}

View File

@@ -1,9 +1,11 @@
{% extends 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}
{% import "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'admin_customer.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_customer.subtitle'|trans }}{% endblock %}
{% block page_actions %}{{ actions.customer(customer, 'delete') }}{% endblock %}
{% block main %}

View File

@@ -1,7 +1,10 @@
{% extends app.request.xmlHttpRequest ? 'form.html.twig' : 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'admin_customer.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_customer.subtitle'|trans }}{% endblock %}
{% block page_actions %}{{ actions.customer(customer, 'edit') }}{% endblock %}
{% block main %}
{{ include(app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig', {

View File

@@ -2,16 +2,11 @@
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}
{% import "macros/toolbar.html.twig" as toolbar %}
{% import "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'admin_customer.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_customer.subtitle'|trans }} {{ 'subtitle.amount'|trans({'%count%': entries.count}) }}{% endblock %}
{% block page_actions %}
{% set actions = {'filter': '#collapseCustomerAdmin', 'visibility': '#modal_customer_admin'} %}
{% if is_granted('create_customer') %}
{% set actions = actions|merge({'create': path('admin_customer_create')}) %}
{% endif %}
{{ widgets.page_actions(actions) }}
{% endblock %}
{% block page_actions %}{{ actions.customers('index') }}{% endblock %}
{% block main_before %}
{{ toolbar.toolbar(toolbarForm, 'collapseCustomerAdmin', showFilter) }}
@@ -26,7 +21,7 @@
'name': 'alwaysVisible',
'comment': 'hidden-xs',
'country': 'hidden-xs',
'customer_number': 'hidden-xs',
'number': 'hidden-xs',
'currency': 'hidden-xs',
'visible': 'hidden-xs',
'actions': 'alwaysVisible',
@@ -41,21 +36,11 @@
<td>{{ entry.name }} {% if entry.company is not empty %}({{ entry.company }}){% endif %}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'comment') }}">{{ entry.comment }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'country') }}">{{ entry.country|country }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'customer_number') }}">{{ entry.number }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'number') }}">{{ entry.number }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'currency') }}">{{ entry.currency }} {{ entry.currency|currency }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'visible') }}">{{ widgets.label_visible(entry.visible) }}</td>
<td>
{% set actionButtons = {} %}
{% if is_granted('edit', entry) %}
{% set actionButtons = {'edit': path('admin_customer_edit', {'id': entry.id})}|merge(actionButtons) %}
{% endif %}
{% if is_granted('view_project') %}
{% set actionButtons = actionButtons|merge({'project': path('admin_project', {'customer': entry.id})}) %}
{% endif %}
{% if is_granted('delete', entry) %}
{% set actionButtons = actionButtons|merge({'trash': path('admin_customer_delete', {'id': entry.id})}) %}
{% endif %}
{{ widgets.button_group(actionButtons) }}
{{ actions.customer(entry, 'index') }}
</td>
</tr>
{% endfor %}

View File

@@ -91,8 +91,8 @@
'label.activity',
'label.description',
'label.exported',
'label.hourly_rate',
'label.fixed_rate',
'label.hourlyRate',
'label.fixedRate',
'label.duration',
'label.rate',
] %}

View File

@@ -28,9 +28,9 @@
<br>
{{ 'label.phone'|trans }}: {{ model.customer.phone }}
{% endif %}
{% if model.customer.mail is not empty %}
{% if model.customer.email is not empty %}
<br>
{{ 'label.email'|trans }}: {{ model.customer.mail }}
{{ 'label.email'|trans }}: {{ model.customer.email }}
{% endif %}
</address>
</div>
@@ -41,10 +41,10 @@
<p contenteditable="true">
<b>{{ 'invoice.due_days'|trans }}:</b> {{ model.dueDate|date_short }}
{% if model.customer.number is not empty %}
<br><b>{{ 'label.customer_number'|trans }}:</b> {{ model.customer.number }}
<br><b>{{ 'label.number'|trans }}:</b> {{ model.customer.number }}
{% endif %}
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
<br><b>{{ 'label.order_number'|trans }}:</b> {{ model.query.project.orderNumber }}
<br><b>{{ 'label.orderNumber'|trans }}:</b> {{ model.query.project.orderNumber }}
{% endif %}
</p>
</div>

View File

@@ -53,7 +53,7 @@
</tr>
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
<tr>
<th>{{ 'label.order_number'|trans }}</th>
<th>{{ 'label.orderNumber'|trans }}</th>
<td contenteditable="true">
{{ model.query.project.orderNumber }}
</td>

View File

@@ -42,7 +42,7 @@
</tr>
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
<tr>
<th>{{ 'label.order_number'|trans }}</th>
<th>{{ 'label.orderNumber'|trans }}</th>
<td contenteditable="true">
{{ model.query.project.orderNumber }}
</td>

View File

@@ -0,0 +1,222 @@
{# This file contains twig macros used to display possible actions for all available entities #}
{% macro activities(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {'filter': '#collapseActivityAdmin', 'visibility': '#modal_activity_admin'} %}
{% if is_granted('create_activity') %}
{% set actions = actions|merge({'create': path('admin_activity_create')}) %}
{% endif %}
{% set event = trigger('actions.activities', {'actions': actions, 'view': view}) %}
{{ widgets.page_actions(event.payload.actions) }}
{% endmacro %}
{% macro activity(activity, view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {} %}
{% if activity.id is not empty %}
{% if is_granted('edit', activity) %}
{% set actions = actions|merge({'edit': path('admin_activity_edit', {'id': activity.id})}) %}
{% endif %}
{% if is_granted('delete', activity) %}
{% set actions = actions|merge({'trash': path('admin_activity_delete', {'id': activity.id})}) %}
{% endif %}
{% endif %}
{% if view != 'index' %}
{% set actions = actions|merge({'list': path('admin_activity')}) %}
{% endif %}
{% set event = trigger('actions.activity', {'actions': actions, 'view': view, 'activity': activity}) %}
{% if view == 'index' %}
{{ widgets.button_group(event.payload.actions) }}
{% else %}
{{ widgets.page_actions(event.payload.actions) }}
{% endif %}
{% endmacro %}
{% macro projects(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {'filter': '#collapseProjectAdmin', 'visibility': '#modal_project_admin'} %}
{% if is_granted('create_project') %}
{% set actions = actions|merge({'create': path('admin_project_create')}) %}
{% endif %}
{% set event = trigger('actions.projects', {'actions': actions, 'view': view}) %}
{{ widgets.page_actions(event.payload.actions) }}
{% endmacro %}
{% macro project(project, view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {} %}
{% if project.id is not empty %}
{% if is_granted('edit', project) %}
{% set actions = actions|merge({'edit': path('admin_project_edit', {'id': project.id})}) %}
{% endif %}
{% if is_granted('view_activity') %}
{% set actions = actions|merge({'activity': path('admin_activity', {'customer': project.customer.id, 'project': project.id})}) %}
{% endif %}
{% if is_granted('delete', project) %}
{% set actions = actions|merge({'trash': path('admin_project_delete', {'id': project.id})}) %}
{% endif %}
{% endif %}
{% if view != 'index' %}
{% set actions = actions|merge({'list': path('admin_project')}) %}
{% endif %}
{% set event = trigger('actions.project', {'actions': actions, 'view': view, 'project': project}) %}
{% if view == 'index' %}
{{ widgets.button_group(event.payload.actions) }}
{% else %}
{{ widgets.page_actions(event.payload.actions) }}
{% endif %}
{% endmacro %}
{% macro customers(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {'filter': '#collapseCustomerAdmin', 'visibility': '#modal_customer_admin'} %}
{% if is_granted('create_customer') %}
{% set actions = actions|merge({'create': path('admin_customer_create')}) %}
{% endif %}
{% set event = trigger('actions.customers', {'actions': actions, 'view': view}) %}
{{ widgets.page_actions(event.payload.actions) }}
{% endmacro %}
{% macro customer(customer, view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {} %}
{% if customer.id is not empty %}
{% if is_granted('edit', customer) %}
{% set actions = actions|merge({'edit': path('admin_customer_edit', {'id': customer.id})}) %}
{% endif %}
{% if is_granted('view_project') %}
{% set actions = actions|merge({'project': path('admin_project', {'customer': customer.id})}) %}
{% endif %}
{% if is_granted('delete', customer) %}
{% set actions = actions|merge({'trash': path('admin_customer_delete', {'id': customer.id})}) %}
{% endif %}
{% endif %}
{% if view != 'index' %}
{% set actions = actions|merge({'list': path('admin_customer')}) %}
{% endif %}
{% set event = trigger('actions.customer', {'actions': actions, 'view': view, 'customer': customer}) %}
{% if view == 'index' %}
{{ widgets.button_group(event.payload.actions) }}
{% else %}
{{ widgets.page_actions(event.payload.actions) }}
{% endif %}
{% endmacro %}
{% macro timesheets(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {'filter': '#collapseTimesheet'} %}
{% if is_granted('export_own_timesheet') %}
{% set actions = actions|merge({'download': {'onclick': 'return exportTimesheet()'}}) %}
{% endif %}
{% set actions = actions|merge({'visibility': '#modal_timesheet'}) %}
{% set actions = actions|merge({'calendar': path('calendar')}) %}
{% if is_granted('create_own_timesheet') %}
{% set actions = actions|merge({'create': {'url': path('timesheet_create'), 'class': 'modal-ajax-form'}}) %}
{% endif %}
{% set event = trigger('actions.timesheets', {'actions': actions, 'view': view}) %}
{{ widgets.page_actions(event.payload.actions) }}
{% endmacro %}
{% macro timesheet(timesheet, view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {} %}
{% if timesheet.id is not empty %}
{% if timesheet.end %}
{% if is_granted('start', timesheet) %}
{% set actions = actions|merge({'repeat': path('timesheet_start', {'id' : timesheet.id})}) %}
{% endif %}
{% else %}
{% if is_granted('stop', timesheet) %}
{% set actions = actions|merge({'stop': path('timesheet_stop', {'id' : timesheet.id})}) %}
{% endif %}
{% endif %}
{% if is_granted('edit', timesheet) %}
{% set class = '' %}
{% if view != 'edit' %}
{% set class = 'modal-ajax-form' %}
{% endif %}
{% set actions = actions|merge({'edit': {'url': path('timesheet_edit', {'id': timesheet.id}), 'class': class}}) %}
{% endif %}
{% if is_granted('delete', timesheet) %}
{% set actions = actions|merge({'trash': path('timesheet_delete', {'id' : timesheet.id})}) %}
{% endif %}
{% endif %}
{% if view != 'index' %}
{% set actions = actions|merge({'list': path('timesheet')}) %}
{% endif %}
{% set event = trigger('actions.timesheet', {'actions': actions, 'view': view, 'timesheet': timesheet}) %}
{% if view == 'index' %}
{{ widgets.button_group(event.payload.actions) }}
{% else %}
{{ widgets.page_actions(event.payload.actions) }}
{% endif %}
{% endmacro %}
{% macro timesheets_team(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {'filter': '#collapseTimesheetAdmin'} %}
{% if is_granted('export_own_timesheet') %}
{% set actions = actions|merge({'download': 'onclick:return exportTimesheet()'}) %}
{% endif %}
{% set actions = actions|merge({'visibility': '#modal_timesheet_admin'}) %}
{% if is_granted('create_other_timesheet') %}
{% set actions = actions|merge({'create': {'url': path('admin_timesheet_create'), 'class': 'modal-ajax-form'}}) %}
{% endif %}
{% set event = trigger('actions.timesheets_team', {'actions': actions, 'view': view}) %}
{{ widgets.page_actions(event.payload.actions) }}
{% endmacro %}
{% macro timesheet_team(timesheet, view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {} %}
{% if timesheet.id is not empty %}
{% if not timesheet.end and is_granted('stop', timesheet) %}
{% set actions = actions|merge({'stop': path('admin_timesheet_stop', {'id' : timesheet.id})}) %}
{% endif %}
{% if is_granted('edit', timesheet) %}
{% set class = '' %}
{% if view != 'edit' %}
{% set class = 'modal-ajax-form' %}
{% endif %}
{% set actions = actions|merge({'edit': {'url': path('admin_timesheet_edit', {'id': timesheet.id}), 'class': class}}) %}
{% endif %}
{% if is_granted('delete', timesheet) %}
{% set actions = actions|merge({'trash': path('admin_timesheet_delete', {'id' : timesheet.id})}) %}
{% endif %}
{% endif %}
{% if view != 'index' %}
{% set actions = actions|merge({'list': path('admin_timesheet')}) %}
{% endif %}
{% set event = trigger('actions.timesheet_team', {'actions': actions, 'view': view, 'timesheet': timesheet}) %}
{% if view == 'index' %}
{{ widgets.button_group(event.payload.actions) }}
{% else %}
{{ widgets.page_actions(event.payload.actions) }}
{% endif %}
{% endmacro %}

View File

@@ -1,9 +1,11 @@
{% extends 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}
{% import "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'admin_project.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_project.subtitle'|trans }}{% endblock %}
{% block page_actions %}{{ actions.project(project, 'delete') }}{% endblock %}
{% block main %}

View File

@@ -1,7 +1,10 @@
{% extends app.request.xmlHttpRequest ? 'form.html.twig' : 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'admin_project.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_project.subtitle'|trans }}{% endblock %}
{% block page_actions %}{{ actions.project(project, 'edit') }}{% endblock %}
{% block main %}
{{ include(app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig', {

View File

@@ -2,16 +2,11 @@
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}
{% import "macros/toolbar.html.twig" as toolbar %}
{% import "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'admin_project.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_project.subtitle'|trans }} {{ 'subtitle.amount'|trans({'%count%': entries.count}) }}{% endblock %}
{% block page_actions %}
{% set actions = {'filter': '#collapseProjectAdmin', 'visibility': '#modal_project_admin'} %}
{% if is_granted('create_project') %}
{% set actions = actions|merge({'create': path('admin_project_create')}) %}
{% endif %}
{{ widgets.page_actions(actions) }}
{% endblock %}
{% block page_actions %}{{ actions.projects('index') }}{% endblock %}
{% block main_before %}
{{ toolbar.toolbar(toolbarForm, 'collapseProjectAdmin', showFilter) }}
@@ -45,17 +40,7 @@
<td class="{{ tables.data_table_column_class(tableName, columns, 'budget') }}">{{ entry.budget|money(entry.customer.currency) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'visible') }}">{{ widgets.label_visible(entry.visible) }}</td>
<td>
{% set actionButtons = {} %}
{% if is_granted('edit', entry) %}
{% set actionButtons = {'edit': path('admin_project_edit', {'id': entry.id})}|merge(actionButtons) %}
{% endif %}
{% if is_granted('view_activity') %}
{% set actionButtons = actionButtons|merge({'activity': path('admin_activity', {'customer': entry.customer.id, 'project': entry.id})}) %}
{% endif %}
{% if is_granted('delete', entry) %}
{% set actionButtons = actionButtons|merge({'trash': path('admin_project_delete', {'id': entry.id})}) %}
{% endif %}
{{ widgets.button_group(actionButtons) }}
{{ actions.project(entry, 'index') }}
</td>
</tr>
{% endfor %}

View File

@@ -0,0 +1,15 @@
{% extends app.request.xmlHttpRequest ? 'form.html.twig' : 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'admin_timesheet.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_timesheet.subtitle'|trans }}{% endblock %}
{% block page_actions %}{{ actions.timesheet_team(timesheet, 'edit') }}{% endblock %}
{% block main %}
{{ include(app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig', {
'title': (timesheet.id ? 'timesheet.edit'|trans : 'create'|trans),
'form': form,
'back': path('admin_timesheet')
}) }}
{% endblock %}

View File

@@ -2,20 +2,11 @@
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}
{% import "macros/toolbar.html.twig" as toolbar %}
{% import "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'admin_timesheet.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_timesheet.subtitle'|trans }}{% endblock %}
{% block page_actions %}
{% set actions = {'filter': '#collapseTimesheetAdmin'} %}
{% if is_granted('export_own_timesheet') %}
{% set actions = actions|merge({'download': 'onclick:return exportTimesheet()'}) %}
{% endif %}
{% set actions = actions|merge({'visibility': '#modal_timesheet_admin'}) %}
{% if is_granted('create_other_timesheet') %}
{% set actions = actions|merge({'create': {'url': path('admin_timesheet_create'), 'class': 'modal-ajax-form'}}) %}
{% endif %}
{{ widgets.page_actions(actions) }}
{% endblock %}
{% block page_actions %}{{ actions.timesheets_team('index') }}{% endblock %}
{% block main_before %}
{{ toolbar.toolbar(toolbarForm, 'collapseTimesheetAdmin', showFilter) }}
@@ -74,28 +65,20 @@
{% endif %}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'customer') }}">
<a href="{{ path('admin_customer_edit', {'id': entry.project.customer.id}) }}">{{ widgets.label_customer(entry.project.customer) }}</a>
{{ widgets.label_customer(entry.project.customer) }}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'project') }}">
<a href="{{ path('admin_project_edit', {'id': entry.project.id}) }}">{{ widgets.label_project(entry.project) }}</a>
{{ widgets.label_project(entry.project) }}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'activity') }}">
<a href="{{ path('admin_activity_edit', {'id': entry.activity.id}) }}">{{ widgets.label_activity(entry.activity) }}</a>
{{ widgets.label_activity(entry.activity) }}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'username') }}">
{{ widgets.label_user(entry.user) }}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'username') }}"><a href="{{ path('user_profile'|route_alias, {'username' : entry.user.username}) }}">{{ widgets.label_user(entry.user) }}</a></td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'description') }}">{{ entry.description|nl2br }}</td>
<td>
{% set actionButtons = {} %}
{% if is_granted('edit', entry) %}
{% set actionButtons = actionButtons|merge({'edit': {'url': path('admin_timesheet_edit', {'id': entry.id, 'page': page}), 'class': 'modal-ajax-form'}}) %}
{% endif %}
{% if not entry.end and is_granted('stop', entry) %}
{% set actionButtons = {'stop': path('admin_timesheet_stop', {'id' : entry.id})}|merge(actionButtons) %}
{% endif %}
{% if is_granted('delete', entry) %}
{% set actionButtons = actionButtons|merge({'trash': path('admin_timesheet_delete', {'id' : entry.id, 'page': page})}) %}
{% endif %}
{{ widgets.button_group(actionButtons) }}
{{ actions.timesheet_team(entry, 'index') }}
</td>
</tr>
{% endfor %}

View File

@@ -1,11 +1,14 @@
{% extends app.request.xmlHttpRequest ? 'form.html.twig' : 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'timesheet.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'timesheet.subtitle'|trans }}{% endblock %}
{% block page_actions %}{{ actions.timesheet(timesheet, 'edit') }}{% endblock %}
{% block main %}
{{ include(app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig', {
'title': (entry.id ? 'timesheet.edit'|trans : 'create'|trans),
'title': (timesheet.id ? 'timesheet.edit'|trans : 'create'|trans),
'form': form,
'back': path('timesheet')
}) }}

View File

@@ -2,43 +2,11 @@
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}
{% import "macros/toolbar.html.twig" as toolbar %}
{% macro summary(day, duration, dayRates, columns) %}
<tr class="summary info">
<td class="text-nowrap">{{ day }}</td>
<td></td>
<td></td>
<td class="text-nowrap">{{ duration|duration }}</td>
{% if is_granted('view_rate_own_timesheet') %}
<td class="text-nowrap">
{% for currency, rate in dayRates %}
{{ rate|money(currency) }}
{% if not loop.last %}
<br>
{% endif %}
{% endfor %}
</td>
<td colspan="{{ (columns|length) - 5 }}"></td>
{% else %}
<td colspan="{{ (columns|length) - 4 }}"></td>
{% endif %}
</tr>
{% endmacro %}
{% import "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'timesheet.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'timesheet.subtitle'|trans }}{% endblock %}
{% block page_actions %}
{% set actions = {'filter': '#collapseTimesheet'} %}
{% if is_granted('export_own_timesheet') %}
{% set actions = actions|merge({'download': {'onclick': 'return exportTimesheet()'}}) %}
{% endif %}
{% set actions = actions|merge({'visibility': '#modal_timesheet'}) %}
{% set actions = actions|merge({'calendar': path('calendar')}) %}
{% if is_granted('create_own_timesheet') %}
{% set actions = actions|merge({'create': {'url': path('timesheet_create'), 'class': 'modal-ajax-form'}}) %}
{% endif %}
{{ widgets.page_actions(actions) }}
{% endblock %}
{% block page_actions %}{{ actions.timesheets('index') }}{% endblock %}
{% block main_before %}
{{ toolbar.toolbar(toolbarForm, 'collapseTimesheet', showFilter) }}
@@ -117,25 +85,7 @@
<td class="{{ tables.data_table_column_class(tableName, columns, 'activity') }}">{{ widgets.label_activity(entry.activity) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'description') }} timesheet-description">{{ entry.description|desc2html }}</td>
<td>
{% set actionButtons = {} %}
{% if is_granted('edit', entry) %}
{% set actionButtons = actionButtons|merge({'edit': {'url': path('timesheet_edit', {'id': entry.id, 'page': page}), 'class': 'modal-ajax-form'}}) %}
{% endif %}
{% if entry.end %}
{% if is_granted('start', entry) %}
{% set actionButtons = {'repeat': path('timesheet_start', {'id' : entry.id})}|merge(actionButtons) %}
{% endif %}
{% else %}
{% if is_granted('stop', entry) %}
{% set actionButtons = {'stop': path('timesheet_stop', {'id' : entry.id})}|merge(actionButtons) %}
{% endif %}
{% endif %}
{% if is_granted('delete', entry) %}
{% set actionButtons = actionButtons|merge({'trash': path('timesheet_delete', {'id' : entry.id, 'page': page})}) %}
{% endif %}
{{ widgets.button_group(actionButtons) }}
{{ actions.timesheet(entry, 'index') }}
</td>
</tr>
{% if entry.end %}
@@ -169,3 +119,25 @@
}
</script>
{% endblock %}
{% macro summary(day, duration, dayRates, columns) %}
<tr class="summary info">
<td class="text-nowrap">{{ day }}</td>
<td></td>
<td></td>
<td class="text-nowrap">{{ duration|duration }}</td>
{% if is_granted('view_rate_own_timesheet') %}
<td class="text-nowrap">
{% for currency, rate in dayRates %}
{{ rate|money(currency) }}
{% if not loop.last %}
<br>
{% endif %}
{% endfor %}
</td>
<td colspan="{{ (columns|length) - 5 }}"></td>
{% else %}
<td colspan="{{ (columns|length) - 4 }}"></td>
{% endif %}
</tr>
{% endmacro %}

View File

@@ -133,7 +133,7 @@
<li><a href="#">{{ 'label.username'|trans }} <span class="pull-right badge bg-blue">{{ user.username }}</span></a></li>
<li><a href="#">{{ 'profile.first_entry'|trans }} <span class="pull-right badge bg-purple">{{ stats.firstEntry|date_short }}</span></a></li>
{% if is_granted('view_rate_own_timesheet') %}
<li><a href="#">{{ 'label.hourly_rate'|trans }} <span class="pull-right badge bg-blue">{{ user.preferenceValue('hourly_rate') }}</span></a></li>
<li><a href="#">{{ 'label.hourlyRate'|trans }} <span class="pull-right badge bg-blue">{{ user.preferenceValue('hourly_rate') }}</span></a></li>
{% endif %}
<li><a href="#">{{ 'label.now'|trans }} <span class="pull-right badge bg-blue">{{ local_time|date_short }} {{ local_time|time }}</span></a></li>
</ul>