@@ -41,6 +41,7 @@ use Lc\SovBundle\Definition\ActionDefinition; | |||
use Lc\SovBundle\Doctrine\Extension\DevAliasInterface; | |||
use Lc\SovBundle\Doctrine\Extension\SeoInterface; | |||
use Lc\SovBundle\Doctrine\Extension\SortableInterface; | |||
use Lc\SovBundle\Doctrine\Extension\StatusInterface; | |||
use Lc\SovBundle\Doctrine\Extension\TranslatableInterface; | |||
use Lc\SovBundle\Doctrine\Extension\TreeInterface; | |||
use Lc\SovBundle\Field\CollectionField; | |||
@@ -78,16 +79,9 @@ abstract class AbstractAdminController extends EaAbstractCrudController | |||
if (Crud::PAGE_INDEX === $responseParameters->get('pageName')) { | |||
$responseParameters->set('fields', $this->configureFields('index')); | |||
//TODO supprimer ce code rapport au filtre dans les index | |||
/*if ($this->filtersForm === null) { | |||
die('nncncd'); | |||
$options['fields'] = $responseParameters->get('fields'); | |||
$options['entity_class'] = $this->getEntityFqcn(); | |||
$options['entity_name'] = $responseParameters->get('entity')->getName(); | |||
$this->filtersForm = $this->createForm(FiltersFormType::class, null, $options); | |||
}*/ | |||
$responseParameters->set('filters_form', $this->filtersForm); | |||
if(isset($this->filtersForm)) { | |||
$responseParameters->set('filters_form', $this->filtersForm); | |||
} | |||
} | |||
$responseParameters->set('translation_entity_name', $this->getTranslationEntityName()); | |||
@@ -142,11 +136,18 @@ abstract class AbstractAdminController extends EaAbstractCrudController | |||
} | |||
} | |||
protected function getRequestCrudAction() :string{ | |||
return $this->getRequestStack()->getCurrentRequest()->get('crudAction'); | |||
} | |||
public function configureCrud(Crud $crud): Crud | |||
{ | |||
$crud = parent::configureCrud($crud); | |||
$this->setMaxResults($crud); | |||
if($this->getRequestCrudAction() === ActionDefinition::SORT) { | |||
$crud->setPaginatorPageSize(9999); | |||
}else { | |||
$this->setMaxResults($crud); | |||
} | |||
$crud->setFormOptions(['translation_entity_name' => $this->getTranslationEntityName()]); | |||
@@ -228,7 +229,8 @@ abstract class AbstractAdminController extends EaAbstractCrudController | |||
$fields, | |||
$context->getEntity() | |||
); | |||
$queryBuilder = $this->createIndexQueryBuilder($context->getSearch(), $context->getEntity(), $fields, $filters); | |||
$queryBuilder = $this->createSortQueryBuilder($context->getSearch(), $context->getEntity(), $fields, $filters); | |||
$paginator = $this->get(PaginatorFactory::class)->create($queryBuilder); | |||
$entities = $this->get(EntityFactory::class)->createCollection($context->getEntity(), $paginator->getResults()); | |||
@@ -362,6 +364,9 @@ abstract class AbstractAdminController extends EaAbstractCrudController | |||
$repositoryQuery->filterIsParent(); | |||
} | |||
} | |||
if ($this->isInstanceOf(StatusInterface::class)) { | |||
$repositoryQuery->filterIsOnlineAndOffline(); | |||
} | |||
$this->filtersForm = $this->createForm( | |||
FiltersFormType::class, | |||
@@ -382,6 +387,15 @@ abstract class AbstractAdminController extends EaAbstractCrudController | |||
return $repositoryQuery; | |||
} | |||
public function createSortRepositoryQuery( | |||
SearchDto $searchDto, | |||
EntityDto $entityDto, | |||
FieldCollection $fields, | |||
FilterCollection $filters | |||
): RepositoryQueryInterface { | |||
return $this->createIndexRepositoryQuery($searchDto,$entityDto, $fields, $filters); | |||
} | |||
public function createIndexQueryBuilder( | |||
SearchDto $searchDto, | |||
EntityDto $entityDto, | |||
@@ -398,9 +412,8 @@ abstract class AbstractAdminController extends EaAbstractCrudController | |||
FieldCollection $fields, | |||
FilterCollection $filters | |||
): QueryBuilder { | |||
$queryBuilder = $this->createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters); | |||
return $queryBuilder; | |||
$repositoryQuery = $this->createSortRepositoryQuery($searchDto, $entityDto, $fields, $filters); | |||
return $repositoryQuery->getQueryBuilder(); | |||
} | |||
public function edit(AdminContext $context) |
@@ -3,6 +3,7 @@ | |||
namespace Lc\SovBundle\Definition\Field; | |||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; | |||
@@ -46,6 +47,8 @@ abstract class AbstractFieldDefinition | |||
->hideOnIndex(), | |||
'devAlias' => TextField::new('devAlias')->hideOnIndex(), | |||
'status' => StatusField::new('status')->setSortable(true), | |||
'createdAt' => DateTimeField::new('createdAt')->setSortable(true), | |||
'updatedAt' => DateTimeField::new('updatedAt')->setSortable(true), | |||
]; | |||
} | |||
@@ -174,10 +177,22 @@ abstract class AbstractFieldDefinition | |||
throw new \Exception($method . ' n\'existe pas '); | |||
} | |||
$fieldPanel = FormField::addPanel($panel); | |||
$method = 'panel'.ucfirst($panel).'CustomOptions'; | |||
if(method_exists($this, $method)) { | |||
foreach ($this->$method() as $customOptionKey => $customOptionValue){ | |||
$fieldPanel->setCustomOption($customOptionKey, $customOptionValue); | |||
} | |||
} | |||
return array_merge( | |||
['panel_' . $panel => FormField::addPanel($panel)], | |||
[ | |||
'panel_' . $panel => $fieldPanel | |||
], | |||
$this->buildFieldArray($panelFieldArray) | |||
); | |||
} | |||
} | |||
} |
@@ -72,7 +72,9 @@ class UserFieldDefinition extends AbstractFieldDefinition | |||
'firstname' => TextField::new('firstname')->setSortable(true), | |||
'email' => TextField::new('email')->setSortable(true), | |||
'phone' => TextField::new('phone')->setSortable(true), | |||
'birthdate' => DateField::new('birthdate')->setSortable(true), | |||
'birthdate' => DateField::new('birthdate') | |||
->setFormTypeOption('required', false) | |||
->setSortable(true), | |||
'groupUsers' => AssociationField::new('groupUsers')->setSortable(true), | |||
'ticketTypesNotification' => ChoiceField::new('ticketTypesNotification') | |||
->setSortable(true) |
@@ -19,7 +19,7 @@ final class BooleanField implements FieldInterface | |||
return (new self()) | |||
->setProperty($propertyName) | |||
->setLabel($label) | |||
->setTemplatePath('@LcSov/adminlte/crud/field/boolean.html.twig') | |||
->setTemplatePath('@LcSov/adminlte/crud/field/toggle.html.twig') | |||
->setFormType(CheckboxType::class); | |||
} | |||
@@ -134,7 +134,7 @@ abstract class UserModel implements EntityInterface, UserInterface, DevAliasInte | |||
return $this->birthdate; | |||
} | |||
public function setBirthdate(\DateTimeInterface $birthdate): self | |||
public function setBirthdate(?\DateTimeInterface $birthdate): self | |||
{ | |||
$this->birthdate = $birthdate; | |||
@@ -11,4 +11,17 @@ class GroupUserRepositoryQuery extends AbstractRepositoryQuery implements GroupU | |||
{ | |||
parent::__construct($repository, 'r', $paginator); | |||
} | |||
protected $isJoinUsers = false; | |||
public function joinUsers(): self | |||
{ | |||
if (!$this->isJoinUsers) { | |||
$this->isJoinUsers = true; | |||
return $this | |||
->innerJoin('.users', 'user'); | |||
} | |||
return $this; | |||
} | |||
} |
@@ -27,6 +27,7 @@ class GroupUserStore extends AbstractStore implements GroupUserStoreInterface | |||
public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | |||
{ | |||
$query->joinUsers(); | |||
return $query; | |||
} | |||
} |
@@ -14,6 +14,22 @@ class UserRepositoryQuery extends AbstractRepositoryQuery implements UserReposit | |||
parent::__construct($repository, 'r', $paginator); | |||
} | |||
protected $isJoinGroupUsers = false; | |||
public function joinGroupUsers($addSelect = true): self | |||
{ | |||
if (!$this->isJoinGroupUsers) { | |||
$this->isJoinGroupUsers = true; | |||
$this->innerJoin('.groupUsers', 'groupUser'); | |||
if($addSelect){ | |||
$this->addSelect('groupUser'); | |||
} | |||
} | |||
return $this; | |||
} | |||
public function filterByNewsletter(Newsletter $newsletter): self | |||
{ | |||
return $this |
@@ -26,3 +26,13 @@ table.table { | |||
white-space: normal; | |||
} | |||
} | |||
table.fixedHeader-floating{margin-top: 0px !important;} | |||
table th.sorting_asc, table th.sorting_desc{border-top:2px solid var(--success);} | |||
.card-body table th.filtered{border-top:2px solid var(--primary);} | |||
/*.card-body table.lc-table-list th{border-top:3px solid var(--success);}*/ | |||
table th.filtered{border-top:2px solid var(--primary);} | |||
.card-body table th.sorted, table th.sorting_asc, table th.sorting_desc{border-top:2px solid var(--success);} | |||
.card-body table th.sorted.filtered{border-top:0px; position: relative;} | |||
.card-body table th.sorted.filtered:after{ content: ''; height: 2px; position: absolute; left: 0; width: 100%; right: 0; top: -1px; background: linear-gradient(to right, var(--success) 0%, var(--success) 50%, var(--primary) 50%, var(--primary) 100%);} |
@@ -20,8 +20,7 @@ function initSovSortableList() { | |||
// Replace '__name__' in the prototype's HTML to | |||
$(li).find('div:last-child').remove(); | |||
$(li).append(newForm); | |||
$(li).find('td:first').append('<div class="hidden">'+newForm+'</div>'); | |||
$(li).find('#form_entities_' + index + '_id').val($(li).data('id')); | |||
/* if ($('.sov-sortable').data('parent-position') !== '') { | |||
//Ajout d'un 0 initial pour les nuémros <10 |
@@ -0,0 +1,12 @@ | |||
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | |||
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #} | |||
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} | |||
{% if 'toMany' == field.customOptions.get('associationType') %} | |||
<span class="badge badge-secondary">{{ field.formattedValue }}</span> | |||
{% else %} | |||
{% if field.customOption('crudControllerFqcn') is not null and field.value is not null%} | |||
<a href="{{ ea_url_short(field.customOption('crudControllerFqcn'), 'edit', field.value.id) }}">{{ field.formattedValue }}</a> | |||
{% else %} | |||
{{ field.formattedValue }} | |||
{% endif %} | |||
{% endif %} |
@@ -3,13 +3,10 @@ | |||
{% set id_toggle = 'toggle-'~item.id~'-'~property_name %} | |||
{% block toggle %} | |||
<div class="custom-control custom-switch custom-switch-on-success custom-switch-off-default" | |||
<div class="custom-control custom-switch custom-switch-on-success custom-switch-off-default" data-toggle="tooltip" title="{{ field.getCustomOption('toggle_label') ? field.label : field.property|sov_trans_admin_field(entity.instance) }}" | |||
data-url="{{ ea_url({crudAction: 'edit', entityId: item.id, fieldName: property_name }) }}"> | |||
<input type="checkbox" class="custom-control-input" id="{{ id_toggle }}" {{ field.value ? 'checked' }}> | |||
<label class="custom-control-label" for="{{ id_toggle }}"> | |||
{% block label %} | |||
{{ field.getCustomOption('toggle_label') ? field.label : field.property|sov_trans_admin_field(entity.instance) }} | |||
{% endblock label %} | |||
<input type="checkbox" class="custom-control-input" id="{{ id_toggle }}" {{ field.value ? 'checked' }}> | |||
<label class="custom-control-label" for="{{ id_toggle }}" > | |||
</label> | |||
</div> | |||
{% endblock toggle %} |
@@ -342,11 +342,17 @@ | |||
{% block class %}{{ loop.first ? 'active' }}{% endblock %} | |||
{% block id %}{{ panel_name }}{% endblock %} | |||
{% block content %} | |||
{% if panel_config['prepend_content_path'] is defined %} | |||
{% include panel_config['prepend_content_path'] %} | |||
{% endif %} | |||
{% for field in form|filter(field => 'hidden' not in field.vars.block_prefixes and field.vars.ea_crud_form.form_panel == panel_name) %} | |||
{% if not field.vars.ea_crud_form.form_tab or field.vars.ea_crud_form.form_tab == tab_name %} | |||
{{ form_row(field) }} | |||
{% endif %} | |||
{% endfor %} | |||
{% if panel_config['append_content_path'] is defined %} | |||
{% include panel_config['append_content_path'] %} | |||
{% endif %} | |||
{% endblock %} | |||
{% endembed %} | |||
{% else %} |
@@ -66,7 +66,7 @@ | |||
{% endblock %} | |||
{% block card_body_wrapper %} | |||
<div class="card-body"> | |||
<div class="table-responsive"> | |||
<div class=""> | |||
<table class="table table-bordered table-hover table-striped"> | |||
<thead> | |||
{% block table_head %} |
@@ -60,7 +60,13 @@ | |||
{% set is_sorting_field = ea.search.isSortingField(field.property) %} | |||
<th class="{{ is_sorting_field ? 'sorted' }} {{ field.isVirtual ? 'field-virtual' }} {% if field.textAlign %}text-{{ field.textAlign }}{% endif %}" | |||
dir="{{ ea.i18n.textDirection }}"> | |||
<span>{{ field.label ? field.label|raw : field.getProperty|raw }}</span> | |||
<span> | |||
{% if field.label is not null %} | |||
{{ field.label|raw }} | |||
{% else %} | |||
{{ field.getProperty|sov_trans_admin_field_index(translation_entity_name) }} | |||
{% endif %} | |||
</span> | |||
</th> | |||
{% endif %} | |||
{% endfor %} |