Преглед изворни кода

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

develop
Fab пре 3 година
родитељ
комит
42e58d4b06
7 измењених фајлова са 104 додато и 62 уклоњено
  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 Прегледај датотеку

@@ -92,7 +92,7 @@ class DashboardAdminController extends AbstractDashboardController
->setFormThemes(
[
'@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 Прегледај датотеку

@@ -15,6 +15,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use Lc\SovBundle\Factory\Ticket\TicketFactory;
use Lc\SovBundle\Factory\Ticket\TicketFactoryInterface;
use Lc\SovBundle\Factory\Ticket\TicketMessageFactory;
use Lc\SovBundle\Factory\Ticket\TicketMessageFactoryInterface;
use Lc\SovBundle\Form\Ticket\TicketFormType;
use Lc\SovBundle\Form\Ticket\TicketMessageFormType;
@@ -27,23 +28,6 @@ use Symfony\Component\HttpFoundation\JsonResponse;

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
{
@@ -67,6 +51,7 @@ class TicketAdminController extends AbstractAdminController

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

)
->setTemplatePath('@LcSov/admin/ticket/field/status.html.twig')
@@ -109,14 +94,11 @@ class TicketAdminController extends AbstractAdminController
return parent::configureActions($actions);
}

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

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);

@@ -127,7 +109,7 @@ class TicketAdminController extends AbstractAdminController
$this->get('em')->persist($ticket);
$this->get('em')->flush();

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

@@ -144,9 +126,10 @@ class TicketAdminController extends AbstractAdminController

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

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

@@ -159,7 +142,8 @@ class TicketAdminController extends AbstractAdminController
]
);

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


+ 73
- 29
Resources/assets/app/adminlte/main/init.js Прегледај датотеку

@@ -1,37 +1,81 @@
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 Прегледај датотеку

@@ -40,7 +40,7 @@ export class SovWidgets {

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

+ 5
- 2
Resources/translations/admin.fr.yaml Прегледај датотеку

@@ -94,6 +94,9 @@ entity:
TicketMessage:
fields:
message: Votre réponse
ProductFamily:
label: Produit
label_plurial: Produits
default:
fields:
id: Id
@@ -122,13 +125,13 @@ entity:
date: Date
day: Jour
groupUser: Groupe d'utilisateur

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

form:
account_profile:
message:

+ 5
- 0
Resources/views/adminlte/crud/form.html.twig Прегледај датотеку

@@ -60,6 +60,11 @@
<script src="{{ asset(js_asset) }}"></script>
{% 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 %}
{{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry) }}
{% endfor %}

+ 7
- 1
Resources/views/adminlte/crud/form_theme.html.twig Прегледај датотеку

@@ -329,4 +329,10 @@
{% endfor %}
{% endblock %}
{% 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…
Откажи
Сачувај