Browse Source

Refactoring, suppression champ merchant si section existe, adaption des repository et des factory

develop
Fab 3 years ago
parent
commit
42e58d4b06
7 changed files with 104 additions and 62 deletions
  1. +1
    -1
      Controller/Dashboard/DashboardAdminController.php
  2. +12
    -28
      Controller/Ticket/TicketAdminController.php
  3. +73
    -29
      Resources/assets/app/adminlte/main/init.js
  4. +1
    -1
      Resources/assets/functions/widgets.js
  5. +5
    -2
      Resources/translations/admin.fr.yaml
  6. +5
    -0
      Resources/views/adminlte/crud/form.html.twig
  7. +7
    -1
      Resources/views/adminlte/crud/form_theme.html.twig

+ 1
- 1
Controller/Dashboard/DashboardAdminController.php View File

->setFormThemes( ->setFormThemes(
[ [
'@LcSov/adminlte/crud/form_theme.html.twig', '@LcSov/adminlte/crud/form_theme.html.twig',
'@FOSCKEditor/Form/ckeditor_widget.html.twig'
//'@FOSCKEditor/Form/ckeditor_widget.html.twig'
] ]
); );
} }

+ 12
- 28
Controller/Ticket/TicketAdminController.php View File

use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use Lc\SovBundle\Factory\Ticket\TicketFactory; use Lc\SovBundle\Factory\Ticket\TicketFactory;
use Lc\SovBundle\Factory\Ticket\TicketFactoryInterface; use Lc\SovBundle\Factory\Ticket\TicketFactoryInterface;
use Lc\SovBundle\Factory\Ticket\TicketMessageFactory;
use Lc\SovBundle\Factory\Ticket\TicketMessageFactoryInterface; use Lc\SovBundle\Factory\Ticket\TicketMessageFactoryInterface;
use Lc\SovBundle\Form\Ticket\TicketFormType; use Lc\SovBundle\Form\Ticket\TicketFormType;
use Lc\SovBundle\Form\Ticket\TicketMessageFormType; use Lc\SovBundle\Form\Ticket\TicketMessageFormType;


