mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 22:34:24 +00:00
layout of index page for customfieldsgroup
- add a "default" column (according to chill-project/custom-fields#3 ) - translation
This commit is contained in:
parent
7cf270cee4
commit
9d65ca5088
@ -4,7 +4,7 @@ namespace Chill\CustomFieldsBundle\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
|
||||
|
||||
/**
|
||||
@ -22,12 +22,64 @@ class CustomFieldsGroupController extends Controller
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$entities = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->findAll();
|
||||
$cfGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->findAll();
|
||||
$defaultGroups = $this->getDefaultGroupsId();
|
||||
|
||||
$makeDefaultFormViews = array();
|
||||
foreach ($cfGroups as $group) {
|
||||
if (!in_array($group->getId(), $defaultGroups)){
|
||||
$makeDefaultFormViews[$group->getId()] = $this->createMakeDefaultForm($group)->createView();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:index.html.twig', array(
|
||||
'entities' => $entities,
|
||||
'entities' => $cfGroups,
|
||||
'default_groups' => $defaultGroups,
|
||||
'make_default_forms' => $makeDefaultFormViews
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of CustomFieldsGroupId which are marked as default
|
||||
* for their entity
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
private function getDefaultGroupsId()
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$customFieldsGroupIds = $em->createQuery('SELECT g.id FROM '
|
||||
. 'ChillCustomFieldsBundle:CustomFieldsDefaultGroup d '
|
||||
. 'JOIN d.customFieldsGroup g')
|
||||
->getResult(Query::HYDRATE_SCALAR);
|
||||
|
||||
$result = array();
|
||||
foreach ($customFieldsGroupIds as $row) {
|
||||
$result[] = $row['id'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* create a form to make the group default
|
||||
*
|
||||
* @param CustomFieldsGroup $group
|
||||
* @return \Symfony\Component\Form\Form
|
||||
*/
|
||||
private function createMakeDefaultForm(CustomFieldsGroup $group)
|
||||
{
|
||||
return $this->createFormBuilder($group, array(
|
||||
'method' => 'POST',
|
||||
'action' => $this->generateUrl('customfieldsgroup_makedefault')
|
||||
))
|
||||
->add('id', 'hidden')
|
||||
->add('submit', 'submit', array('label' => 'Make default'))
|
||||
->getForm();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new CustomFieldsGroup entity.
|
||||
*
|
||||
|
@ -10,6 +10,10 @@ customfieldsgroup:
|
||||
customfieldsgroup_show:
|
||||
path: /{_locale}/admin/customfieldsgroup/{id}/show
|
||||
defaults: { _controller: "ChillCustomFieldsBundle:CustomFieldsGroup:show" }
|
||||
|
||||
customfieldsgroup_makedefault:
|
||||
path: /{_locale}/admin/customfieldsgroup/make_default
|
||||
defaults: { _controller: "ChillCustomFieldsBundle:CustomFieldsGroup:makeDefault" }
|
||||
|
||||
customfieldsgroup_new:
|
||||
path: /{_locale}/admin/customfieldsgroup/new
|
||||
|
@ -1,3 +1,14 @@
|
||||
'Not available in your language': 'Traduction pas disponible dans votre langue'
|
||||
'Other value': 'Autre valeur'
|
||||
'None': 'Pas spécifié'
|
||||
|
||||
Custom fields configuration: Configuration des champs personnalisés
|
||||
CustomFieldsGroup list: Groupes de champs personnalisés
|
||||
Entity: Entité
|
||||
"Is default ?": "Par défaut ?"
|
||||
"Some module select default groups for some usage. Example: the default person group is shown under person page.": "Certains modules sélectionnent en priorité les formulaires par défaut. Exemple: le formulaire par défaut pour une personne est affiché sur la page principale pour la personne"
|
||||
Make default: Assigner comme formulaire par défaut
|
||||
Create a new group: Créer un nouveau groupe
|
||||
|
||||
CustomFields List: Liste des champs personnalisés
|
||||
CustomFields Groups: Groupe de champs personnalisés
|
||||
|
@ -17,30 +17,38 @@
|
||||
{% extends "ChillCustomFieldsBundle::Admin/layout.html.twig" %}
|
||||
|
||||
{% block admin_content %}
|
||||
<h1>CustomFieldsGroup list</h1>
|
||||
<h1>{{ 'CustomFieldsGroup list'|trans }}</h1>
|
||||
|
||||
<table class="records_list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Name</th>
|
||||
<th>Entity</th>
|
||||
<th>Actions</th>
|
||||
<th>{{ 'Name'|trans }}</th>
|
||||
<th>{{ 'Entity'|trans }}</th>
|
||||
<th>{{ 'Is default ?'|trans }} <i class="fa fa-info-circle" title="{{ 'Some module select default groups for some usage. Example: the default person group is shown under person page.'|trans|escape('html_attr') }}"></i></th>
|
||||
<th>{{ 'Actions'|trans }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for entity in entities %}
|
||||
<tr>
|
||||
<td><a href="{{ path('customfieldsgroup_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
|
||||
<td>{{ entity.name['fr'] }}</td>
|
||||
<td>{{ entity.entity }}</td>
|
||||
<td><a href="{{ path('customfieldsgroup_show', { 'id': entity.id }) }}">{{ entity.name|localize_translatable_string }}</a></td>
|
||||
<td>{{ entity.entity|trans }}</td>
|
||||
<td style="text-align: center;">
|
||||
{%- if entity.id in default_groups -%}
|
||||
<i class="fa fa-star"></i>
|
||||
{%- else -%}
|
||||
{{ form_start(make_default_forms[entity.id]) }}
|
||||
{{ form_widget(make_default_forms[entity.id].submit, { 'attr' : { 'class' : 'sc-button bt-action' } } ) }}
|
||||
{{ form_end(make_default_forms[entity.id]) }}
|
||||
{%- endif -%}
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('customfieldsgroup_show', { 'id': entity.id }) }}">show</a>
|
||||
<a href="{{ path('customfieldsgroup_show', { 'id': entity.id }) }}">{{ 'show'|trans }}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('customfieldsgroup_edit', { 'id': entity.id }) }}">edit</a>
|
||||
<a href="{{ path('customfieldsgroup_edit', { 'id': entity.id }) }}">{{ 'edit'|trans }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
@ -52,7 +60,7 @@
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('customfieldsgroup_new') }}">
|
||||
Create a new entry
|
||||
{{ 'Create a new group'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
Loading…
x
Reference in New Issue
Block a user