Skip to content

Commit

Permalink
Automatically go to Edit Post page after creating
Browse files Browse the repository at this point in the history
  • Loading branch information
hongquan committed Nov 24, 2024
1 parent 3986a96 commit 145fcd4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion admin/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const routes: RouteRecordRaw[] = [
path: 'posts', component: SimpleWrap, name: 'post', redirect: () => ({ name: 'post.list' }),
children: [
{ path: '', component: BlogPostList, name: 'post.list' },
{ path: 'new', component: BlogPostEdit, name: 'post.new' },
{ path: 'new', component: BlogPostEdit, name: 'post.new', props: { postId: null } },
{ path: ':postId', component: BlogPostEdit, name: 'post.edit', props: true },
],
},
Expand Down
10 changes: 5 additions & 5 deletions admin/src/views/BlogPostEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
:loading='isSubmitting'
@click='onSubmit(true)'
>
Save and stay
{{ postId ? 'Save and stay' : 'Save and continue to edit' }}
</FwbButton>
</div>
</form>
Expand Down Expand Up @@ -170,12 +170,10 @@ import '../../../static/css/syntect.css'
import { User, UserSchema } from '@/models/user'
interface Props {
postId?: string | null
postId: string | null
}
const props = withDefaults(defineProps<Props>(), {
postId: null,
})
const props = defineProps<Props>()
Prism.manual = true
Prism.languages.console = Prism.languages['shell-session']
Expand Down Expand Up @@ -292,6 +290,8 @@ async function onSubmit(toStay: boolean) {
toast.success(message)
if (!toStay) {
await router.push({ name: 'post.list' })
} else if (isCreating) {
await router.push({ name: 'post.edit', params: { postId: updatedPost.id }})
}
} catch (e) {
console.debug(e)
Expand Down

0 comments on commit 145fcd4

Please sign in to comment.