pouvoir gérer les icones directement via la selection des icones (ref #188)

This commit is contained in:
afornerot 2020-07-17 12:02:25 +02:00
parent bdddfc925f
commit de803ac336
6 changed files with 58 additions and 159 deletions

View File

@ -32,7 +32,7 @@ class IconController extends Controller
return $this->render($this->labelentity.':list.html.twig',[ return $this->render($this->labelentity.':list.html.twig',[
'useheader' => !($inframe), 'useheader' => !($inframe),
'usemenu' => false, 'usemenu' => false,
'usesidebar' => ($access=="config"), 'usesidebar' => ($access=="config"&&!$inframe),
'access' => $access, 'access' => $access,
$this->labeldatas => $icons, $this->labeldatas => $icons,
'inframe' => $inframe 'inframe' => $inframe
@ -74,7 +74,7 @@ class IconController extends Controller
return $this->render($this->labelentity.':edit.html.twig', [ return $this->render($this->labelentity.':edit.html.twig', [
'useheader' => !($inframe), 'useheader' => !($inframe),
'usemenu' => false, 'usemenu' => false,
'usesidebar' => ($access=="config"), 'usesidebar' => ($access=="config"&&!$inframe),
'access' => $access, 'access' => $access,
$this->labeldata => $data, $this->labeldata => $data,
'mode' => 'submit', 'mode' => 'submit',
@ -119,7 +119,7 @@ class IconController extends Controller
return $this->render($this->labelentity.':edit.html.twig', [ return $this->render($this->labelentity.':edit.html.twig', [
'useheader' => !($inframe), 'useheader' => !($inframe),
'usemenu' => false, 'usemenu' => false,
'usesidebar' => ($access=="config"), 'usesidebar' => ($access=="config"&&!$inframe),
'access' => $access, 'access' => $access,
$this->labeldata => $data, $this->labeldata => $data,
'mode' => 'update', 'mode' => 'update',

View File

@ -57,49 +57,31 @@
<div class="col-md-12" style="text-align:center;padding:0px"> <div class="col-md-12" style="text-align:center;padding:0px">
{{ form_row(form.idicon) }} {{ form_row(form.idicon) }}
<a class="btn btn-success" data-toggle="modal" data-target="#selicon" title='Ajouter' style="width:100%">Selectionner une Icône</a> <a class="btn btn-success" onClick="selectIcon()" title='Ajouter' style="width:100%">Selectionner une Icône</a>
<a class="btn btn-danger" onClick="delIcon()" title='Détacher' style="width:100%">Détacher l'Icône</a> <a class="btn btn-danger" onClick="delIcon()" title='Détacher' style="width:100%">Détacher l'Icône</a>
</div> </div>
</div> </div>
</div> </div>
<div id="selicon" 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 UNE ICONE</h4>
</div>
<div class="modal-body">
<div class="form-group row clearfix">
<div class="col-md-12" style="margin-bottom:15px">
<a onclick="$('#selicon').modal('hide');" class="btn btn-default">Annuler</a>
</div>
<div class="col-md-12">
{% for icon in icons %}
<a href="#" onClick="selIcon({{ icon.id }})">
<img id="icon-{{ icon.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ icon.label }}" style="padding:2px; margin-bottom:2px; background-color: #{{ color["main"]}}">
</a>
{% endfor %}
</div>
</div>
</div>
</div>
</div>
</div>
{{ form_end(form) }} {{ form_end(form) }}
{% endblock %} {% endblock %}
{% block localjavascript %} {% block localjavascript %}
function selIcon(idicon) { function selIcon(idicon,label) {
$("#alertcategory_idicon").val(idicon); $("#alertcategory_idicon").val(idicon);
$("#diviconsel img").remove(); $("#diviconsel img").remove();
$("#icon-"+idicon).clone().appendTo($("#diviconsel")); url="/{{ alias }}/"+label;
$("#diviconsel").append("<img src='"+url+"'>");
$("#diviconsel img").attr("height","100px"); $("#diviconsel img").attr("height","100px");
$('#selicon').modal('hide'); $("#mymodal").modal("hide");
}
function selectIcon() {
$("#mymodal").find(".modal-title").html("SELECTIONNER UNE ICONE");
var url="{{ path('cadoles_portal_config_icon_select') }}";
$("#mymodal").find("#framemodal").attr("src",url);
$("#mymodal").modal("show");
} }
function delIcon() { function delIcon() {

View File

@ -69,51 +69,11 @@
<div class="col-md-12" style="text-align:center;padding:0px"> <div class="col-md-12" style="text-align:center;padding:0px">
{{ form_row(form.idicon) }} {{ form_row(form.idicon) }}
<a class="btn btn-success" data-toggle="modal" data-target="#selicon" title='Ajouter' style="width:100%">Selectionner une Icône</a> <a class="btn btn-success" onClick="selectIcon()" title='Ajouter' style="width:100%">Selectionner une Icône</a>
<a class="btn btn-danger" onClick="delIcon()" title='Détacher' style="width:100%">Détacher l'Icône</a> <a class="btn btn-danger" onClick="delIcon()" title='Détacher' style="width:100%">Détacher l'Icône</a>
</div> </div>
</div> </div>
</div> </div>
<div id="selicon" 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 UNE ICONE</h4>
</div>
<div class="modal-body">
<div class="form-group row clearfix">
<div class="col-md-12" style="margin-bottom:15px">
<a onclick="$('#selicon').modal('hide');" class="btn btn-default">Annuler</a>
{% if access=="user" %}
<a href="{{ path('cadoles_portal_user_icon') }}" target="_parent" class="btn btn-default">Gérer mes Icônes</a>
{% endif %}
</div>
<div class="col-md-12">
{% if iconsuser is not empty %}
<h3>Mes Icônes</h3>
{% for icon in iconsuser %}
<a style="cursor:pointer" onClick="selIcon({{ icon.id }})">
<img id="icon-{{ icon.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ icon.label }}" style="padding:2px">
</a>
{% endfor %}
<h3>Icônes Communs</h3>
{% endif %}
{% for icon in icons %}
<a style="cursor:pointer" onClick="selIcon({{ icon.id }})">
<img id="icon-{{ icon.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ icon.label }}" style="padding:2px">
</a>
{% endfor %}
</div>
</div>
</div>
</div>
</div>
</div>
{{ form_end(form) }} {{ form_end(form) }}
{% endblock %} {% endblock %}
@ -126,13 +86,21 @@
showhide(); showhide();
}); });
function selIcon(idicon) { function selIcon(idicon,label) {
$("#bookmark_idicon").val(idicon); $("#bookmark_idicon").val(idicon);
$("#diviconsel img").remove(); $("#diviconsel img").remove();
$("#icon-"+idicon).clone().appendTo($("#diviconsel")); url="/{{ alias }}/"+label;
$("#diviconsel").append("<img src='"+url+"'>");
$("#diviconsel img").attr("height","100px"); $("#diviconsel img").attr("height","100px");
$('#selicon').modal('hide'); $("#mymodal").modal("hide");
}
function selectIcon() {
$("#mymodal").find(".modal-title").html("SELECTIONNER UNE ICONE");
var url="{{ path('cadoles_portal_user_icon_select') }}";
$("#mymodal").find("#framemodal").attr("src",url);
$("#mymodal").modal("show");
} }
function delIcon() { function delIcon() {

View File

@ -6,6 +6,8 @@
<a onclick="window.parent.$('#mymodal').modal('hide');" class="btn btn-default">Fermer</a> <a onclick="window.parent.$('#mymodal').modal('hide');" class="btn btn-default">Fermer</a>
{% if access=="user" %} {% if access=="user" %}
<a href="{{ path('cadoles_portal_user_icon',{'inframe':true}) }}" class="btn btn-default">Gérer mes Icônes</a> <a href="{{ path('cadoles_portal_user_icon',{'inframe':true}) }}" class="btn btn-default">Gérer mes Icônes</a>
{% else %}
<a href="{{ path('cadoles_portal_config_icon',{'inframe':true}) }}" class="btn btn-default">Gérer les Icônes</a>
{% endif %} {% endif %}
</div> </div>
@ -13,17 +15,13 @@
{% if iconsuser is not empty %} {% if iconsuser is not empty %}
<h3>Mes Icônes</h3> <h3>Mes Icônes</h3>
{% for icon in iconsuser %} {% for icon in iconsuser %}
<a style="cursor:pointer" onClick="window.parent.selIcon({{ icon.id }},'{{icon.label}}')"> <img onClick="window.parent.selIcon({{ icon.id }},'{{icon.label}}')" id="icon-{{ icon.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ icon.label }}" style="cursor:pointer; padding:2px; margin-bottom:2px; background-color: #{{ color["main"]}}">
<img id="icon-{{ icon.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ icon.label }}" style="padding:2px; margin-bottom:2px; background-color: #{{ color["main"]}}">
</a>
{% endfor %} {% endfor %}
<h3>Icônes Communs</h3> <h3>Icônes Communs</h3>
{% endif %} {% endif %}
{% for icon in icons %} {% for icon in icons %}
<a style="cursor:pointer" onClick="window.parent.selIcon({{ icon.id }},'{{icon.label}}')"> <img onClick="window.parent.selIcon({{ icon.id }},'{{icon.label}}')" id="icon-{{ icon.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ icon.label }}" style="cursor:pointer; padding:2px; margin-bottom:2px; background-color: #{{ color["main"]}}">
<img id="icon-{{ icon.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ icon.label }}" style="padding:2px; margin-bottom:2px; background-color: #{{ color["main"]}}">
</a>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>

View File

@ -71,37 +71,10 @@
<div class="col-md-12" style="text-align:center;padding:0px"> <div class="col-md-12" style="text-align:center;padding:0px">
{{ form_row(form.idicon) }} {{ form_row(form.idicon) }}
<a class="btn btn-success" data-toggle="modal" data-target="#selicon" title='Ajouter' style="width:100%">Selectionner une Icône</a> <a class="btn btn-success" onClick="selectIcon()" title='Ajouter' style="width:100%">Selectionner une Icône</a>
<a class="btn btn-danger" onClick="delIcon()" title='Détacher' style="width:100%">Détacher l'Icône</a> <a class="btn btn-danger" onClick="delIcon()" title='Détacher' style="width:100%">Détacher l'Icône</a>
</div> </div>
</div> </div>
</div>
<div id="selicon" 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 UNE ICONE</h4>
</div>
<div class="modal-body">
<div class="form-group row clearfix">
<div class="col-md-12" style="margin-bottom:15px">
<a onclick="$('#selicon').modal('hide');" class="btn btn-default">Annuler</a>
</div>
<div class="col-md-12">
{% for icon in icons %}
<a href="#" onClick="selIcon({{ icon.id }})">
<img id="icon-{{ icon.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ icon.label }}" style="padding:2px;; margin-bottom:2px; background-color: #{{ color["main"]}}">
</a>
{% endfor %}
</div>
</div>
</div>
</div>
</div>
</div> </div>
{{ form_end(form) }} {{ form_end(form) }}
{% endblock %} {% endblock %}
@ -115,15 +88,24 @@
showhide(); showhide();
}); });
function selIcon(idicon) { function selIcon(idicon,label) {
$("#item_idicon").val(idicon); $("#item_idicon").val(idicon);
$("#diviconsel img").remove(); $("#diviconsel img").remove();
$("#icon-"+idicon).clone().appendTo($("#diviconsel")); url="/{{ alias }}/"+label;
$("#diviconsel").append("<img src='"+url+"'>");
$("#diviconsel img").attr("height","100px"); $("#diviconsel img").attr("height","100px");
$('#selicon').modal('hide'); $("#mymodal").modal("hide");
} }
function selectIcon() {
$("#mymodal").find(".modal-title").html("SELECTIONNER UNE ICONE");
var url="{{ path('cadoles_portal_config_icon_select') }}";
$("#mymodal").find("#framemodal").attr("src",url);
$("#mymodal").modal("show");
}
function delIcon() { function delIcon() {
$("#diviconsel img").remove(); $("#diviconsel img").remove();
$("#item_idicon").val(null); $("#item_idicon").val(null);

View File

@ -61,7 +61,7 @@
</div> </div>
<div class="col-md-12" style="text-align:center;padding:0px"> <div class="col-md-12" style="text-align:center;padding:0px">
{{ form_row(form.idicon) }} {{ form_row(form.idicon) }}
<a class="btn btn-success" data-toggle="modal" data-target="#selicon" title='Ajouter' style="width:100%">Selectionner une Icône</a> <a class="btn btn-success" onClick="selectIcon()" title='Ajouter' style="width:100%">Selectionner une Icône</a>
</div> </div>
</div> </div>
</div> </div>
@ -88,46 +88,6 @@
{{ form_widget(form) }} {{ form_widget(form) }}
</div> </div>
<div id="selicon" 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 UNE ICONE</h4>
</div>
<div class="modal-body" style="height: 480px; overflow-y: scroll;">
<div class="form-group row clearfix">
<div class="col-md-12" style="margin-bottom:15px">
<a onclick="$('#selicon').modal('hide');" class="btn btn-default">Annuler</a>
{% if access=="user" %}
<a href="{{ path('cadoles_portal_user_icon') }}" target="_parent" class="btn btn-default">Gérer mes Icônes</a>
{% endif %}
</div>
<div class="col-md-12">
{% if iconsuser is not empty %}
<h3>Mes Icônes</h3>
{% for icon in iconsuser %}
<a style="cursor:pointer" onClick="selIcon({{ icon.id }})">
<img id="icon-{{ icon.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ icon.label }}" style="padding:2px; margin-bottom:2px; background-color: #{{ color["main"]}}">
</a>
{% endfor %}
<h3>Icônes Communs</h3>
{% endif %}
{% for icon in icons %}
<a href="#" onClick="selIcon({{ icon.id }})">
<img id="icon-{{ icon.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ icon.label }}" style="padding:2px; margin-bottom:2px; background-color: #{{ color["main"]}}">
</a>
{% endfor %}
</div>
</div>
</div>
</div>
</div>
</div>
{{ form_end(form) }} {{ form_end(form) }}
{% endblock %} {% endblock %}
@ -155,13 +115,22 @@
}); });
}); });
function selIcon(idicon) { function selIcon(idicon,label) {
$("#pagewidget_idicon").val(idicon); $("#pagewidget_idicon").val(idicon);
$("#diviconsel img").remove(); $("#diviconsel img").remove();
$("#icon-"+idicon).clone().appendTo($("#diviconsel")); url="/{{ alias }}/"+label;
$("#diviconsel").append("<img src='"+url+"'>");
$("#diviconsel img").attr("height","100px"); $("#diviconsel img").attr("height","100px");
$('#selicon').modal('hide'); $("#mymodal").modal("hide");
} }
function selectIcon() {
$("#mymodal").find(".modal-title").html("SELECTIONNER UNE ICONE");
var url="{{ path('cadoles_portal_user_icon_select') }}";
$("#mymodal").find("#framemodal").attr("src",url);
$("#mymodal").modal("show");
}
{% endblock %} {% endblock %}