Skip to content

Commit ba0a3a6

Browse files
committed
fix: affiche une erreur pour les parcelles avec des internal rings
Signed-off-by: Maud Royer <hello@maudroyer.fr>
1 parent 1864fe5 commit ba0a3a6

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/pages/exploitations/[id]/modifier/[featureId].vue

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ meta:
1919

2020
<div class="fr-grid-row fr-grid-row--gutters">
2121
<div class="fr-col-9">
22+
<div v-if="loadingError" class="fr-alert fr-alert--error fr-my-3v">
23+
<p>{{ loadingError }}</p>
24+
</div>
2225
<MapContainer v-if="recordStore.isSetup" :options="{ interactive: true }" class="map" :bounds="mapBounds" ref="map" >
2326
<GeojsonLayer :style="baseStyle" name="base" />
2427
<GeojsonLayer :data="otherCollection" name="parcellaire-operateur" />
@@ -34,15 +37,15 @@ meta:
3437
<button
3538
class="fr-btn fr-btn--tertiary-no-outline fr-btn--icon-left fr-icon-arrow-go-back-fill fr-mb-4w"
3639
@click="reset"
37-
:disabled="feature === null"
40+
:disabled="loadingError || feature === null"
3841
>
3942
Réinitialiser le tracé</button>
40-
<div v-if="error" class="fr-alert fr-alert--error">
43+
<div v-if="!loadingError && error" class="fr-alert fr-alert--error">
4144
<p>{{ error }}</p>
4245
</div>
4346
<button
4447
class="fr-btn fr-btn--primary fr-btn--icon-left fr-icon-save-fill"
45-
:disabled="error !== ''"
48+
:disabled="error !== '' || loadingError !== ''"
4649
@click="showConfirmModal = true"
4750
>
4851
Enregistrer le tracé
@@ -107,7 +110,7 @@ const permissions = usePermissions()
107110
const messages = useMessages()
108111
const router = useRouter()
109112
110-
const otherCollection = computed(() => featureCollection(
113+
const otherCollection = computed(() => loadingError.value ? featureStore.collection : featureCollection(
111114
featureStore.collection.features.filter(f => f.id !== Number(props.featureId)))
112115
)
113116
const modifiedFeature = ref(null)
@@ -122,6 +125,7 @@ const mapBounds = computed(() => {
122125
123126
const map = ref(null) // MapContainer instance
124127
let draw // TerraDraw instance
128+
const loadingError = ref('')
125129
const error = ref('')
126130
const showConfirmModal = ref(false)
127131
@@ -183,7 +187,15 @@ function loadFeature () {
183187
coord => coord.map(c => c.map(n => Number(n.toFixed(COORDINATE_PRECISION - 1))))
184188
)
185189
terraDrawFeature.properties.mode = 'polygon'
186-
draw.addFeatures([terraDrawFeature])
190+
try {
191+
draw.addFeatures([terraDrawFeature])
192+
} catch (e) {
193+
if (e.message.startsWith('Feature is not')) {
194+
loadingError.value = 'La modification de contour n’est pas encore disponible pour les parcelles évidées. Veuillez nous en excuser.'
195+
} else {
196+
throw e
197+
}
198+
}
187199
188200
// Clone feature to avoid modifying the featureStore
189201
modifiedFeature.value = JSON.parse(JSON.stringify(featureStore.getFeatureById(Number(props.featureId))))

0 commit comments

Comments
 (0)