mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
[activity] handle case when there is no action associated to selected
issues
This commit is contained in:
parent
55b9242690
commit
7b0c7988df
@ -50,19 +50,26 @@
|
||||
<i class="chill-green fa fa-circle-o-notch fa-spin fa-lg"></i>
|
||||
</div>
|
||||
|
||||
<check-social-action
|
||||
v-if="socialIssuesSelected.length || socialActionsSelected.length"
|
||||
v-for="action in socialActionsList"
|
||||
v-bind:key="action.id"
|
||||
v-bind:action="action"
|
||||
v-bind:selection="socialActionsSelected"
|
||||
@updateSelected="updateActionsSelected">
|
||||
</check-social-action>
|
||||
|
||||
<span v-else class="inline-choice chill-no-data-statement mt-3">
|
||||
<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"
|
||||
v-bind:key="action.id"
|
||||
v-bind:action="action"
|
||||
v-bind:selection="socialActionsSelected"
|
||||
@updateSelected="updateActionsSelected">
|
||||
</check-social-action>
|
||||
</template>
|
||||
|
||||
<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();
|
||||
}));
|
||||
},
|
||||
|
@ -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",
|
||||
|
@ -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) {
|
||||
$this->context
|
||||
->buildViolation($constraint->socialActionsMessage)
|
||||
->addViolation();
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user