{% extends 'ClarolineCoreBundle:Workspace:layout.html.twig' %}

{% block title %}{{ parent() ~ ' - ' ~ "roles" | trans({}, "platform") | striptags | raw }}{% endblock %}

{% block breadcrumb %}
    {{
        macros.workspaceBreadcrumbs(
            workspace,
            [
                {
                    'name': 'roles'|trans({}, 'platform'),
                    'href': ''
                },
            ]
        )
    }}
{% endblock %}

{% block section_content %}
    <div class="panel-body">
        <ul class="nav nav-tabs margin-bottom-md">
            <li> <a href="{{ path('claro_workspace_registered_user_list', {'workspace': workspace.getId() }) }}"> {{'users'|trans({}, 'platform') }} </a> </li>
            <li> <a href="{{ path('claro_workspace_registered_group_list', {'workspace': workspace.getId() }) }}"> {{'groups'|trans({}, 'platform') }} </a> </li>
            <li class="active"> <a href="#">{{ 'roles'|trans({}, 'platform') }}</a> </li>
            <li><a href="{{path('claro_users_pending',{'workspace':workspace.getId()})}}"> {{'pending'|trans({},'platform') }} </a> </li>
        </ul>
        <h3>{{ 'roles_management'|trans({}, 'platform') }}</h3>
    </div>
    <div class="list-group">
        <div class="list-group-item">
            <div class="margin-md">
                <a class="btn btn-default" href="{{ path('claro_workspace_role_create_form', {'workspace': workspace.getId() }) }}" role="button">
                    <i class="fa fa-plus"></i> {{ 'add_role'|trans({}, 'platform') }}
                </a>
            </div>
            <div class="table-responsive">
                <table class="table-striped table-bordered table-condensed" width="100%">
                    <thead>
                        <th> {{ 'name'|trans({}, 'platform') }} </th>
                        <th colspan="2"> {{ 'Actions'|trans({}, 'platform') }} </th>
                    </thead>
                    <tbody>
                        {% for role in roles %}
                            <tr>
                                <td> {{ role.getTranslationKey|trans({}, 'platform') }} </td>
                                <td>
                                    <a class="btn btn-default" href="{{ path('claro_workspace_role_edit_form', {'workspace': workspace.getId(), 'role': role.getId()}) }}" role="button">
                                        <i class="fa fa-pencil"></i> {{ 'edit'|trans({}, 'platform') }}
                                    </a>
                                </td>
                                <td>
                                    <a class="role-delete-btn btn btn-default {% if role.isReadOnly %} disabled {% endif %}" href="{{ path('claro_workspace_role_remove', {'workspace': workspace.getId(), 'role': role.getId()} ) }}">
                                        <i class="fa fa-trash-o"></i> {{ 'delete'|trans({}, 'platform') }}
                                    </a>
                                </td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>

{% endblock %}

{% block javascripts %}
    {{ parent() }}
    <script src="{{ asset('bundles/clarolinecore/js/tool/workspace/roles.js') }}" type="text/javascript"></script>
{% endblock %}
