Bläddra i källkod

listing tickets

ideas
Charly 3 år sedan
förälder
incheckning
82e6b27d25
9 ändrade filer med 100 tillägg och 62 borttagningar
  1. +56
    -47
      Controller/AbstractAdminController.php
  2. +13
    -7
      Controller/Ticket/TicketAdminController.php
  3. +6
    -0
      Resources/translations/admin.fr.yaml
  4. +0
    -8
      Resources/views/admin/ticket/index-status.html.twig
  5. +0
    -0
      Resources/views/admin/ticket/index_email.html.twig
  6. +0
    -0
      Resources/views/admin/ticket/index_lastmessage.html.twig
  7. +10
    -0
      Resources/views/admin/ticket/index_status.html.twig
  8. +0
    -0
      Resources/views/admin/ticket/index_username.html.twig
  9. +15
    -0
      Resources/views/adminlte/macro/badge.html.twig

+ 56
- 47
Controller/AbstractAdminController.php Visa fil

@@ -60,8 +60,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
RequestStack $request,
EntityManagerInterface $em,
TranslatorAdmin $translatorAdmin
)
{
) {
$this->session = $session;
$this->request = $request;
$this->em = $em;
@@ -99,6 +98,15 @@ abstract class AbstractAdminController extends EaAbstractCrudController
'title' => $this->translatorAdmin->transAction('edit')
)
],
Action::DETAIL => [
'icon' => 'eye',
'add_class' => 'btn btn-success',
'label' => false,
'html_attributes' => array(
'data-toggle' => 'tooltip',
'title' => $this->translatorAdmin->transAction('detail')
)
],
Action::DELETE => [
'icon' => 'trash',
'dropdown' => true,
@@ -112,7 +120,6 @@ abstract class AbstractAdminController extends EaAbstractCrudController
];

/* Boutons des actions dans l'édition */

$actionSaveAndReturn = [
'add_class' => 'float-right',
'icon' => 'check',
@@ -192,37 +199,40 @@ abstract class AbstractAdminController extends EaAbstractCrudController

foreach ($actionsArray as $crudActionName => $actionsStyle) {
foreach ($actionsStyle as $actionName => $button) {
$actions->update(
$crudActionName,
$actionName,
function (Action $action) use ($button) {
if (isset($button['add_class'])) {
$action->addCssClass($button['add_class']);
}

if (isset($button['class'])) {
$action->setCssClass($button['class']);
}

if (isset($button['icon'])) {
$action->setIcon('fa fa-' . $button['icon']);
// si l'action existe
if ($actions->getAsDto('actions')->getAction($crudActionName, $actionName)) {
$actions->update(
$crudActionName,
$actionName,
function (Action $action) use ($button) {
if (isset($button['add_class'])) {
$action->addCssClass($button['add_class']);
}

if (isset($button['class'])) {
$action->setCssClass($button['class']);
}

if (isset($button['icon'])) {
$action->setIcon('fa fa-' . $button['icon']);
}

if (isset($button['label'])) {
$action->setLabel($button['label']);
}

if (isset($button['dropdown']) && $button['dropdown']) {
$action->addCssClass('in-dropdown');
}

if (isset($button['html_attributes']) && $button['html_attributes']) {
$action->setHtmlAttributes($button['html_attributes']);
}

return $action;
}

if (isset($button['label'])) {
$action->setLabel($button['label']);
}

if (isset($button['dropdown']) && $button['dropdown']) {
$action->addCssClass('in-dropdown');
}

if (isset($button['html_attributes']) && $button['html_attributes']) {
$action->setHtmlAttributes($button['html_attributes']);
}

return $action;
}
);
);
}
}
}

@@ -390,16 +400,16 @@ abstract class AbstractAdminController extends EaAbstractCrudController
}

public function createIndexQueryBuilder(
SearchDto $searchDto,
EntityDto $entityDto,
FieldCollection $fields,
FilterCollection $filters
SearchDto $searchDto,
EntityDto $entityDto,
FieldCollection $fields,
FilterCollection $filters
): QueryBuilder {
$queryBuilder = parent::createIndexQueryBuilder(
$searchDto,
$entityDto,
$fields,
$filters
$searchDto,
$entityDto,
$fields,
$filters
);

if ($this->isInstanceOf(TreeInterface::class)) {
@@ -417,13 +427,12 @@ abstract class AbstractAdminController extends EaAbstractCrudController
}

public function createSortQueryBuilder(
SearchDto $searchDto,
EntityDto $entityDto,
FieldCollection $fields,
FilterCollection $filters
SearchDto $searchDto,
EntityDto $entityDto,
FieldCollection $fields,
FilterCollection $filters
): QueryBuilder {

$queryBuilder = $this->createIndexQueryBuilder($searchDto,$entityDto,$fields,$filters);
$queryBuilder = $this->createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters);

return $queryBuilder;
}

+ 13
- 7
Controller/Ticket/TicketAdminController.php Visa fil

@@ -32,16 +32,16 @@ abstract class TicketAdminController extends AbstractAdminController
DateField::new('createdAt')->setFormat('short')
->hideOnForm(),
TextField::new('visitorFirstName')
->setTemplatePath('@LcSov/admin/ticket/index-username.html.twig')
->setTemplatePath('@LcSov/admin/ticket/index_username.html.twig')
->hideOnForm(),
TextField::new('visitorEmail')
->setTemplatePath('@LcSov/admin/ticket/index-email.html.twig')
->setTemplatePath('@LcSov/admin/ticket/index_email.html.twig')
->hideOnForm(),
AssociationField::new('user')
->hideOnIndex(),
TextField::new('subject'),
TextField::new('lastMessage')
->setTemplatePath('@LcSov/admin/ticket/index-lastmessage.html.twig')
->setTemplatePath('@LcSov/admin/ticket/index_lastmessage.html.twig')
->hideOnForm(),
ChoiceField::new('type')
->autocomplete()
@@ -60,7 +60,7 @@ abstract class TicketAdminController extends AbstractAdminController
'entity.Ticket.fields.statusOptions.' . Ticket::TICKET_STATUS_CLOSED => Ticket::TICKET_STATUS_CLOSED,
]
)
->setTemplatePath('@LcSov/admin/ticket/index-status.html.twig')
->setTemplatePath('@LcSov/admin/ticket/index_status.html.twig')
->hideOnForm(),
];
}
@@ -68,17 +68,23 @@ abstract class TicketAdminController extends AbstractAdminController
// public function configureCrud(Crud $crud): Crud
// {
// $crud
// ->overrideTemplate('layout', '@LcSov/admin/layout.html.twig');
//// ->overrideTemplate('layout', '@LcCaracole/adminlte/layout.html.twig');
// ->overrideTemplate('crud/detail', '@LcSov/admin/ticket/detail.html.twig');
//
// return parent::configureCrud($crud);
// }

