Prevent route changing when editing with changes
Close #197 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
7773f819bd
commit
36a57cfcf2
@ -266,6 +266,9 @@ import { ICurrentUser } from '@/types/current-user.model';
|
|||||||
query: TAGS,
|
query: TAGS,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
beforeRouteLeave(to, from, next) {
|
||||||
|
this.confirmGoElsewhere(() => next());
|
||||||
|
},
|
||||||
})
|
})
|
||||||
export default class EditEvent extends Vue {
|
export default class EditEvent extends Vue {
|
||||||
@Prop({ type: Boolean, default: false }) isUpdate!: boolean;
|
@Prop({ type: Boolean, default: false }) isUpdate!: boolean;
|
||||||
@ -499,9 +502,9 @@ export default class EditEvent extends Vue {
|
|||||||
/**
|
/**
|
||||||
* Confirm cancel
|
* Confirm cancel
|
||||||
*/
|
*/
|
||||||
confirmGoBack() {
|
confirmGoElsewhere(callback) {
|
||||||
if (!this.isEventModified) {
|
if (!this.isEventModified) {
|
||||||
return this.$router.go(-1);
|
return callback();
|
||||||
}
|
}
|
||||||
const title: string = this.isUpdate ?
|
const title: string = this.isUpdate ?
|
||||||
this.$t('Cancel edition') as string :
|
this.$t('Cancel edition') as string :
|
||||||
@ -519,10 +522,17 @@ export default class EditEvent extends Vue {
|
|||||||
cancelText: this.$t('Continue editing') as string,
|
cancelText: this.$t('Continue editing') as string,
|
||||||
type: 'is-warning',
|
type: 'is-warning',
|
||||||
hasIcon: true,
|
hasIcon: true,
|
||||||
onConfirm: () => this.$router.go(-1),
|
onConfirm: callback,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirm cancel
|
||||||
|
*/
|
||||||
|
confirmGoBack() {
|
||||||
|
this.confirmGoElsewhere(() => this.$router.go(-1));
|
||||||
|
}
|
||||||
|
|
||||||
get isEventModified(): boolean {
|
get isEventModified(): boolean {
|
||||||
return JSON.stringify(this.event.toEditJSON()) !== JSON.stringify(this.unmodifiedEvent);
|
return JSON.stringify(this.event.toEditJSON()) !== JSON.stringify(this.unmodifiedEvent);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user