Browse Source

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

pull/69/head
Ryan Wang 5 years ago committed by GitHub
parent
commit
65f078efa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 66
      src/views/post/PostEdit.vue
  2. 42
      src/views/post/components/PostSettingDrawer.vue
  3. 54
      src/views/sheet/SheetEdit.vue
  4. 42
      src/views/sheet/components/SheetSettingDrawer.vue

66
src/views/post/PostEdit.vue

@ -185,25 +185,37 @@ export default {
if (this.postToStage.id) {
// Update the post
if (draftOnly) {
postApi.updateDraft(this.postToStage.id, this.postToStage.originalContent).then(response => {
this.$message.success('保存草稿成功!')
this.saving = false
})
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 => {
this.$log.debug('Updated post', response.data.data)
this.$message.success('保存草稿成功!')
this.saving = false
})
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 => {
this.$log.debug('Created post', response.data.data)
this.$message.success('保存草稿成功!')
this.postToStage = response.data.data
this.saving = false
})
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
})
}
},
handleAttachmentUpload(pos, $file) {
@ -234,20 +246,28 @@ 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 => {
window.open(response.data, '_blank')
this.saving = false
})
postApi
.preview(this.postToStage.id)
.then(response => {
window.open(response.data, '_blank')
})
.finally(() => {
this.saving = false
})
})
} else {
// Create the post
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 => {
window.open(response.data, '_blank')
this.saving = false
})
postApi
.preview(this.postToStage.id)
.then(response => {
window.open(response.data, '_blank')
})
.finally(() => {
this.saving = false
})
})
}
},

42
src/views/post/components/PostSettingDrawer.vue

@ -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 => {
this.$log.debug('Updated post', response.data.data)
if (updateSuccess) {
updateSuccess()
postApi
.update(this.selectedPost.id, this.selectedPost, autoSave)
.then(response => {
this.$log.debug('Updated post', response.data.data)
if (updateSuccess) {
updateSuccess()
this.$emit('onSaved', true)
this.$router.push({ name: 'PostList' })
}
})
.finally(() => {
this.saving = false
this.$emit('onSaved', true)
this.$router.push({ name: 'PostList' })
}
})
})
} else {
// Create the post
postApi.create(this.selectedPost, autoSave).then(response => {
this.$log.debug('Created post', response.data.data)
if (createSuccess) {
createSuccess()
postApi
.create(this.selectedPost, autoSave)
.then(response => {
this.$log.debug('Created post', response.data.data)
if (createSuccess) {
createSuccess()
this.$emit('onSaved', true)
this.$router.push({ name: 'PostList' })
}
this.selectedPost = response.data.data
})
.finally(() => {
this.saving = false
this.$emit('onSaved', true)
this.$router.push({ name: 'PostList' })
}
this.selectedPost = response.data.data
})
})
}
},
onClose() {

54
src/views/sheet/SheetEdit.vue

@ -171,18 +171,26 @@ 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 => {
this.$log.debug('Updated sheet', response.data.data)
this.$message.success('保存草稿成功!')
this.saving = false
})
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 => {
this.$log.debug('Created sheet', response.data.data)
this.$message.success('保存草稿成功!')
this.sheetToStage = response.data.data
this.saving = false
})
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
})
}
},
handleAttachmentUpload(pos, $file) {
@ -212,19 +220,27 @@ 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 => {
window.open(response.data, '_blank')
this.saving = false
})
sheetApi
.preview(this.sheetToStage.id)
.then(response => {
window.open(response.data, '_blank')
})
.finally(() => {
this.saving = false
})
})
} else {
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 => {
window.open(response.data, '_blank')
this.saving = false
})
sheetApi
.preview(this.sheetToStage.id)
.then(response => {
window.open(response.data, '_blank')
})
.finally(() => {
this.saving = false
})
})
}
},

42
src/views/sheet/components/SheetSettingDrawer.vue

@ -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 => {
this.$log.debug('Updated sheet', response.data.data)
if (updateSuccess) {
updateSuccess()
sheetApi
.update(this.selectedSheet.id, this.selectedSheet, autoSave)
.then(response => {
this.$log.debug('Updated sheet', response.data.data)
if (updateSuccess) {
updateSuccess()
this.$emit('onSaved', true)
this.$router.push({ name: 'SheetList' })
}
})
.finally(() => {
this.saving = false
this.$emit('onSaved', true)
this.$router.push({ name: 'SheetList' })
}
})
})
} else {
sheetApi.create(this.selectedSheet, autoSave).then(response => {
this.$log.debug('Created sheet', response.data.data)
if (createSuccess) {
createSuccess()
sheetApi
.create(this.selectedSheet, autoSave)
.then(response => {
this.$log.debug('Created sheet', response.data.data)
if (createSuccess) {
createSuccess()
this.$emit('onSaved', true)
this.$router.push({ name: 'SheetList' })
}
this.selectedSheet = response.data.data
})
.finally(() => {
this.saving = false
this.$emit('onSaved', true)
this.$router.push({ name: 'SheetList' })
}
this.selectedSheet = response.data.data
})
})
}
},
onClose() {

Loading…
Cancel
Save