Compare commits

..

1 Commits

12 changed files with 59 additions and 105 deletions

View File

@@ -0,0 +1,6 @@
kind: Feature
body: Add columns for comments linked to an activity in the activity list export
time: 2025-10-29T15:25:10.493968528+01:00
custom:
Issue: "404"
SchemaChange: No schema change

View File

@@ -1,6 +0,0 @@
kind: UX
body: Remove the label if there is only one scope and no scope picking field is displayed.
time: 2025-10-30T15:31:26.807444365+01:00
custom:
Issue: "449"
SchemaChange: No schema change

View File

@@ -14,7 +14,7 @@
"ext-openssl": "*",
"ext-redis": "*",
"ext-zlib": "*",
"champs-libres/wopi-bundle": "dev-master#1be045ee95310d2037683859ecefdbf3a10f7be6 as 0.4.x-dev",
"champs-libres/wopi-bundle": "dev-master@dev",
"champs-libres/wopi-lib": "dev-master@dev",
"doctrine/data-fixtures": "^1.8",
"doctrine/doctrine-bundle": "^2.1",

View File

@@ -66,6 +66,9 @@ class ListActivityHelper
->leftJoin('activity.location', 'location')
->addSelect('location.name AS locationName')
->addSelect('activity.sentReceived')
->addSelect('activity.comment.comment AS commentText')
->addSelect('activity.comment.date AS commentDate')
->addSelect('JSON_BUILD_OBJECT(\'uid\', activity.comment.userId, \'d\', activity.comment.date) AS commentUser')
->addSelect('JSON_BUILD_OBJECT(\'uid\', IDENTITY(activity.createdBy), \'d\', activity.createdAt) AS createdBy')
->addSelect('activity.createdAt')
->addSelect('JSON_BUILD_OBJECT(\'uid\', IDENTITY(activity.updatedBy), \'d\', activity.updatedAt) AS updatedBy')
@@ -87,6 +90,8 @@ class ListActivityHelper
'createdAt', 'updatedAt' => $this->dateTimeHelper->getLabel($key),
'createdBy', 'updatedBy' => $this->userHelper->getLabel($key, $values, $key),
'date' => $this->dateTimeHelper->getLabel(self::MSG_KEY.$key),
'commentDate' => $this->dateTimeHelper->getLabel(self::MSG_KEY.'comment_date'),
'commentUser' => $this->userHelper->getLabel($key, $values, self::MSG_KEY.'comment_user'),
'attendeeName' => function ($value) {
if ('_header' === $value) {
return 'Attendee';
@@ -176,6 +181,9 @@ class ListActivityHelper
'usersNames',
'thirdPartiesIds',
'thirdPartiesNames',
'commentText',
'commentDate',
'commentUser',
'createdBy',
'createdAt',
'updatedBy',

View File

@@ -18,7 +18,6 @@ use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
use Chill\DocStoreBundle\Form\CollectionStoredObjectType;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Location;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\CommentType;
@@ -48,7 +47,6 @@ use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Security;
class ActivityType extends AbstractType
{
@@ -62,7 +60,6 @@ class ActivityType extends AbstractType
protected array $timeChoices,
protected SocialIssueRender $socialIssueRender,
protected SocialActionRender $socialActionRender,
private readonly Security $security,
) {
if (!$tokenStorage->getToken()->getUser() instanceof User) {
throw new \RuntimeException('you should have a valid user');
@@ -90,22 +87,10 @@ class ActivityType extends AbstractType
$activityType = $options['activityType'];
if (null !== $options['data']->getPerson()) {
$reachableScopes = array_values(
array_filter(
$this->authorizationHelper->getReachableScopes(
$this->security->getUser(),
ActivityVoter::CREATE === (string) $options['role'] ? ActivityVoter::CREATE_PERSON : (string) $options['role'],
$options['center']
),
static fn (Scope $s) => $s->isActive()
)
);
$builder->add('scope', ScopePickerType::class, [
'reachable_scopes' => $reachableScopes,
'center' => $options['center'],
'role' => ActivityVoter::CREATE === (string) $options['role'] ? ActivityVoter::CREATE_PERSON : (string) $options['role'],
'required' => true,
'label' => count($reachableScopes) > 1 ? 'Scope' : false,
]);
}

View File

@@ -404,7 +404,9 @@ export:
id: Identifiant
List activities linked to an accompanying course: Liste les échanges liés à un parcours en fonction de différents filtres.
List activity linked to a course: Liste des échanges liés à un parcours
commentText: Commentaire
comment_date: Date de la dernière édition du commentaire
comment_user: Dernière édition par
filter:
activity:

View File

@@ -14,11 +14,9 @@ namespace Chill\DocStoreBundle\Form;
use Chill\DocStoreBundle\Entity\Document;
use Chill\DocStoreBundle\Entity\DocumentCategory;
use Chill\DocStoreBundle\Entity\PersonDocument;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\ChillTextareaType;
use Chill\MainBundle\Form\Type\ScopePickerType;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
@@ -29,11 +27,10 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
class PersonDocumentType extends AbstractType
{
public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly Security $security, private readonly AuthorizationHelperInterface $authorizationHelper, private readonly ScopeResolverDispatcher $scopeResolverDispatcher, private readonly ParameterBagInterface $parameterBag, private readonly CenterResolverDispatcher $centerResolverDispatcher) {}
public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly ScopeResolverDispatcher $scopeResolverDispatcher, private readonly ParameterBagInterface $parameterBag, private readonly CenterResolverDispatcher $centerResolverDispatcher) {}
public function buildForm(FormBuilderInterface $builder, array $options)
{
@@ -59,19 +56,9 @@ class PersonDocumentType extends AbstractType
]);
if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) {
$reachableScopes = array_values(
array_filter(
$this->authorizationHelper->getReachableScopes(
$this->security->getUser(),
$options['role'],
$this->centerResolverDispatcher->resolveCenter($document)
),
static fn (Scope $s) => $s->isActive()
)
);
$builder->add('scope', ScopePickerType::class, [
'reachable_scopes' => $reachableScopes,
'label' => count($reachableScopes) > 1 ? 'Scope' : false,
'center' => $this->centerResolverDispatcher->resolveCenter($document),
'role' => $options['role'],
]);
}
}

