From 53fe90adc38895bdcc3ad367ee9226c4454d08c1 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 18 Aug 2021 13:43:56 +0200 Subject: [PATCH] AccompanyingCourse: check if conditions of confirmation are met, or display alert --- .../AccompanyingCourse/components/Confirm.vue | 85 +++++++++++++------ .../vuejs/AccompanyingCourse/js/i18n.js | 10 ++- .../vuejs/AccompanyingCourse/store/index.js | 23 +++++ 3 files changed, 90 insertions(+), 28 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue index 13752f383..eaef2c875 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue @@ -3,24 +3,43 @@

{{ $t('confirm.title') }}

-
-

- {{ $t('confirm.text_draft') }} - {{ $t('course.step.draft') }} -

-

- {{ $t('confirm.text_active') }} - {{ $t('course.step.active') }} -

+

+ +
+
+ {{ $t('confirm.alert_validation') }} +
    +
  • + {{ $t(notValidMessages[k].msg) }} + + + +
  • +
+
+
    +
  • + +
  • +
+
+ +
+

+
    +
  • + +
  • +
+
-
@@ -43,6 +62,7 @@ - - diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js index a620a384f..0a90fda47 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js @@ -97,10 +97,14 @@ const appMessages = { }, confirm: { title: "Confirmation", - text_draft: "Le parcours est actuellement à l'état de ", - text_active: "En validant cette étape, vous lui donnez le statut ", + text_draft: "Le parcours est actuellement à l'état de {0}.", + text_active: "En validant cette étape, vous lui donnez le statut {0}.", + alert_validation: "Certaines conditions ne sont pas remplies pour pouvoir confirmer le parcours :", + participation_not_valid: "sélectionnez au minimum 1 usager", + socialIssue_not_valid: "sélectionnez au minimum une problématique sociale", + location_not_valid: "indiquez au minimum une localisation temporaire du parcours", sure: "Êtes-vous sûr ?", - sure_description: "Une fois le changement confirmé, il n'est plus possible de le remettre à l'état de brouillon !", + sure_description: "Une fois le changement confirmé, il ne sera plus possible de le remettre à l'état de brouillon !", ok: "Confirmer le parcours" }, // catch errors diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js index 499b40439..054a147a5 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js @@ -25,6 +25,29 @@ let initPromise = getAccompanyingCourse(id) errorMsg: [] }, getters: { + isParticipationValid(state) { + return state.accompanyingCourse.participations.length > 0; + }, + isSocialIssueValid(state) { + return state.accompanyingCourse.socialIssues.length > 0; + }, + isLocationValid(state) { + return state.accompanyingCourse.location !== null; + }, + validationKeys(state, getters) { + let keys = []; + if (!getters.isParticipationValid) { keys.push('participation'); } + if (!getters.isSocialIssueValid) { keys.push('socialIssue'); } + if (!getters.isLocationValid) { keys.push('location'); } + //console.log('getter keys', keys); + return keys; + }, + isValidToBeConfirmed(state, getters) { + if (getters.validationKeys.length === 0) { + return true; + } + return false; + } }, mutations: { catchError(state, error) {