[activity] handle case when there is no action associated to selected

issues
This commit is contained in:
Julien Fastré 2021-11-29 22:43:14 +01:00
parent 55b9242690
commit 7b0c7988df
4 changed files with 41 additions and 14 deletions

View File

@ -50,6 +50,11 @@
<i class="chill-green fa fa-circle-o-notch fa-spin fa-lg"></i>
</div>
<span v-else-if="socialIssuesSelected.length === 0" class="inline-choice chill-no-data-statement mt-3">
{{ $t('activity.select_first_a_social_issue') }}
</span>
<template v-else-if="socialActionsList.length > 0">
<check-social-action
v-if="socialIssuesSelected.length || socialActionsSelected.length"
v-for="action in socialActionsList"
@ -58,11 +63,13 @@
v-bind:selection="socialActionsSelected"
@updateSelected="updateActionsSelected">
</check-social-action>
</template>
<span v-else class="inline-choice chill-no-data-statement mt-3">
{{ $t('activity.select_first_a_social_issue') }}
<span v-else-if="actionAreLoaded && socialActionsList.length === 0" class="inline-choice chill-no-data-statement mt-3">
{{ $t('activity.social_action_list_empty') }}
</span>
</div>
</div>
@ -85,7 +92,8 @@ export default {
data() {
return {
issueIsLoading: false,
actionIsLoading: false
actionIsLoading: false,
actionAreLoaded: false,
}
},
computed: {
@ -109,6 +117,7 @@ export default {
/* Load others issues in multiselect
*/
this.issueIsLoading = true;
this.actionAreLoaded = false;
getSocialIssues().then(response => new Promise((resolve, reject) => {
this.$store.commit('updateIssuesOther', response.results);
@ -141,6 +150,7 @@ export default {
this.$store.commit('filterList', 'actions');
this.issueIsLoading = false;
this.actionAreLoaded = true;
resolve();
}));
},

View File

@ -9,6 +9,7 @@ const activityMessages = {
choose_other_social_issue: "Ajouter une autre problématique sociale...",
social_actions: "Actions d'accompagnement",
select_first_a_social_issue: "Sélectionnez d'abord une problématique sociale",
social_action_list_empty: "Aucune action sociale disponible",
//
add_persons: "Ajouter des personnes concernées",

View File

@ -10,10 +10,12 @@
namespace Chill\ActivityBundle\Validator\Constraints;
use Chill\ActivityBundle\Entity\Activity;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use function array_merge;
class ActivityValidityValidator extends ConstraintValidator
{
@ -118,9 +120,19 @@ class ActivityValidityValidator extends ConstraintValidator
}
if ($activity->getActivityType()->getSocialActionsVisible() === 2 && $activity->getSocialActions()->count() === 0) {
// check if a social action may be added
$actions = [];
foreach ($activity->getSocialIssues() as $socialIssue) {
/** @var SocialIssue $socialIssue */
$actions = array_merge($actions, $socialIssue->getRecursiveSocialActions()->toArray());
}
if (0 < count($actions)) {
$this->context
->buildViolation($constraint->socialActionsMessage)
->addViolation();
}
}
}
}

View File

@ -103,6 +103,10 @@ class Paginator implements PaginatorInterface
public function countPages()
{
if (0 === $this->itemPerPage) {
return 1;
}
$nb = floor($this->totalItems / $this->itemPerPage);
if ($this->totalItems % $this->itemPerPage > 0) {