View File

@@ -40,39 +40,41 @@ use Symfony\Component\Security\Core\Security;
class ScopePickerType extends AbstractType
{
public function __construct(
private readonly AuthorizationHelperInterface $authorizationHelper,
private readonly Security $security,
private readonly TranslatableStringHelperInterface $translatableStringHelper,
) {}
public function buildForm(FormBuilderInterface $builder, array $options)
{
/* $items = array_values(
array_filter(
$this->authorizationHelper->getReachableScopes(
$this->security->getUser(),
$options['role'],
$options['center']
),
static fn (Scope $s) => $s->isActive()
)
);*/
$items = array_values(
array_filter(
$this->authorizationHelper->getReachableScopes(
$this->security->getUser(),
$options['role'],
$options['center']
),
static fn (Scope $s) => $s->isActive()
)
);
if (0 === \count($options['reachable_scopes'])) {
if (0 === \count($items)) {
throw new \RuntimeException('no scopes are reachable. This form should not be shown to user');
}
if (1 !== \count($options['reachable_scopes'])) {
if (1 !== \count($items)) {
$builder->add('scope', EntityType::class, [
'class' => Scope::class,
'placeholder' => 'Choose the circle',
'choice_label' => fn (Scope $c) => $this->translatableStringHelper->localize($c->getName()),
'choices' => $options['reachable_scopes'],
'choices' => $items,
]);
$builder->setDataMapper(new ScopePickerDataMapper());
} else {
$builder->add('scope', HiddenType::class, [
'data' => $options['reachable_scopes'][0]->getId(),
'data' => $items[0]->getId(),
]);
$builder->setDataMapper(new ScopePickerDataMapper($options['reachable_scopes'][0]));
$builder->setDataMapper(new ScopePickerDataMapper($items[0]));
}
}
@@ -84,13 +86,11 @@ class ScopePickerType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setRequired('reachable_scopes')
->setAllowedTypes('reachable_scopes', ['array']);
// create `center` option
// ->setRequired('center')
// ->setAllowedTypes('center', [Center::class, 'array', 'null'])
// create ``role` option
// ->setRequired('role')
// ->setAllowedTypes('role', ['string']);
// create `center` option
->setRequired('center')
->setAllowedTypes('center', [Center::class, 'array', 'null'])
// create ``role` option
->setRequired('role')
->setAllowedTypes('role', ['string']);
}
}

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Form\Type;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Form\Type\ScopePickerType;
@@ -41,7 +42,8 @@ final class ScopePickerTypeTest extends TypeTestCase
public function estBuildOneScopeIsSuccessful()
{
$form = $this->factory->create(ScopePickerType::class, null, [
'reachable_scopes' => [new Scope()],
'center' => new Center(),
'role' => 'ONE_SCOPE',
]);
$view = $form->createView();
@@ -52,7 +54,8 @@ final class ScopePickerTypeTest extends TypeTestCase
public function testBuildThreeScopesIsSuccessful()
{
$form = $this->factory->create(ScopePickerType::class, null, [
'reachable_scopes' => [new Scope(), new Scope(), new Scope()],
'center' => new Center(),
'role' => 'THREE_SCOPE',
]);
$view = $form->createView();
@@ -63,7 +66,8 @@ final class ScopePickerTypeTest extends TypeTestCase
public function testBuildTwoScopesIsSuccessful()
{
$form = $this->factory->create(ScopePickerType::class, null, [
'reachable_scopes' => [new Scope(), new Scope()],
'center' => new Center(),
'role' => 'TWO_SCOPE',
]);
$view = $form->createView();

View File

@@ -60,7 +60,6 @@ import {
EVALUATION_DOCUMENT_MOVE_SUCCESS,
} from "translator";
import { useToast } from "vue-toast-notification";
import { buildLinkCreate as buildLinkCreateNotification } from "ChillMainAssets/lib/entity-notification/api";
const props = defineProps(["evaluation", "docAnchorId"]);
const store = useStore();

View File

@@ -167,20 +167,10 @@ final readonly class PersonContext implements PersonContextInterface
}
if ($this->isScopeNecessary($entity)) {
$reachableScopes = array_values(
array_filter(
$this->authorizationHelper->getReachableScopes(
$this->security->getUser(),
PersonDocumentVoter::CREATE,
$this->centerResolverManager->resolveCenters($entity)
),
static fn (Scope $s) => $s->isActive()
)
);
$builder->add('scope', ScopePickerType::class, [
'reachable_scopes' => $reachableScopes,
'label' => count($reachableScopes) > 1 ? 'Scope' : false,
'center' => $this->centerResolverManager->resolveCenters($entity),
'role' => PersonDocumentVoter::CREATE,
'label' => 'Scope',
]);
}
}

View File

@@ -11,13 +11,11 @@ declare(strict_types=1);
namespace Chill\TaskBundle\Form;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\ChillTextareaType;
use Chill\MainBundle\Form\Type\DateIntervalType;
use Chill\MainBundle\Form\Type\ScopePickerType;
use Chill\MainBundle\Form\Type\UserPickerType;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher;
use Chill\TaskBundle\Security\Authorization\TaskVoter;
@@ -26,18 +24,10 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
class SingleTaskType extends AbstractType
{
public function __construct(
private readonly ParameterBagInterface $parameterBag,
private readonly CenterResolverDispatcherInterface $centerResolverDispatcher,
private readonly Security $security,
private readonly AuthorizationHelperInterface $authorizationHelper,
private readonly ScopeResolverDispatcher $scopeResolverDispatcher,
) {}
public function __construct(private readonly ParameterBagInterface $parameterBag, private readonly CenterResolverDispatcherInterface $centerResolverDispatcher, private readonly ScopeResolverDispatcher $scopeResolverDispatcher) {}
public function buildForm(FormBuilderInterface $builder, array $options)
{
@@ -72,22 +62,11 @@ class SingleTaskType extends AbstractType
]);
if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) {
$reachableScopes = array_values(
array_filter(
$this->authorizationHelper->getReachableScopes(
$this->security->getUser(),
$options['role'],
$center
),
static fn (Scope $s) => $s->isActive()
)
);
$builder
->add('circle', ScopePickerType::class, [
'reachable_scopes' => $reachableScopes,
'center' => $center,
'role' => $options['role'],
'required' => true,
'label' => count($reachableScopes) > 1 ? 'Scope' : false,
]);
}
}