Skip to content
Snippets Groups Projects
Commit f320313d authored by Timothee P's avatar Timothee P :sunflower:
Browse files

ask user confirmation to leave filtered features detail view & display return button after edition

parent 5fe4d0fb
No related branches found
No related tags found
1 merge request!437REDINE_ISSUE-14293|Parcours d'une liste de signalements - Si j'édite un signalement et que je le valide, je ne suis plus en mode liste
...@@ -4,6 +4,20 @@ ...@@ -4,6 +4,20 @@
<div class="content"> <div class="content">
{{ currentFeature.title || currentFeature.feature_id }} {{ currentFeature.title || currentFeature.feature_id }}
<div class="ui icon right floated compact buttons"> <div class="ui icon right floated compact buttons">
<router-link
v-if="displayToListButton"
id="feature-detail-to-features-list"
:to="{
name: 'liste-signalements',
params: { slug: $route.params.slug },
}"
custom
>
<div class="ui button tiny-margin teal">
<i class="ui icon arrow right" />
Retour à la liste des signalements
</div>
</router-link>
<span <span
v-if="featuresCount" v-if="featuresCount"
id="feature-count" id="feature-count"
...@@ -129,6 +143,10 @@ export default { ...@@ -129,6 +143,10 @@ export default {
type: Object, type: Object,
default: () => {}, default: () => {},
}, },
displayToListButton: {
type: Boolean,
default: false,
},
}, },
computed: { computed: {
...@@ -185,4 +203,8 @@ export default { ...@@ -185,4 +203,8 @@ export default {
#next-feature { #next-feature {
margin-right: .5rem !important; margin-right: .5rem !important;
} }
#feature-detail-to-features-list {
line-height: 0;
margin-right: 5px;
}
</style> </style>
\ No newline at end of file
...@@ -193,7 +193,6 @@ const feature = { ...@@ -193,7 +193,6 @@ const feature = {
slug_signal: featureId, slug_signal: featureId,
message: routeName === 'editer-signalement' ? 'Le signalement a été mis à jour' : 'Le signalement a été crée' message: routeName === 'editer-signalement' ? 'Le signalement a été mis à jour' : 'Le signalement a été crée'
}, },
query: router.history.current.query,
}); });
dispatch('projects/GET_ALL_PROJECTS', null, { root:true }); //* & refresh project list dispatch('projects/GET_ALL_PROJECTS', null, { root:true }); //* & refresh project list
}); });
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
:features-count="featuresCount" :features-count="featuresCount"
:slug-signal="slugSignal" :slug-signal="slugSignal"
:feature-type="featureType" :feature-type="featureType"
:display-to-list-button="displayToListButton"
@setIsCancelling="isCanceling = true" @setIsCancelling="isCanceling = true"
@tofeature="pushNgo" @tofeature="pushNgo"
/> />
...@@ -118,6 +119,30 @@ export default { ...@@ -118,6 +119,30 @@ export default {
FeatureComments FeatureComments
}, },
beforeRouteEnter (to, from, next) {
// if the user edited the feature, coming from filtered features details browsing,
// display a button to turn back to the list view, in order to start again from the list
// because order changes after edition, depending the sort criteria
// in beforeRouteEnter, the component is not mounted and this doesn't exist yet, thus we store the value in window object
window.displayToListButton = false; // reinitialisation of the value
if (from.query.offset !== undefined) { // if a queryset for filtered features is stored in the route from
window.displayToListButton = true; // toggle the value to display the button
}
next(); // continue page loading
},
beforeRouteLeave (to, from, next) {
if (// In case of filtered listed featuers, if the user wants to edit a feature,
from.query.offset >= 0 &&
to.name === 'editer-signalement' &&
!this.confirmLeave() // warn the user that features order might change
){
next(false);
} else {// Navigate to next view
next();
}
},
data() { data() {
return { return {
attachments: [], attachments: [],
...@@ -139,6 +164,7 @@ export default { ...@@ -139,6 +164,7 @@ export default {
featuresCount: null, featuresCount: null,
isCanceling: false, isCanceling: false,
slugSignal: '', slugSignal: '',
displayToListButton: false,
}; };
}, },
...@@ -170,6 +196,8 @@ export default { ...@@ -170,6 +196,8 @@ export default {
mounted() { mounted() {
this.initPage(); this.initPage();
// when this is available, set the value with previously stored value in windows to pass it as a prop
this.displayToListButton = window.displayToListButton;
}, },
beforeDestroy() { beforeDestroy() {
...@@ -232,6 +260,10 @@ export default { ...@@ -232,6 +260,10 @@ export default {
this.DISCARD_LOADER(); this.DISCARD_LOADER();
}, },
confirmLeave() {
return window.confirm('Vous allez quittez la vue signalement filtré, l\'ordre des signalements pourrait changer après édition d\'un signalement.');
},
async pushNgo(newEntry) { async pushNgo(newEntry) {
this.$router.push(newEntry); //* update the params or queries in the route/url this.$router.push(newEntry); //* update the params or queries in the route/url
await this.getPageInfo(); await this.getPageInfo();
......
...@@ -75,17 +75,21 @@ ...@@ -75,17 +75,21 @@
ref="map" ref="map"
/> />
<div <router-link
id="features-list" id="features-list"
class="ui button fluid teal" :to="{
@click="$router.push({
name: 'liste-signalements', name: 'liste-signalements',
params: { slug: slug }, params: { slug: slug },
})" }"
custom
> >
<i class="ui icon arrow right" /> <div
Voir tous les signalements class="ui button fluid teal"
</div> >
<i class="ui icon arrow right" />
Voir tous les signalements
</div>
</router-link>
<div <div
id="popup" id="popup"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment