From cb02124aa9619ca07dc00be1030a5f2cfa3656c7 Mon Sep 17 00:00:00 2001 From: mathsuky Date: Thu, 26 Oct 2023 23:59:54 +0900 Subject: [PATCH] =?UTF-8?q?=E9=96=A2=E6=95=B0=E3=81=AE=E3=83=8D=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=82=92=E6=B5=85=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/event/EventFormBase.vue | 69 ++++++++++++-------------- src/pages/GroupEdit.vue | 32 ++++++------ src/pages/GroupNew.vue | 32 ++++++------ 3 files changed, 61 insertions(+), 72 deletions(-) diff --git a/src/components/event/EventFormBase.vue b/src/components/event/EventFormBase.vue index 40620187..8d6f53fa 100644 --- a/src/components/event/EventFormBase.vue +++ b/src/components/event/EventFormBase.vue @@ -232,46 +232,43 @@ export default class EventFormBase extends Vue { } beforLeaveGuardinEventEdit = (to, from, next) => { - if (from.name === 'EventEdit') { - if (this.isChanged()) { - if ( - confirm( - '入力されたデータは送信されないまま破棄されますが,よろしいですか。' - ) - ) { - removeDraftConfirmer() - this.cleanupContent() - next() - } else { - next(false) - } - } else { - next() - } - } else { - next() + if (from.name !== 'EventEdit') { + return next() + } + + if (!this.isChanged()) { + return next() } + + if ( + confirm( + '入力されたデータは送信されないまま破棄されますが,よろしいですか。' + ) + ) { + removeDraftConfirmer() + this.cleanupContent() + return next() + } + + return next(false) } + beforLeaveGuardinEventNew = (to, from, next) => { - if (from.name === 'EventNew') { - if (this.isChanged()) { - if ( - confirm( - '入力されたデータは送信されないまま破棄されますが,よろしいですか。' - ) - ) { - removeDraftConfirmer() - this.cleanupContent() - next() - } else { - next(false) - } - } else { - next() - } - } else { - next() + if (from.name !== 'EventNew' || !this.isChanged()) { + return next() } + + if ( + confirm( + '入力されたデータは送信されないまま破棄されますが,よろしいですか。' + ) + ) { + removeDraftConfirmer() + this.cleanupContent() + return next() + } + + return next(false) } mounted() { diff --git a/src/pages/GroupEdit.vue b/src/pages/GroupEdit.vue index 7d9d6c5d..91b72c20 100644 --- a/src/pages/GroupEdit.vue +++ b/src/pages/GroupEdit.vue @@ -110,25 +110,21 @@ export default class GroupEdit extends Vue { } beforeLeaveGuard = (to, from, next) => { - if (from.path === `/groups/edit/${this.groupId}`) { - if (this.isChanged()) { - if ( - confirm( - '入力されたデータは送信されないまま破棄されますが,よろしいですか。' - ) - ) { - removeDraftConfirmer() - this.cleanupContent() - next() - } else { - next(false) - } - } else { - next() - } - } else { - next() + if (from.path !== `/groups/edit/${this.groupId}` || !this.isChanged()) { + return next() } + + if ( + confirm( + '入力されたデータは送信されないまま破棄されますが,よろしいですか。' + ) + ) { + removeDraftConfirmer() + this.cleanupContent() + return next() + } + + return next(false) } async submitGroup() { diff --git a/src/pages/GroupNew.vue b/src/pages/GroupNew.vue index 54412b08..6f9a0adb 100644 --- a/src/pages/GroupNew.vue +++ b/src/pages/GroupNew.vue @@ -78,25 +78,21 @@ export default class GroupNew extends Vue { } beforeLeaveGuard = (to, from, next) => { - if (from.name === 'GroupNew') { - if (this.hasContent()) { - if ( - confirm( - '入力されたデータは送信されないまま破棄されますが,よろしいですか。' - ) - ) { - removeDraftConfirmer() - this.cleanupContent() - next() - } else { - next(false) - } - } else { - next() - } - } else { - next() + if (from.name !== 'GroupNew' || this.hasContent()) { + return next() } + + if ( + confirm( + '入力されたデータは送信されないまま破棄されますが,よろしいですか。' + ) + ) { + removeDraftConfirmer() + this.cleanupContent() + return next() + } + + return next(false) } mounted() {