@@ -0,0 +1,97 @@ | |||
<?php | |||
namespace Lc\SovBundle\Definition\Field; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use Lc\SovBundle\Field\CollectionField; | |||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||
use PhpParser\Node\Expr\Throw_; | |||
use Symfony\Component\Form\Extension\Core\Type\TextType; | |||
abstract class AbstractFieldDefinition | |||
{ | |||
protected array $panels; | |||
protected array $fieldsByPanel; | |||
protected array $fieldList; | |||
protected bool $isPopulate = false; | |||
protected TranslatorAdmin $translatorAdmin; | |||
abstract public function configurePanels(): array; | |||
abstract public function configureFields(): array; | |||
public function __construct(TranslatorAdmin $translatorAdmin) | |||
{ | |||
$this->translatorAdmin = $translatorAdmin; | |||
} | |||
protected function populate(): void | |||
{ | |||
if ($this->isPopulate === false) { | |||
$this->fieldList = $this->configureFields(); | |||
$this->panels = $this->configurePanels(); | |||
foreach ($this->panels as $panel) { | |||
$method = 'configureFieldsPanel' . ucfirst($panel); | |||
if (method_exists($this, $method)) { | |||
$this->fieldsByPanel[$panel] = array_merge( | |||
array('panel_' . $panel => FormField::addPanel($panel)), | |||
$this->$method() | |||
); | |||
$this->fieldList = array_merge($this->fieldList, $this->fieldsByPanel[$panel]); | |||
}else{ | |||
throw new \Exception($method . ' n\'esxite pas '); | |||
} | |||
} | |||
$this->isPopulate = false; | |||
} | |||
} | |||
public function getFieldList() | |||
{ | |||
$this->populate(); | |||
return $this->fieldList; | |||
} | |||
public function getFieldListByPanel($panel) | |||
{ | |||
$this->populate(); | |||
return $this->fieldsByPanel[$panel]; | |||
} | |||
public function getPanelList() | |||
{ | |||
$this->populate(); | |||
return $this->fieldsByPanel; | |||
} | |||
public function configureFieldsPanelSeo(): array | |||
{ | |||
return array( | |||
'metaTitle' => TextField::new('metaTitle') | |||
->setLabel('Meta Title') | |||
->setHelp('Affiché dans les résultats de recherche Google') | |||
->hideOnIndex(), | |||
'metaDescription' => TextareaField::new('metaDescription') | |||
->setLabel('Meta description') | |||
->setHelp('Affiché dans les résultats de recherche Google') | |||
->hideOnIndex(), | |||
'oldUrls' => CollectionField::new('oldUrls') | |||
->setFormTypeOption('entry_type', TextType::class) | |||
->setLabel('Anciennes urls du document') | |||
->hideOnIndex(), | |||
); | |||
} | |||
public function configureFieldsPanelConf(): array | |||
{ | |||
return [ | |||
//FormField::addPanel('configuration')->setTemplateName('crud/field/generic'), | |||
'devAlias' => TextField::new('devAlias')->hideOnIndex(), | |||
]; | |||
} | |||
} |
@@ -40,7 +40,8 @@ class CrudFormType extends AbstractType | |||
$formPanels = []; | |||
$currentFormPanel = 0; | |||
foreach ($entityDto->getFields() as $fieldDto) { | |||
dump($fieldDto); | |||
dump( $fieldDto->getFormType()); | |||
if (null === $formFieldType = $fieldDto->getFormType()) { | |||
$guessType = $this->doctrineOrmTypeGuesser->guessType($entityDto->getFqcn(), $fieldDto->getProperty()); | |||
$formFieldType = $guessType->getType(); |
@@ -77,8 +77,8 @@ class FiltersFormType extends AbstractType | |||
$textFilter->buildProperty($builder, $fieldDto); | |||
break; | |||
case EntityType::class: | |||
$associationFilter = new AssociationFilter(); | |||
$associationFilter->buildProperty($builder, $fieldDto, $options); | |||
// $associationFilter = new AssociationFilter(); | |||
// $associationFilter->buildProperty($builder, $fieldDto, $options); | |||
break; | |||
case 'dateinterval': | |||
@@ -0,0 +1,88 @@ | |||
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | |||
{# @var entities \EasyCorp\Bundle\EasyAdminBundle\Collection\EntityDtoCollection #} | |||
{# @var paginator \EasyCorp\Bundle\EasyAdminBundle\Orm\EntityPaginator #} | |||
{% extends ea.templatePath('layout') %} | |||
{% trans_default_domain ea.i18n.translationDomain %} | |||
{% block body_id 'ea-detail-' ~ entity.name ~ '-' ~ entity.primaryKeyValue %} | |||
{% block body_class 'ea-detail ea-detail-' ~ entity.name %} | |||
{% block content_title %} | |||
{{ 'detail'|sov_trans_admin_title(ea.getEntity().getFqcn()) }} | |||
{% endblock %} | |||
{% block content_breadcrumb %} | |||
{{ include('@LcSov/adminlte/block/breadcrumb.html.twig') }} | |||
{% endblock content_breadcrumb %} | |||
{% set has_batch_actions = batch_actions|length > 0 %} | |||
{% block page_actions %} | |||
{% endblock page_actions %} | |||
{% block main %} | |||
{% block main_prepend %}{% endblock %} | |||
<div class="col-12" id="{% block detail_id %}{% endblock detail_id %}"> | |||
{% block card_wrapper %} | |||
<div class="card card-table card-outline card-primary"> | |||
{% block card_header_wrapper %} | |||
<div class="card-header"> | |||
<div class="btn-list float-sm-right"> | |||
</div> | |||
</div> | |||
{% endblock %} | |||
{% block card_body_wrapper %} | |||
<div class="card-body"> | |||
{% block detail_fields %} | |||
{% set row_number = 0 %} | |||
{% for field in entity.fields %} | |||
{% set is_decoration_field = 'field-form_panel' in field.cssClass %} | |||
{% if loop.first and not is_decoration_field %} | |||
{% set row_number = 0 %} | |||
{{ _self.open_empty_content_panel(field) }} | |||
{% endif %} | |||
{% if is_decoration_field %} | |||
{% if not loop.first %} | |||
{{ _self.close_content_panel() }} | |||
{% endif %} | |||
{% set row_number = 0 %} | |||
{% if field.label is empty and field.help is empty %} | |||
{{ _self.open_empty_content_panel(field) }} | |||
{% else %} | |||
{{ _self.open_content_panel_with_header(field) }} | |||
{% endif %} | |||
{% endif %} | |||
{% block detail_field %} | |||
{% if not is_decoration_field %} | |||
{{ _self.render_field(entity, field, row_number) }} | |||
{% endif %} | |||
{% endblock %} | |||
{% set row_number = is_decoration_field ? row_number : row_number + 1 %} | |||
{% endfor %} | |||
{{ _self.close_content_panel() }} | |||
{% endblock %} | |||
</div> | |||
{% endblock %} | |||
{% block card_footer_wrapper %} | |||
<div class="card-footer"> | |||
<div class="row"> | |||
{% block delete_form %} | |||
{{ include('@EasyAdmin/crud/includes/_delete_form.html.twig', { entity_id: entity.primaryKeyValue }, with_context = false) }} | |||
{% endblock delete_form %} | |||
</div> | |||
</div> | |||
{% endblock %} | |||
</div> | |||
{% endblock card_wrapper %} | |||
</div> | |||
{% block main_append %}{% endblock %} | |||
{% endblock main %} |
@@ -0,0 +1,15 @@ | |||
<div class="info-box"> | |||
<span class="info-box-icon {% block class %}bg-info{% endblock %}"> | |||
<i class="fa fa-{% block icon %}bg-info{% endblock %}"></i></span> | |||
<div class="info-box-content"> | |||
{% block info_box %} | |||
<span class="info-box-text">{% block label %}{% endblock %}</span> | |||
<strong>{% block value %}{% endblock %}</strong> | |||
{% endblock %} | |||
<div class="float-right"> {% block button %}{% endblock %} | |||
</div> | |||
</div> | |||
</div> |