Skip to content

Commit

Permalink
feat: empêche le changement de statuts en hors ligne
Browse files Browse the repository at this point in the history
Signed-off-by: Maud Royer <hello@maudroyer.fr>
  • Loading branch information
jillro committed May 6, 2024
1 parent 2638779 commit 8d16ab0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
22 changes: 19 additions & 3 deletions src/components/record/CertificationSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { usePermissions } from "@/stores/permissions.js"
import { useRecordStore } from "@/stores/record.js"
import CertificationModal from "@/components/record/modals/CertificationModal.vue"
import SaveAuditModal from "@/components/record/modals/SaveAuditModal.vue"
import { useOnline } from "@vueuse/core"
const isOnline = useOnline()
const recordStore = useRecordStore()
const operatorStore = useOperatorStore()
const featuresSets = useFeaturesSetsStore()
Expand Down Expand Up @@ -75,21 +77,35 @@ async function handleCertify ({ patch }) {
<div class="fr-callout fr-callout--blue-ecume fr-mb-2w" v-if="canEndAudit && record.certification_state === CERTIFICATION_STATE.OPERATOR_DRAFT">
<h3 class="fr-callout__title">Parcellaire complet <span aria-hidden="true">🎉</span></h3>

<button v-if="permissions.canSaveAudit" class="fr-btn" @click="showSaveAuditModal = true">Terminer l'audit</button>
<button
v-if="permissions.canSaveAudit"
class="fr-btn"
@click="showSaveAuditModal = true"
:disabled="!isOnline"
>Terminer l'audit</button>
<span v-else>L'auditeur doit maintenant terminer l'audit.</span>
</div>

<div class="fr-callout fr-callout--blue-ecume fr-mb-2w" v-else-if="canEndAudit && record.certification_state === CERTIFICATION_STATE.AUDITED">
<h3 class="fr-callout__title">Audit terminé</h3>

<button v-if="permissions.canSendAudit" class="fr-btn" @click="handleSendAudit">Soumettre pour certification</button>
<button
v-if="permissions.canSendAudit"
class="fr-btn"
@click="handleSendAudit"
:disabled="!isOnline"
>Soumettre pour certification</button>
<span v-else>L'auditeur doit maintenant soumettre l'audit pour certification.</span>
</div>

<div class="fr-callout fr-callout--blue-ecume fr-mb-2w" v-else-if="canEndAudit && record.certification_state === CERTIFICATION_STATE.PENDING_CERTIFICATION">
<h3 class="fr-callout__title">Certification en cours</h3>

<button v-if="permissions.canCertify" class="fr-btn" @click="showCertificationModal = true">Certifier le parcellaire</button>
<button
v-if="permissions.canCertify"
class="fr-btn" @click="showCertificationModal = true"
:disabled="!isOnline"
>Certifier le parcellaire</button>
<span v-else>Le chargé de certification doit maintenant certifier le parcellaire.</span>
</div>

Expand Down
4 changes: 3 additions & 1 deletion src/components/record/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<FeatureGroup v-for="featureGroup in featureGroups" :featureGroup="featureGroup" :key="featureGroup.key" @edit:featureId="(featuredId) => editedFeatureId = featuredId" @delete:featureId="(featureId) => maybeDeletedFeatureId = featureId" />
</table>

<p class="fr-my-3w" v-if="permissions.canAddParcelle">
<p class="fr-my-3w" v-if="permissions.canAddParcelle && isOnline">
<router-link :to="`/exploitations/${operator.numeroBio}/${record.record_id}/ajout-parcelle`" class="fr-btn fr-btn--secondary fr-icon--sm fr-btn--icon-left fr-icon-add-line">Ajouter une parcelle</router-link>
</p>
</div>
Expand Down Expand Up @@ -127,6 +127,7 @@ import {
} from '../Features/index.js'
import toast from "@/components/toast.js"
import { statsPush } from "@/stats.js"
import { useOnline } from "@vueuse/core"
defineProps({
editForm: {
Expand All @@ -138,6 +139,7 @@ defineProps({
},
})
const isOnline = useOnline()
const operatorStore = useOperatorStore()
const recordStore = useRecordStore()
const featuresStore = useFeaturesStore()
Expand Down

0 comments on commit 8d16ab0

Please sign in to comment.