class TicketAdminController extends AbstractAdminController class TicketAdminController extends AbstractAdminController
{ {
protected $ticketFactory;
protected $ticketMessageFactory;
protected $adminUrlGenerator;
protected $em;
protected $translatorAdmin;

public function __construct(
TicketFactoryInterface $ticketFactory,
TicketMessageFactoryInterface $ticketMessageFactory,
AdminUrlGenerator $adminUrlGenerator,
TranslatorAdmin $translatorAdmin
) {
$this->ticketFactory = $ticketFactory;
$this->ticketMessageFactory = $ticketMessageFactory;
$this->adminUrlGenerator = $adminUrlGenerator;
$this->translatorAdmin = $translatorAdmin;
}


public static function getEntityFqcn(): string public static function getEntityFqcn(): string
{ {


public function configureFields(string $pageName): iterable public function configureFields(string $pageName): iterable
{ {
$translatorAdmin = $this->get('translator_admin');
return [ return [
IntegerField::new('id') IntegerField::new('id')
->hideOnForm(), ->hideOnForm(),
ChoiceField::new('type') ChoiceField::new('type')
->autocomplete() ->autocomplete()
->setChoices( ->setChoices(
$this->translatorAdmin->transChoices(TicketModel::getTypeChoices(), 'Ticket', 'type')
$translatorAdmin->transChoices(TicketModel::getTypeChoices(), 'Ticket', 'type')
), ),
ChoiceField::new('status') ChoiceField::new('status')
->autocomplete() ->autocomplete()
->setChoices( ->setChoices(
$this->translatorAdmin->transChoices(TicketModel::getStatusChoices(), 'Ticket', 'status')
$translatorAdmin->transChoices(TicketModel::getStatusChoices(), 'Ticket', 'status')


) )
->setTemplatePath('@LcSov/admin/ticket/field/status.html.twig') ->setTemplatePath('@LcSov/admin/ticket/field/status.html.twig')
return parent::configureActions($actions); return parent::configureActions($actions);
} }


public function createEntityFromFactory()
{
return $this->ticketFactory->create();
}

public function new(AdminContext $context) public function new(AdminContext $context)
{ {
$ticket = $this->createEntityFromFactory();
$adminUrlGenerator = $this->get(AdminUrlGenerator::class);

$ticket = $this->createEntity($context->getEntity()->getFqcn());


$form = $this->createForm(TicketFormType::class, $ticket); $form = $this->createForm(TicketFormType::class, $ticket);


$this->get('em')->persist($ticket); $this->get('em')->persist($ticket);
$this->get('em')->flush(); $this->get('em')->flush();


$url = $this->adminUrlGenerator
$url = $adminUrlGenerator
->setAction('index') ->setAction('index')
->generateUrl(); ->generateUrl();




public function detail(AdminContext $context) public function detail(AdminContext $context)
{ {
$adminUrlGenerator = $this->get(AdminUrlGenerator::class);
$ticket = $context->getEntity()->getInstance(); $ticket = $context->getEntity()->getInstance();


$url = $this->adminUrlGenerator
$url = $adminUrlGenerator
->setAction('ticketStatusAction') ->setAction('ticketStatusAction')
->generateUrl(); ->generateUrl();


] ]
); );


$ticketMessage = $this->ticketMessageFactory->create();
$ticketMessageFactory = new TicketMessageFactory();
$ticketMessage = $ticketMessageFactory->create();
$formAddTicketMessage = $this->createForm(TicketMessageFormType::class, $ticketMessage); $formAddTicketMessage = $this->createForm(TicketMessageFormType::class, $ticketMessage);
$formAddTicketMessage->handleRequest($this->get('request')->getMasterRequest()); $formAddTicketMessage->handleRequest($this->get('request')->getMasterRequest());



+ 73
- 29
Resources/assets/app/adminlte/main/init.js View File

window.addEventListener('load', (event) => {


SovNotification.init() ;


SovWidgets.setDateRange();
SovWidgets.setAutoCompleteField();
SovNotification.init();


/* Tooltip */
$('[data-toggle="tooltip"]').tooltip();
SovWidgets.setDateRange();
SovWidgets.setAutoCompleteField();


/* Select2 */
if ($('.select2, select.form-control').length) {
/* Tooltip */
$('[data-toggle="tooltip"]').tooltip();


$('form .form-widget>select.form-control, .select2').each(function (i, elm) {
if (!$(this).hasClass('disable-select2')) {
SovWidgets.setSelect2($(elm));
}
/* Select2 */
if ($('.select2, select.form-control').length) {

$('form .form-widget>select.form-control, .select2').each(function (i, elm) {
if (!$(this).hasClass('disable-select2')) {
SovWidgets.setSelect2($(elm));
}
});

$('form select.form-control').each(function (i, elm) {
if (!$(this).hasClass('disable-select2')) {
SovWidgets.setSelect2($(elm));
}
});
}

$('.action-delete').on('click', function (e) {
e.preventDefault();
const formAction = $(this).attr('formaction');

$('#modal-delete').modal({backdrop: true, keyboard: true})
.off('click', '#modal-delete-button')
.on('click', '#modal-delete-button', function () {
let deleteForm = $('#delete-form');
deleteForm.attr('action', formAction);
deleteForm.submit();
});
}); });


$('form select.form-control').each(function (i, elm) {
if (!$(this).hasClass('disable-select2')) {
SovWidgets.setSelect2($(elm));

var elements = $('.lc-ckeditor');

if (elements.length) {
for (var i = 0; i < elements.length; ++i) {
if ($(elements[i]).data('config') === 'simple_config') {
CKEDITOR.replace(elements[i], {
"toolbar": [
{
items: ['Bold', 'Italic', 'Underline', 'Strike']
},
{
items: ["TextColor"]
}
],
"language": "fr",
'height': 100
});
} else {
CKEDITOR.replace(elements[i], {
"toolbar": [
{
name: "styles",
items: ["Format", 'Bold', 'Italic', 'Underline', 'Strike', "Link", "BulletedList"]
},
{
items: ["TextColor"]
},
{name: 'paragraph', items: ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock']},
{name: 'insert', items: ['Image', 'SpecialChar']},
{name: "document", items: ["Source"]},
],
"language": "fr"
});
}

} }
});
}

$('.action-delete').on('click', function (e) {
e.preventDefault();
const formAction = $(this).attr('formaction');

$('#modal-delete').modal({backdrop: true, keyboard: true})
.off('click', '#modal-delete-button')
.on('click', '#modal-delete-button', function () {
let deleteForm = $('#delete-form');
deleteForm.attr('action', formAction);
deleteForm.submit();
});
});
}


});

+ 1
- 1
Resources/assets/functions/widgets.js View File



static setDateRange() { static setDateRange() {
$('.date-time-range, .date-range').each(function (i, picker) { $('.date-time-range, .date-range').each(function (i, picker) {
options = {
let options = {
autoUpdateInput: false, autoUpdateInput: false,
locale: { locale: {
"format": "DD/MM/YY", "format": "DD/MM/YY",

+ 5
- 2
Resources/translations/admin.fr.yaml View File

TicketMessage: TicketMessage:
fields: fields:
message: Votre réponse message: Votre réponse
ProductFamily:
label: Produit
label_plurial: Produits
default: default:
fields: fields:
id: Id id: Id
date: Date date: Date
day: Jour day: Jour
groupUser: Groupe d'utilisateur groupUser: Groupe d'utilisateur

quantity: Quantité
unit: Unité
panels: panels:
general: Général general: Général
configuration: Configuration configuration: Configuration
gallery: Galerie gallery: Galerie
seo: Référencement seo: Référencement

form: form:
account_profile: account_profile:
message: message:

+ 5
- 0
Resources/views/adminlte/crud/form.html.twig View File

<script src="{{ asset(js_asset) }}"></script> <script src="{{ asset(js_asset) }}"></script>
{% endfor %} {% endfor %}


<script type="text/javascript">
var CKEDITOR_BASEPATH = "{{ ckeditor_base_path("/bundles/fosckeditor/") }}";
</script>
<script type="text/javascript" src="{{ asset('bundles/fosckeditor/ckeditor.js') }}"></script>

{% for webpack_encore_entry in form.vars.ea_crud_form.assets.webpackEncoreAssets %} {% for webpack_encore_entry in form.vars.ea_crud_form.assets.webpackEncoreAssets %}
{{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry) }} {{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry) }}
{% endfor %} {% endfor %}

+ 7
- 1
Resources/views/adminlte/crud/form_theme.html.twig View File

{% endfor %} {% endfor %}
{% endblock %} {% endblock %}
{% endembed %} {% endembed %}
{% endblock ea_crud_widget_panels %}
{% endblock ea_crud_widget_panels %}

{% block ckeditor_widget %}

<textarea class="lc-ckeditor" {{ block('widget_attributes') }}>{{ value }}</textarea>

{% endblock %}

Loading…
Cancel
Save