Merge branch 'admin-for-users' into 'master'

improve admin for users

See merge request Chill-Projet/chill-bundles!150
This commit is contained in:
2021-09-24 10:35:09 +00:00
34 changed files with 484 additions and 702 deletions

View File

@@ -0,0 +1,8 @@
{% extends '@ChillMain/Admin/layout_permissions.html.twig' %}
{% block title %}{{ ('crud.' ~ crud_name ~ '.index.title')|trans({'%crud_name%': crud_name}) }}{% endblock %}
{% block content %}
{% embed '@ChillMain/CRUD/_index.html.twig' %}
{% endembed %}
{% endblock content %}

View File

@@ -1,17 +1,15 @@
{% extends "@ChillMain/Admin/layoutWithVerticalMenu.html.twig" %}
{% block vertical_menu_content %}
{% endblock %}
{% block admin_content %}
<h1>{{ 'Administration interface'|trans }}</h1>
{{ 'welcome_message_raw'|trans|raw }}
<div>
<h2>{{ 'Configuration alerts'|trans }}</h2>
<p>{{ 'Here you can check the configuration of your instance.'|trans }}</p>
{{ chill_widget('configuration_warnings', {}) }}
</div>
{% endblock %}
<p>{{ 'Welcome to the admin section !'|trans }}</p>
{{ chill_menu('admin_index', {
'layout': '@ChillMain/Admin/menu_admin_index.html.twig'
}) }}
{% endblock %}

View File

