fix: If the post fails to save, the button will not be restored to clickable. (#68)

pull/69/head
Ryan Wang 2020-02-22 14:35:03 +08:00 committed by GitHub
parent 86adfb42a1
commit 65f078efa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 128 additions and 76 deletions

View File

@ -185,23 +185,35 @@ export default {
if (this.postToStage.id) {
// Update the post
if (draftOnly) {
postApi.updateDraft(this.postToStage.id, this.postToStage.originalContent).then(response => {
postApi
.updateDraft(this.postToStage.id, this.postToStage.originalContent)
.then(response => {
this.$message.success('保存草稿成功!')
})
.finally(() => {
this.saving = false
})
} else {
postApi.update(this.postToStage.id, this.postToStage, false).then(response => {
postApi
.update(this.postToStage.id, this.postToStage, false)
.then(response => {
this.$log.debug('Updated post', response.data.data)
this.$message.success('保存草稿成功!')
})
.finally(() => {
this.saving = false
})
}
} else {
// Create the post
postApi.create(this.postToStage, false).then(response => {
postApi
.create(this.postToStage, false)
.then(response => {
this.$log.debug('Created post', response.data.data)
this.$message.success('保存草稿成功!')
this.postToStage = response.data.data
})
.finally(() => {
this.saving = false
})
}
@ -234,8 +246,12 @@ export default {
// Update the post
postApi.update(this.postToStage.id, this.postToStage, false).then(response => {
this.$log.debug('Updated post', response.data.data)
postApi.preview(this.postToStage.id).then(response => {
postApi
.preview(this.postToStage.id)
.then(response => {
window.open(response.data, '_blank')
})
.finally(() => {
this.saving = false
})
})
@ -244,8 +260,12 @@ export default {
postApi.create(this.postToStage, false).then(response => {
this.$log.debug('Created post', response.data.data)
this.postToStage = response.data.data
postApi.preview(this.postToStage.id).then(response => {
postApi
.preview(this.postToStage.id)
.then(response => {
window.open(response.data, '_blank')
})
.finally(() => {
this.saving = false
})
})

View File

@ -469,27 +469,35 @@ export default {
this.saving = true
if (this.selectedPost.id) {
// Update the post
postApi.update(this.selectedPost.id, this.selectedPost, autoSave).then(response => {
postApi
.update(this.selectedPost.id, this.selectedPost, autoSave)
.then(response => {
this.$log.debug('Updated post', response.data.data)
if (updateSuccess) {
updateSuccess()
this.saving = false
this.$emit('onSaved', true)
this.$router.push({ name: 'PostList' })
}
})
.finally(() => {
this.saving = false
})
} else {
// Create the post
postApi.create(this.selectedPost, autoSave).then(response => {
postApi
.create(this.selectedPost, autoSave)
.then(response => {
this.$log.debug('Created post', response.data.data)
if (createSuccess) {
createSuccess()
this.saving = false
this.$emit('onSaved', true)
this.$router.push({ name: 'PostList' })
}
this.selectedPost = response.data.data
})
.finally(() => {
this.saving = false
})
}
},
onClose() {

View File

@ -171,16 +171,24 @@ export default {
this.sheetToStage.title = moment(new Date()).format('YYYY-MM-DD-HH-mm-ss')
}
if (this.sheetToStage.id) {
sheetApi.update(this.sheetToStage.id, this.sheetToStage, false).then(response => {
sheetApi
.update(this.sheetToStage.id, this.sheetToStage, false)
.then(response => {
this.$log.debug('Updated sheet', response.data.data)
this.$message.success('保存草稿成功!')
})
.finally(() => {
this.saving = false
})
} else {
sheetApi.create(this.sheetToStage, false).then(response => {
sheetApi
.create(this.sheetToStage, false)
.then(response => {
this.$log.debug('Created sheet', response.data.data)
this.$message.success('保存草稿成功!')
this.sheetToStage = response.data.data
})
.finally(() => {
this.saving = false
})
}
@ -212,8 +220,12 @@ export default {
if (this.sheetToStage.id) {
sheetApi.update(this.sheetToStage.id, this.sheetToStage, false).then(response => {
this.$log.debug('Updated sheet', response.data.data)
sheetApi.preview(this.sheetToStage.id).then(response => {
sheetApi
.preview(this.sheetToStage.id)
.then(response => {
window.open(response.data, '_blank')
})
.finally(() => {
this.saving = false
})
})
@ -221,8 +233,12 @@ export default {
sheetApi.create(this.sheetToStage, false).then(response => {
this.$log.debug('Created sheet', response.data.data)
this.sheetToStage = response.data.data
sheetApi.preview(this.sheetToStage.id).then(response => {
sheetApi
.preview(this.sheetToStage.id)
.then(response => {
window.open(response.data, '_blank')
})
.finally(() => {
this.saving = false
})
})

View File

@ -304,26 +304,34 @@ export default {
this.selectedSheet.sheetMetas = this.selectedSheetMetas
this.saving = true
if (this.selectedSheet.id) {
sheetApi.update(this.selectedSheet.id, this.selectedSheet, autoSave).then(response => {
sheetApi
.update(this.selectedSheet.id, this.selectedSheet, autoSave)
.then(response => {
this.$log.debug('Updated sheet', response.data.data)
if (updateSuccess) {
updateSuccess()
this.saving = false
this.$emit('onSaved', true)
this.$router.push({ name: 'SheetList' })
}
})
.finally(() => {
this.saving = false
})
} else {
sheetApi.create(this.selectedSheet, autoSave).then(response => {
sheetApi
.create(this.selectedSheet, autoSave)
.then(response => {
this.$log.debug('Created sheet', response.data.data)
if (createSuccess) {
createSuccess()
this.saving = false
this.$emit('onSaved', true)
this.$router.push({ name: 'SheetList' })
}
this.selectedSheet = response.data.data
})
.finally(() => {
this.saving = false
})
}
},
onClose() {