nineskeletor/templates/Page/pages.html.twig

462 lines
20 KiB
Twig
Raw Normal View History

2023-01-12 16:14:31 +01:00
2023-01-23 09:46:34 +01:00
{% extends 'base.html.twig' %}
2023-01-12 16:14:31 +01:00
{% block localstyle %}
2023-01-23 09:46:34 +01:00
<style>
body{
overflow-y:hidden
}
2023-01-12 16:14:31 +01:00
2023-01-23 09:46:34 +01:00
#page{
padding:0px !important;
overflow-y:hidden;
}
</Style>
{% endblock %}
2023-01-12 16:14:31 +01:00
2023-01-23 09:46:34 +01:00
{% block menuapp %}
<ul id="menupagesportal" class="navbar-nav">
{% for page in pagesportal %}
<li id="menupage-{{page.id}}" class="menupage nav-item" style="cursor:pointer">
<a onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','portal','{{page.pagecategory.id==1?page.toreload:true}}',null,'{{page.name}}')">
{% if page.fonticon %}
<i class="{{ page.fonticon }} fa-fw"></i>
{% elseif loop.first %}
<i class="fas fa-home fa-fw"></i>
{% else %}
<i class="fas fa-door-closed fa-fw"></i>
{% endif %}
{{ page.name }}
</a>
</li>
2023-01-12 16:14:31 +01:00
{% endfor %}
</ul>
2023-01-23 09:46:34 +01:00
<ul id="menupagesuser" class="navbar-nav">
2023-01-12 16:14:31 +01:00
{% for page in pagesuser %}
2023-01-23 09:46:34 +01:00
<li id="menupage-{{page.id}}" class="menupage nav-item" style="cursor:pointer">
<a onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','user','{{page.pagecategory.id==1?page.toreload:true}}',null,'{{page.name}}')">
{% if page.fonticon %}
<i class="{{ page.fonticon }} fa-fw"></i>
{% else %}
<i class="fas fa-user fa-fw"></i>
{% endif %}
{{ page.name }}
</a>
2023-01-12 16:14:31 +01:00
</li>
2023-01-23 09:46:34 +01:00
{% endfor %}
2023-01-12 16:14:31 +01:00
</ul>
2023-01-23 09:46:34 +01:00
{% if groups|length > 0 and groups|length < 10 %}
<ul id="menupagesgroup" class="navbar-nav">
{% for groupshared in groups %}
{% if groupshared.pagesshared|length > 1 %}
<li id="menugroup-{{groupshared.id}}" class="nav-item menupage dropdown">
<a class="dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-users fa-fw"></i>
{{ groupshared.label }}
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
{% endif %}
2023-01-12 16:14:31 +01:00
2023-01-23 09:46:34 +01:00
{% for page in groupshared.pagesshared %}
{% if groupshared.pagesshared|length == 1 %}
<li id="menupage-{{page.id}}" class="menupage nav-item">
{%endif%}
2023-01-12 16:14:31 +01:00
2023-01-23 09:46:34 +01:00
<a id="menupage-{{page.id}}" style="cursor:pointer" class="{{ groupshared.pagesshared|length > 1 ? "menupage dropdown-item" : "" }}" onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','group','{{page.pagecategory.id==1?page.toreload:true}}',{{groupshared.id}},'{{page.name}}')">
{% if page.fonticon %}
<i class="{{ page.fonticon }} fa-fw"></i>
{% else %}
<i class="fa fa-users fa-fw"></i>
{% endif %}
{{ page.name }}
</a>
2023-01-12 16:14:31 +01:00
2023-01-23 09:46:34 +01:00
{% if groupshared.pagesshared|length == 1 %}
</li>
{%endif%}
2023-01-12 16:14:31 +01:00
2023-01-23 09:46:34 +01:00
{% endfor %}
2023-01-12 16:14:31 +01:00
2023-01-23 09:46:34 +01:00
{% if groupshared.pagesshared|length > 1 %}
</div>
</li>
{% endif %}
{% endfor %}
</ul>
{% elseif groups|length > 0 %}
<ul id="menupagesgroup" class="navbar-nav">
<li class="nav-item" style="cursor:pointer">
<a onclick="$('#selmenu').modal('show');">
<i class="fa fa-users fa-fw"></i> Mes Groupes
</a>
</li>
</ul>
{% endif %}
2023-01-12 16:14:31 +01:00
{% endblock %}
2023-01-23 09:46:34 +01:00
{% block menuuser %}
2023-02-01 09:03:27 +01:00
{% if canadd and app.user %}
2023-01-23 09:46:34 +01:00
<a id="menusubmit" style="cursor:pointer" onclick="submitPage()" title='Ajouter une page'><i class='fa fa-plus fa-fw'></i></a>
2023-01-12 16:14:31 +01:00
{% endif %}
2023-01-23 09:46:34 +01:00
<a id="menuupdate" style="cursor:pointer;display:none" onclick="updatePage()" title='Modifier une page'><i class='fa fa-file fa-fw'></i></a>
<a id="menushare" style="cursor:pointer;display:none" onclick="sharePage()" title='Partager une page'><i class='fa fa-share-alt fa-fw'></i></a>
<a id="menudelete" style="cursor:pointer;display:none" onclick="deletePage()" title='Supprimer une page'><i class='fa fa-trash fa-fw'></i></a>
<a id="menuwidgetuser" class="btn-modal" style='cursor:pointer' data-modalid='selwidgetuser' title='Ajouter un widget'><i class='fa fa-cubes fa-fw'></i></a></li>
<a id="menuwidgetgroup" class="btn-modal" style='cursor:pointer' data-modalid='selwidgetgroup' title='Ajouter un widget'><i class='fa fa-cubes fa-fw'></i></a></li>
{% endblock %}
{% block body %}
<div id="pagecontainer"></div>
<div id="selmenu" class="modal fade" role="dialog">
<div class="modal-dialog modal-xl" role="document">
<div class="modal-content">
<div id="mymodalheader" class="modal-header">
<h4 class="modal-title">SELECTIONNER UNE PAGE</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div id="pagesportal" style="display:none">
{% for page in pagesportal %}
{%if loop.first %}
<div class="card mb-3">
<div class="card-header">PAGES PORTAIL</div>
<ul class="list-group list-group-flush">
{%endif%}
<a class="list-group-item" onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','portal','{{page.pagecategory.id==1?page.toreload:true}}',null,'{{page.name}}')">
{% if page.fonticon %}
<i class="{{ page.fonticon }} fa-fw"></i>
{% elseif loop.first %}
<i class="fas fa-home fa-fw"></i>
{% else %}
<i class="fas fa-door-closed fa-fw"></i>
{% endif %}
{{ page.name }}
</a>
2023-01-12 16:14:31 +01:00
2023-01-23 09:46:34 +01:00
{%if loop.last %}
</ul></div>
{%endif%}
{% endfor %}
2023-01-12 16:14:31 +01:00
</div>
2023-01-23 09:46:34 +01:00
<div id="pagesuser" style="display:none">
{% for page in pagesuser %}
{%if loop.first %}
<div class="card mb-3">
<div class="card-header">PAGES PERSONNEL</div>
<ul class="list-group list-group-flush">
{%endif%}
<a class="list-group-item" onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','user','{{page.pagecategory.id==1?page.toreload:true}}',null,'{{page.name}}')">
{% if page.fonticon %}
<i class="{{ page.fonticon }} fa-fw"></i>
{% else %}
<i class="fas fa-user fa-fw"></i>
{% endif %}
{{ page.name }}
</a>
{%if loop.last %}
</ul></div>
{%endif%}
{% endfor %}
</div>
2023-01-12 16:14:31 +01:00
2023-01-23 09:46:34 +01:00
<div id="pagesgroup">
{% for groupshared in groups %}
{%if loop.first %}
<div class="card mb-3">
<div class="card-header">PAGES GROUPE DE TRAVAIL</div>
<ul class="list-group list-group-flush">
{%endif%}
{% for page in groupshared.pagesshared %}
<a class="list-group-item" onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','group','{{page.pagecategory.id==1?page.toreload:true}}',{{groupshared.id}},'{{page.name}}')">
{% if page.fonticon %}
<i class="{{ page.fonticon }} fa-fw"></i>
{% else %}
<i class="fas fa-users fa-fw"></i>
{% endif %}
{{page.name == groupshared.label ? page.name : groupshared.label~" - "~page.name}}
</a>
{% endfor %}
{%if loop.last %}
</ul></div>
{%endif%}
{% endfor %}
2023-01-12 16:14:31 +01:00
</div>
</div>
</div>
2023-01-23 09:46:34 +01:00
</div>
</div>
2023-01-12 16:14:31 +01:00
2023-01-23 09:46:34 +01:00
<div id="selwidgetuser" class="modal fade" role="dialog">
<div class="modal-dialog modal-xl" role="document">
2023-01-12 16:14:31 +01:00
<div class="modal-content">
2023-01-23 09:46:34 +01:00
<div id="mymodalheader" class="modal-header">
2023-01-12 16:14:31 +01:00
<h4 class="modal-title">SELECTIONNER UN WIDGET</h4>
2023-01-23 09:46:34 +01:00
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
2023-01-12 16:14:31 +01:00
</div>
<div class="modal-body">
2023-01-23 09:46:34 +01:00
<table id="dataTablesuser" class="table table-striped table-bordered table-hover" style="width:100%">
<thead>
2023-01-12 16:14:31 +01:00
<tr>
2023-01-23 09:46:34 +01:00
<th class="no-sort" width="80px"></th>
<th width="100px">Nom</th>
<th class="no-sort" width="500px">Description</th>
2023-01-12 16:14:31 +01:00
</tr>
2023-01-23 09:46:34 +01:00
</thead>
<tbody>
{% for widget in widgetsuser %}
<tr>
<td>
<a onClick="selWidget({{ widget.id }},'user')" style="cursor:pointer;">
<img id="widgettype-{{ widget.id }}" class="grid-item-img" height="40" src="{{path('app_minio_image',{file:widget.icon.label}) }}" style="padding:2px">
</a>
</td>
<td>{{ widget.name }}</td>
<td>{{ widget.description }}</td>
</tr>
{% endfor %}
</tbody>
</table>
2023-01-12 16:14:31 +01:00
</div>
</div>
</div>
2023-01-23 09:46:34 +01:00
</div>
2023-01-12 16:14:31 +01:00
2023-01-23 09:46:34 +01:00
<div id="selwidgetgroup" class="modal fade" role="dialog">
<div class="modal-dialog modal-xl" role="document">
2023-01-12 16:14:31 +01:00
<div class="modal-content">
2023-01-23 09:46:34 +01:00
<div id="mymodalheader" class="modal-header">
2023-01-12 16:14:31 +01:00
<h4 class="modal-title">SELECTIONNER UN WIDGET</h4>
2023-01-23 09:46:34 +01:00
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
2023-01-12 16:14:31 +01:00
</div>
<div class="modal-body">
2023-01-23 09:46:34 +01:00
<table id="dataTablesgroup" class="table table-striped table-bordered table-hover" style="width:100%">
<thead>
2023-01-12 16:14:31 +01:00
<tr>
2023-01-23 09:46:34 +01:00
<th class="no-sort" width="80px"></th>
<th width="100px">Nom</th>
<th class="no-sort" width="500px">Description</th>
2023-01-12 16:14:31 +01:00
</tr>
2023-01-23 09:46:34 +01:00
</thead>
<tbody>
{% for widget in widgetsgroup %}
<tr>
<td>
<a onClick="selWidget({{ widget.id }},'group')" style="cursor:pointer;">
<img id="widgettype-{{ widget.id }}" class="grid-item-img" height="40" src="{{path('app_minio_image',{file:widget.icon.label}) }}" style="padding:2px">
</a>
</td>
<td>{{ widget.name }}</td>
<td>{{ widget.description }}</td>
</tr>
{% endfor %}
</tbody>
</table>
2023-01-12 16:14:31 +01:00
</div>
</div>
</div>
</div>
{% endblock %}
2023-01-23 09:46:34 +01:00
{% block localscript %}
<script>
2023-01-12 16:14:31 +01:00
var idpage;
$('document').ready(function(){
2023-01-23 09:46:34 +01:00
// Afficher la page courrante
{% for page in pagesportal %}
{% if page.id==entity.id %}
showPage({{ page.id }}, {{ page.pagecategory.id }},'{{ page.canupdate }}','portal',false,null,'{{page.name}}');
{% endif %}
{% endfor %}
{% for page in pagesuser %}
{% if page.id==entity.id %}
showPage({{ page.id }}, {{ page.pagecategory.id }},'{{ page.canupdate }}','user',false,null,'{{page.name}}');
{% endif %}
{% endfor %}
{% for groupshared in groups %}
{% for page in groupshared.pagesshared %}
2023-01-12 16:14:31 +01:00
{% if page.id==entity.id %}
2023-01-23 09:46:34 +01:00
showPage({{ page.id }}, {{ page.pagecategory.id }},'{{ page.canupdate }}','group',true,{{groupshared.id}},'{{page.name}}');
2023-01-12 16:14:31 +01:00
{% endif %}
2023-01-23 09:46:34 +01:00
{% endfor %}
{% endfor %}
2023-01-12 16:14:31 +01:00
// Rendre les pages user déplacable
2023-01-23 09:46:34 +01:00
$("#menupagesuser").sortable({
2023-01-12 16:14:31 +01:00
axis: "x",
forcePlaceholderSize: true,
placeholder: "placeholder",
update: function( event, ui ) {
$('#pagesuser li').each(function(order) {
var idpage=$(this).attr('id').replace("menupage-","");
$.ajax({
method: "POST",
2023-01-23 09:46:34 +01:00
url: "{{ path('app_'~access~'_page_user_order') }}",
2023-01-12 16:14:31 +01:00
data: {
id:idpage,
order:order
}
});
});
}
});
// Initialisation du tableau des widgets selectionnable à la création
$('.table').DataTable({
columnDefs: [ { "targets": 'no-sort', "orderable": false }, { "targets": 0, "className": "text-center" } ],
iDisplayLength: 10,
order: [[ 1, "asc" ]],
2023-01-23 09:46:34 +01:00
scrollX: false,
2023-01-12 16:14:31 +01:00
});
});
// Affichage des frames associés aux items de bureau
2023-01-23 09:46:34 +01:00
function showItemframe(id,url,forcereload) {
2023-01-12 16:14:31 +01:00
$(".pageframereload").remove();
$(".pageframe").hide();
// Si force le rechargement et frame existante on la détruit
if(forcereload&&$("#frameitem-"+id).length)
$("#frameitem-"+id).remove();
// Si la frame en cours existe déjà on l'affiche
if($("#frameitem-"+id).length)
$("#frameitem-"+id).show();
// Sinon on la génère
else {
var myclass="";
if(forcereload) myclass="pageframereload";
$("#pagecontainer").append("<iframe onload='this.contentWindow.focus()' id='frameitem-"+id+"' class='pageframe "+myclass+"' src='"+url+"' style='border:none; width:100%'></iframe>");
}
2023-01-23 09:46:34 +01:00
Resize();
2023-01-12 16:14:31 +01:00
}
// Affichages des pages
function showPage(id,catid,canupdate,usage,forcereload,groupid,pagename) {
// Sauvegarder la page en cours
idpage=id;
// Cacher toutes les pages
$(".pageframereload").remove();
$(".pageframe").hide();
2023-01-23 09:46:34 +01:00
$(".dropdown-menu").hide();
2023-01-12 16:14:31 +01:00
// Rendre actif le page en cours dans le menu
2023-01-23 09:46:34 +01:00
$(".menupage").removeClass("active");
$(".dropdown-toggle").removeClass("active");
2023-01-12 16:14:31 +01:00
$("#menupage-"+id).addClass("active");
2023-01-23 09:46:34 +01:00
$("#menugroup-"+groupid).addClass("active");
2023-01-12 16:14:31 +01:00
2023-01-23 09:46:34 +01:00
if(usage=="portal")
var url="{{ path('app_all_page_portal_view',{id:'xx'}) }}";
else if(usage=="user")
var url="{{ path('app_all_page_user_view',{id:'xx'}) }}";
else
var url="{{ path('app_all_page_group_view',{id:'xx'}) }}";
2023-01-12 16:14:31 +01:00
url=url.replace('xx',id);
2023-01-23 09:46:34 +01:00
passurl="{{ path('app_home',{id:'xx'}) }}";
2023-01-12 16:14:31 +01:00
passurl=passurl.replace('xx',id);
history.pushState('data to be passed', 'Title of the page', passurl);
// Si force le rechargement et frame existante on la détruit
if(forcereload&&$("#page-"+id).length)
$("#page-"+id).remove();
// Si la frame en cours existe déjà on l'affiche
if($("#page-"+id).length)
$("#page-"+id).show();
// Sinon on la génère
else {
var myclass="";
if(forcereload) myclass="pageframereload";
$("#pagecontainer").append("<iframe onload='this.contentWindow.focus()' id='page-"+id+"' data-category='"+catid+"' class='pageframe "+myclass+"' src='"+url+"' style='border:none; width:100%'></iframe>");
}
// Cacher les actions possibles sur la page
$("#menuupdate").hide();
$("#menushare").hide();
$("#menudelete").hide();
$("#menuwidgetuser").hide();
$("#menuwidgetgroup").hide();
if(canupdate) {
$("#menuupdate").show();
$("#menudelete").show();
}
// Si page de type widget on affiche la selection des widgets à insérer
if($("#page-"+id).data('category')==2&&canupdate) {
if(usage=="user") $("#menuwidgetuser").show();
if(usage=="group") $("#menuwidgetgroup").show();
}
2023-01-23 09:46:34 +01:00
Resize();
2023-01-12 16:14:31 +01:00
}
function submitPage() {
2023-01-23 09:46:34 +01:00
var url="{{ path('app_'~access~'_page_user_submit') }}";
2023-01-12 16:14:31 +01:00
$(location).attr('href',url);
}
function updatePage() {
if($("#page-"+idpage).length) {
2023-01-23 09:46:34 +01:00
var url="{{ path('app_'~access~'_page_user_update',{id:'xx'}) }}";
2023-01-12 16:14:31 +01:00
url=url.replace('xx',idpage);
$(location).attr('href',url);
}
}
function deletePage() {
if($("#page-"+idpage).length) {
if (confirm('Êtes-vous sûr de vouloir supprimer ?')) {
2023-01-23 09:46:34 +01:00
var url="{{ path('app_'~access~'_page_user_delete',{id:'xx'}) }}";
2023-01-12 16:14:31 +01:00
url=url.replace('xx',idpage);
$(location).attr('href',url);
}
}
}
// Création d'un widget selectionné
2023-01-23 09:46:34 +01:00
function selWidget(idwidgettype,usage) {
var url="{{ path('app_all_pagewidget_widget_sumbit',{idpage:'yy',idwidgettype:'xx',usage:'zz'})}}";
2023-01-12 16:14:31 +01:00
url=url.replace('xx',idwidgettype);
url=url.replace('yy',idpage);
2023-01-23 09:46:34 +01:00
url=url.replace('zz',usage);
$(".modal").modal("hide");
$("#page-"+idpage).attr("src",url);
2023-01-12 16:14:31 +01:00
};
2023-01-23 09:46:34 +01:00
</script>
2023-01-12 16:14:31 +01:00
{% endblock %}