@@ -1,26 +1,3 @@
{#
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
<info@champs-libres.coop> / <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
{#
The layout of the admin section. All the page / template of the admin section must use this
layout.
#}
{% extends "@ChillMain/layout.html.twig" %}
{% block navigation_search_bar %}{% endblock %}
@@ -38,4 +15,4 @@
</div>
</div>
{% endblock %}
{% endblock %}
{% endblock %}

View File

@@ -1,37 +1,14 @@
{#
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
<info@champs-libres.coop> / <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
{#
The layout of the admin section. All the page / template of the admin section must use this
layout.
#}
{% extends "@ChillMain/layoutWithVerticalMenu.html.twig" %}
{% block navigation_search_bar %}{% endblock %}
{% block navigation_section_menu %}
{{ chill_menu('admin_section', {
'layout': '@ChillMain/Menu/adminSection.html.twig',
'layout': '@ChillMain/Admin/menu_admin_section.html.twig',
}) }}
{% endblock %}
{% block layout_wvm_content %}
{% block admin_content %}<!-- block personcontent empty -->
<h2>{{ 'Welcome to the admin section !'|trans }}</h2>
{% block admin_content %}
<!-- block admin content emty -->
{% endblock %}
{% endblock %}
{% endblock %}

View File

@@ -1,5 +1,5 @@
{#
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
<info@champs-libres.coop> / <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
@@ -20,7 +20,7 @@
{% block vertical_menu_content %}
{{ chill_menu('admin_permissions', {
'layout': '@ChillMain/Menu/admin_permissions.html.twig',
'layout': '@ChillMain/Admin/menu_admin_permissions.html.twig',
}) }}
{% endblock %}
@@ -28,4 +28,4 @@
{% block admin_content %}<!-- block personcontent empty -->
<h1>{{ 'Permissions management of your chill installation' |trans }}</h1>
{% endblock %}
{% endblock %}
{% endblock %}

View File

@@ -0,0 +1,18 @@
<div class="{{ 'menu-' ~ menus.name }}">
<ul>
{% for menu in menus %}
<li>
<a class=""
href="{{ menu.uri }}">
<h3>{{ menu.label|trans }}</h3>
{% if menu.extras.explain is defined %}
<div class="" >
{{ menu.extras.explain|trans }}
</div>
{% endif %}
</a>
</li>
{% endfor %}
</ul>
</div>

View File

@@ -1,17 +1,22 @@
{% set formId = crudMainFormId|default('crud_main_form') %}
<div class="{% block crud_content_main_div_class %}{% endblock %}">
{% block crud_content_header %}
<h1>{{ ('crud.'~crud_name~'.title_edit')|trans }}</h1>
{% endblock crud_content_header %}
{% block crud_content_form %}
{{ form_start(form) }}
{{ form_start(form, { 'attr' : { 'id': formId } } ) }}
{% block crud_content_form_rows %}
{% for f in form %}
{{ form_row(f) }}
{% endfor %}
{% endblock crud_content_form_rows %}
{{ form_end(form) }}
{% block crud_content_after_form %}{% endblock %}
{% block crud_content_form_actions %}
<ul class="record_actions sticky-form-buttons">
{% block content_form_actions_back %}
@@ -30,7 +35,7 @@
</li>
{% endif %}
{% endif %}
{% endblock content_form_actions_delete %}
{% endblock content_form_actions_delete %}
{% block content_form_actions_view %}
{% if chill_crud_action_exists(crud_name, 'view') %}
{% if is_granted(chill_crud_config('role', crud_name, 'view'), entity) %}
@@ -39,17 +44,17 @@
</li>
{% endif %}
{% endif %}
{% endblock content_form_actions_view %}
{% endblock content_form_actions_view %}
{% block content_form_actions_save_and_close %}
<li class="">
<button type="submit" name="submit" value="save-and-close" class="btn btn-update">
<button type="submit" name="submit" value="save-and-close" class="btn btn-update" form="{{ formId }}">
{{ 'crud.edit.save_and_close'|trans }}
</button>
</li>
{% endblock %}
{% block content_form_actions_save_and_show %}
<li class="">
<button type="submit" name="submit" value="save-and-show" class="btn btn-update">
<button type="submit" name="submit" value="save-and-show" class="btn btn-update" form="{{ formId }}">
{{ 'crud.edit.save_and_show'|trans }}
</button>
</li>
@@ -58,6 +63,5 @@
</ul>
{% endblock %}
{{ form_end(form) }}
{% endblock %}
</div>

View File

@@ -5,14 +5,16 @@
{% block crud_content_form %}
{{ form_start(form) }}
{% block crud_content_form_rows %}
{% for f in form %}{% if f.vars.name != 'submit' %}
{{ form_row(f) }}
{% endif %}{% endfor %}
{% endblock crud_content_form_rows %}
{% block crud_content_form_actions %}
{% block crud_content_after_form %}{% endblock %}
{% block crud_content_form_actions %}
<ul class="record_actions sticky-form-buttons">
{% block content_form_actions_back %}
<li class="cancel">
@@ -20,7 +22,7 @@
{{ 'Cancel'|trans }}
</a>
</li>
{% endblock %}
{% endblock %}
{% block content_form_actions_save_and_close %}
<li class="">
<button type="submit" name="submit" value="save-and-close" class="btn btn-create">

View File

@@ -1,20 +1,3 @@
{#
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS,
* <info@champs-libres.coop> / <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
<header>
<nav class="navbar navbar-dark bg-primary navbar-expand-md">
<div class="container-xxl">
@@ -24,12 +7,12 @@
{{ include('@ChillMain/Layout/_header-logo.html.twig') }}
</a>
</div>
<div class="col-8">
<button class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
<button class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarContent"
aria-controls="navbarContent"
aria-expanded="false"
@@ -43,8 +26,8 @@
{% block navigation_search_bar %}
<li class="nav-item navigation-search">
<form class="form-inline" action="{{ path('chill_main_search') }}" method="get">
<input class="form-control"
name="q" type="search" placeholder="{{ 'Search'|trans }}"
<input class="form-control"
name="q" type="search" placeholder="{{ 'Search'|trans }}"
{% if _search_pattern is defined %}value="{{ _search_pattern }}"{% endif %}/>
<button class="btn text-white-50" type="submit">
<i class="fa fa-lg fa-search fa-flip-horizontal"></i>
@@ -71,15 +54,15 @@
</li>
{% else %}
<li class="nav-item dropdown btn btn-primary nav-language">
<a id="menu-languages"
class="nav-link dropdown-toggle"
type="button"
data-bs-toggle="dropdown"
aria-haspopup="true"
<a id="menu-languages"
class="nav-link dropdown-toggle"
type="button"
data-bs-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
<a href="#" class="more">{{ app.request.locale | capitalize }}</a>
</a>
<div class="dropdown-menu dropdown-menu-end"
<div class="dropdown-menu dropdown-menu-end"
aria-labelledby="menu-languages">
{% for lang in available_languages %}
<a class="dropdown-item list-group-item bg-dark text-white{% if lang == app.request.locale %} active{% endif %}"
@@ -93,7 +76,7 @@
</ul>
</div>
</div>
</div>
</nav>

View File

@@ -1,5 +1,5 @@
{#
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
<info@champs-libres.coop> / <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
@@ -17,7 +17,7 @@
#}
{#
Layout for a vertical menu (like admin, export) to use with the
Layout for a vertical menu (like admin, export) to use with the
layout ../layoutWithVerticalMenu.html.twig.
#}
@@ -25,13 +25,9 @@
<li class="title">
{% block v_menu_title %}<!-- title of the verticalMenu is empty -->{% endblock %}
</li>
{% for route in routes %}
<li class="{% apply spaceless %}
{% if route.key == activeRouteKey %}
active
{% endif %}
{% endapply %} ">
<a href="{{ path(route.key, args ) }}" >{{ route.label|trans }}</a>
{% for menu in menus %}
<li class="{% if menu is knp_menu_current %}current {% endif %}">
<a href="{{ menu.uri }}" >{{ menu.label|trans }}</a>
</li>
{% endfor %}
</ul>
</ul>

View File

@@ -1,78 +1,56 @@
{% extends '@ChillMain/Admin/layout_permissions.html.twig' %}
{% block title %}{{ 'User edit'|trans }}{% endblock %}
{% extends '@ChillMain/Admin/Permission/layout_crud_permission_index.html.twig' %}
{% block admin_content -%}
<h1>{{ 'User edit'|trans }}</h1>
{% embed '@ChillMain/CRUD/_edit_content.html.twig' %}
{% block crud_content_after_form %}
<h2>{{ 'Permissions granted'|trans }}</h2>
{{ form_start(edit_form) }}
{{ form_row(edit_form.username) }}
{{ form_row(edit_form.email) }}
{{ form_row(edit_form.enabled, { 'label': "User'status"}) }}
{{ form_widget(edit_form.submit, { 'attr': { 'class' : 'btn btn-chill-green center' } } ) }}
<a href="{{ path('admin_user_edit_password', { 'id' : entity.id }) }}" class="btn btn-chill-orange">{{ 'Edit password'|trans }}</a>
{{ form_end(edit_form) }}
<h2>{{ 'Permissions granted'|trans }}</h2>
{% if entity.groupcenters|length > 0 %}
<table>
<thead>
<tr>
<th>{{ 'Permission group'|trans }}</th>
<th>{{ 'Center'|trans }}</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{% for groupcenter in entity.groupcenters %}
<tr>
<td>
{% if entity.groupcenters|length > 0 %}
<table>
<thead>
<tr>
<th>{{ 'Permission group'|trans }}</th>
<th>{{ 'Center'|trans }}</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{% for groupcenter in entity.groupcenters %}
<tr>
<td>
<span class="user_group permissionsgroup">
{{ groupcenter.permissionsgroup.name }}
</span>
</td>
<td>
</td>
<td>
<span class="user_group center">
{{ groupcenter.center.name }}
</span>
</td>
<td>
{{ form_start(delete_groupcenter_form[groupcenter.id]) }}
{{ form_row(delete_groupcenter_form[groupcenter.id].submit, { 'attr': { 'class': 'btn btn-chill-red' } } ) }}
{{ form_rest(delete_groupcenter_form[groupcenter.id]) }}
{{ form_end(delete_groupcenter_form[groupcenter.id]) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>{{ 'Any permissions granted to this user'|trans }}.</p>
{% endif %}
<h3>{{ 'Grant new permissions'|trans }}</h3>
{{ form_start(add_groupcenter_form) }}
{{ form_row(add_groupcenter_form.composed_groupcenter.center) }}
{{ form_row(add_groupcenter_form.composed_groupcenter.permissionsgroup) }}
{{ form_row(add_groupcenter_form.submit, { 'attr' : { 'class': 'btn btn-chill-green' } } ) }}
</td>
<td>
{{ form_start(delete_groupcenter_form[groupcenter.id]) }}
{{ form_row(delete_groupcenter_form[groupcenter.id].submit, { 'attr': { 'class': 'btn btn-chill-red' } } ) }}
{{ form_rest(delete_groupcenter_form[groupcenter.id]) }}
{{ form_end(delete_groupcenter_form[groupcenter.id]) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>{{ 'Any permissions granted to this user'|trans }}.</p>
{% endif %}
{{ form_end(add_groupcenter_form) }}
<ul class="record_actions">
<li>
<a href="{{ path('admin_user_show', { 'id': entity.id }) }}">
{{ 'show'|trans }}
</a>
</li>
<li>
<a href="{{ path('admin_user') }}">
{{ 'Back to the list'|trans }}
</a>
</li>
</ul>
<h3>{{ 'Grant new permissions'|trans }}</h3>
{{ form_start(add_groupcenter_form) }}
{{ form_row(add_groupcenter_form.composed_groupcenter.center) }}
{{ form_row(add_groupcenter_form.composed_groupcenter.permissionsgroup) }}
{{ form_row(add_groupcenter_form.submit, { 'attr' : { 'class': 'btn btn-chill-green' } } ) }}
{{ form_end(add_groupcenter_form) }}
{% endblock %}
{% block content_form_actions_save_and_show %}{% endblock %}
{% endembed %}
{% endblock %}

View File

@@ -1,4 +1,4 @@
{% extends '@ChillMain/Admin/layout_permissions.html.twig' %}
{% extends '@ChillMain/Admin/Permission/layout_crud_permission_index.html.twig' %}
{% block title %}{{ 'Edit password for %username%'|trans( { '%username%': entity.username } ) }}{% endblock %}
@@ -7,19 +7,17 @@
{{ form_start(edit_form) }}
{{ form_row(edit_form.new_password) }}
{{ form_widget(edit_form.submit, { 'attr': { 'class': 'btn btn-chill-orange' } } ) }}
<ul class="record_actions">
<li class="cancel">
<a href="{{ chill_return_path_or('chill_crud_admin_user_index') }}" class="btn btn-cancel">
{{ 'Cancel'|trans }}
</a>
</li>
<li>
{{ form_widget(edit_form.submit, { 'attr': { 'class': 'btn btn-edit' } } ) }}
</li>
</ul>
{{ form_end(edit_form) }}
<ul class="record_actions">
<li>
<a href="{{ path('admin_user') }}">
{{ 'Back to the list'|trans }}
</a>
</li>
<li>
<a href="{{ path('admin_user_edit', { 'id' : entity.id }) }}">
{{ 'Back to the user edition'|trans }}
</a>
</li>
</ul>
{% endblock %}

View File

@@ -1,53 +1,60 @@
{% extends '@ChillMain/Admin/layout_permissions.html.twig' %}
{% block title %}{{ 'user list'|trans|capitalize }}{% endblock %}
{% extends '@ChillMain/Admin/Permission/layout_crud_permission_index.html.twig' %}
{% block admin_content -%}
<h1>{{ 'user list'|trans|capitalize }}</h1>
<table class="records_list">
<thead>
{% embed '@ChillMain/CRUD/_index.html.twig' %}
{% block table_entities_thead_tr %}
<th>{{ 'crud.admin_user.index.is_active'|trans }}</th>
<th>{{ 'crud.admin_user.index.usernames'|trans }}</th>
<th>{{ 'crud.admin_user.index.mains'|trans }}</th>
<th>&nbsp;</th>
{% endblock %}
{% block table_entities_tbody %}
{% for entity in entities %}
<tr>
<th>{{ 'Username'|trans|capitalize }}</th>
<th>{{ 'Actions'|trans|capitalize }}</th>
</tr>
</thead>
<tbody>
{% for entity in entities %}
<tr class="{% if entity.isEnabled == false %}user-disabled{% else %}user-enabled{% endif %}" >
<td><a href="{{ path('admin_user_show', { 'id': entity.id }) }}">{{ entity.username }}</a></td>
<td>
<ul>
<li>
<a href="{{ path('admin_user_show', { 'id': entity.id }) }}">{{ 'show'|trans }}</a>
</li>
<li>
<a href="{{ path('admin_user_edit', { 'id': entity.id }) }}">{{ 'edit'|trans }}</a>
</li>
<li>
<a href="{{ path('admin_user_edit_password', { 'id' : entity.id }) }}">{{ 'Edit password'|trans }}</a>
</li>
{% if is_granted('ROLE_ALLOWED_TO_SWITCH') %}
<li>
<a href="{{ path('chill_main_homepage', {'_switch_user': entity.username }) }}">
{{ 'Impersonate'|trans }}
</a>
</li>
{% if entity.isEnabled %}
<i class="fa fa-check chill-green"></i>
{% else %}
<i class="fa fa-times chill-red"></i>
{% endif %}
</ul>
</td>
<td>
{{ entity.username }}
<br/>
{{ entity.label }}
<br/>
{{ entity.email }}
</td>
<td>
{% if entity.userJob %}
{{ entity.userJob.label|localize_translatable_string }}
<br/>
{% endif %}
{% if entity.mainScope %}
{{ entity.mainScope.name|localize_translatable_string }}
<br/>
{% endif %}
{% if entity.mainCenter %}
{{ entity.mainCenter.name }}
{% endif %}
</td>
<td>
<ul class="record_actions">
<li>
<a class="btn btn-edit" href="{{ path('chill_crud_admin_user_edit', { 'id': entity.id }) }}"></a>
</li>
<li>
<a class="btn btn-chill-red" href="{{ path('admin_user_edit_password', { 'id' : entity.id }) }}" title="{{ 'Edit password'|trans|e('html_attr') }}"><i class="fa fa-ellipsis-h"></i></a>
</li>
{% if is_granted('ROLE_ALLOWED_TO_SWITCH') %}
<li>
<a class="btn btn-chill-blue" href="{{ path('chill_main_homepage', {'_switch_user': entity.username }) }}" title="{{ "Impersonate"|trans|e('html_attr') }}"><i class="fa fa-user-secret"></i></a>
</li>
{% endif %}
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul>
<li>
<a href="{{ path('admin_user_new') }}">
{{ 'Add a new user'|trans|capitalize }}
</a>
</li>
</ul>
{% endblock admin_content %}
{% endfor %}
{% endblock %}
{% endembed %}
{% endblock %}

View File

@@ -1,22 +1,7 @@
{% extends '@ChillMain/Admin/layout_permissions.html.twig' %}
{% block title %}{{ 'User creation'|trans }}{% endblock %}
{% extends '@ChillMain/Admin/Permission/layout_crud_permission_index.html.twig' %}
{% block admin_content -%}
<h1>{{ 'User creation'|trans }}</h1>
{{ form_start(form) }}
{{ form_row(form.username) }}
{{ form_row(form.email) }}
{{ form_row(form.plainPassword) }}
{{ form_widget(form.submit, { 'attr' : { 'class': 'btn btn-chill-blue' } }) }}
{{ form_end(form) }}
<ul class="record_actions">
<li>
<a href="{{ path('admin_user') }}">
{{ 'Back to the list'|trans }}
</a>
</li>
</ul>
{% embed '@ChillMain/CRUD/_new_content.html.twig' %}
{% block content_form_actions_save_and_show %}{% endblock %}
{% endembed %}
{% endblock %}

View File

@@ -1,25 +1,3 @@
{#
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS,
<info@champs-libres.coop> / <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
{#
The basic layout of Chill. All the page / template of Chill must use this template.
#}
<!DOCTYPE html>
<html lang="fr">
<head>

View File

@@ -1,26 +1,3 @@
{#
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS,
<info@champs-libres.coop> / <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
{#
Layout with a vertical menu and a conainer for the content (like admin, export)
( for the vertical menu you can extends Menu/veticalMenu.html.twig ).
#}
{% extends "@ChillMain/layout.html.twig" %}
{% block sublayout_content %}