admin custom fields integration

This commit is contained in:
nobohan 2022-05-10 14:36:10 +02:00
parent cb1bbe940f
commit fde1d563c2
16 changed files with 78 additions and 63 deletions

View File

@ -59,6 +59,6 @@ final class AdminMenuBuilder implements LocalMenuBuilderInterface
public static function getMenuIds(): array public static function getMenuIds(): array
{ {
return ['admin_index', 'admin_section', 'admin_activity']; return ['admin_section', 'admin_activity'];
} }
} }

View File

@ -34,6 +34,7 @@ class ChillCustomFieldsExtension extends Extension implements PrependExtensionIn
$loader->load('services/fixtures.yaml'); $loader->load('services/fixtures.yaml');
$loader->load('services/controller.yaml'); $loader->load('services/controller.yaml');
$loader->load('services/command.yaml'); $loader->load('services/command.yaml');
$loader->load('services/menu.yaml');
//add at least a blank array at 'customizable_entities' options //add at least a blank array at 'customizable_entities' options
//$customizable_entities = (isset($config['customizables_entities']) //$customizable_entities = (isset($config['customizables_entities'])

View File

@ -0,0 +1,55 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\CustomFieldsBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
class AdminMenuBuilder implements LocalMenuBuilderInterface
{
/**
* @var AuthorizationCheckerInterface
*/
protected $authorizationChecker;
public function __construct(AuthorizationCheckerInterface $authorizationChecker)
{
$this->authorizationChecker = $authorizationChecker;
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
if (!$this->authorizationChecker->isGranted('ROLE_ADMIN')) {
return;
}
$menu->addChild('Custom fields', [
'route' => 'customfield_section',
])
->setAttribute('class', 'list-group-item-header')
->setExtras(['order' => 4500]);
$menu->addChild('Custom fields group', [
'route' => 'customfield_section',
])->setExtras(['order' => 4510]);
$menu->addChild('Custom fields group', [
'route' => 'customfieldsgroup',
])->setExtras(['order' => 4520]);
}
public static function getMenuIds(): array
{
return ['admin_section', 'admin_custom_fields'];
}
}

View File

@ -1,26 +1,8 @@
{#
* 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/>.
#}
{% extends "@ChillMain/Admin/layoutWithVerticalMenu.html.twig" %} {% extends "@ChillMain/Admin/layoutWithVerticalMenu.html.twig" %}
{% block vertical_menu_content %} {% block vertical_menu_content %}
{{ chill_menu('admin_custom_fields', { {{ chill_menu('admin_custom_fields', {
'layout': '@ChillCustomFields/Admin/menu.html.twig', 'layout': '@ChillMain/Admin/menu_admin_section.html.twig',
}) }} }) }}
{% endblock %} {% endblock %}

View File

@ -1,20 +0,0 @@
{#
* 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/>.
#}
{% extends "@ChillMain/Menu/verticalMenu.html.twig" %}
{% block v_menu_title %}{{ 'Custom fields configuration menu'|trans }}{% endblock %}

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
#} #}
{% extends "@ChillCustomFields/Admin/layout.html.twig" %} {% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %}
{% block title %}{{ 'CustomField edit'|trans }}{% endblock title %} {% block title %}{{ 'CustomField edit'|trans }}{% endblock title %}

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
#} #}
{% extends "@ChillCustomFields/Admin/layout.html.twig" %} {% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %}
{% block title %}{{ 'CustomField creation'|trans }}{% endblock title %} {% block title %}{{ 'CustomField creation'|trans }}{% endblock title %}

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
#} #}
{% extends "@ChillCustomFields/Admin/layout.html.twig" %} {% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %}
{% block admin_content %} {% block admin_content %}
<h1>CustomField</h1> <h1>CustomField</h1>

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
#} #}
{% extends "@ChillCustomFields/Admin/layout.html.twig" %} {% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %}
{% block title %}{{ 'CustomFieldsGroup edit'|trans }}{% endblock %} {% block title %}{{ 'CustomFieldsGroup edit'|trans }}{% endblock %}

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
#} #}
{% extends "@ChillCustomFields/Admin/layout.html.twig" %} {% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %}
{% block title %}{{ 'CustomFieldsGroup list'|trans }}{% endblock %} {% block title %}{{ 'CustomFieldsGroup list'|trans }}{% endblock %}

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
#} #}
{% extends "@ChillCustomFields/Admin/layout.html.twig" %} {% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %}
{% block admin_content %} {% block admin_content %}
<h1>{{ 'CustomFieldsGroup creation'|trans }}</h1> <h1>{{ 'CustomFieldsGroup creation'|trans }}</h1>

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
#} #}
{% extends "@ChillCustomFields/Admin/layout.html.twig" %} {% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %}
{% block title %}{{ 'CustomFieldsGroup details'|trans }}{% endblock %} {% block title %}{{ 'CustomFieldsGroup details'|trans }}{% endblock %}

View File

@ -1,12 +1,6 @@
customfield_section: customfield_section:
path: /{_locale}/admin/customfield/ path: /{_locale}/admin/customfield/
defaults: { _controller: "ChillCustomFieldsBundle:Admin:index" } defaults: { _controller: "ChillCustomFieldsBundle:Admin:index" }
options:
menus:
admin_section:
order: 1000
label: "Custom fields configuration"
icons: ['asterisk']
customfield_new: customfield_new:
path: /{_locale}/admin/customfield/new path: /{_locale}/admin/customfield/new

View File

@ -1,11 +1,6 @@
customfieldsgroup: customfieldsgroup:
path: /{_locale}/admin/customfieldsgroup/ path: /{_locale}/admin/customfieldsgroup/
defaults: { _controller: "ChillCustomFieldsBundle:CustomFieldsGroup:index" } defaults: { _controller: "ChillCustomFieldsBundle:CustomFieldsGroup:index" }
options:
menus:
admin_custom_fields:
order: 1010
label: "CustomFields Groups"
customfieldsgroup_show: customfieldsgroup_show:
path: /{_locale}/admin/customfieldsgroup/{id}/show path: /{_locale}/admin/customfieldsgroup/{id}/show

View File

@ -0,0 +1,7 @@
services:
Chill\CustomFieldsBundle\Menu\:
autowire: true
autoconfigure: true
resource: '../../Menu/'
tags: ['chill.menu_builder']

View File

@ -37,16 +37,17 @@ CustomFields List: Liste des champs personnalisés
CustomFields Groups: Groupe de champs personnalisés CustomFields Groups: Groupe de champs personnalisés
#customfield administration #customfield administration
Custom fields: Champs personnalisés
CustomField edit: Modification d'un champ personnalisé CustomField edit: Modification d'un champ personnalisé
CustomField creation: Nouveau champ personnalisé CustomField creation: Nouveau champ personnalisé
General informations: Informations générales General informations: Informations générales
Options: Options Options: Options
Custom fields group: Groupe de champ personnalisé Custom fields group: Groupe de champs personnalisés
Ordering: Ordre d'apparition Ordering: Ordre d'apparition
Required field: Champs requis Required field: Champs requis
An answer is required: Une réponse est requise An answer is required: Une réponse est requise
Any answer is required: Aucune réponse n'est requise Any answer is required: Aucune réponse n'est requise
Back to the group: Retour au groupe de champs personnalisé Back to the group: Retour au groupe de champs personnalisés
Slug: Identifiant textuel Slug: Identifiant textuel
The custom field has been created: Le champ personnalisé est créé The custom field has been created: Le champ personnalisé est créé
The custom field form contains errors: Le formulaire contient des erreurs The custom field form contains errors: Le formulaire contient des erreurs