nineskeletor/templates/Item/list.html.twig

231 lines
9.5 KiB
Twig

{% extends 'base.html.twig' %}
{% block localstyle %}
<style>
</style>
{% endblock %}
{% block body %}
<h1 class="page-header">
Gestion des Items
</h1>
<p>
<a href="{{ path('app_'~access~'_item_submit') }}" class="btn btn-success">Ajouter un Item</a>
<a href="{{ path('app_'~access~'_itemcategory_submit') }}" class="btn btn-success">Ajouter une Categorie</a>
</p>
<div class="row">
<div class="col-md-9 list-categorysitem">
{% for itemcategory in itemcategorys %}
<div class="card list-categoryitem mb-3" data-itemcategory-id="{{ itemcategory.id }}">
<div class="card-header">
<h3 class="m-0">
<a href="{{ path('app_'~access~'_itemcategory_update', { id: itemcategory.id }) }}">
<small><i class="fa fa-arrows-v" style="display: inline-block; margin-top: -26px;"></i></small>
{{ itemcategory.label }}
</a>
</h2>
</div>
<div class="card-body items-list">
{% for item in itemcategory.items %}
<div class="item item-medium
{% for group in item.groups %}{{ ' group-' ~ group.id }}{% endfor %}
{% for role in item.roles %}{{ ' group-' ~ role }}{% endfor %}"
data-item-id="{{ item.id }}" style="background-color: {{ item.color ? item.color : "var(--colorbgbodydark)" }};">
<div class="item-container">
<div class="item-content">
<a class="item-link" href="{{ path('app_'~access~'_item_update', {"id": item.id}) }}">
{% if item.icon %}
<img height="35" src="{{ path('app_minio_image',{file:item.icon.label}) }}">
{% else %}
<img height="35" src="{{ path('app_minio_image',{file:"icon/icon_pin.png"}) }}">
{% endif %}
<div class="item-title">
<h3 >{{ item.title }}</h3>
<div class="item-subtitle">{{ item.subtitle|nl2br }}</div>
</div>
</a>
<div class="item-action">
<a style="display:none"><i class="item-info fas fa-circle-info"></i></a>
</div>
</div>
<div class="item-description hide">{{ item.content|raw }}</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endfor %}
</div>
<div class="col-md-3">
<div class="card">
<div class="card-header">
<i class="fa fa-filter"></i>
Afficher par Rôle
</div>
<ul id="group-filter" class="list-group list-group-flush">
<a class="active list-group-item" id="allrole" style="cursor:pointer">
<i class="fa fa-users"></i>
Toutes les Rôles
<span class="badge bg-success float-end"></span>
</a>
<a class="list-group-item" data-role="ROLE_ANONYME" style="cursor:pointer">
<i class="fa fa-user"></i>
Visiteur
<span class="badge bg-success float-end"></span>
</a>
<a class="list-group-item" data-role="ROLE_USER" style="cursor:pointer">
<i class="fa fa-user"></i>
Utilisateur
<span class="badge bg-success float-end"></span>
</a>
<a class="list-group-item" data-role="ROLE_MANAGER" style="cursor:pointer">
<i class="fa fa-user"></i>
Manager
<span class="badge bg-success float-end"></span>
</a>
<a class="list-group-item" data-role="ROLE_MASTER" style="cursor:pointer">
<i class="fa fa-user"></i>
Master
<span class="badge bg-success float-end"></span>
</a>
<a class="list-group-item" data-role="ROLE_MODO" style="cursor:pointer">
<i class="fa fa-user"></i>
Modérateur
<span class="badge bg-success float-end"></span>
</a>
<a class="list-group-item" data-role="ROLE_ADMIN" style="cursor:pointer">
<i class="fa fa-user"></i>
Administrateur
<span class="badge bg-success float-end"></span>
</a>
</ul>
</div>
<div class="card mt-3">
<div class="card-header">
<i class="fa fa-filter"></i>
Afficher par Groupe
</div>
<ul id="group-filter" class="list-group list-group-flush">
<a class="active list-group-item" style="cursor:pointer" id="allgroup">
<i class="fa fa-users"></i>
Toutes les Groupes
<span class="badge bg-success float-end"></span>
</a>
{% for group in groups %}
<a class="list-group-item" data-role="{{ group.id }}" style="cursor:pointer">
<i class="fa fa-user"></i>
{{ group.label }}
<span class="badge bg-success float-end">{{ group.items|length }}</span>
</a>
{% endfor %}
</ul>
</div>
</div>
</div>
{% endblock %}
{% block localscript %}
<script>
$( function() {
var changes = false;
$("#allrole").children("span").html($('.grid-item').length);
$("#allgroup").children("span").html($('.grid-item').length);
$("a[data-role='ROLE_ANONYME']").children("span").html($('.group-ROLE_ANONYME').length);
$("a[data-role='ROLE_USER']").children("span").html($('.group-ROLE_USER').length);
$("a[data-role='ROLE_MANAGER']").children("span").html($('.group-ROLE_MANAGER').length);
$("a[data-role='ROLE_MASTER']").children("span").html($('.group-ROLE_MASTER').length);
$("a[data-role='ROLE_MODO']").children("span").html($('.group-ROLE_MODO').length);
$("a[data-role='ROLE_ADMIN']").children("span").html($('.group-ROLE_ADMIN').length);
function updateItems() {
// Pour chaque catégorie
$('.list-categoryitem').each(function(i) {
// On récupère id et order
var categoryid = $(this).data('itemcategory-id');
$(this).find('input[name="itemcategory[rowOrder][]"]').val(i);
// Mise à jour en base de l'order
$.ajax({
method: "POST",
url: "{{ path('app_'~access~'_itemcategory_order') }}",
data: {
id:categoryid,
order:i
}
});
// Pour chaque item de la catégorie
$(this).find('.item').each(function(j) {
// On récupère les id
var itemid = $(this).data('item-id');
// Mise à jour en base de l'order
$.ajax({
method: "POST",
url: "{{ path('app_'~access~'_item_order') }}",
data: {
id:itemid,
categoryid:categoryid,
order:j
}
});
});
});
}
$( ".items-list" ).sortable({
connectWith: ".items-list",
placeholder: "item placeholder",
update: updateItems
});
$( ".list-categorysitem" ).sortable({
axis: "y",
placeholder: "category-list placeholder",
update: updateItems
});
$('a.list-group-item').click(function(){
$('#group-filter a.list-group-item').removeClass('active');
$(this).addClass('active');
console.log('.group-'+$(this).attr('data-role'));
if($(this).attr('data-role')){
$('.item').hide();
$('.group-'+$(this).attr('data-role')).show();
} else {
$('.item').show();
}
});
});
</script>
{% endblock %}