ninegate/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/pages.html.twig

222 lines
8.4 KiB
Twig
Raw Normal View History

2019-04-02 11:26:41 +02:00
{% extends '@CadolesCore/base.html.twig' %}
{% block localstyle %}
body{overflow-y:hidden}
{% endblock %}
{% block appmenu %}
<ul class="nav navbar-top-links navbar-left">
{% for page in pagesadmin %}
{% if entity.id is defined and page.id==entity.id %}
<li id="menupage-{{page.id}}" class="active" style="cursor:pointer"><a onClick="showPage({{ page.id }},{{ page.pagecategory.id }},{{ page.canupdate }})">{{ page.name }}</a></li>
{% else %}
<li id="menupage-{{page.id}}"><a style="cursor:pointer" onClick="showPage({{ page.id }},{{ page.pagecategory.id }},{{ page.canupdate }})">{{ page.name }}</a></li>
{% endif %}
{% endfor %}
{% for page in pagesuser %}
{% if entity.id is defined and page.id==entity.id %}
<li id="menupage-{{page.id}}" class="active" style="cursor:pointer"><a onClick="showPage({{ page.id }},{{ page.pagecategory.id }},{{ page.canupdate }})">{{ page.name }}</a></li>
{% else %}
<li id="menupage-{{page.id}}"><a style="cursor:pointer" onClick="showPage({{ page.id }},{{ page.pagecategory.id }},{{ page.canupdate }})">{{ page.name }}</a></li>
{% endif %}
{% endfor %}
</ul>
<div id="menupageaction">
{% if canadd %}
<a id="menusubmit" style="cursor:pointer" onclick="submitPage()" title='Ajouter une page'><i class='fa fa-plus fa-fw'></i></a>
{% endif %}
<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="menudelete" style="cursor:pointer;display:none" onclick="deletePage()" title='Supprimer une page'><i class='fa fa-trash fa-fw'></i></a>
<a id="menuwidget" style='cursor:pointer;display:none' data-toggle='modal' data-target='#selwidget' title='Ajouter un widget'><i class='fa fa-cubes fa-fw'></i></a>
</div>
{% endblock %}
{% block pagewrapper %}
<div id="pagecontainer" style="margin: 0px -30px;"></div>
<div id="selwidget" class="modal fade bs-item-modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">SELECTIONNER UN WIDGET</h4>
</div>
<div class="modal-body">
<div class="form-group row clearfix">
<div class="col-md-12" style="margin-bottom:15px">
<a onclick="$('#selwidget').modal('hide');" class="btn btn-default">
Annuler
</a>
</div>
<div class="dataTable_wrapper col-md-12">
<table id="dataTables" class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th width="100px">#</th>
<th>Nom</th>
<th class="no-sort">Description</th>
</tr>
</thead>
<tbody>
{% for widget in widgets %}
<tr>
<td>
<a onClick="selWidget({{ widget.id }})" style="cursor:pointer;">
<img id="widgettype-{{ widget.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ widget.icon.label }}" style="padding:2px">
</a>
</td>
<td>{{ widget.name }}</td>
<td>{{ widget.description }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block localjavascript %}
var idpage;
$('document').ready(function(){
{% for page in pagesadmin %}
{% if page.id==entity.id %}
showPage({{ page.id }}, {{ page.pagecategory.id }},{{ page.canupdate }});
{% endif %}
{% endfor %}
{% for page in pagesuser %}
{% if page.id==entity.id %}
showPage({{ page.id }}, {{ page.pagecategory.id }},{{ page.canupdate }});
{% endif %}
{% endfor %}
});
$(window).resize(function() {
resizeFrame();
});
function resizeFrame() {
var iFrame = document.getElementById('frameContent');
var heightbody = $('html').height();
var heightheader = $('.header').height();
if($('#appmenu').css("display")=="none")
var heightmenu = 0;
else
var heightmenu = $('#appmenu').height();
var heightframe = heightbody-heightheader-heightmenu;
$(".pageframe").each(function( index ) {
$(this).height(heightframe);
});
}
// Affichage des frames associés aux items de bureau
function showFrameitem(id,url,forcereload) {
$(".pageframe").hide();
if($("#frameitem-"+id).length) {
if(forcereload) {
$("#frameitem-"+id).attr("src",url);
}
$("#frameitem-"+id).show();
}
else {
$("#pagecontainer").append("<iframe id='frameitem-"+id+"' class='pageframe' src='"+url+"' style='border:none; width:100%'></iframe>");
}
resizeFrame();
}
// Affichages des pages
function showPage(id,catid,canupdate) {
// Sauvegarder la page en cours
idpage=id;
// Cacher toutes les pages
$(".pageframe").hide();
// Rendre actif le page en cours dans le menu
$(".navbar-top-links li").removeClass("active");
$("#menupage-"+id).addClass("active");
// Si la page en cours existe déjà on l'affiche
if($("#page-"+id).length) {
$("#page-"+id).show();
}
// Sinon on la génère
else {
var url="{{ path('cadoles_portal_user_page_view',{id:'xx'}) }}";
url=url.replace('xx',id);
$("#pagecontainer").append("<iframe id='page-"+id+"' data-category='"+catid+"' class='pageframe' src='"+url+"' style='border:none; width:100%'></iframe>");
}
// Cacher les actions possibles sur la page
$("#menuupdate").hide();
$("#menudelete").hide();
$("#menuwidget").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)
$("#menuwidget").show();
// On resize les frame
resizeFrame();
}
function submitPage() {
var url="{{ path('cadoles_portal_'~access~'_page_submit') }}";
$(location).attr('href',url);
}
function updatePage() {
if($("#page-"+idpage).length) {
var url="{{ path('cadoles_portal_'~access~'_page_update',{id:'xx'}) }}";
url=url.replace('xx',idpage);
$(location).attr('href',url);
}
}
function deletePage() {
if($("#page-"+idpage).length) {
if (confirm('Êtes-vous sûr de vouloir supprimer ?')) {
var url="{{ path('cadoles_portal_'~access~'_page_delete',{id:'xx'}) }}";
url=url.replace('xx',idpage);
$(location).attr('href',url);
}
}
}
// Création d'un widget selectionné
function selWidget(idwidgettype) {
var url="{{ path('cadoles_portal_user_pagewidget_widget_sumbit',{idpage:'yy',idwidgettype:'xx'})}}";
url=url.replace('xx',idwidgettype);
url=url.replace('yy',idpage);
$(location).attr('href', url);
};
{% endblock %}