Guillaume hace 4 años
padre
commit
dc7c382b44
Se han modificado 8 ficheros con 135 adiciones y 80 borrados
  1. +3
    -2
      ShopBundle/Controller/Admin/AdminController.php
  2. +2
    -1
      ShopBundle/Resources/public/css/backend/custom.css
  3. +3
    -0
      ShopBundle/Resources/public/js/backend/script/default/init-common.js
  4. +5
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  5. +3
    -4
      ShopBundle/Resources/views/backend/default/action.html.twig
  6. +1
    -1
      ShopBundle/Resources/views/backend/default/layout.html.twig
  7. +9
    -1
      ShopBundle/Resources/views/backend/default/list.html.twig
  8. +109
    -71
      ShopBundle/Resources/views/backend/default/sortable.html.twig

+ 3
- 2
ShopBundle/Controller/Admin/AdminController.php Ver fichero

@@ -214,12 +214,13 @@ class AdminController extends EasyAdminController
$latsPos = $elm['position'];

}
//die();
//to do récupérer les élements hors ligne et incrémenter position
foreach ($repo->findBy(array('status'=> false)) as $offlineEntity) {
/*foreach ($repo->findBy(array('status'=> false)) as $offlineEntity) {
$latsPos++;
$offlineEntity->setPosition($latsPos);
$this->em->persist($offlineEntity);
}
}*/
$this->em->flush();

$this->addFlash('success', 'Position modifié', array(), 'mweb');

+ 2
- 1
ShopBundle/Resources/public/css/backend/custom.css Ver fichero

@@ -13,7 +13,7 @@ table.fixedHeader-floating{margin-top: 0px !important;}
table th.sorting_asc, table th.sorting_desc{border-top:3px solid var(--success);}
table th.filtered{border-top:3px solid var(--primary);}

td.actions{white-space: nowrap;}
td.actions{white-space: nowrap; text-align: right;}


/************************ form error *********************/
@@ -56,6 +56,7 @@ td.actions{white-space: nowrap;}

/* Général */
.btn.btn-primary.action-save{float: right;}
.button-action .btn{margin-left: 10px;}

.input-group-text {
padding: 0.250rem .75rem ;

+ 3
- 0
ShopBundle/Resources/public/js/backend/script/default/init-common.js Ver fichero

@@ -83,6 +83,9 @@ function setSelect2($select) {
minimumResultsForSearch: 8
};

if ($select.data('width')) {
options.width = 'auto'
}
if ($select.find('option[value=""]')) {
options.placeholder = $select.find('option[value=""]').html()
}

+ 5
- 0
ShopBundle/Resources/translations/lcshop.fr.yaml Ver fichero

@@ -5,6 +5,9 @@ list:
nbResultsOnline: Total d'élements en ligne
nbResultsOffline: Total d'élements hors ligne
nbResultsDeleted: Total d'élements supprimé
listChildren: Afficher les enfants
edit: Éditer
delete: Supprimer
product:
title: Titre
titleHelp: Un message d'aide
@@ -34,6 +37,8 @@ field:
placeholder: Choisissez une option
id: Id
status: En ligne
position: Position
createdAt: Date de création
supplier: Producteur
title: Titre
titleHelp: Ceci est une texte d'aide, utilises <i>le nom du champ</i>Help pour en ajouter un

+ 3
- 4
ShopBundle/Resources/views/backend/default/action.html.twig Ver fichero

@@ -1,7 +1,6 @@
{#{{ dump(action) }}#}
<a class="btn {{ is_dropdown|default(false) ? 'dropdown-item' }} {{ action.css_class|default('btn-default') }}" title="{{ action.title|default('') is empty ? '' : action.title|trans(trans_parameters, translation_domain) }}" href="{{ action_href }}" target="{{ action.target }}">
<a class="btn {{ is_dropdown|default(false) ? 'dropdown-item' }} {{ action.css_class|default('btn-default') }}" data-toggle="tooltip"
title="{{ action.label|trans(arguments = trans_parameters|merge({ '%entity_id%': item_id }), domain = translation_domain) }}"
href="{{ action_href }}" target="{{ action.target }}">
{%- if action.icon %}<i class="fa fa-fw fa-{{ action.icon }}"></i> {% endif -%}
{%- if action.label is defined and not action.label is empty -%}
{{ action.label|trans(arguments = trans_parameters|merge({ '%entity_id%': item_id }), domain = translation_domain) }}
{%- endif -%}
</a>

+ 1
- 1
ShopBundle/Resources/views/backend/default/layout.html.twig Ver fichero

@@ -105,7 +105,7 @@
<label for="switch-merchant"><i
class="fa fa-store"></i> {{ 'action.switchMerchant'|trans() }} :
</label>
<select id="switch-merchant" class="select2" name="id_merchant">
<select id="switch-merchant" class="select2" data-width="auto" name="id_merchant">
{% for merchant in merchants %}
<option value="{{ merchant.id }}"
{% if current_merchant and current_merchant.id == merchant.id %}selected="selected"{% endif %}>

+ 9
- 1
ShopBundle/Resources/views/backend/default/list.html.twig Ver fichero

@@ -91,9 +91,17 @@
{% block new_action %}
<div class="button-action">
<a class="float-right {{ _action.css_class|default('') }}" href="{{ path('easyadmin', _request_parameters|merge({ action: _action.name })) }}" target="{{ _action.target }}">
{% if _action.icon %}<i class="fa fa-fw fa-{{ _action.icon }}"></i>{% endif %}
<i class="fa fa-fw fa-pencil-alt"></i>
{{ _action.label is defined and not _action.label is empty ? _action.label|trans(_trans_parameters) }}
</a>

{% if _entity_config['list']['edit_position'] is defined %}
<a class="float-right btn btn-success action-sort"
href="{{ path('easyadmin', _request_parameters|merge({ action: 'sort' })) }}"
target="{{ _action.target }}">
<i class="fa fa-sort"></i> Modifier position
</a>
{% endif %}
</div>
{% endblock new_action %}
{% endif %}

+ 109
- 71
ShopBundle/Resources/views/backend/default/sortable.html.twig Ver fichero

@@ -1,4 +1,4 @@
{% extends '@EasyAdmin/default/list.html.twig' %}
{% extends '@LcShop/backend/default/list.html.twig' %}

{% block content_title %}
Édition des positions
@@ -14,80 +14,118 @@
{% set _list_item_actions = easyadmin_get_actions_for_list_item(_entity_config.name) %}

{{ form_start(postion_form) }}
<div class="row">
<div class="col-12">
<div class="card card-outline card-primary">

<table class="table datagrid lc-sortable" data-parent-position="{{ entity is not null ? entity.position : ''}}">
<thead>
{% block table_head %}
<tr>
<th></th>
{% for field, metadata in _fields_visible_by_user %}
{% set isSortingField = (metadata.property == app.request.get('sortField')) or ('association' == metadata.type and app.request.get('sortField') starts with metadata.property ~ '.') %}
{% set nextSortDirection = isSortingField ? (app.request.get('sortDirection') == 'DESC' ? 'ASC' : 'DESC') : 'DESC' %}
{% set _column_label = metadata.label|trans(_trans_parameters) %}
{% set _column_icon = isSortingField ? (nextSortDirection == 'DESC' ? 'fa-arrow-up' : 'fa-arrow-down') : 'fa-sort' %}

<th class="{{ isSortingField ? 'sorted' }} {{ metadata.virtual ? 'virtual' }} {{ metadata.dataType|lower }} {{ metadata.css_class }}" {{ easyadmin_config('design.rtl') ? 'dir="rtl"' }}>
<span>{{ _column_label|raw }}</span>
</th>
{% endfor %}

</tr>
{% endblock table_head %}
</thead>

<tbody>
{% block table_body %}
{% for item in paginator.currentPageResults %}
{% if not easyadmin_is_granted(_entity_config.list.item_permission, item) %}
{% set _number_of_hidden_results = _number_of_hidden_results + 1 %}
{% else %}
{# the empty string concatenation is needed when the primary key is an object (e.g. an Uuid object) #}
{% set _item_id = '' ~ attribute(item, _entity_config.primary_key_field_name) %}
<tr class="lc-draggable" data-id="{{ _item_id }}">
<td>
<i class="fa fa-fw fa-sort"></i>
</td>

{% for field, metadata in _fields_visible_by_user %}
{% set isSortingField = metadata.property == app.request.get('sortField') %}
{% set _column_label = (metadata.label ?: field|humanize)|trans(_trans_parameters) %}

<td class="{{ isSortingField ? 'sorted' }} {{ metadata.dataType|lower }} {{ metadata.css_class }}" {{ easyadmin_config('design.rtl') ? 'dir="rtl"' }}>
{{ easyadmin_render_field_for_list_view(_entity_config.name, item, metadata) }}
</td>
{% endfor %}

</tr>
{% endif %}
{% else %}
<tr>
<td class="no-results" colspan="{{ _fields_visible_by_user|length + 1 }}">
{{ 'search.no_results'|trans(_trans_parameters, 'EasyAdminBundle') }}
</td>
</tr>
{% endfor %}

{% if _number_of_hidden_results > 0 %}
<tr class="datagrid-row-empty">
<td class="text-center" colspan="{{ _fields_visible_by_user|length + 1 }}">
<span class="datagrid-row-empty-message"><i
class="fa fa-lock mr-1"></i> {{ 'security.list.hidden_results'|trans({}, 'EasyAdminBundle') }}</span>
</td>
</tr>
{% endif %}
{% endblock table_body %}
</tbody>
</table>
<div style="display: none;">
{{ form_row(postion_form.entities) }}

{{ form_rest(postion_form) }}
<div class="card-body p-0">

<table class="table lc-sortable"
data-parent-position="{{ entity is not null ? entity.position : '' }}">
<thead>
{% block table_head %}
<tr>
<th></th>
{% for field, metadata in _fields_visible_by_user %}
{% set isSortingField = (metadata.property == app.request.get('sortField')) or ('association' == metadata.type and app.request.get('sortField') starts with metadata.property ~ '.') %}
{% set nextSortDirection = isSortingField ? (app.request.get('sortDirection') == 'DESC' ? 'ASC' : 'DESC') : 'DESC' %}
{% set _column_label = metadata.label|trans(_trans_parameters) %}
{% set _column_icon = isSortingField ? (nextSortDirection == 'DESC' ? 'fa-arrow-up' : 'fa-arrow-down') : 'fa-sort' %}

<th class="{{ isSortingField ? 'sorted' }} {{ metadata.virtual ? 'virtual' }} {{ metadata.dataType|lower }} {{ metadata.css_class }}" {{ easyadmin_config('design.rtl') ? 'dir="rtl"' }}>
<span>{{ _column_label|raw }}</span>
</th>
{% endfor %}

</tr>
{% endblock table_head %}
</thead>

<tbody>
{% block table_body %}
{% for item in paginator.currentPageResults %}
{% if not easyadmin_is_granted(_entity_config.list.item_permission, item) %}
{% set _number_of_hidden_results = _number_of_hidden_results + 1 %}
{% else %}
{# the empty string concatenation is needed when the primary key is an object (e.g. an Uuid object) #}
{% set _item_id = '' ~ attribute(item, _entity_config.primary_key_field_name) %}
<tr class="lc-draggable" data-id="{{ _item_id }}">
<td>
<i class="fa fa-fw fa-sort"></i>
</td>

{% for field, metadata in _fields_visible_by_user %}
{% set isSortingField = metadata.property == app.request.get('sortField') %}
{% set _column_label = (metadata.label ?: field|humanize)|trans(_trans_parameters) %}

<td class="{{ isSortingField ? 'sorted' }} {{ metadata.dataType|lower }} {{ metadata.css_class }}" {{ easyadmin_config('design.rtl') ? 'dir="rtl"' }}>
{{ easyadmin_render_field_for_list_view(_entity_config.name, item, metadata) }}
</td>
{% endfor %}

</tr>
{% endif %}
{% else %}
<tr>
<td class="no-results" colspan="{{ _fields_visible_by_user|length + 1 }}">
{{ 'search.no_results'|trans(_trans_parameters, 'EasyAdminBundle') }}
</td>
</tr>
{% endfor %}

{# {% if _number_of_hidden_results > 0 %}
<tr class="datagrid-row-empty">
<td class="text-center" colspan="{{ _fields_visible_by_user|length + 1 }}">
<span class="datagrid-row-empty-message"><i
class="fa fa-lock mr-1"></i> {{ 'security.list.hidden_results'|trans({}, 'EasyAdminBundle') }}</span>
</td>
</tr>
{% endif %}#}
{% endblock table_body %}
</tbody>
</table>
<div style="display: none;">
{{ form_row(postion_form.entities) }}

{{ form_rest(postion_form) }}
</div>

</div>
</div>
</div>
</div>

<div class="form-actions">
<button type="submit" class="btn btn-primary"> Sauvegarder</button>
<div class="card">
<div class="card-footer">
<div class="form-actions">
{% set _action = easyadmin_get_action_for_edit_view('list', _entity_config.name) %}

<div class="button-action">
<a class=" {{ _action.css_class|default('') }}" href="{{ path('easyadmin', _request_parameters|merge({ action: _action.name })) }}" target="{{ _action.target }}">
{{ _action.label is defined and not _action.label is empty ? _action.label|trans(_trans_parameters) }}
</a>

<button type="submit" class="btn btn-primary float-right"> Sauvegarder</button>
</div>

</div>
</div>
</div>
{{ form_end(postion_form) }}

{% endblock main %}
{% endblock main %}

{% block head_stylesheets %}
{{ parent() }}

{% endblock %}
{% block plugin_javascript %}
{{ parent() }}

<script src="{{ asset('bundles/lcshop/js/backend/plugin/jquery-ui/jquery-ui.min.js') }}"></script>
{% endblock %}

{% block script_javascript %}
{{ parent() }}
<script src="{{ asset('bundles/lcshop/js/backend/script/default/init-sort.js') }}"></script>
{% endblock %}

Cargando…
Cancelar
Guardar