mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'features/improve-activity' into 'master'
Features/improve activity See merge request Chill-Projet/chill-bundles!103
This commit is contained in:
commit
54316d148c
@ -72,6 +72,7 @@ class ActivityController extends AbstractController
|
|||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$view = null;
|
$view = null;
|
||||||
|
// TODO: add pagination
|
||||||
|
|
||||||
[$person, $accompanyingPeriod] = $this->getEntity($request);
|
[$person, $accompanyingPeriod] = $this->getEntity($request);
|
||||||
|
|
||||||
@ -80,10 +81,9 @@ class ActivityController extends AbstractController
|
|||||||
->getReachableCircles($this->getUser(), new Role('CHILL_ACTIVITY_SEE'),
|
->getReachableCircles($this->getUser(), new Role('CHILL_ACTIVITY_SEE'),
|
||||||
$person->getCenter());
|
$person->getCenter());
|
||||||
|
|
||||||
$activities = $em->getRepository('ChillActivityBundle:Activity')->findBy(
|
$activities = $em->getRepository(Activity::class)
|
||||||
['person' => $person, 'scope' => $reachableScopes],
|
->findByPersonImplied($person, $reachableScopes)
|
||||||
['date' => 'DESC'],
|
;
|
||||||
);
|
|
||||||
|
|
||||||
$event = new PrivacyEvent($person, array(
|
$event = new PrivacyEvent($person, array(
|
||||||
'element_class' => Activity::class,
|
'element_class' => Activity::class,
|
||||||
|
@ -224,7 +224,8 @@ class ActivityType extends AbstractType
|
|||||||
|
|
||||||
if ($activityType->isVisible('comment')) {
|
if ($activityType->isVisible('comment')) {
|
||||||
$builder->add('comment', CommentType::class, [
|
$builder->add('comment', CommentType::class, [
|
||||||
'label' => $activityType->getLabel('comment'),
|
'label' => empty($activityType->getLabel('comment'))
|
||||||
|
? 'activity.comment' : $activityType->getLabel('comment'),
|
||||||
'required' => $activityType->isRequired('comment'),
|
'required' => $activityType->isRequired('comment'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
namespace Chill\ActivityBundle\Menu;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
|
||||||
use Knp\Menu\MenuItem;
|
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
|
||||||
*/
|
|
||||||
class MenuBuilder implements LocalMenuBuilderInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var TokenStorageInterface
|
|
||||||
*/
|
|
||||||
protected $tokenStorage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var TranslatorInterface
|
|
||||||
*/
|
|
||||||
protected $translator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var AuthorizationHelper
|
|
||||||
*/
|
|
||||||
protected $authorizationHelper;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
TokenStorageInterface $tokenStorage,
|
|
||||||
TranslatorInterface $translator,
|
|
||||||
AuthorizationHelper $authorizationHelper
|
|
||||||
) {
|
|
||||||
$this->tokenStorage = $tokenStorage;
|
|
||||||
$this->translator = $translator;
|
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
|
||||||
{
|
|
||||||
/* @var $person \Chill\PersonBundle\Entity\Person */
|
|
||||||
$person = $parameters['person'];
|
|
||||||
$user = $this->tokenStorage->getToken()->getUser();
|
|
||||||
$roleSee = new Role(ActivityVoter::SEE);
|
|
||||||
$roleAdd = new Role(ActivityVoter::CREATE);
|
|
||||||
|
|
||||||
if ($this->authorizationHelper->userHasAccess($user, $person, $roleSee)) {
|
|
||||||
$menu->addChild($this->translator->trans('Activity list'), [
|
|
||||||
'route' => 'chill_activity_activity_list',
|
|
||||||
'routeParameters' => [
|
|
||||||
'person_id' => $person->getId()
|
|
||||||
]
|
|
||||||
])
|
|
||||||
->setExtras([
|
|
||||||
'order' => 201
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->authorizationHelper->userHasAccess($user, $person, $roleAdd)) {
|
|
||||||
$menu->addChild($this->translator->trans('Add a new activity'), [
|
|
||||||
'route' => 'chill_activity_activity_new',
|
|
||||||
'routeParameters' => [
|
|
||||||
'person_id' => $person->getId()
|
|
||||||
]
|
|
||||||
])
|
|
||||||
->setExtras([
|
|
||||||
'order' => 200
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getMenuIds(): array
|
|
||||||
{
|
|
||||||
return [ 'person' ];
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,8 +15,7 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Chill\ActivityBundle\Menu;
|
namespace Chill\ActivityBundle\Menu;
|
||||||
|
|
||||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||||
use Knp\Menu\MenuItem;
|
use Knp\Menu\MenuItem;
|
||||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||||
@ -65,15 +64,6 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
->setExtra('order', 201)
|
->setExtra('order', 201)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
if ($this->authorizationChecker->isGranted(ActivityVoter::CREATE, $person)) {
|
|
||||||
$menu->addChild(
|
|
||||||
$this->translator->trans('Add a new activity'), [
|
|
||||||
'route' => 'chill_activity_activity_new',
|
|
||||||
'routeParameters' => [ 'person_id' => $person->getId() ],
|
|
||||||
])
|
|
||||||
->setExtra('order', 200)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getMenuIds(): array
|
public static function getMenuIds(): array
|
||||||
|
@ -38,5 +38,30 @@ class ActivityRepository extends ServiceEntityRepository
|
|||||||
{
|
{
|
||||||
parent::__construct($registry, Activity::class);
|
parent::__construct($registry, Activity::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function findByPersonImplied($person, array $scopes, $orderBy = [ 'date' => 'DESC'], $limit = 100, $offset = 0)
|
||||||
|
{
|
||||||
|
$qb = $this->createQueryBuilder('a');
|
||||||
|
$qb->select('a');
|
||||||
|
|
||||||
|
$qb
|
||||||
|
// TODO add acl
|
||||||
|
//->where($qb->expr()->in('a.scope', ':scopes'))
|
||||||
|
//->setParameter('scopes', $scopes)
|
||||||
|
->andWhere(
|
||||||
|
$qb->expr()->orX(
|
||||||
|
$qb->expr()->eq('a.person', ':person'),
|
||||||
|
':person MEMBER OF a.persons'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
->setParameter('person', $person)
|
||||||
|
;
|
||||||
|
|
||||||
|
foreach ($orderBy as $k => $dir) {
|
||||||
|
$qb->addOrderBy('a.'.$k, $dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $qb->getQuery()
|
||||||
|
->getResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<button class="sc-button bt-update" type="submit">{{ 'Save activity'|trans }}</button>
|
<button class="sc-button bt-update" type="submit">{{ 'Save'|trans }}</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{{ form_end(edit_form) }}
|
{{ form_end(edit_form) }}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
|
{{ parent() }}
|
||||||
{{ encore_entry_link_tags('async_upload') }}
|
{{ encore_entry_link_tags('async_upload') }}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.addEventListener('DOMContentLoaded', function (e) {
|
window.addEventListener('DOMContentLoaded', function (e) {
|
||||||
@ -22,6 +23,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
|
{{ parent() }}
|
||||||
{{ encore_entry_link_tags('async_upload') }}
|
{{ encore_entry_link_tags('async_upload') }}
|
||||||
{{ encore_entry_link_tags('vue_activity') }}
|
{{ encore_entry_link_tags('vue_activity') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
</p>
|
</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
||||||
<div class="flex-table list-records {{ context }}">
|
<div class="flex-table list-records context-{{ context }}">
|
||||||
<!--
|
<!--
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -54,6 +54,20 @@
|
|||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if context == 'person' and activity.accompanyingPeriod is not empty %}
|
||||||
|
<div class="accompanyingPeriodLink" style="margin-top: 1rem">
|
||||||
|
<a
|
||||||
|
href="{{ chill_path_add_return_path(
|
||||||
|
"chill_person_accompanying_course_index",
|
||||||
|
{ 'accompanying_period_id': activity.accompanyingPeriod.id }
|
||||||
|
) }}"
|
||||||
|
>
|
||||||
|
<i class="fa fa-random"></i>
|
||||||
|
{{ activity.accompanyingPeriod.id }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="item-col">
|
<div class="item-col">
|
||||||
@ -147,13 +161,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{%
|
{%
|
||||||
if activity.comment.comment is not empty
|
if activity.comment.comment is not empty
|
||||||
or activity.persons|length > 0
|
or activity.persons|length > 0
|
||||||
or activity.thirdParties|length > 0
|
or activity.thirdParties|length > 0
|
||||||
or activity.users|length > 0
|
or activity.users|length > 0
|
||||||
%}
|
%}
|
||||||
<div class="item-row details">
|
<div class="item-row details">
|
||||||
<div class="item-col">
|
<div class="item-col">
|
||||||
|
|
||||||
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'row', 'entity': activity } %}
|
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'row', 'entity': activity } %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -170,10 +185,13 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<ul class="record_actions">
|
{% if context != 'person' %}
|
||||||
<li>
|
{# TODO set this condition in configuration #}
|
||||||
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'accompanying_period_id': accompanying_course_id}) }}" class="sc-button bt-create">
|
<ul class="record_actions">
|
||||||
{{ 'Add a new activity' | trans }}
|
<li>
|
||||||
</a>
|
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'accompanying_period_id': accompanying_course_id}) }}" class="sc-button bt-create">
|
||||||
</li>
|
{{ 'Add a new activity' | trans }}
|
||||||
</ul>
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
@ -98,7 +98,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<button class="sc-button bt-create" type="submit">
|
<button class="sc-button bt-create" type="submit">
|
||||||
{{ 'Add a new activity'|trans }}
|
{{ 'Create'|trans }}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
|
{{ parent() }}
|
||||||
{{ encore_entry_script_tags('async_upload') }}
|
{{ encore_entry_script_tags('async_upload') }}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.addEventListener('DOMContentLoaded', function (e) {
|
window.addEventListener('DOMContentLoaded', function (e) {
|
||||||
@ -22,6 +23,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
|
{{ parent() }}
|
||||||
<link rel="stylesheet" href="{{ asset('build/async_upload.css') }}"/>
|
<link rel="stylesheet" href="{{ asset('build/async_upload.css') }}"/>
|
||||||
{{ encore_entry_link_tags('vue_activity') }}
|
{{ encore_entry_link_tags('vue_activity') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -117,7 +117,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="sc-button bt-update" href="{{ path('chill_activity_activity_edit', { 'id': entity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id }) }}">
|
<a class="sc-button bt-update" href="{{ path('chill_activity_activity_edit', { 'id': entity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id }) }}">
|
||||||
{{ 'Edit the activity'|trans }}
|
{{ 'Edit'|trans }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{# TODO
|
{# TODO
|
||||||
|
@ -74,6 +74,7 @@ Users concerned: T(M)S
|
|||||||
activity:
|
activity:
|
||||||
Insert a document: Insérer un document
|
Insert a document: Insérer un document
|
||||||
Remove a document: Supprimer le document
|
Remove a document: Supprimer le document
|
||||||
|
comment: Commentaire
|
||||||
|
|
||||||
|
|
||||||
#timeline
|
#timeline
|
||||||
|
@ -45,7 +45,8 @@ class CommentType extends AbstractType
|
|||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('comment', ChillTextareaType::class, [
|
->add('comment', ChillTextareaType::class, [
|
||||||
'disable_editor' => $options['disable_editor']
|
'disable_editor' => $options['disable_editor'],
|
||||||
|
'label' => $options['label'],
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user