@@ -9,18 +9,54 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | |||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController as EaAbstractCrudController; | |||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | |||
use Lc\SovBundle\Doctrine\Extension\TranslatableInterface; | |||
use Symfony\Component\HttpFoundation\RequestStack; | |||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | |||
abstract class AbstractCrudController extends EaAbstractCrudController | |||
{ | |||
protected $session; | |||
protected $request; | |||
public function __construct(SessionInterface $session, RequestStack $request) | |||
{ | |||
$this->session = $session; | |||
$this->request = $request; | |||
} | |||
public function configureActions(Actions $actions): Actions | |||
{ | |||
/* Translatable */ | |||
if (in_array(TranslatableInterface::class, class_implements($this->getEntityFqcn()))) { | |||
$actions->update( | |||
Crud::PAGE_INDEX, | |||
Action::EDIT, | |||
function (Action $action) { | |||
return $action->setTemplatePath('@LcSov/adminlte/crud/action/translatable.html.twig'); | |||
$action->setTemplatePath('@LcSov/adminlte/crud/action/translatable.html.twig'); | |||
return $action; | |||
} | |||
); | |||
} | |||
/* Boutons des actions dans les listes */ | |||
$listButtonsStyleArray = [ | |||
Action::EDIT => [ | |||
'class' => 'btn btn-sm btn-primary', | |||
'icon' => 'edit' | |||
], | |||
Action::DELETE => [ | |||
'class' => 'btn btn-sm btn-default', | |||
'icon' => 'trash' | |||
] | |||
]; | |||
foreach($listButtonsStyleArray as $actionName => $button) { | |||
$actions->update( | |||
Crud::PAGE_INDEX, | |||
$actionName, | |||
function (Action $action) use ($button) { | |||
$action->setCssClass($button['class']); | |||
$action->setIcon('fa fa-'.$button['icon'])->setLabel(false); | |||
return $action; | |||
} | |||
); | |||
} | |||
@@ -30,45 +66,28 @@ abstract class AbstractCrudController extends EaAbstractCrudController | |||
public function configureCrud(Crud $crud): Crud | |||
{ | |||
return $crud | |||
->overrideTemplates( | |||
[ | |||
'layout' => '@LcSov/adminlte/layout.html.twig', | |||
'main_menu' => '@LcSov/adminlte/block/menu.html.twig', | |||
'crud/index' => '@LcSov/adminlte/crud/index.html.twig', | |||
'crud/paginator' => '@LcSov/adminlte/crud/paginator.html.twig', | |||
'crud/edit' => '@LcSov/adminlte/crud/edit.html.twig', | |||
'crud/new' => '@LcSov/adminlte/crud/new.html.twig', | |||
] | |||
) | |||
->setFormThemes([ | |||
'@LcSov/adminlte/crud/form_theme.html.twig', | |||
'@FOSCKEditor/Form/ckeditor_widget.html.twig' | |||
]); | |||
} | |||
$crud = parent::configureCrud($crud);; | |||
$this->setMaxResults($crud); | |||
return $crud; | |||
} | |||
/*public function configureAssets(Assets $assets): Assets | |||
public function setMaxResults(Crud $crud) | |||
{ | |||
return $assets | |||
// adds the CSS and JS assets associated to the given Webpack Encore entry | |||
// it's equivalent to calling encore_entry_link_tags('...') and encore_entry_script_tags('...') | |||
//->addWebpackEncoreEntry('admin-app') | |||
$entityClass = $this->getEntityFqcn(); | |||
$paramListMaxResults = 'listMaxResults'; | |||
$paramSessionListMaxResults = $entityClass . '-' . $paramListMaxResults; | |||
$requestListMaxResults = $this->request->getCurrentRequest()->get($paramListMaxResults); | |||
// the argument of these methods is passed to the asset() Twig function | |||
// CSS assets are added just before the closing </head> element | |||
// and JS assets are added just before the closing </body> element | |||
->addJsFile('bundles/lc_sov/js/utils.js'); | |||
}*/ | |||
if ($requestListMaxResults) { | |||
$this->session->set($paramSessionListMaxResults, $requestListMaxResults); | |||
} | |||
$maxResults = $this->session->get($paramSessionListMaxResults) ? $this->session->get( | |||
$paramSessionListMaxResults | |||
) : 30; | |||
/* | |||
public function configureFields(string $pageName): iterable | |||
{ | |||
return [ | |||
IdField::new('id'), | |||
TextField::new('title'), | |||
TextEditorField::new('description'), | |||
]; | |||
$crud->setPaginatorPageSize($maxResults); | |||
} | |||
*/ | |||
} |
@@ -74,7 +74,7 @@ class DashboardController extends AbstractDashboardController | |||
->overrideTemplates( | |||
[ | |||
'layout' => '@LcSov/adminlte/layout.html.twig', | |||
'main_menu' => '@LcSov/adminlte/menu.html.twig', | |||
'main_menu' => '@LcSov/adminlte/block/menu.html.twig', | |||
'crud/index' => '@LcSov/adminlte/crud/index.html.twig', | |||
'crud/paginator' => '@LcSov/adminlte/crud/paginator.html.twig', | |||
'crud/edit' => '@LcSov/adminlte/crud/edit.html.twig', |
@@ -1,22 +1,7 @@ | |||
import 'jquery'; | |||
global.$ = global.jQuery = $; | |||
import './common.scss'; | |||
import 'adminlte-js' ; | |||
import 'adminlte-plugin/bootstrap/js/bootstrap.min.js'; | |||
import log from './utils/log.js'; | |||
log('ncnnc'); | |||
$('#test22').modal('show'); | |||
//require('select2'); | |||
//require('adminlte'); | |||
//import 'adminltePlugin/bootstrap/js/bootstrap.min.js' | |||
///import 'admin-lte/dist/css/adminlte.min.css' ; | |||
//require('admin-lte-css') ; | |||
// import './common.js' ; | |||
import './utils/log.js'; |
@@ -1,7 +1,51 @@ | |||
@import "adminlte-css"; | |||
@import "fontawesome-css"; | |||
body{ | |||
/* global */ | |||
body { | |||
font-size: 0.9rem; | |||
} | |||
/* card */ | |||
.card { | |||
&.card-table { | |||
.card-header { | |||
border-bottom: 0px none ; | |||
font-size: 1.1rem ; | |||
} | |||
.card-body { | |||
padding: 0px ; | |||
table.table { | |||
margin-bottom: 0px ; | |||
tr { | |||
th { | |||
input.form-check-input { | |||
position: relative ; | |||
top: 0px ; | |||
} | |||
} | |||
td { | |||
padding: 3px 12px ; | |||
input.form-batch-checkbox { | |||
position: relative ; | |||
top: 4px ; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
.card-footer { | |||
background-color: white ; | |||
padding-top: 25px ; | |||
.nb-results { | |||
margin-bottom: 10px; | |||
} | |||
} | |||
} | |||
} |
@@ -1,8 +1,7 @@ | |||
export default function log(name) { | |||
function log(name) { | |||
try { | |||
return console.log(name); | |||
} catch (e) { | |||
return null; | |||
} | |||
} | |||
} |
@@ -11,4 +11,6 @@ | |||
//$('#test22').modal('show'); | |||
$('#test22').modal('show'); | |||
// start the Stimulus application |
@@ -0,0 +1,6 @@ | |||
{% if field.value %} | |||
<div class="badge badge-success">En ligne</div> | |||
{% else %} | |||
<div class="badge badge-danger">Hors ligne</div> | |||
{% endif %} |
@@ -44,141 +44,126 @@ | |||
{% set has_filters = filters|length > 0 %} | |||
{% set has_datagrid_tools = has_search or has_filters %} | |||
<div class="card"> | |||
<div class="card card-table card-outline card-primary"> | |||
<div class="card-header"> | |||
<div class="d-flex"> | |||
<div class="text-muted"> | |||
Show | |||
<div class="mx-2 d-inline-block"> | |||
<input type="text" class="form-control form-control-sm" value="8" size="3" | |||
aria-label="Invoices count" data-cip-id="cIPJQ342845640"> | |||
</div> | |||
entries | |||
</div> | |||
<div class="ms-auto text-muted"> | |||
Search: | |||
<div class="ms-2 d-inline-block"> | |||
<input type="text" class="form-control form-control-sm" aria-label="Search invoice" | |||
data-cip-id="cIPJQ342845641"> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="card-body border-bottom py-3"> | |||
<span data-toggle="tooltip" class="badge badge-light" data-original-title="Total" title="Total"> | |||
{{ paginator.numResults }} résultats | |||
</span> | |||
</div> | |||
<div class="table-responsive"> | |||
<table class="table card-table table-vcenter text-nowrap table-mobile-md table-striped"> | |||
<thead> | |||
{% block table_head %} | |||
<tr> | |||
{% if has_batch_actions %} | |||
<th class="w-1"><span><input type="checkbox" | |||
class="form-check-input m-0 align-middle form-batch-checkbox-all"></span> | |||
</th> | |||
{% endif %} | |||
<div class="card-body"> | |||
<div class="table-responsive"> | |||
<table class="table table-bordered table-hover table-striped"> | |||
<thead> | |||
{% block table_head %} | |||
{% set ea_sort_asc = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Option\\SortOrder::ASC') %} | |||
{% set ea_sort_desc = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Option\\SortOrder::DESC') %} | |||
{% for field in entities|first.fields ?? [] %} | |||
{% set is_sorting_field = ea.search.isSortingField(field.property) %} | |||
{% set next_sort_direction = is_sorting_field ? (ea.search.sortDirection(field.property) == ea_sort_desc ? ea_sort_asc : ea_sort_desc) : ea_sort_desc %} | |||
{% set column_icon = is_sorting_field ? (next_sort_direction == ea_sort_desc ? 'fa-arrow-up' : 'fa-arrow-down') : 'fa-sort' %} | |||
<th class="{{ is_sorting_field ? 'sorted' }} {{ field.isVirtual ? 'field-virtual' }} text-{{ field.textAlign }}" | |||
dir="{{ ea.i18n.textDirection }}"> | |||
{% if field.isSortable %} | |||
<a href="{{ ea_url({ page: 1, sort: { (field.property): next_sort_direction } }).includeReferrer() }}"> | |||
{{ field.label|raw }} <i class="fa fa-fw {{ column_icon }}"></i> | |||
</a> | |||
{% else %} | |||
<span>{{ field.label|raw }}</span> | |||
{% endif %} | |||
<tr> | |||
{% if has_batch_actions %} | |||
<th class=""><span><input type="checkbox" | |||
class="form-check-input m-0 align-middle form-batch-checkbox-all"></span> | |||
</th> | |||
{% endif %} | |||
{% set ea_sort_asc = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Option\\SortOrder::ASC') %} | |||
{% set ea_sort_desc = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Option\\SortOrder::DESC') %} | |||
{% for field in entities|first.fields ?? [] %} | |||
{% set is_sorting_field = ea.search.isSortingField(field.property) %} | |||
{% set next_sort_direction = is_sorting_field ? (ea.search.sortDirection(field.property) == ea_sort_desc ? ea_sort_asc : ea_sort_desc) : ea_sort_desc %} | |||
{% set column_icon = is_sorting_field ? (next_sort_direction == ea_sort_desc ? 'fa-arrow-up' : 'fa-arrow-down') : 'fa-sort' %} | |||
<th class="{{ is_sorting_field ? 'sorted' }} {{ field.isVirtual ? 'field-virtual' }} {% if field.textAlign %}text-{{ field.textAlign }}{% endif %}" | |||
dir="{{ ea.i18n.textDirection }}"> | |||
{% if field.isSortable %} | |||
<a href="{{ ea_url({ page: 1, sort: { (field.property): next_sort_direction } }).includeReferrer() }}"> | |||
{{ field.label|raw }} <i class="fa fa-fw {{ column_icon }}"></i> | |||
</a> | |||
{% else %} | |||
<span>{{ field.label|raw }}</span> | |||
{% endif %} | |||
</th> | |||
{% endfor %} | |||
<th class="w-1" {% if ea.crud.showEntityActionsAsDropdown %}width="10px"{% endif %} dir="{{ ea.i18n.textDirection }}"> | |||
<span class="sr-only">{{ 'action.entity_actions'|trans(ea.i18n.translationParameters, 'EasyAdminBundle') }}</span> | |||
</th> | |||
{% endfor %} | |||
<th {% if ea.crud.showEntityActionsAsDropdown %}width="10px"{% endif %} dir="{{ ea.i18n.textDirection }}"> | |||
<span class="sr-only">{{ 'action.entity_actions'|trans(ea.i18n.translationParameters, 'EasyAdminBundle') }}</span> | |||
</th> | |||
</tr> | |||
{% endblock table_head %} | |||
</thead> | |||
</tr> | |||
{% endblock table_head %} | |||
</thead> | |||
<tbody> | |||
{% block table_body %} | |||
{% for entity in entities %} | |||
{% if not entity.isAccessible %} | |||
{% set some_results_are_hidden = true %} | |||
{% else %} | |||
<tr data-id="{{ entity.primaryKeyValueAsString }}"> | |||
{% if has_batch_actions %} | |||
<td><input type="checkbox" class="form-batch-checkbox" | |||
value="{{ entity.primaryKeyValue }}"></td> | |||
{% endif %} | |||
{% for field in entity.fields %} | |||
<td class="{{ field.property == sort_field_name ? 'sorted' }} text-{{ field.textAlign }} {{ field.cssClass }}" | |||
dir="{{ ea.i18n.textDirection }}"> | |||
{{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }} | |||
</td> | |||
{% endfor %} | |||
{% block entity_actions %} | |||
<td class="actions"> | |||
{% if not ea.crud.showEntityActionsAsDropdown %} | |||
{% for action in entity.actions %} | |||
{{ include(action.templatePath, { action: action, entity: entity, isIncludedInDropdown: ea.crud.showEntityActionsAsDropdown }, with_context = false) }} | |||
{% endfor %} | |||
{% else %} | |||
<div class="dropdown dropdown-actions"> | |||
<a class="dropdown-toggle btn btn-secondary btn-sm" href="#" | |||
role="button" data-toggle="dropdown" aria-haspopup="true" | |||
aria-expanded="false"> | |||
<i class="fa fa-fw fa-ellipsis-h"></i> | |||
</a> | |||
<div class="dropdown-menu dropdown-menu-right"> | |||
{% for action in entity.actions %} | |||
{{ include(action.templatePath, { action: action, isIncludedInDropdown: ea.crud.showEntityActionsAsDropdown }, with_context = false) }} | |||
{% endfor %} | |||
</div> | |||
</div> | |||
{% endif %} | |||
</td> | |||
{% endblock entity_actions %} | |||
</tr> | |||
<tbody> | |||
{% block table_body %} | |||
{% for entity in entities %} | |||
{% if not entity.isAccessible %} | |||
{% set some_results_are_hidden = true %} | |||
{% endif %} | |||
{% else %} | |||
<tr data-id="{{ entity.primaryKeyValueAsString }}"> | |||
{% if has_batch_actions %} | |||
<td><input type="checkbox" class="form-batch-checkbox" | |||
value="{{ entity.primaryKeyValue }}"></td> | |||
{% endif %} | |||
{% for field in entity.fields %} | |||
<td class="{{ field.property == sort_field_name ? 'sorted' }} text-{{ field.textAlign }} {{ field.cssClass }}" | |||
dir="{{ ea.i18n.textDirection }}"> | |||
{{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }} | |||
</td> | |||
{% endfor %} | |||
{% block entity_actions %} | |||
<td class="actions"> | |||
{% if not ea.crud.showEntityActionsAsDropdown %} | |||
{% for action in entity.actions %} | |||
{{ include(action.templatePath, { action: action, entity: entity, isIncludedInDropdown: ea.crud.showEntityActionsAsDropdown }, with_context = false) }} | |||
{% endfor %} | |||
{% else %} | |||
<div class="dropdown dropdown-actions"> | |||
<a class="dropdown-toggle btn btn-secondary btn-sm" href="#" | |||
role="button" data-toggle="dropdown" aria-haspopup="true" | |||
aria-expanded="false"> | |||
<i class="fa fa-fw fa-ellipsis-h"></i> | |||
</a> | |||
<div class="dropdown-menu dropdown-menu-right"> | |||
{% for action in entity.actions %} | |||
{{ include(action.templatePath, { action: action, isIncludedInDropdown: ea.crud.showEntityActionsAsDropdown }, with_context = false) }} | |||
{% endfor %} | |||
</div> | |||
</div> | |||
{% endif %} | |||
</td> | |||
{% endblock entity_actions %} | |||
<tr> | |||
<td class="no-results" colspan="100"> | |||
{{ 'datagrid.no_results'|trans(ea.i18n.translationParameters, 'EasyAdminBundle') }} | |||
</td> | |||
</tr> | |||
{% endfor %} | |||
{% if some_results_are_hidden %} | |||
<tr class="datagrid-row-empty"> | |||
<td class="text-center" colspan="{{ entities|first.fields|length + 1 }}"> | |||
<span class="datagrid-row-empty-message"><i | |||
class="fa fa-lock mr-1"></i> {{ 'datagrid.hidden_results'|trans({}, 'EasyAdminBundle') }}</span> | |||
</td> | |||
</tr> | |||
{% endif %} | |||
{% else %} | |||
<tr> | |||
<td class="no-results" colspan="100"> | |||
{{ 'datagrid.no_results'|trans(ea.i18n.translationParameters, 'EasyAdminBundle') }} | |||
</td> | |||
</tr> | |||
{% endfor %} | |||
{% if some_results_are_hidden %} | |||
<tr class="datagrid-row-empty"> | |||
<td class="text-center" colspan="{{ entities|first.fields|length + 1 }}"> | |||
<span class="datagrid-row-empty-message"><i | |||
class="fa fa-lock mr-1"></i> {{ 'datagrid.hidden_results'|trans({}, 'EasyAdminBundle') }}</span> | |||
</td> | |||
</tr> | |||
{% endif %} | |||
{% endblock table_body %} | |||
</tbody> | |||
</table> | |||
{% endblock table_body %} | |||
</tbody> | |||
</table> | |||
</div> | |||
</div> | |||
{% if entities|length > 0 %} | |||
<div class="card-footer d-flex align-items-center"> | |||
{% block paginator %} | |||
{{ include(ea.templatePath('crud/paginator')) }} | |||
{% endblock paginator %} | |||
<div class="card-footer"> | |||
<div class="row"> | |||
{% block paginator %} | |||
{{ include(ea.templatePath('crud/paginator')) }} | |||
{% endblock paginator %} | |||
</div> | |||
</div> | |||
{% endif %} | |||
</div> |
@@ -2,30 +2,44 @@ | |||
{# @var paginator \EasyCorp\Bundle\EasyAdminBundle\Orm\EntityPaginator #} | |||
{% trans_default_domain 'EasyAdminBundle' %} | |||
<p class="m-0 text-muted"> | |||
{{ 'paginator.results'|trans({'%count%': paginator.numResults})|raw }} | |||
</p> | |||
<ul class="pagination m-0 ms-auto"> | |||
<li class="page-item {{ not paginator.hasPreviousPage ? 'disabled' }}"> | |||
<a class="page-link" href="{{ not paginator.hasPreviousPage ? '#' : paginator.generateUrlForPage(paginator.previousPage) }}" {{ not paginator.hasPreviousPage ? 'aria-disabled="true"' }}> | |||
<i class="ti ti-arrow-left"></i> <span class="btn-label">{{ 'paginator.previous'|trans }}</span> | |||
</a> | |||
</li> | |||
<div class="col-sm-12 col-md-6"> | |||
{# <div class="nb-results"> | |||
{{ 'paginator.results'|trans({'%count%': paginator.numResults})|raw }} | |||
</div> #} | |||
<div class="items-per-page btn-group"> | |||
{% set itemsPerPage = [15,30,50,100,200] %} | |||
{% for itemPerPage in itemsPerPage %} | |||
{% set url = ea_url({listMaxResults: itemPerPage, page : "1"}) %} | |||
<a href="{{ url }}" | |||
class="btn btn-sm {{ paginator.pageSize == itemPerPage ? 'btn-secondary' : 'btn-default' }}">{{ itemPerPage }}</a> | |||
{% endfor %} | |||
</div> | |||
</div> | |||
{% for page in paginator.pageRange %} | |||
<li class="page-item {{ page == paginator.currentPage ? 'active' }} {{ page is null ? 'disabled' }}"> | |||
{% if page is null %} | |||
<span class="page-link">…</span> | |||
{% else %} | |||
<a class="page-link" href="{{ paginator.generateUrlForPage(page) }}">{{ page }}</a> | |||
{% endif %} | |||
</li> | |||
{% endfor %} | |||
<div class="col-sm-12 col-md-6"> | |||
<div class="float-sm-right"> | |||
<ul class="pagination"> | |||
<li class="page-item {{ not paginator.hasPreviousPage ? 'disabled' }}"> | |||
<a class="page-link" href="{{ not paginator.hasPreviousPage ? '#' : paginator.generateUrlForPage(paginator.previousPage) }}" {{ not paginator.hasPreviousPage ? 'aria-disabled="true"' }}> | |||
<i class="ti ti-arrow-left"></i> <span class="btn-label">{{ 'paginator.previous'|trans }}</span> | |||
</a> | |||
</li> | |||
<li class="page-item {{ not paginator.hasNextPage ? 'disabled' }}"> | |||
<a class="page-link" href="{{ not paginator.hasNextPage ? '#' : paginator.generateUrlForPage(paginator.nextPage) }}" {{ not paginator.hasNextPage ? 'aria-disabled="true"' }}> | |||
<span class="btn-label">{{ 'paginator.next'|trans }}</span> <i class="ti ti-arrow-right"></i> | |||
</a> | |||
</li> | |||
</ul> | |||
{% for page in paginator.pageRange %} | |||
<li class="page-item {{ page == paginator.currentPage ? 'active' }} {{ page is null ? 'disabled' }}"> | |||
{% if page is null %} | |||
<span class="page-link">…</span> | |||
{% else %} | |||
<a class="page-link" href="{{ paginator.generateUrlForPage(page) }}">{{ page }}</a> | |||
{% endif %} | |||
</li> | |||
{% endfor %} | |||
<li class="page-item {{ not paginator.hasNextPage ? 'disabled' }}"> | |||
<a class="page-link" href="{{ not paginator.hasNextPage ? '#' : paginator.generateUrlForPage(paginator.nextPage) }}" {{ not paginator.hasNextPage ? 'aria-disabled="true"' }}> | |||
<span class="btn-label">{{ 'paginator.next'|trans }}</span> <i class="ti ti-arrow-right"></i> | |||
</a> | |||
</li> | |||
</ul> | |||
</div> | |||
</div> |
@@ -114,10 +114,8 @@ | |||
</div><!-- /.col --> | |||
<div class="col-sm-6"> | |||
{% block page_actions_wrapper %} | |||
<div class="col-auto ms-auto d-print-none"> | |||
<div class="btn-list"> | |||
{% block page_actions %}{% endblock %} | |||
</div> | |||
<div class="btn-list float-sm-right"> | |||
{% block page_actions %}{% endblock %} | |||
</div> | |||
{% endblock %} | |||
</div><!-- /.col --> |