Skip to content

Commit

Permalink
feat: header, summary et certification sur page parcellaire
Browse files Browse the repository at this point in the history
Signed-off-by: Maud Royer <[email protected]>
  • Loading branch information
jillro committed Mar 26, 2024
1 parent 9f95096 commit f1ba46c
Show file tree
Hide file tree
Showing 21 changed files with 176 additions and 164 deletions.
108 changes: 0 additions & 108 deletions src/components/Certification/Summary.vue

This file was deleted.

140 changes: 140 additions & 0 deletions src/components/record/CertificationSection.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<script setup>
import { computed, ref } from 'vue'
import { CERTIFICATION_STATE, isCertificationImmutable } from '@/referentiels/ab.js'
import { updateAuditState } from '@/cartobio-api.js'
import { useFeaturesSetsStore, useOperatorStore, usePermissions, useRecordStore } from '@/stores/index.js'
import CertificationModal from "@/components/record/modals/CertificationModal.vue"
import SaveAuditModal from "@/components/record/modals/SaveAuditModal.vue"
import toast from "@/components/toast.js"
const recordStore = useRecordStore()
const operatorStore = useOperatorStore()
const featuresSets = useFeaturesSetsStore()
const permissions = usePermissions()
const { record } = recordStore
const { operator } = operatorStore
const displayCallout = computed(() => record.audit_demandes && isCertificationImmutable(record.certification_state))
const showSaveAuditModal = ref(false)
const showCertificationModal = ref(false)
const canEndAudit = computed(() => permissions.isOc && recordStore.hasFeatures && !featuresSets.hasRequiredSets)
async function handleSaveAudit ({ record_id: recordId, patch }) {
let newRecord
try {
newRecord = await updateAuditState(recordId, {
...patch,
certification_state: CERTIFICATION_STATE.AUDITED
}
)
} catch (e) {
if (e.response?.status === 400) {
toast.error(e.response.data.error)
return
}
throw e
}
recordStore.update(newRecord)
showSaveAuditModal.value = false
}
async function handleSendAudit () {
let newRecord
try {
newRecord = await updateAuditState(
record.record_id,
{ certification_state: CERTIFICATION_STATE.PENDING_CERTIFICATION }
)
} catch (e) {
if (e.response?.status === 400) {
toast.error(e.response.data.error)
return
}
throw e
}
recordStore.update(newRecord)
}
async function handleCertify ({ record_id: recordId, patch }) {
let newRecord
try {
newRecord = await updateAuditState(recordId, {
...patch,
certification_state: CERTIFICATION_STATE.CERTIFIED
}
)
} catch (e) {
if (e.response?.status === 400) {
toast.error(e.response.data.error)
return
}
throw e
}
recordStore.update(newRecord)
showCertificationModal.value = false
}
</script>
<template>
<div class="demandes fr-callout fr-callout--blue-ecume fr-mb-2w" v-if="displayCallout">
<h3 class="fr-callout__title">Demandes formulées lors de l'audit</h3>
<div v-html="record.audit_demandes" />
</div>
<!-- Agri -->
<div
v-if="permissions.isAgri && record.certification_state !== CERTIFICATION_STATE.OPERATOR_DRAFT"
class="fr-alert fr-alert--info fr-alert--sm fr-mb-2w"
>
<p class="fr-text--sm">Votre parcellaire est en cours de certification, vous ne pouvez pas modifier les données.</p>
</div>
<!-- OC -->
<div class="fr-callout fr-callout--blue-ecume fr-mb-2w" v-if="permissions.isOc && record.audit_notes">
<h3 class="fr-callout__title">Notes finales de l'audit</h3>
<div v-html="record.audit_notes" />
</div>
<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>
<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>
<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>
<span v-else>Le chargé de certification doit maintenant certifier le parcellaire.</span>
</div>
<Teleport to="body">
<SaveAuditModal :operator="operator" :record="record" v-if="showSaveAuditModal" @close="showSaveAuditModal = false" @submit="handleSaveAudit" />
<CertificationModal :operator="operator" :record="record" v-if="showCertificationModal" @close="showCertificationModal = false" @submit="handleCertify" />
</Teleport>
</template>
<style scoped>
</style>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<header class="fr-mb-3w">
<span :data-numerobio="operator.numeroBio">{{ operator.nom }}</span>
<h1 class="fr-h4 fr-my-2v">
<header class="fr-mb-2w">
<span class="fr-text--bold" :data-numerobio="operator.numeroBio">{{ operator.nom }}</span>
<h1 class="fr-h4 fr-my-0 fr-mb-1v">
{{ record.version_name }}

<button class="fr-btn fr-btn--tertiary-no-outline fr-icon fr-icon-edit-line" @click="showEditVersionModal = true">
Expand All @@ -14,7 +14,7 @@
</p>


<div v-if="disableActions === false" class="actions fr-btns-group fr-btns-group--inline-sm fr-btns-group--icon-left fr-mt-4v">
<div v-if="disableActions === false" class="actions fr-btns-group fr-btns-group--sm fr-btns-group--inline-sm fr-btns-group--icon-left">
<nav role="navigation" class="fr-translate fr-nav">
<div class="fr-nav-item">
<button
Expand Down Expand Up @@ -51,23 +51,10 @@
Historique
</button>

