Skip to content

Commit

Permalink
feat: v0 multiversion
Browse files Browse the repository at this point in the history
Signed-off-by: Maud Royer <[email protected]>
  • Loading branch information
jillro committed Feb 7, 2024
1 parent 001f2f7 commit 3b92b45
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 9 deletions.
8 changes: 7 additions & 1 deletion src/components/Operator/Summary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Export
</button>

<button v-if="permissions.canDeleteParcellaire && isSetup" class="import-action fr-btn fr-btn--tertiary-no-outline fr-btn--icon-left fr-icon-arrow-go-forward-line" @click="deleteModal = true">
<button v-if="permissions.canCreateVersion && isSetup" class="import-action fr-btn fr-btn--tertiary-no-outline fr-btn--icon-left fr-icon-arrow-go-forward-line" @click="newVersion">
Réimporter
</button>
</div>
Expand Down Expand Up @@ -86,6 +86,12 @@ const { isSetup } = storeToRefs(recordStore)
const displayCallout = computed(() => props.record.audit_demandes && isCertificationImmutable(props.record.certification_state))
const canDisplayHistory = computed(() => Array.isArray(props.record.audit_history) && props.record.audit_history.length)
function newVersion () {
const operator = recordStore.record.operator
recordStore.reset()
recordStore.update({ operator })
}
</script>

<style scoped>
Expand Down
5 changes: 3 additions & 2 deletions src/components/OperatorSetup/Flow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ function handleUpload ({ geojson, metadata: data, source, warnings: warns }) {
emit('upload', { geojson, metadata: unref(metadata), warnings: warns })
}
async function handlePreviewConfirmation () {
async function handlePreviewConfirmation (importPrevious) {
const { numeroBio } = props.operator
record.value = await createOperatorRecord(numeroBio, {
geojson: featureCollection.value,
metadata: metadata.value
metadata: metadata.value,
importPrevious
})
emit('submit', unref(record.value))
Expand Down
44 changes: 38 additions & 6 deletions src/components/OperatorSetup/Preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,46 @@

<MapPreview :controls="false" :collection="featureCollection" class="fr-mb-3w" />

<p>
<button class="fr-btn" @click="emit('submit')">
Importer ces données
</button>
</p>
<div class="fr-alert fr-alert--info fr-mb-3w">
Récupération des informations
<p>
Vous pouvez récupérer les informations renseignées sur le dernier parcellaire certifié&nbsp;:
dates et niveaux de conversion, parcelles ajoutées manuellement, variété des parcelles de la culture principale,
commentaires et noms de parcelle modifiés.
</p>
</div>

<form @submit.prevent="emit('submit', importPrevious === 'oui')">
<fieldset class="fr-fieldset" id="radio-import" aria-labelledby="radio-import-legend">
<legend class="fr-fieldset__legend fr-fieldset__legend--regular" id="radio-import-legend">
Souhaitez-vous récupérer les informations renseignées dans le dernier parcellaire certifié ?
</legend>

<div class="fr-fieldset__element">
<div class="fr-radio-group">
<input type="radio" id="radio-import-oui" name="radio-import" v-model="importPrevious" value="oui" required="required" />
<label class="fr-label" for="radio-import-oui">Oui</label>
</div>
</div>
<div class="fr-fieldset__element">
<div class="fr-radio-group">
<input type="radio" id="radio-import-non" name="radio-import" v-model="importPrevious" value="non" required="required" />
<label class="fr-label" for="radio-import-non">Non</label>
</div>
</div>
</fieldset>

<p>
<button class="fr-btn" type="submit">
Importer ces données
</button>
</p>
</form>
</section>
</template>

<script setup>
import { computed } from 'vue'
import { computed, ref } from 'vue'
import MapPreview from '@/components/Map/Preview.vue'
Expand All @@ -37,5 +67,7 @@ const props = defineProps({
}
})
const importPrevious = ref()
const surfaceTotale = computed(() => inHa(surface(props.featureCollection)))
</script>
5 changes: 5 additions & 0 deletions src/stores/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export const usePermissions = defineStore('permissions', () => {
return canEditParcellaire();
})

const canCreateVersion = computed(() => {
return canEditParcellaire();
})

const canChangeCulture = computed(() => {
return canEditParcellaire();
})
Expand Down Expand Up @@ -91,6 +95,7 @@ export const usePermissions = defineStore('permissions', () => {
canAddParcelle,
canDeleteFeature,
canDeleteParcellaire,
canCreateVersion,
canChangeCulture,
canChangeGeometry,
canAddParcelleNote,
Expand Down

0 comments on commit 3b92b45

Please sign in to comment.