preference utilisateur modedesktop (fixes #32763)

This commit is contained in:
afornerot 2021-06-11 15:31:33 +02:00
parent 3ba041b207
commit fa62b8aa36
6 changed files with 65 additions and 5 deletions

View File

@ -1259,7 +1259,7 @@ class UserController extends Controller
$key=$request->request->get('key');
$id=$request->request->get('id');
$value=$request->request->get('value');
// Récupérer les préférences de l'utilisateur
$preference=$this->getUser()->getPreference();
@ -1294,7 +1294,7 @@ class UserController extends Controller
$toupdate=true;
$preference[$key][$id]=$value;
}
if($value&&$preference[$key][$id]!=$value) {
if($preference[$key][$id]!=$value) {
$toupdate=true;
$preference[$key][$id]=$value;
}

View File

@ -343,8 +343,8 @@ span.item-drag {
.grid-item .item-link img {
display: block;
max-width: 100%;
//max-height: 110px;
max-width: 80%;
margin: 10px;
height: auto;
}

View File

@ -447,6 +447,26 @@ class PagewidgetController extends Controller
}
}
protected function getKeyPreference(&$entity,$key,$value) {
$user=$this->getUser();
if(!$user)
return $value;
$preference=$user->getPreference();
$id=$entity->getId();
if(!is_array($preference))
return $value;
if(!array_key_exists($key,$preference))
return $value;
if(!array_key_exists($id,$preference[$key]))
return $value;
return $preference[$key][$id];
}
protected function getRender($view,$params) {
// Paramétres toujours présent dans un rendu de widget
$allways = [
@ -602,6 +622,9 @@ class PagewidgetController extends Controller
}
}
// Préference utilisateur
$modedesktop = $this->getKeyPreference($this->entity,"modedesktop",$modedesktop);
// Profilage
$itemsordered = $this->em->getRepository("CadolesPortalBundle:Item")->getUserItems($this->user,$bookmarks,$items,$itemcategorys,$iditemcategory,$this->get('session')->get('ssoitems'),$withbookmark,false);
}
@ -639,10 +662,14 @@ class PagewidgetController extends Controller
break;
}
}
// Préference utilisateur
$modedesktop = $this->getKeyPreference($this->entity,"modedesktop",$modedesktop);
// Profilage
$itemsordered = $this->em->getRepository("CadolesPortalBundle:Item")->getUserItems($this->user,$bookmarks,$items,$itemcategorys,null,$this->get('session')->get('ssoitems'),0,true);
}
// Render
return $this->getRender('viewitemessential.html.twig', [

View File

@ -403,6 +403,31 @@
}
}
// Changer widget
function changeWidget(idwidget,key,value) {
{% if app.user %}
if(key=="modedesktop") {
value=value+1;
console.log(value);
if(value==4) value=0;
console.log(value);
}
$.ajax({
method: "POST",
url: "{{ path('cadoles_core_user_preference') }}",
data: {
id:idwidget,
key:key,
value:value
},
success: function() {
location.reload();
}
});
{% endif %}
}
// Aggrandir widget
function bigWidget(idwidget) {
var url="{{ path('cadoles_portal_'~access~'_page_view',{id:entity.id,group:group,usage:usage,by:mode,look:'list',selwidget:'xx'})}}";

View File

@ -48,6 +48,10 @@
{% else %}
<div class="widget {%if entity.border %} widget-bordered {%else%} widget-notbordered {%endif%} widget-item" data-id="{{ entity.id }}" loc="{{ entity.loc }}" style="{{ stylewidget }}" height="{{ entity.height }}px">
<div class="widgetmenu">
{% if canadd %}
<i class="fas fa-text-height" title="Changer taille des items" onClick="changeWidget({{ entity.id }},'modedesktop',{{modedesktop}})" style="{{ stylewidgetmenu }}"></i>
{% endif %}
{% if canupdate %}
<i class="fa fa-trash fa-fw" title="Supprimer le Widget" onClick="delWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
<i class="fa fa-file fa-fw" title="Modifier le Widget" onClick="modWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>

View File

@ -48,6 +48,10 @@
{% else %}
<div class="widget {%if entity.border %} widget-bordered {%else%} widget-notbordered {%endif%} widget-itemessential" data-id="{{ entity.id }}" loc="{{ entity.loc }}" style="{{ stylewidget }}" height="{{ entity.height }}px">
<div class="widgetmenu">
{% if canadd %}
<i class="fas fa-text-height" title="Changer taille des items" onClick="changeWidget({{ entity.id }},'modedesktop',{{modedesktop}})" style="{{ stylewidgetmenu }}"></i>
{% endif %}
{% if canupdate %}
<i class="fa fa-trash fa-fw" title="Supprimer le Widget" onClick="delWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
<i class="fa fa-file fa-fw" title="Modifier le Widget" onClick="modWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>