ajout widget mes groupes de travail (fixes #7)

This commit is contained in:
afornerot 2019-08-19 15:25:27 +02:00
parent fd260e096c
commit caf2cf21fe
4 changed files with 134 additions and 1 deletions

View File

@ -714,7 +714,24 @@ class InitDataCommand extends ContainerAwareCommand
$em->remove($entityWidget);
}
// Widget Mes Groupes
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1830);
if(!$entityWidget) $entityWidget = new Widget();
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_users.png"]);
$entityWidget->setId(-1830);
$entityWidget->setRoworder(2);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Mes Groupes de Travail');
$entityWidget->setDescription("Affiche la liste de vos groupes de travail");
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_group");
$entityWidget->setHeight("630");
$entityWidget->setAutoajust(true);
$entityWidget->setBorder(true);
$entityWidget->setOpened(true);
$entityWidget->setAccess(["config","user","group"]);
$parameter = json_decode('{"fields": []}');
$entityWidget->setParameter($parameter);
$em->persist($entityWidget);
// Widget Séparateur
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1600);

View File

@ -1922,4 +1922,49 @@ class PagewidgetController extends Controller
'group' => $group,
]);
}
public function viewgroupAction(Request $request,$id,$access="config") {
$usage=$request->query->get('usage');
$group=$request->query->get('group');
$user=$this->getUser();
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository($this->labelentity)->find($id);
if (!$entity) throw $this->createNotFoundException('Unable to find entity.');
// Permissions
if($access=="config") {
$canupdate = true;
}
else {
// On s'assure que l'utilisateur à la permission de voir
$page=$entity->getPage();
$em->getRepository("CadolesPortalBundle:Page")->getPermission($this->getUser(),$page,$cansee,$canupdate);
if(!$cansee) throw $this->createNotFoundException('Permission denied');
}
$mygroups=[];
foreach($this->getUser()->getGroups() as $usergroup) {
if($usergroup->getGroup()->getFgcanshare()) {
$title=$usergroup->getGroup()->getLabel();
$icon=null;
if($usergroup->getGroup()->getIcon())
$icon="/".$group->getIcon()->getLabel();
array_push($mygroups,["title"=>$title,"icon"=>$icon]);
}
}
// Render
return $this->render($this->labelentity.':viewgroup.html.twig', [
'entity' => $entity,
'canadd' => ($user),
'canupdate' => $canupdate,
'usage' => $usage,
'groups' => $mygroups,
]);
}
}

View File

@ -763,6 +763,10 @@ cadoles_portal_config_panelwidget_view_chat:
path: /config/pagewidget/view/chat/{id}
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewchat, access: config }
cadoles_portal_config_panelwidget_view_group:
path: /config/pagewidget/view/group/{id}
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewgroup, access: config }
#-- Access user
cadoles_portal_user_pagewidget_widget_sumbit:
path: /user/pagewidget/submit/{idpage}/{idwidgettype}
@ -863,3 +867,8 @@ cadoles_portal_user_panelwidget_view_info:
cadoles_portal_user_panelwidget_view_chat:
path: /pagewidget/view/chat/{id}
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewchat, access: user }
cadoles_portal_user_panelwidget_view_group:
path: /pagewidget/view/group/{id}
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewgroup, access: user }

View File

@ -0,0 +1,62 @@
{% set theme = app.session.get('theme') %}
{% if theme is not empty %}
{{ include('@Theme/'~theme~'/function.html.twig') }}
{% endif %}
{% import "@CadolesPortal/Pagewidget/constants.twig" as constants %}
{% set stylewidget = constants.mystylewidget(entity) %}
{% set stylewidgetmenu = constants.mystylewidgetmenu(entity) %}
{% set stylewidgetheader = constants.mystylewidgetheader(entity) %}
{% set stylewidgetbody = constants.mystylewidgetbody(entity) %}
{% set stylewidgetbodyreverse = constants.mystylewidgetbodyreverse(entity) %}
<div class="widget {%if entity.border %} widget-bordered {%endif%} widget-editor" data-id="{{ entity.id }}" loc="{{ entity.loc }}" style="{{ stylewidget }}" height="{{ entity.height }}px">
{% if canupdate %}
<div class="widgetmenu">
{% if canupdate %}
<i class="fa fa-trash fa-fw" onClick="delWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
<i class="fa fa-file fa-fw" onClick="modWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
{% endif %}
</div>
{% endif %}
<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 }}; overflow-x:hidden; ">
<div class="grid clearfix">
<div class="grid-sizer grid-small"></div>
<div class="grid-gutter-sizer"></div>
{% for group in groups %}
<div class="grid-item grid-small">
<div class="grid-item-content" style="{{ stylewidgetbodyreverse }}">
<div class="grid-item-logo">
{% if group.icon %}
<img class="grid-item-img" height="110" src="/{{ alias }}{{ group.icon }}" />
{% else %}
<img class="grid-item-img" height="110" src="/{{ alias }}/uploads/icon/icon_users.png" />
{% endif %}
</div>
<div class="grid-item-title">
{{ group.title }}
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>