update crud of categories

This commit is contained in:
Simon Vieille 2022-02-03 23:55:46 +01:00
parent 6afdb366ac
commit ce25a107f4
2 changed files with 19 additions and 0 deletions

View file

@ -62,6 +62,18 @@ class CategoryAdminController extends CrudController
'button_attr' => ['class' => 'btn btn-sm btn-light'],
'raw' => true,
])
->setField('index', 'Status', ButtonField::class, [
'sort' => ['isActive', '.isActive'],
'attr' => ['class' => 'miw-100'],
'property_builder' => function(EntityInterface $entity) {
return $entity->getIsActive() ? 'Actif' : 'Non actif';
},
'button_attr_builder' => function(EntityInterface $entity) {
$class = 'btn btn-sm '.($entity->getIsActive() ? 'btn-success' : 'btn-secondary');
return ['class' => $class];
},
])
;
}

View file

@ -0,0 +1,7 @@
{% set map = {
0: ['warning', 'Brouillon'],
1: ['success', 'Publié'],
} %}
<button class="btn btn-sm btn-{{ map[entity.status].0 }}">
{{ map[entity.status].1 }}
</button>