-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only pass basic information to the client when getting post list
- Loading branch information
Showing
11 changed files
with
150 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,24 @@ | ||
<template> | ||
<div class="badge-container"> | ||
<div | ||
v-for="tag in [...tags].sort((a, b) => a.name.localeCompare(b.name))" | ||
:key="tag.id" | ||
class="badge me-1" | ||
@click="searchWord(tag.name)" | ||
> | ||
{{ tag.name }} | ||
</div> | ||
</div> | ||
<md-chip-set> | ||
<md-suggestion-chip v-for="tag in sortedTags()" v-bind:key="tag" :label="tag" @click="searchWord(tag)"></md-suggestion-chip> | ||
</md-chip-set> | ||
</template> | ||
|
||
<style lang="scss"> | ||
.badge-container { | ||
padding: 0; | ||
margin: 0; | ||
.badge { | ||
background-color: $badge-background-color; | ||
color: $badge-text-color; | ||
cursor: pointer; | ||
} | ||
} | ||
</style> | ||
|
||
<script setup lang="ts"> | ||
import type { Tag } from "@fumix/fu-blog-common"; | ||
import type { PropType } from "vue"; | ||
import { useRouter } from "vue-router"; | ||
import "@material/web/chips/chip-set.js"; | ||
import "@material/web/chips/filter-chip.js"; | ||
import "@material/web/chips/suggestion-chip.js"; | ||
const router = useRouter(); | ||
const props = defineProps({ tags: { type: Array as PropType<Tag[]>, required: true } }); | ||
const props = defineProps({ tags: { type: Array as PropType<string[]>, required: true } }); | ||
const sortedTags = () => [...props.tags].sort((a, b) => a.localeCompare(b)); | ||
const searchWord = (word: string): void => { | ||
if (word) { | ||
router.push(`/posts/?search=${word}&operator=and`); | ||
router.push(`/posts/?search=${encodeURIComponent(word)}&operator=and`); | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Post } from "@common/entity/Post.js"; | ||
import { LoggedInUserInfo } from "@common/types/logged-in-user-info.js"; | ||
|
||
export type PublicPost = { | ||
id: number | undefined; | ||
title: string; | ||
description: string; | ||
created: | ||
| { | ||
at: Date; | ||
by: string | undefined; | ||
} | ||
| undefined; | ||
updated: | ||
| { | ||
at: Date; | ||
by: string | undefined; | ||
} | ||
| undefined; | ||
draft: boolean; | ||
tags: string[]; | ||
permissions: { | ||
canEdit: boolean; | ||
canDelete: boolean; | ||
}; | ||
}; | ||
|
||
export function createPublicPostFromPostEntity(loggedInUser: LoggedInUserInfo | undefined, post: Post): PublicPost { | ||
return { | ||
id: post.id, | ||
title: post.title, | ||
description: post.description, | ||
tags: post.tags?.map((it) => it.name) ?? [], | ||
created: post.createdAt ? { at: post.createdAt, by: post.createdBy?.fullName } : undefined, | ||
updated: post.updatedAt ? { at: post.updatedAt, by: post.updatedBy?.fullName } : undefined, | ||
draft: post.draft, | ||
permissions: { | ||
canEdit: loggedInUser?.permissions?.canEditPost === true || loggedInUser?.user?.id === post.createdBy?.id, | ||
canDelete: loggedInUser?.permissions?.canDeletePost === true || loggedInUser?.user?.id === post.createdBy?.id, | ||
}, | ||
}; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters