@@ -0,0 +1,29 @@ | |||
<?php | |||
namespace Lc\SovBundle\Builder\Ticket; | |||
use Lc\SovBundle\Component\FormComponent; | |||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||
class TicketBuilder | |||
{ | |||
protected FormComponent $formComponent; | |||
protected ParameterBagInterface $parameterBag; | |||
public function __construct(FormComponent $formComponent, ParameterBagInterface $parameterBag) | |||
{ | |||
$this->formComponent = $formComponent; | |||
$this->parameterBag = $parameterBag; | |||
} | |||
// uploadImageTicketMessage | |||
public function uploadImageTicketMessage($formTicket) | |||
{ | |||
return $this->formComponent->uploadFile( | |||
$formTicket, | |||
'image', | |||
$this->parameterBag->get('app.ticket_images_directory'), | |||
$this->parameterBag->get('app.ticket_images_subdirectory') | |||
); | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
<?php | |||
namespace Lc\SovBundle\Builder\User; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
class UserBuilder | |||
{ | |||
protected EntityManagerInterface $entityManager; | |||
public function __construct(EntityManagerInterface $entityManager) | |||
{ | |||
$this->entityManager = $entityManager; | |||
} | |||
public function setNewsletter(UserInterface $user, NewsletterInterface $newsletter, bool $subscribeNewsletter) | |||
{ | |||
if ($subscribeNewsletter) { | |||
$user->addNewsletter($newsletter); | |||
} else { | |||
$user->removeNewsletter($newsletter); | |||
} | |||
$this->entityManager->persist($user); | |||
$this->entityManager->flush(); | |||
} | |||
} |
@@ -0,0 +1,33 @@ | |||
<?php | |||
namespace Lc\SovBundle\Component; | |||
use Lc\SovBundle\Resolver\UrlResolver; | |||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||
class CookieComponent | |||
{ | |||
protected UrlResolver $urlResolver; | |||
protected ParameterBagInterface $parameterBag; | |||
public function __construct(UrlResolver $urlResolver, ParameterBagInterface $parameterBag) | |||
{ | |||
$this->urlResolver = $urlResolver; | |||
$this->parameterBag = $parameterBag; | |||
} | |||
public function getCookieDomain() | |||
{ | |||
return ($this->urlResolver->isServerLocalhost()) ? null : $this->parameterBag->get('app.cookie_domain_distant'); | |||
} | |||
public function cryptCookie($data) | |||
{ | |||
return base64_encode($data); | |||
} | |||
public function decryptCookie($data) | |||
{ | |||
return base64_decode($data); | |||
} | |||
} |
@@ -0,0 +1,95 @@ | |||
<?php | |||
namespace Lc\SovBundle\Component; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||
use Lc\SovBundle\Doctrine\Extension\SluggableInterface; | |||
use Lc\SovBundle\Model\File\FileInterface; | |||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||
class EntityComponent | |||
{ | |||
protected EntityManagerInterface $entityManager; | |||
protected ParameterBagInterface $parameterBag; | |||
public function __construct( | |||
EntityManagerInterface $entityManager, | |||
ParameterBagInterface $parameterBag | |||
) { | |||
$this->entityManager = $entityManager; | |||
$this->parameterBag = $parameterBag; | |||
} | |||
public function duplicateEntity($entity, $flush = true) | |||
{ | |||
$newEntity = clone $entity; | |||
if ($newEntity instanceof FileInterface) { | |||
$newEntity = $this->duplicateImage($newEntity); | |||
} | |||
if ($newEntity instanceof ProductFamilyInterface) { | |||
// @TODO : à adapter | |||
//$newEntity = $this->productFamilyUtils->processBeforePersistProductFamily($newEntity, false, true); | |||
} | |||
if (method_exists($newEntity, 'getAddress') && is_object($newEntity->getAddress())) { | |||
$address = $newEntity->getAddress(); | |||
$newAddress = $this->duplicateEntity($address); | |||
$newEntity->setAddress($newAddress); | |||
$this->entityManager->persist($newAddress); | |||
} | |||
if ($newEntity instanceof SluggableInterface) { | |||
$this->entityManager->persist($newEntity); | |||
if ($flush) { | |||
$this->entityManager->flush(); | |||
} | |||
$newEntity->setSlug(null); | |||
} | |||
$this->entityManager->persist($newEntity); | |||
if ($flush) { | |||
$this->entityManager->flush(); | |||
} | |||
return $newEntity; | |||
} | |||
public function duplicateEntityToOtherHub($entity, $hub) | |||
{ | |||
$newEntity = $this->duplicateEntity($entity); | |||
if ($hub) { | |||
$newEntity->setMerchant($hub); | |||
} | |||
$this->entityManager->persist($newEntity); | |||
$this->entityManager->flush(); | |||
return $newEntity; | |||
} | |||
public function duplicateImage($entity, $folder = false) | |||
{ | |||
$basePath = $this->parameterBag->get('kernel.project_dir') . '/public/uploads/images/'; | |||
if ($entity->getImage() && file_exists($basePath . $entity->getImage())) { | |||
$extension = strtolower(pathinfo($basePath . $entity->getImage(), PATHINFO_EXTENSION)); | |||
if ($extension == "jpg" || $extension == "png" || $extension == "gif") { | |||
$newImage = md5(uniqid()) . '.' . $extension; | |||
if ($folder) { | |||
$newImage = $folder . '/' . $newImage; | |||
} | |||
copy($basePath . $entity->getImage(), $basePath . $newImage); | |||
$entity->setImage($newImage); | |||
} else { | |||
$entity->setImage(null); | |||
} | |||
} else { | |||
$entity->setImage(null); | |||
} | |||
return $entity; | |||
} | |||
} |
@@ -5,6 +5,7 @@ namespace Lc\SovBundle\Component; | |||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||
use Symfony\Component\Form\Extension\Core\Type\HiddenType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\HttpFoundation\File\Exception\FileException; | |||
class FormComponent | |||
{ | |||
@@ -30,4 +31,28 @@ class FormComponent | |||
]); | |||
} | |||
// uploadImageTicketMessage | |||
public function uploadFile($form, $child, $directory, $subdirectory) | |||
{ | |||
$file = $form->get($child)->getData(); | |||
if ($file) { | |||
$originalFilename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME); | |||
$newFilename = uniqid().'.'.$file->guessExtension(); | |||
try { | |||
$file->move( | |||
$directory, | |||
$newFilename | |||
); | |||
} catch (FileException $e) { | |||
throw new \ErrorException("Une erreur est survenue lors de l'upload du fichier."); | |||
} | |||
return $subdirectory.$newFilename; | |||
} | |||
return false; | |||
} | |||
} |
@@ -311,10 +311,9 @@ abstract class AbstractAdminController extends EaAbstractCrudController | |||
if ($this->isInstanceOf(TreeInterface::class)) { | |||
$entityId = $searchDto->getRequest()->get('entityId'); | |||
if ($entityId !== null) { | |||
$queryBuilder->andWhere('entity.parent = :entityId'); | |||
$queryBuilder->setParameter('entityId', $searchDto->getRequest()->get('entityId')); | |||
$queryBuilder->andWhereParent('entity', $entityId); | |||
} else { | |||
$queryBuilder->andWhere('entity.parent IS NULL'); | |||
$queryBuilder->andWhereParentIsNull('entity'); | |||
} | |||
} | |||
@@ -6,7 +6,6 @@ use Doctrine\ORM\Decorator\EntityManagerDecorator; | |||
use Doctrine\ORM\EntityManager as DoctrineEntityManager; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\SovBundle\Event\EntityManager\EntityManagerEvent; | |||
use Lc\SovBundle\Doctrine\EntityInterface; | |||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | |||
/** | |||
@@ -27,6 +26,11 @@ class EntityManager extends EntityManagerDecorator | |||
parent::__construct($wrapped); | |||
} | |||
public function createQueryBuilder() | |||
{ | |||
return new QueryBuilder($this); | |||
} | |||
public function getRepository($className) | |||
{ | |||
return $this->wrapped->getRepository($this->getEntityName($className)); |
@@ -0,0 +1,32 @@ | |||
<?php | |||
namespace Lc\SovBundle\Doctrine; | |||
use Doctrine\ORM\QueryBuilder as DoctrineQueryBuilder; | |||
/** | |||
* class QueryBuilder. | |||
* | |||
* @author La clic !!!! | |||
*/ | |||
class QueryBuilder extends DoctrineQueryBuilder | |||
{ | |||
public function andWhereParent($dqlId, $entityId):self | |||
{ | |||
$this->andWhere($dqlId.'.parent = :entityId'); | |||
$this->setParameter('entityId', $entityId); | |||
return $this; | |||
} | |||
public function andWhereParentIsNull($dqlId):self | |||
{ | |||
$this->andWhere($dqlId.'.parent IS NULL'); | |||
return $this; | |||
} | |||
/*public function andIsOnline(){ | |||
}*/ | |||
} |
@@ -5,19 +5,20 @@ namespace Lc\SovBundle\Factory\Ticket; | |||
use App\Entity\Ticket\Ticket; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
use Lc\SovBundle\Model\Ticket\TicketInterface; | |||
use Lc\SovBundle\Model\Ticket\TicketModel; | |||
class TicketFactory extends AbstractFactory implements TicketFactoryInterface | |||
{ | |||
public function create(): TicketInterface | |||
{ | |||
$ticket = new Ticket(); | |||
$ticketMessageFactory = new TicketMessageFactory(); | |||
$ticketMessage = $ticketMessageFactory->create() ; | |||
$ticketMessage = $ticketMessageFactory->create($ticket) ; | |||
$ticket->setStatus(TicketModel::TICKET_STATUS_OPEN); | |||
$ticket->addTicketMessage($ticketMessage) ; | |||
return $ticket; | |||
} | |||
} |
@@ -4,14 +4,16 @@ namespace Lc\SovBundle\Factory\Ticket; | |||
use App\Entity\Ticket\TicketMessage; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
use Lc\SovBundle\Model\Ticket\TicketInterface; | |||
use Lc\SovBundle\Model\Ticket\TicketMessageInterface; | |||
class TicketMessageFactory extends AbstractFactory implements TicketMessageFactoryInterface | |||
{ | |||
public function create(): TicketMessageInterface | |||
public function create(TicketInterface $ticket): TicketMessageInterface | |||
{ | |||
$ticketMessage = new TicketMessage(); | |||
$ticketMessage->setTicket($ticket); | |||
$ticketMessage->setStatus(1); | |||
return $ticketMessage; |
@@ -27,17 +27,20 @@ class CrudFormType extends AbstractType | |||
DoctrineOrmTypeGuesser $doctrineOrmTypeGuesser, | |||
\EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType $crudFormType | |||
) { | |||
$this->parent = $crudFormType; | |||
$this->doctrineOrmTypeGuesser = $doctrineOrmTypeGuesser; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$this->parent->buildForm($builder, $options); | |||
$entityDto = $options['entityDto']; | |||
$formPanels = []; | |||
$currentFormPanel = 0; | |||
foreach ($entityDto->getFields() as $fieldDto) { | |||
if (null === $formFieldType = $fieldDto->getFormType()) { | |||
$guessType = $this->doctrineOrmTypeGuesser->guessType($entityDto->getFqcn(), $fieldDto->getProperty()); | |||
$formFieldType = $guessType->getType(); |
@@ -5,6 +5,7 @@ namespace Lc\SovBundle\Model\User; | |||
use Doctrine\Common\Collections\Collection; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\SovBundle\Doctrine\EntityInterface; | |||
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | |||
use Symfony\Component\Security\Core\User\UserInterface; | |||
/** | |||
@@ -48,6 +49,37 @@ abstract class User implements EntityInterface, UserInterface | |||
*/ | |||
protected $groupUsers; | |||
// isUserInGroupVip | |||
public function isInGroupUserVip() | |||
{ | |||
return $this->isInGroupByDevAlias('vip') ; | |||
} | |||
// isUserInGroup | |||
public function isInGroupUser(GroupUserInterface $groupUser) | |||
{ | |||
return $this->isInGroupByDevAlias($groupUser->getDevAlias()); | |||
} | |||
// isUserInGroupByDevAlias | |||
public function isInGroupByDevAlias(string $groupUserDevAlias) | |||
{ | |||
$groupUsers = $this->getGroupUsers(); | |||
foreach($groupUsers as $groupUser) { | |||
if($groupUser->getDevAlias() == $groupUserDevAlias) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
public function isSubscribedToNewsletter(NewsletterInterface $newsletter) | |||
{ | |||
return $this->getNewsletters()->contains($newsletter); | |||
} | |||
public function getEmail(): ?string | |||
{ | |||
return $this->email; |
@@ -3,6 +3,7 @@ | |||
namespace Lc\SovBundle\Repository\Ticket; | |||
use Knp\Component\Pager\PaginatorInterface; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||
class TicketRepositoryQuery extends AbstractRepositoryQuery implements TicketRepositoryQueryInterface | |||
@@ -11,4 +12,11 @@ class TicketRepositoryQuery extends AbstractRepositoryQuery implements TicketRep | |||
{ | |||
parent::__construct($repository, 'r', $paginator); | |||
} | |||
public function filterByUser(UserInterface $user) | |||
{ | |||
return $this | |||
->andWhere('.user = :user') | |||
->setParameter('user', $user); | |||
} | |||
} |
@@ -12,4 +12,14 @@ class TicketStore extends AbstractStore implements TicketStoreInterface | |||
{ | |||
$this->query = $query; | |||
} | |||
// getTicketsByUser | |||
public function getByUser($user) | |||
{ | |||
$query = $this->query->create(); | |||
$query->filterByUser($user); | |||
return $query->find(); | |||
} | |||
} |
@@ -2,6 +2,7 @@ | |||
namespace Lc\SovBundle\Repository\User; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
class UserStore extends AbstractStore implements UserStoreInterface |
@@ -23,11 +23,6 @@ class UrlResolver | |||
return in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']); | |||
} | |||
public function getCookieDomain() | |||
{ | |||
return ($this->isServerLocalhost()) ? null : $this->parameterBag->get('app.cookie_domain_distant'); | |||
} | |||
public function isBot() | |||
{ | |||
if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match( |
@@ -32,6 +32,11 @@ import 'daterangepicker/daterangepicker.css' ; | |||
import { SovTools } from '../../../functions/tools.js'; | |||
global.SovTools = SovTools; | |||
// Prices | |||
import { SovPrices } from '../../../functions/prices.js'; | |||
global.SovPrices = SovPrices; | |||
// Widgets | |||
import { SovWidgets } from '../../../functions/widgets.js'; | |||
global.SovWidgets = SovWidgets; |
@@ -0,0 +1,34 @@ | |||
export class SovPrices { | |||
static getPrice(priceWithTax, taxRate) { | |||
return parseFloat(parseFloat(priceWithTax) / ((taxRate/100) + 1)).toFixed(4); | |||
} | |||
static getPriceWithTax(priceWithoutTax, taxRate) { | |||
return parseFloat(parseFloat(priceWithoutTax) * ((taxRate/100) + 1)).toFixed(2); | |||
} | |||
static getMargin(price, buyingPrice){ | |||
return parseFloat(price - buyingPrice).toFixed(2); | |||
} | |||
static getMarginPercent(price, buyingPrice){ | |||
return parseFloat(((price - buyingPrice) / price) * 100).toFixed(2); | |||
} | |||
static applyReductionPercent(price, percentage) | |||
{ | |||
return applyPercent(price, -percentage); | |||
} | |||
static applyReductionAmount(price, amount) | |||
{ | |||
return parseFloat(price - amount).toFixed(2); | |||
} | |||
static applyPercent(price, percentage) | |||
{ | |||
return parseFloat(price * (percentage / 100 + 1)).toFixed(2); | |||
} | |||
} |
@@ -59,4 +59,32 @@ export class SovTools { | |||
for (; input[i] < '0' || input[i] > '9'; i--) ; | |||
return i == input.length ? -1 : i; | |||
} | |||
static formatNumber(number, toFixed){ | |||
if(number)return Number(number.replace(',', '.')).toFixed(toFixed); | |||
else return null; | |||
} | |||
static formatNumberWithoutFixed(number){ | |||
if(typeof number == 'string')number = number.replace(',', '.'); | |||
if(number)return Number(number); | |||
else return null; | |||
} | |||
static getUrlParameter(sParam) { | |||
var sPageURL = window.location.search.substring(1), | |||
sURLVariables = sPageURL.split('&'), | |||
sParameterName, | |||
i; | |||
for (i = 0; i < sURLVariables.length; i++) { | |||
sParameterName = sURLVariables[i].split('='); | |||
if (sParameterName[0] === sParam) { | |||
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); | |||
} | |||
} | |||
}; | |||
} |
@@ -8,6 +8,7 @@ services: | |||
exclude: | |||
- '../../DependencyInjection/' | |||
- '../../Entity/' | |||
- '../../Doctrine/QueryBuilder' | |||
- '../../Kernel.php' | |||
- '../../Tests/' | |||
@@ -13,112 +13,116 @@ | |||
{%- else -%} | |||
{% set form_method = "POST" %} | |||
{%- endif -%} | |||
<form{% if name != '' %} name="{{ name }}"{% endif %} method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{{ block('attributes') }}{% if multipart %} enctype="multipart/form-data"{% endif %}> | |||
<form{% if name != '' %} name="{{ name }}"{% endif %} | |||
method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{{ block('attributes') }}{% if multipart %} enctype="multipart/form-data"{% endif %}> | |||
{%- if form_method != method -%} | |||
<input type="hidden" name="_method" value="{{ method }}" /> | |||
<input type="hidden" name="_method" value="{{ method }}"/> | |||
{%- endif -%} | |||
<input type="hidden" name="referrer" value="{% if ea is defined %}{{ ea.request.query.get('referrer') }}{% endif %}"> | |||
{% endblock form_start %} | |||
<input type="hidden" name="referrer" | |||
value="{% if ea is defined %}{{ ea.request.query.get('referrer') }}{% endif %}"> | |||
{% endblock form_start %} | |||
{% block form_row %} | |||
{% set row_attr = row_attr|merge({ | |||
class: row_attr.class|default('') ~ ' form-group' | |||
}) %} | |||
{% block form_row %} | |||
{% set row_attr = row_attr|merge({ | |||
class: row_attr.class|default('') ~ ' form-group' | |||
}) %} | |||
<div {% with { attr: row_attr } %}{{ block('attributes') }}{% endwith %}> | |||
{{- form_label(form) -}} | |||
<div class="form-widget"> | |||
<div {% with { attr: row_attr } %}{{ block('attributes') }}{% endwith %}> | |||
{{- form_label(form) -}} | |||
<div class="form-widget"> | |||
{# | |||
{# | |||
{% set has_prepend_html = ea.field.prepend_html|default(null) is not null %} | |||
{% set has_append_html = ea.field.append_html|default(null) is not null %} | |||
{% set has_input_groups = has_prepend_html or has_append_html %} | |||
#} | |||
#} | |||
{% set has_prepend_html = false %} | |||
{% set has_append_html = false %} | |||
{% set has_input_groups = false %} | |||
{% if ea_crud_form.ea_field is defined and ea_crud_form.ea_field is not null %} | |||
{% set prepend_html = ea_crud_form.ea_field.customOptions.get('prependHtml') %} | |||
{% set append_html = ea_crud_form.ea_field.customOptions.get('appendHtml') %} | |||
{% set has_prepend_html = prepend_html is not null %} | |||
{% set has_append_html = append_html is not null %} | |||
{% set has_input_groups = has_prepend_html or has_append_html %} | |||
{% endif %} | |||
{% set has_prepend_html = false %} | |||
{% set has_append_html = false %} | |||
{% set has_input_groups = false %} | |||
{% if has_input_groups %} | |||
<div class="input-group">{% endif %} | |||
{% if has_prepend_html %} | |||
<div class="input-group-prepend"> | |||
<span class="input-group-text">{{ prepend_html|raw }}</span> | |||
</div> | |||
{% endif %} | |||
{% if ea_crud_form.ea_field is defined and ea_crud_form.ea_field is not null %} | |||
{% set prepend_html = ea_crud_form.ea_field.customOptions.get('prependHtml') %} | |||
{% set append_html = ea_crud_form.ea_field.customOptions.get('appendHtml') %} | |||
{% set has_prepend_html = prepend_html is not null %} | |||
{% set has_append_html = append_html is not null %} | |||
{% set has_input_groups = has_prepend_html or has_append_html %} | |||
{% endif %} | |||
{{ form_widget(form) }} | |||
{% if has_input_groups %} | |||
<div class="input-group">{% endif %} | |||
{% if has_prepend_html %} | |||
<div class="input-group-prepend"> | |||
<span class="input-group-text">{{ prepend_html|raw }}</span> | |||
{% if has_append_html %} | |||
<div class="input-group-append"> | |||
<span class="input-group-text">{{ append_html|raw }}</span> | |||
</div> | |||
{% endif %} | |||
{% if has_input_groups %}</div>{% endif %} | |||
{% set nullable_fields_fqcn = [ | |||
'EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField', | |||
'EasyCorp\Bundle\EasyAdminBundle\Field\DateField', | |||
'EasyCorp\Bundle\EasyAdminBundle\Field\TimeField', | |||
] %} | |||
{% if form.vars.ea_crud_form.ea_field.fieldFqcn|default(false) in nullable_fields_fqcn and ea.field.nullable|default(false) %} | |||
<div class="nullable-control"> | |||
<label> | |||
<input type="checkbox" {% if data is null %}checked="checked"{% endif %}> | |||
{{ 'label.nullable_field'|trans({}, 'EasyAdminBundle') }} | |||
</label> | |||
</div> | |||
{% endif %} | |||
{{ form_widget(form) }} | |||
{% if has_append_html %} | |||
<div class="input-group-append"> | |||
<span class="input-group-text">{{ append_html|raw }}</span> | |||
</div> | |||
{% set help_message = name|sov_trans_admin_help(form.parent.vars.data) %} | |||
{% if help_message != '' %} | |||
<small class="form-help">{{ help_message }}</small> | |||
{% endif %} | |||
{% if has_input_groups %}</div>{% endif %} | |||
{% set nullable_fields_fqcn = [ | |||
'EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField', | |||
'EasyCorp\Bundle\EasyAdminBundle\Field\DateField', | |||
'EasyCorp\Bundle\EasyAdminBundle\Field\TimeField', | |||
] %} | |||
{% if form.vars.ea_crud_form.ea_field.fieldFqcn|default(false) in nullable_fields_fqcn and ea.field.nullable|default(false) %} | |||
<div class="nullable-control"> | |||
<label> | |||
<input type="checkbox" {% if data is null %}checked="checked"{% endif %}> | |||
{{ 'label.nullable_field'|trans({}, 'EasyAdminBundle') }} | |||
</label> | |||
</div> | |||
{% endif %} | |||
{% set help_message = name|sov_trans_admin_help(form.parent.vars.data) %} | |||
{% if help_message != '' %} | |||
<small class="form-help">{{ help_message }}</small> | |||
{% endif %} | |||
{{- form_errors(form) -}} | |||
{{- form_errors(form) -}} | |||
</div> | |||
</div> | |||
</div> | |||
{% endblock form_row %} | |||
{% endblock form_row %} | |||
{% block form_label -%} | |||
{% block form_label -%} | |||
{% if label is same as(false) -%} | |||
<label>{# the empty <label> is needed to not break the form design #}</label> | |||
<label>{# the empty <label> is needed to not break the form design #}</label> | |||
{%- else -%} | |||
{%- if compound is defined and compound -%} | |||
{%- set element = 'legend' -%} | |||
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%} | |||
{%- if compound is defined and compound -%} | |||
{%- set element = 'legend' -%} | |||
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%} | |||
{%- else -%} | |||
{%- set label_attr = label_attr|merge({for: id, class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%} | |||
{%- endif -%} | |||
{% if required -%} | |||
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} | |||
{%- endif -%} | |||
{% if label is empty -%} | |||
{%- if label_format is not empty -%} | |||
{% set label = label_format|replace({ | |||
'%name%': name, | |||
'%id%': id, | |||
}) %} | |||
{%- else -%} | |||
{%- set label_attr = label_attr|merge({for: id, class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%} | |||
{%- endif -%} | |||
{% if required -%} | |||
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} | |||
{%- endif -%} | |||
{% if label is empty -%} | |||
{%- if label_format is not empty -%} | |||
{% set label = label_format|replace({ | |||
'%name%': name, | |||
'%id%': id, | |||
}) %} | |||
{%- else -%} | |||
{# {% set label = name|humanize %} #} | |||
{%- endif -%} | |||
{# {% set label = name|humanize %} #} | |||
{%- endif -%} | |||
{%- endif -%} | |||
{% set entityNameOrObject = form.parent.vars.data %} | |||
{% if not entityNameOrObject and form.parent.vars.errors.form.config.dataClass is defined %} | |||
{% set entityNameOrObject = form.parent.vars.errors.form.config.dataClass %} | |||
{% endif %} | |||
{% set entityNameOrObject = form.parent.vars.data %} | |||
{% if not entityNameOrObject and form.parent.vars.errors.form.config.dataClass is defined %} | |||
{% set entityNameOrObject = form.parent.vars.errors.form.config.dataClass %} | |||
{% endif %} | |||
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|sov_trans_admin_field(entityNameOrObject) }}</{{ element|default('label') }}> | |||
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %} | |||
>{{ (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|sov_trans_admin_field(entityNameOrObject) }} | |||
</{{ element|default('label') }}> | |||
{%- endif -%} | |||
{%- endblock form_label %} | |||
@@ -216,8 +220,8 @@ | |||
{% endif %} | |||
<div class="col-12"> | |||
{# {{ dump(form.vars) }}#} | |||
{# {{ dump(form.vars.ea_crud_form.ea_field) }}#} | |||
{# {{ dump(form.vars) }} #} | |||
{# {{ dump(form.vars.ea_crud_form.ea_field) }} #} | |||
<div class="input-group"> | |||
<div class="input-group-prepend"> | |||
{% if form.parent.vars['row_attr']['data-sortable'] is defined %} | |||
@@ -226,7 +230,8 @@ | |||
<i class="fa fa-arrows-alt"></i> | |||
</button> | |||
{% endif %} | |||
<button type="button" class="btn btn-primary lc-filemanager-open" data-id="{{ form.path.vars.id }}" | |||
<button type="button" class="btn btn-primary lc-filemanager-open" | |||
data-id="{{ form.path.vars.id }}" | |||
data-toggle="tooltip" title="Sélectionner un fichier" | |||
data-target="{{ path('file_manager', {module:1, conf: managerDir})|raw }}"> | |||
<i class="fa fa-folder-open"></i> | |||
@@ -249,7 +254,7 @@ | |||
{% endblock file_manager_widget %} | |||
{% block checkbox_radio_label -%} | |||
{#- Do not display the label if widget is not defined in order to prevent double label rendering -#} | |||
{#- Do not display the label if widget is not defined in order to prevent double label rendering -#} | |||
{%- if widget is defined -%} | |||
{% set is_parent_custom = parent_label_class is defined and ('checkbox-custom' in parent_label_class or 'radio-custom' in parent_label_class or 'switch-custom' in parent_label_class) %} | |||
{% set is_custom = label_attr.class is defined and ('checkbox-custom' in label_attr.class or 'radio-custom' in label_attr.class or 'switch-custom' in label_attr.class) %} | |||
@@ -279,19 +284,27 @@ | |||
{%- endif -%} | |||
{%- endif -%} | |||
{% if attr.disabled is defined and attr.disabled %} | |||
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' disabled')|trim}) -%} | |||
{% endif %} | |||
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}> | |||
{{ widget|raw }} | |||
<span class="checkmark"></span> | |||
{# {{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain))|raw -}} #} | |||
{# {{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain))|raw -}} #} | |||
{% set entityNameOrObject = form.parent.vars.data %} | |||
{% if not entityNameOrObject and form.parent.vars.errors.form.config.dataClass is defined %} | |||
{% set entityNameOrObject = form.parent.vars.errors.form.config.dataClass %} | |||
{% endif %} | |||
{{- (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|sov_trans_admin_field(entityNameOrObject) -}} | |||
<!-- lorsque que le name est un entier "case radio"--> | |||
{% if name matches '/^\\d+$/' %} | |||
{{- label|trans({}, 'admin') -}} | |||
{% else %} | |||
{{- (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|sov_trans_admin_field(entityNameOrObject) -}} | |||
{% endif %} | |||
{{- form_errors(form) -}} | |||
</label> | |||
{%- endif -%} |