added team permissions (#996)
This commit is contained in:
@@ -38,13 +38,13 @@
|
||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'customer') }}">
|
||||
{% if entry.project and entry.project.customer %}
|
||||
{# only none-global activities have a project and customer assigned #}
|
||||
{{ widgets.label_customer(entry.project.customer, path('admin_customer_edit', {'id' : entry.project.customer.id})) }}
|
||||
{{ widgets.label_customer(entry.project.customer) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'project') }}">
|
||||
{% if entry.project %}
|
||||
{# only none-global activities have a project and customer assigned #}
|
||||
{{ widgets.label_project(entry.project, path('admin_project_edit', {'id' : entry.project.id})) }}
|
||||
{{ widgets.label_project(entry.project) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'comment') }}">{{ entry.comment|comment2html }}</td>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
'comment': 'hidden-xs',
|
||||
'country': 'hidden-xs',
|
||||
'number': 'hidden-xs',
|
||||
'team': '',
|
||||
'visible': 'hidden-xs',
|
||||
'actions': 'actions alwaysVisible',
|
||||
} %}
|
||||
@@ -37,6 +38,13 @@
|
||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'comment') }}">{{ entry.comment|comment2html }}</td>
|
||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'country') }}">{{ entry.country|country }}</td>
|
||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'number') }}">{{ entry.number }}</td>
|
||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'team') }}">
|
||||
{% if entry.teams|length > 0 %}
|
||||
{{ widgets.badge_counter(entry.teams|length) }}
|
||||
{% else %}
|
||||
{{ widgets.icon('unlocked') }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'visible') }}">{{ widgets.label_visible(entry.visible) }}</td>
|
||||
<td class="actions">
|
||||
{{ actions.customer(entry, 'index') }}
|
||||
|
||||
15
templates/customer/permissions.html.twig
Normal file
15
templates/customer/permissions.html.twig
Normal 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_customer.title'|trans }}{% endblock %}
|
||||
{% block page_subtitle %}{{ 'admin_customer.subtitle'|trans }}{% endblock %}
|
||||
{% block page_actions %}{{ actions.customer(customer, 'permissions') }}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{{ include(app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig', {
|
||||
'title': customer.name,
|
||||
'form': form,
|
||||
'back': path('admin_customer')
|
||||
}) }}
|
||||
{% endblock %}
|
||||
@@ -1,4 +1,5 @@
|
||||
<div class="box box-primary">
|
||||
{{ form_start(form) }}
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">
|
||||
{{ title }}
|
||||
@@ -7,7 +8,6 @@
|
||||
{% endif %}
|
||||
</h3>
|
||||
</div>
|
||||
{{ form_start(form) }}
|
||||
<div class="box-body">
|
||||
{{ form_widget(form) }}
|
||||
</div>
|
||||
@@ -16,6 +16,9 @@
|
||||
{% if back|default(false) %}
|
||||
<a href="{{ back }}" class="btn btn-link">{{ 'action.back'|trans }}</a>
|
||||
{% endif %}
|
||||
{% if reset|default(true) %}
|
||||
<input type="reset" value="{{ 'action.reset'|trans }}" class="btn btn-link pull-right" />
|
||||
{% endif %}
|
||||
</div>
|
||||
{{ form_end(form) }}
|
||||
</div>
|
||||
@@ -145,6 +145,9 @@
|
||||
{% if is_granted('budget', project) %}
|
||||
{% set actions = actions|merge({'report': {'url': path('admin_project_budget', {'id': project.id})}}) %}
|
||||
{% endif %}
|
||||
{% if is_granted('permissions', project) %}
|
||||
{% set actions = actions|merge({'permissions': {'url': path('admin_project_permissions', {'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 %}
|
||||
@@ -198,6 +201,9 @@
|
||||
{% if is_granted('budget', customer) %}
|
||||
{% set actions = actions|merge({'report': {'url': path('admin_customer_budget', {'id': customer.id})}}) %}
|
||||
{% endif %}
|
||||
{% if is_granted('permissions', customer) %}
|
||||
{% set actions = actions|merge({'permissions': {'url': path('admin_customer_permissions', {'id': customer.id})}}) %}
|
||||
{% endif %}
|
||||
{% if is_granted('view_project') %}
|
||||
{% set actions = actions|merge({'project': path('admin_project', {'customer': customer.id})}) %}
|
||||
{% endif %}
|
||||
@@ -443,3 +449,40 @@
|
||||
{{ widgets.page_actions(actions) }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro teams(view) %}
|
||||
{% import "macros/widgets.html.twig" as widgets %}
|
||||
|
||||
{% set actions = {} %}
|
||||
{% if is_granted('create_team') %}
|
||||
{% set actions = actions|merge({'create': {'url': path('admin_team_create')}}) %}
|
||||
{% endif %}
|
||||
|
||||
{% set event = trigger('actions.teams', {'actions': actions, 'view': view}) %}
|
||||
{{ widgets.page_actions(event.payload.actions) }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro team(team, view) %}
|
||||
{% import "macros/widgets.html.twig" as widgets %}
|
||||
|
||||
{% set actions = {} %}
|
||||
{% if team.id is not empty %}
|
||||
{% if is_granted('edit', team) %}
|
||||
{% set class = '' %}
|
||||
{% if view != 'edit' %}
|
||||
{% set class = 'modal-ajax-form' %}
|
||||
{% endif %}
|
||||
{% set actions = actions|merge({'edit': {'url': path('admin_team_edit', {'id': team.id}), 'class': class}}) %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if view == 'index' and is_granted('delete', team) %}
|
||||
{% set actions = actions|merge({'trash': {'url': path('delete_team', {'id' : team.id}), 'class': 'api-link', 'attr': {'data-event': 'kimai.teamDelete kimai.teamUpdate', 'data-method': 'DELETE', 'data-question': 'confirm.delete', 'data-msg-error': 'action.delete.error', 'data-msg-success': 'action.delete.success'}}}) %}
|
||||
{% endif %}
|
||||
|
||||
{% set event = trigger('actions.team', {'actions': actions, 'view': view, 'team': team}) %}
|
||||
{% if view == 'index' %}
|
||||
{{ widgets.table_actions(event.payload.actions) }}
|
||||
{% else %}
|
||||
{{ widgets.entity_actions(event.payload.actions) }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
{% import _self as macro %}
|
||||
{% if role == 'ROLE_SUPER_ADMIN' %}
|
||||
{{ macro.label(role, 'danger') }}
|
||||
{% elseif role == 'ROLE_ADMIN' %}
|
||||
{{ macro.label(role, 'warning') }}
|
||||
{% else %}
|
||||
{{ macro.label(role, 'primary') }}
|
||||
{% endif %}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
'name': 'alwaysVisible',
|
||||
'customer': 'hidden-xs',
|
||||
'comment': 'hidden-xs hidden-sm',
|
||||
'team': '',
|
||||
'visible': '',
|
||||
'actions': 'actions alwaysVisible',
|
||||
} %}
|
||||
@@ -34,9 +35,16 @@
|
||||
<tr{% if is_granted('edit', entry) %} class="modal-ajax-form open-edit" data-href="{{ path('admin_project_edit', {'id': entry.id}) }}"{% endif %}>
|
||||
<td>{{ widgets.label_color_dot('project', true, entry.name, null, entry.color) }}</td>
|
||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'customer') }}">
|
||||
{{ widgets.label_customer(entry.customer, path('admin_customer_edit', {'id' : entry.customer.id})) }}
|
||||
{{ widgets.label_customer(entry.customer) }}
|
||||
</td>
|
||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'comment') }}">{{ entry.comment|comment2html }}</td>
|
||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'team') }}">
|
||||
{% if entry.teams|length > 0 %}
|
||||
{{ widgets.badge_counter(entry.teams|length) }}
|
||||
{% else %}
|
||||
{{ widgets.icon('unlocked') }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'visible') }}">{{ widgets.label_visible(entry.visible) }}</td>
|
||||
<td class="actions">
|
||||
{{ actions.project(entry, 'index') }}
|
||||
|
||||
15
templates/project/permissions.html.twig
Normal file
15
templates/project/permissions.html.twig
Normal 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_project.title'|trans }}{% endblock %}
|
||||
{% block page_subtitle %}{{ 'admin_project.subtitle'|trans }}{% endblock %}
|
||||
{% block page_actions %}{{ actions.project(project, 'permissions') }}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{{ include(app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig', {
|
||||
'title': project.name,
|
||||
'form': form,
|
||||
'back': path('admin_project')
|
||||
}) }}
|
||||
{% endblock %}
|
||||
34
templates/team/edit.html.twig
Normal file
34
templates/team/edit.html.twig
Normal file
@@ -0,0 +1,34 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
{% import "macros/widgets.html.twig" as widgets %}
|
||||
{% import "macros/actions.html.twig" as actions %}
|
||||
|
||||
{% block page_title %}{{ 'teams.title'|trans({}, 'teams') }}{% endblock %}
|
||||
{% block page_subtitle %}{{ 'teams.subtitle'|trans({}, 'teams') }}{% endblock %}
|
||||
{% block page_actions %}{{ actions.team(team, 'edit') }}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{{ include('default/_form.html.twig', {
|
||||
'title': team.name|default('create'|trans),
|
||||
'form': form,
|
||||
'back': path('admin_team')
|
||||
}) }}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{% if not customerForm is null %}
|
||||
{{ include('default/_form.html.twig', {
|
||||
'title': 'teams.customer_access'|trans({}, 'teams'),
|
||||
'form': customerForm,
|
||||
}) }}
|
||||
{% endif %}
|
||||
|
||||
{% if not projectForm is null %}
|
||||
{{ include('default/_form.html.twig', {
|
||||
'title': 'teams.project_access'|trans({}, 'teams'),
|
||||
'form': projectForm,
|
||||
}) }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
49
templates/team/index.html.twig
Normal file
49
templates/team/index.html.twig
Normal file
@@ -0,0 +1,49 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
{% import "macros/widgets.html.twig" as widgets %}
|
||||
{% import "macros/actions.html.twig" as actions %}
|
||||
{% import "macros/datatables.html.twig" as tables %}
|
||||
{% import "macros/toolbar.html.twig" as toolbar %}
|
||||
|
||||
{% block page_title %}{{ 'teams.title'|trans({}, 'teams') }}{% endblock %}
|
||||
{% block page_subtitle %}{{ 'teams.subtitle'|trans({}, 'teams') }}{% endblock %}
|
||||
{% block page_actions %}{{ actions.teams('index') }}{% endblock %}
|
||||
|
||||
{% block main_before %}
|
||||
{{ toolbar.toolbar(toolbarForm, 'collapseTeams', showFilter) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
{% if teams|length == 0 %}
|
||||
{{ widgets.callout('warning', 'error.no_entries_found') }}
|
||||
{% else %}
|
||||
|
||||
{% set columns = {
|
||||
'name': '',
|
||||
'teamlead': '',
|
||||
'user': '',
|
||||
'actions': 'actions alwaysVisible',
|
||||
} %}
|
||||
|
||||
{% set tableName = 'admin_teams' %}
|
||||
|
||||
{{ tables.data_table_header(tableName, columns, false, 'kimai.teamUpdate') }}
|
||||
{% for team in teams %}
|
||||
<tr{% if is_granted('edit', team) %} class="open-edit alternative-link" data-href="{{ path('admin_team_edit', {'id': team.id}) }}"{% endif %}>
|
||||
<td>{{ team.name }}</td>
|
||||
<td>{{ widgets.label_user(team.teamlead) }}</td>
|
||||
<td>
|
||||
{% for user in team.users %}
|
||||
{{ widgets.label_user(user) }}
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td class="actions">
|
||||
{{ actions.team(team, 'index') }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{{ tables.data_table_footer(teams, 'admin_team_paginated') }}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user