Skip to content

Commit

Permalink
Merge pull request #280 from AgenceBio/maud/retours_retours
Browse files Browse the repository at this point in the history
Retours sur les feedbacks
  • Loading branch information
jillro authored Dec 14, 2023
2 parents 1b28f66 + 830d5a0 commit 77c44cd
Showing 6 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/components/Features/AddFlow.vue
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ import { computed, markRaw, reactive, ref, toRaw, watch } from 'vue'
import CadastreField from '@/components/Forms/CadastreField.vue'
import { submitNewParcelle } from '@/cartobio-api.js';
import { featureCollection } from '@turf/helpers'
import { diff, inHa, merge, surface } from './index.js'
import { diff, featureName, inHa, merge, surface } from './index.js'
import CommuneSelect from "@/components/Forms/CommuneSelect.vue";
import { useRouter } from "vue-router";
import { useFeaturesStore, useRecordStore } from "@/stores/index.js"
@@ -216,7 +216,7 @@ async function saveFeature ({ properties }) {
await router.push(props.backLink)
toast.success('Parcelle ajoutée.', 'Voir la parcelle', () => {
toast.success(`Parcelle « ${featureName(feature.value)} » ajoutée.`, 'Voir la parcelle', () => {
featuresStore.select(newId)
})
}
6 changes: 3 additions & 3 deletions src/components/Features/Table.vue
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ import MassActionsSelector from '@/components/Features/MassActionsSelector.vue'
import DeleteFeatureModal from '@/components/Features/DeleteFeatureModal.vue'
import FeatureGroup from '@/components/Features/FeatureGroup.vue'
import { getFeatureGroups, groupingChoices, inHa, surface } from './index.js'
import { featureName, getFeatureGroups, groupingChoices, inHa, surface } from './index.js'
import { deleteSingleFeature, updateFeatureCollectionProperties, updateSingleFeature } from '@/cartobio-api.js'
import toast from "@/components/toast"
import { statsPush } from "@/stats.js"
@@ -140,7 +140,7 @@ async function handleSingleFeatureSubmit ({ id, properties }) {
await performAsyncRecordAction(
updateSingleFeature({ recordId: record.value.record_id }, { id, properties }),
'Parcelle modifiée.'
`Parcelle « ${featureName(featuresStore.getFeatureById(id))} » modifiée.`
)
}
@@ -151,7 +151,7 @@ async function handleSingleFeatureDeletion ({ id, reason }) {
await performAsyncRecordAction(
deleteSingleFeature({ recordId: record.value.record_id }, { id, reason }),
'Parcelle supprimée.'
`Parcelle « ${featureName(featuresStore.getFeatureById(id))} » supprimée.`
)
}
2 changes: 1 addition & 1 deletion src/components/Toast.vue
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
<div style="display: flex">
<div style="flex-grow: 1; display: flex; flex-direction: column; justify-content: center">{{ message }}</div>
<button v-if="actionLabel" @click="actionCb" class="fr-btn fr-btn--tertiary-no-outline fr-ml-3w">{{ actionLabel }} </button>
<button class="fr-btn fr-btn--tertiary-no-outline fr-ml-3w" @click="closeToast">Fermer</button>
<button class="fr-btn fr-btn--tertiary-no-outline fr-ml-3w fr-btn--icon-right fr-icon-close-line" @click="closeToast">Fermer</button>
</div>
</template>

15 changes: 10 additions & 5 deletions src/components/toast.js
Original file line number Diff line number Diff line change
@@ -6,24 +6,29 @@ const toastComponent = (message, actionLabel, actionCb) => {
return ({ closeToast, toastProps }) => h(Toast, { message, actionLabel, actionCb, closeToast, toastProps })
}

const options = {
closeButton: false,
transition: toastify.TRANSITIONS.SLIDE,
}

const toast = (message, actionLabel, actionCb) => {
toastify(toastComponent(message, actionLabel, actionCb), { toastId: message })
toastify(toastComponent(message, actionLabel, actionCb), { toastId: message, ...options })
}

toast.success = (message, actionLabel, actionCb) => {
toastify.success(toastComponent(message, actionLabel, actionCb), { toastId: message })
toastify.success(toastComponent(message, actionLabel, actionCb), options)
}

toast.info = (message, actionLabel, actionCb) => {
toastify.info(toastComponent(message, actionLabel, actionCb), { toastId: message })
toastify.info(toastComponent(message, actionLabel, actionCb), options)
}

toast.warning = (message, actionLabel, actionCb) => {
toastify.warning(toastComponent(message, actionLabel, actionCb), { toastId: message })
toastify.warning(toastComponent(message, actionLabel, actionCb), options)
}

toast.error = (message, actionLabel, actionCb) => {
toastify.error(toastComponent(message, actionLabel, actionCb), { toastId: message })
toastify.error(toastComponent(message, actionLabel, actionCb), { toastId: message, ...options })
}
export default toast

3 changes: 2 additions & 1 deletion src/pages/exploitations/[id]/ajout-parcelle/dessin.vue
Original file line number Diff line number Diff line change
@@ -103,6 +103,7 @@ import cadastreStyle from "@/map-styles/cadastre.json"
import surroundingsStyle from "@/map-styles/surroundings.json"
import LayerSelector from "@/components/Map/LayerSelector.vue"
import satelliteStyle from "@/map-styles/satellite.json"
import { featureName } from "@/components/Features/index.js"
const props = defineProps({
id: {
@@ -238,7 +239,7 @@ async function saveFeature ({ properties }) {
statsPush(['trackEvent', 'Parcelles', 'Ajout par dessin (sauvegarde)'])
await router.push(permissions.isOc ? `/certification/exploitations/${props.id}` : `/exploitations/${props.id}`)
toast.success('Parcelle ajoutée.', 'Voir la parcelle', () => {
toast.success(`Parcelle « ${featureName(feature.value)} » ajoutée.`, 'Voir la parcelle', () => {
featuresStore.select(newId)
})
}
2 changes: 1 addition & 1 deletion src/pages/exploitations/[id]/modifier/[featureId].vue
Original file line number Diff line number Diff line change
@@ -240,7 +240,7 @@ async function saveFeature () {
statsPush(['trackEvent', 'Parcelles', 'Modification (tracé)'])
await router.push(permissions.isOc ? `/certification/exploitations/${props.id}` : `/exploitations/${props.id}`)
toast.success('Parcelle modifiée.', 'Voir la parcelle', () => {
toast.success(`Parcelle « ${featureName(modifiedFeature.value)} » modifiée.`, 'Voir la parcelle', () => {
featuresStore.select(id)
})
}

0 comments on commit 77c44cd

Please sign in to comment.