select icon dans frame + widget info comme les autres (ref #120)

This commit is contained in:
afornerot 2020-04-17 17:21:40 +02:00
parent b49bf9cd9b
commit fa287477c6
7 changed files with 139 additions and 87 deletions

View File

@ -89,20 +89,6 @@
</div>
{% endif %}
<div id="diviconsel" class="col-md-12 text-left" style="height:140px; padding:20px; text-align:center; background-color: {{ group.color ? "#"~group.color : '#000000' }};">
{% if group.icon %}
<img src="/{{ alias }}/{{ group.icon.label }}" height="100" />
{% endif %}
</div>
<div class="col-md-12" style="text-align:center;padding:0px">
{{ form_row(form.idicon) }}
<a class="btn btn-success" data-toggle="modal" data-target="#selicon" title='Ajouter' style="width:100%">Selectionner un 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 class="col-sm-6">
{% if form.fgcancreatepage is defined %}
<div class="panel panel-primary">
<div class="panel-heading">
@ -123,7 +109,24 @@
{{ form_widget(form.fgcancreateproject) }}
</div>
</div>
{% endif %}
</div>
<div class="col-sm-6">
<div id="diviconsel" class="col-md-12 text-left" style="height:140px; padding:20px; text-align:center; background-color: {{ group.color ? "#"~group.color : '#000000' }};">
{% if group.icon %}
<img src="/{{ alias }}/{{ group.icon.label }}" height="100" />
{% endif %}
</div>
<div style="text-align:center;padding:0px">
{{ form_row(form.idicon) }}
<a class="btn btn-success" onClick="selectIcon()" title='Ajouter' style="width:100%">Selectionner un Icône</a>
<a class="btn btn-danger" onClick="delIcon()" title='Détacher' style="width:100%">Détacher l'Icône</a>
</div>
<br>
{% if form.fgcancreatepage is defined %}
<div class="panel panel-primary">
<div class="panel-heading">
<i class="fa fa-pencil fa-fw"></i> Elements du Portail
@ -143,46 +146,6 @@
{% endif %}
</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 UN 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; margin-bottom:2px; background-color: #{{ color["main"]}}">
</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; margin-bottom:2px; background-color: #{{ color["main"]}}">
</a>
{% endfor %}
</div>
</div>
</div>
</div>
</div>
</div>
{{ form_end(form) }}
{% endblock %}
@ -245,13 +208,21 @@
hideshow();
});
function selIcon(idicon) {
function selIcon(idicon,label) {
$("#group_idicon").val(idicon);
$("#diviconsel img").remove();
$("#icon-"+idicon).clone().appendTo($("#diviconsel"));
url="/{{ alias }}/"+label;
$("#diviconsel").append("<img src='"+url+"'>");
$("#diviconsel img").attr("height","100px");
$('#selicon').modal('hide');
$("#mymodal").modal("hide");
}
function selectIcon() {
$("#mymodal").find(".modal-title").html("SELECTIONNER UN ICONE");
var url="{{ path('cadoles_portal_user_icon_select') }}";
$("#mymodal").find("#framemodal").attr("src",url);
$("#mymodal").modal("show");
}
function delIcon() {

View File

@ -19,8 +19,10 @@ class IconController extends Controller
private $labeldata = 'icon';
private $labeldatas = 'icons';
public function listAction($access="config")
public function listAction(Request $request,$access="config")
{
$inframe=$request->get("inframe");
$em = $this->getDoctrine()->getManager();
if($access=="config")
$icons=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findBy(["user"=>null]);
@ -28,16 +30,19 @@ class IconController extends Controller
$icons=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findBy(["user"=>$this->getUser()]);
return $this->render($this->labelentity.':list.html.twig',[
'useheader' => true,
'useheader' => !($inframe),
'usemenu' => false,
'usesidebar' => ($access=="config"),
'access' => $access,
$this->labeldatas => $icons
$this->labeldatas => $icons,
'inframe' => $inframe
]);
}
public function submitAction(Request $request,$access="config")
{
$inframe=$request->get("inframe");
// Initialisation de l'enregistrement
$data = new Icon();
@ -62,23 +67,26 @@ class IconController extends Controller
$em->flush();
// Retour à la liste
return $this->redirectToRoute('cadoles_portal_'.$access.'_icon');
return $this->redirectToRoute('cadoles_portal_'.$access.'_icon',['inframe'=>$inframe]);
}
// Affichage du formulaire
return $this->render($this->labelentity.':edit.html.twig', [
'useheader' => true,
'useheader' => !($inframe),
'usemenu' => false,
'usesidebar' => ($access=="config"),
'access' => $access,
$this->labeldata => $data,
'mode' => 'submit',
'form' => $form->createView(),
'inframe' => $inframe,
]);
}
public function updateAction($id,Request $request,$access="config")
{
$inframe=$request->get("inframe");
// Récupération de l'enregistrement courant
$data=$this->getData($id);
@ -103,13 +111,13 @@ class IconController extends Controller
$em->flush();
// Retour à la liste
return $this->redirectToRoute('cadoles_portal_'.$access.'_icon');
return $this->redirectToRoute('cadoles_portal_'.$access.'_icon',['inframe'=>$inframe]);
}
// Affichage du formulaire
return $this->render($this->labelentity.':edit.html.twig', [
'useheader' => true,
'useheader' => !($inframe),
'usemenu' => false,
'usesidebar' => ($access=="config"),
'access' => $access,
@ -117,11 +125,14 @@ class IconController extends Controller
'mode' => 'update',
'form' => $form->createView(),
'refresh' => false,
'inframe' => $inframe
]);
}
public function deleteAction($id,Request $request,$access="config")
{
$inframe=$request->get("inframe");
// Récupération de l'enregistrement courant
$data=$this->getData($id);
@ -132,9 +143,25 @@ class IconController extends Controller
$em->remove($data);
$em->flush();
return $this->redirectToRoute('cadoles_portal_'.$access.'_icon');
return $this->redirectToRoute('cadoles_portal_'.$access.'_icon',['inframe'=>$inframe]);
}
public function selectAction($access="config") {
// Affichage du formulaire
$icons=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findBy(["user"=>null]);
$iconsuser=null;
if($access=="user") $iconsuser=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findBy(["user"=>$this->getUser()]);
return $this->render($this->labelentity.':select.html.twig',[
'useheader' => false,
'usemenu' => false,
'usesidebar' => false,
'access' => $access,
$this->labeldatas => $icons,
'iconsuser' => $iconsuser
]);
}
public function iconAction()
{

View File

@ -59,6 +59,10 @@ cadoles_portal_config_icon_delete:
path: /config/icon/delete/{id}
defaults: { _controller: CadolesPortalBundle:Icon:delete, access: config }
cadoles_portal_config_icon_select:
path: /config/icon/select
defaults: { _controller: CadolesPortalBundle:Icon:select, access: config }
cadoles_portal_config_icon_icon:
path: /config/icon/icon
defaults: { _controller: CadolesPortalBundle:Icon:icon, access: config }
@ -79,6 +83,10 @@ cadoles_portal_user_icon_delete:
path: /user/icon/delete/{id}
defaults: { _controller: CadolesPortalBundle:Icon:delete, access: user }
cadoles_portal_user_icon_select:
path: /user/icon/select
defaults: { _controller: CadolesPortalBundle:Icon:select, access: user }
cadoles_portal_user_icon_icon:
path: /user/icon/icon
defaults: { _controller: CadolesPortalBundle:Icon:icon, access: user }

View File

@ -2,18 +2,20 @@
{% block pagewrapper %}
{{ form_start(form) }}
<h1 class="page-header">
{% if mode=="update" %}
Modification Icône
{% elseif mode=="submit" %}
Création Icône
{% endif %}
</h1>
{% if not inframe %}
<h1 class="page-header">
{% if mode=="update" %}
Modification Icône
{% elseif mode=="submit" %}
Création Icône
{% endif %}
</h1>
{%endif%}
{{ form_widget(form.submit) }}
<a class="btn btn-default" href={{ path('cadoles_portal_'~access~'_icon') }}>Annuler</a>
<a class="btn btn-default" href={{ path('cadoles_portal_'~access~'_icon',{'inframe':inframe}) }}>Annuler</a>
{% if mode=="update" %}
<a href={{ path('cadoles_portal_'~access~'_icon_delete',{'id':icon.id}) }}
<a href={{ path('cadoles_portal_'~access~'_icon_delete',{'id':icon.id,'inframe':inframe}) }}
class="btn btn-danger pull-right"
data-method="delete" data-csrf="_token:{{ 'csrf' }}"
data-confirm="Êtes-vous sûr de vouloir supprimer cet icône ?">

View File

@ -1,13 +1,20 @@
{% extends '@CadolesCore/base.html.twig' %}
{% block pagewrapper %}
<h1 class="page-header">Gestion des Icônes</h1>
{% if not inframe %}
<h1 class="page-header">Gestion des Icônes</h1>
{% endif %}
<p>
<a class="btn btn-success" href={{ path('cadoles_portal_'~access~'_icon_submit',{'inframe': inframe}) }}>Ajouter</a>
{% if inframe %}
<a class="btn btn-default" href={{ path('cadoles_portal_'~access~'_icon_select') }}>Fermer</a>
{% endif %}
</p>
<p><a class="btn btn-success" href={{ path('cadoles_portal_'~access~'_icon_submit') }}>Ajouter</a></p>
<div class="row">
{% for icon in icons %}
<a href="{{ path('cadoles_portal_'~access~'_icon_update', {id : icon.id}) }}"><img class="icon" height="90" src="/{{ alias }}/{{ icon.label }}" style="padding:10px; margin-bottom:2px; background-color: #{{color["main"]}}"></a>
<a href="{{ path('cadoles_portal_'~access~'_icon_update', {id : icon.id, 'inframe': inframe}) }}"><img class="icon" height="90" src="/{{ alias }}/{{ icon.label }}" style="padding:10px; margin-bottom:2px; background-color: #{{color["main"]}}"></a>
{% endfor %}
</div>
{% endblock %}

View File

@ -0,0 +1,32 @@
{% extends '@CadolesCore/base.html.twig' %}
{% block pagewrapper %}
<div class="row">
<div class="col-md-12" style="margin-bottom:15px">
<a onclick="window.parent.$('#mymodal').modal('hide');" class="btn btn-default">Fermer</a>
{% if access=="user" %}
<a href="{{ path('cadoles_portal_user_icon',{'inframe':true}) }}" 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="window.parent.selIcon({{ icon.id }},'{{icon.label}}')">
<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 style="cursor:pointer" onClick="window.parent.selIcon({{ icon.id }},'{{icon.label}}')">
<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>
{% endblock %}

View File

@ -28,22 +28,27 @@
</div>
{% endif %}
<div class="widgetheader" style="{{ stylewidgetheader }}; padding-top:10px;">
<div class="widgetheader" style="{{ stylewidgetheader }}">
{% if entity.icon %}
<img src="/{{ alias }}/{{ entity.icon.label }}" class="logo"/>
{% else %}
<img src="/{{ alias }}/uploads/icon/icon_pin.png" class="logo"/>
{% endif %}
<span class="title">{{ entity.name }}</span>
</div>
<div class="widgetbody" style="{{ stylewidgetbody }}">
{% set style = "margin: auto; display: inherit;background-color:transparent;" %}
{% if icon %}
<img src="/{{ alias }}{{ icon }}" class="avatar big" style="{{ style }}" />
{% else %}
<img src="/{{ alias }}/uploads/icon/icon_users.png" class="avatar big" style="{{ style }}" />
{% endif %}
</div>
<div class="widgetbody" style="{{ stylewidgetbody }}">
<div style="text-align: center; margin-top:50px;">
<div style="text-align: center;">
{%if usage=="group" %}<small>Groupe<br></small>{% endif %}
<span style="font-size:120%">{{ title }}</span><br><br>
<span style="font-size:120%">{{ title }}</span><br>
{{ description | raw }}
{%if usage=="group" %}