public function configureActions(Actions $actions): Actions
{
// $actions
// ->add(Crud::PAGE_INDEX, Action::DETAIL);
// $actions = parent::configureActions($actions);
// $actions
// ->remove(Crud::PAGE_INDEX, Action::EDIT);
// return $actions;

$actions
->add(Crud::PAGE_INDEX, Action::DETAIL);
// ->remove(Crud::PAGE_EDIT, Action::EDIT);
// ->remove(Crud::PAGE_INDEX, Action::EDIT);
return parent::configureActions($actions);
}
}

+ 6
- 0
Resources/translations/admin.fr.yaml Visa fil

@@ -27,6 +27,7 @@ action:
sort: Ordonner
delete: Supprimer
change: Changer
detail: Voir
index_children: Afficher les enfants
index_parent: Retour au parent
back_index: Retour à la liste
@@ -51,12 +52,17 @@ entity:
label: Page
label_plurial: Pages
Ticket:
status:
open: Ouvert
being-processed: En attente
closed: Fermé
fields:
visitorFirstName: Nom
visitorLastName: Prénom
visitorEmail: E-mail
subject: Sujet
type: Type
lastMessage: Dernier message
typeOptions:
general-question: Questions générales
technical-problem: Problème technique

+ 0
- 8
Resources/views/admin/ticket/index-status.html.twig Visa fil

@@ -1,8 +0,0 @@
{% set status = entity.instance.status %}
{% if status == 'open' %}
<span class="badge badge-success">{{ entity.instance.status|trans }}</span>
{% elseif status == 'being-processed' %}
<span class="badge badge-warning">{{ entity.instance.status|trans }}</span>
{% elseif status == 'closed' %}
<span class="badge badge-danger">{{ entity.instance.status|trans }}</span>
{% endif %}

Resources/views/admin/ticket/index-email.html.twig → Resources/views/admin/ticket/index_email.html.twig Visa fil


Resources/views/admin/ticket/index-lastmessage.html.twig → Resources/views/admin/ticket/index_lastmessage.html.twig Visa fil


+ 10
- 0
Resources/views/admin/ticket/index_status.html.twig Visa fil

@@ -0,0 +1,10 @@
{% import "@LcSov/adminlte/macro/badge.html.twig" as macro %}

{% set status = entity.instance.status %}
{% if status == 'open' %}
{{ macro.badge_success(('entity.Ticket.status.'~entity.instance.status)|trans({},'admin')) }}
{% elseif status == 'being-processed' %}
{{ macro.badge_warning(('entity.Ticket.status.'~entity.instance.status)|trans({},'admin')) }}
{% elseif status == 'closed' %}
{{ macro.badge_danger(('entity.Ticket.status.'~entity.instance.status)|trans({},'admin')) }}
{% endif %}

Resources/views/admin/ticket/index-username.html.twig → Resources/views/admin/ticket/index_username.html.twig Visa fil


+ 15
- 0
Resources/views/adminlte/macro/badge.html.twig Visa fil

@@ -0,0 +1,15 @@
{% macro badge_success(title) %}
{{ _self.badge('success', title) }}
{% endmacro %}

{% macro badge_warning(title) %}
{{ _self.badge('warning', title) }}
{% endmacro %}

{% macro badge_danger(title) %}
{{ _self.badge('danger', title) }}
{% endmacro %}

{% macro badge(status, title) %}
<span class="badge badge-{{ status }}">{{ title }}</span>
{% endmacro %}

Laddar…
Avbryt
Spara