Skip to content

Commit

Permalink
関数のネストを浅く
Browse files Browse the repository at this point in the history
  • Loading branch information
mathsuky committed Oct 26, 2023
1 parent 253efb0 commit cb02124
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 72 deletions.
69 changes: 33 additions & 36 deletions src/components/event/EventFormBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
32 changes: 14 additions & 18 deletions src/pages/GroupEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
32 changes: 14 additions & 18 deletions src/pages/GroupNew.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit cb02124

Please sign in to comment.