Browse Source

Adminlte : ajout fields

tags/0.1
Guillaume 3 years ago
parent
commit
754a880f57
4 changed files with 34 additions and 2 deletions
  1. +1
    -1
      Field/FileManagerField.php
  2. +30
    -0
      Field/StatusField.php
  3. +2
    -0
      Resources/views/adminlte/crud/field/image.html.twig
  4. +1
    -1
      Resources/views/adminlte/crud/field/status.html.twig

+ 1
- 1
Field/FileManagerField.php View File

return (new self()) return (new self())
->setProperty($propertyName) ->setProperty($propertyName)
->setLabel($label) ->setLabel($label)
->setTemplatePath('@LcSov/tabler/crud/field/image.html.twig')
->setTemplatePath('@LcSov/adminlte/crud/field/image.html.twig')
->addWebpackEncoreEntries('field-filemanager') ->addWebpackEncoreEntries('field-filemanager')
->setFormType(FileManagerType::class) ->setFormType(FileManagerType::class)
->addCssClass('field-text') ->addCssClass('field-text')

+ 30
- 0
Field/StatusField.php View File

<?php

namespace Lc\SovBundle\Field;

use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;
use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait;
use Lc\SovBundle\Form\Type\FileManagerType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;

/**
* @author La clic ! <contact@laclic.fr>
*/
final class StatusField implements FieldInterface
{
use FieldTrait;

public static function new(string $propertyName, ?string $label = null): self
{
return (new self())
->setProperty($propertyName)
->setLabel($label)
->setTemplatePath('@LcSov/adminlte/crud/field/status.html.twig')
->setFormType(ChoiceType::class)
->setFormTypeOption('expanded', false)
->setFormTypeOption('multiple', false)
->setFormTypeOption('choices', ['En ligne' => 1, 'Hors ligne' => 0]);
}

}

+ 2
- 0
Resources/views/adminlte/crud/field/image.html.twig View File

<div id="{{ html_id }}" class="ea-lightbox"> <div id="{{ html_id }}" class="ea-lightbox">
<img src="{{ asset(field.value.path) }}"> <img src="{{ asset(field.value.path) }}">
</div> </div>
{% else %}
<div class="badge badge-secondary">Aucun(e)</div>
{% endif %} {% endif %}

+ 1
- 1
Resources/views/adminlte/crud/field/status.html.twig View File



{% if field.value %}
{% if field.value == 1 %}
<div class="badge badge-success">En ligne</div> <div class="badge badge-success">En ligne</div>
{% else %} {% else %}
<div class="badge badge-danger">Hors ligne</div> <div class="badge badge-danger">Hors ligne</div>

Loading…
Cancel
Save