<button v-if="hasFeatures" class="export-action fr-btn fr-btn--tertiary-no-outline fr-btn--icon-left fr-icon-road-map-line" @click="exportModal = true">
Export
<button v-if="hasFeatures" class="export-action fr-btn fr-btn--tertiary-no-outline fr-btn--icon-left fr-icon-table-2" @click="exportModal = true">
Exporter
</button>
</div>

<div
v-if="permissions.isAgri && record.certification_state !== CERTIFICATION_STATE.OPERATOR_DRAFT"
class="fr-alert fr-alert--info fr-alert--sm fr-mt-3w"
>
<p class="fr-text--sm">Votre parcellaire est en cours de certification, vous ne pouvez pas modifier les données.</p>
</div>

<div class="demandes fr-callout fr-callout--blue-ecume" v-if="displayCallout">
<h3 class="fr-callout__title">Demandes formulées lors de l'audit</h3>

<div v-html="record.audit_demandes" />
</div>
</header>

<Teleport to="body">
Expand All @@ -91,13 +78,12 @@
import { computed, ref } from 'vue'
import { storeToRefs } from 'pinia'
import ParcellaireState from '@/components/Certification/State.vue'
import OperatorHistoryModal from '@/components/Operator/HistoryModal.vue'
import ParcellaireState from '@/components/record/State.vue'
import OperatorHistoryModal from '@/components/record/modals/HistoryModal.vue'
import FeaturesExportModal from '@/components/Features/ExportModal.vue'
import DeleteParcellaireModal from '@/components/Operator/DeleteParcelaireModal.vue'
import DeleteParcellaireModal from '@/components/record/modals/DeleteParcelaireModal.vue'
import { CERTIFICATION_STATE, isCertificationImmutable } from '@/referentiels/ab.js'
import { useFeaturesStore, useOperatorStore, usePermissions, useRecordStore } from '@/stores/index.js'
import { useFeaturesStore, useOperatorStore, useRecordStore } from '@/stores/index.js'
import { onClickOutside } from "@vueuse/core"
import EditVersionModal from "@/components/versions/EditVersionModal.vue"
Expand All @@ -114,11 +100,9 @@ const deleteModal = ref(false)
const featuresStore = useFeaturesStore()
const operatorStore = useOperatorStore()
const recordStore = useRecordStore()
const permissions = usePermissions()
const { record } = recordStore
const { operator } = operatorStore
const { collection, hasFeatures } = storeToRefs(featuresStore)
const displayCallout = computed(() => record.audit_demandes && isCertificationImmutable(record.certification_state))
const canDisplayHistory = computed(() => Array.isArray(record.audit_history) && record.audit_history.length)
const versionMenu = ref(false)
Expand Down Expand Up @@ -147,20 +131,16 @@ header {
}
.actions {
background: var(--light-background-alt-blue-france, #F5F5FE);
display: flex;
position: relative;
}
@media screen and (min-width: 62em) {
.actions {
flex-direction: row;
margin-left: 0;
margin-right: 0;
}
display: flex;
flex-direction: row;
column-gap: 0.5rem;
margin: 0;
div.actions .fr-btn {
margin-bottom: 0;
.fr-btn {
margin: 0;
flex-grow: 0;
width: auto;
}
}
Expand All @@ -169,6 +149,7 @@ header {
.fr-menu {
position: absolute;
top: 100%;
left: 0.5rem;
width: 9rem;
padding: 0;
margin: 0;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import { ddmmmmyyyy } from '@/components/dates.js'
import { EventType } from '@agencebio/cartobio-types'
import { deletionReasons } from '@/components/Features/index.js';
import ActionType from '@/components/Certification/ActionType.vue'
import ActionType from '@/components/record/history/ActionType.vue'
import ReferenceCadastrale from '@/components/Features/ReferenceCadastrale.vue';
const props = defineProps({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<script setup>
import Modal from '@/components/Modal.vue'
import HistoryEntry from './HistoryEntry.vue'
import HistoryEntry from '../history/HistoryEntry.vue'
defineProps({
operator: {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/certification/exploitations/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ import { computed, watch, ref, readonly } from 'vue'
import { storeToRefs } from 'pinia'
import { useRoute, useRouter } from 'vue-router'
import ParcellaireState from '@/components/Certification/State.vue'
import ParcellaireState from '@/components/record/State.vue'
import { monthYearDateFormat } from '@/components/dates.js'
import { searchOperators as search, fetchLatestOperators } from '@/cartobio-api.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ import baseStyle from "@/map-styles/base.json"
import MapContainer from "@/components/Map/MapContainer.vue"
import GeojsonLayer from "@/components/Map/GeojsonLayer.vue"
import { useFeaturesStore, useOperatorStore, usePermissions, usePreferences, useRecordStore } from "@/stores/index.js"
import ParcellaireState from "@/components/Certification/State.vue"
import ParcellaireState from "@/components/record/State.vue"
import CommuneSelect from "@/components/Forms/CommuneSelect.vue"
import CertificationBodyEditForm from "@/components/Features/SingleItemCertificationBodyForm.vue"
import OperatorEditForm from "@/components/Features/SingleItemOperatorForm.vue"
Expand Down
Loading

0 comments on commit f1ba46c

Please sign in to comment.