Skip to content

Commit

Permalink
Add button to stay after editing post
Browse files Browse the repository at this point in the history
  • Loading branch information
hongquan committed Nov 21, 2024
1 parent 9f9ff2e commit 7d953f8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Binary file modified admin/bun.lockb
Binary file not shown.
10 changes: 5 additions & 5 deletions admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
"prismjs": "^1.29.0",
"svg-loaders": "^0.2.0",
"transliteration": "^2.3.5",
"vue": "^3.5.12",
"vue": "^3.5.13",
"vue-router": "^4.4.5",
"vue-sonner": "^1.2.2",
"vue-sonner": "^1.2.5",
"zod": "^3.23.8"
},
"devDependencies": {
Expand All @@ -43,16 +43,16 @@
"@types/prismjs": "^1.26.0",
"@typescript-eslint/eslint-plugin": "^8.9.0",
"@typescript-eslint/parser": "^8.9.0",
"@vitejs/plugin-vue": "^5.1.4",
"@vue/eslint-config-typescript": "^14.1.1",
"@vitejs/plugin-vue": "^5.2.0",
"@vue/eslint-config-typescript": "^14.1.3",
"autoprefixer": "^10.4.14",
"eslint": "^9.12.0",
"eslint-plugin-vue": "^9.29.0",
"postcss": "^8.4.24",
"tailwindcss": "^3.4.14",
"type-fest": "^4.26.1",
"typescript": "^5.6.3",
"vite": "^5.4.9",
"vite": "^5.4.11",
"vite-plugin-prismjs": "^0.0.11",
"vite-svg-loader": "^5.1.0",
"vue-tsc": "^2.1.6"
Expand Down
17 changes: 13 additions & 4 deletions admin/src/views/BlogPostEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<form
v-if='post'
method='post'
@submit.prevent='onSubmit'
@submit.prevent='onSubmit(false)'
>
<HorizontalFormField
v-model='post.title'
Expand Down Expand Up @@ -115,7 +115,14 @@
type='submit'
:loading='isSubmitting'
>
Save
Save and quit
</FwbButton>
<FwbButton
type='button'
:loading='isSubmitting'
@click='onSubmit(true)'
>
Save and stay
</FwbButton>
</div>
</form>
Expand Down Expand Up @@ -266,7 +273,7 @@ function onCategoryReleased(id: string) {
post.value.categories = post.value.categories.filter(c => c.id !== id)
}
async function onSubmit() {
async function onSubmit(toStay: boolean) {
if (!post.value) {
return
}
Expand All @@ -282,7 +289,9 @@ async function onSubmit() {
const updatedPost = PostSchema.parse(resp)
const message = isCreating ? `Post "${updatedPost.title}" is created!` : `Post "${updatedPost.title}" is updated!`
toast.success(message)
await router.push({ name: 'post.list' })
if (!toStay) {
await router.push({ name: 'post.list' })
}
} catch (e) {
console.debug(e)
validationErrors.value = await handleApiError(e)
Expand Down

0 comments on commit 7d953f8

Please sign in to comment.