Skip to content

Commit

Permalink
権限周り
Browse files Browse the repository at this point in the history
  • Loading branch information
mehm8128 committed May 22, 2024
1 parent 143b03a commit fc6bd65
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/requestDetail/NewComment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { comment, isSending, submit } = useNewComment(props.request.id)
<SimpleButton
:disabled="isSending"
font-size="md"
padding="sm"
padding="md"
type="success"
@click="submit">
コメントする
Expand Down
9 changes: 8 additions & 1 deletion src/components/requestDetail/RequestContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import EditButton from '/@/components/shared/EditButton.vue'
import MarkdownTextarea from '/@/components/shared/MarkdownTextarea.vue'
import SimpleButton from '/@/components/shared/SimpleButton.vue'
import { useToast } from 'vue-toastification'
import { useRequest } from '/@/features/request/composables'
const props = defineProps<{
request: RequestDetail
Expand All @@ -24,7 +25,10 @@ const formattedDateAndTime = formatDateAndTime(props.request.createdAt)
const userStore = useUserStore()
const { userMap } = storeToRefs(userStore)
const toast = useToast()
const { isRequestCreator } = useRequest(props.request)
const { me } = storeToRefs(userStore)
const hasAuthority = isRequestCreator.value(me.value)
const isEditMode = ref(false)
const editedContent = ref(props.request.content)
const toggleEditContent = () => {
Expand Down Expand Up @@ -72,7 +76,10 @@ const handleUpdateContent = async () => {
v-model="editedContent"
auto-focus
class="flex-1" />
<EditButton :is-edit-mode="isEditMode" @click="toggleEditContent" />
<EditButton
v-if="hasAuthority"
:is-edit-mode="isEditMode"
@click="toggleEditContent" />
</div>
<div class="flex justify-end">
<SimpleButton v-if="isEditMode" padding="sm" @click="handleUpdateContent">
Expand Down
2 changes: 1 addition & 1 deletion src/components/requestDetail/RequestStatusChange.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const { statusOptions } = useStatusOptions(props.request)
<template>
<div class="relative">
<StatusChip
has-menu
:has-menu="statusOptions.length !== 0"
has-text
:status="request.status"
@click.stop="showMenu = true" />
Expand Down
4 changes: 2 additions & 2 deletions src/components/requestDetail/RequestTarget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const props = defineProps<{
const { isSending, postTransactionFromRequest } = useNewTransaction()
const userStore = useUserStore()
const { userMap, userOptions } = storeToRefs(userStore)
const { userMap, userOptions, isAdmin } = storeToRefs(userStore)
const targets = computed(() =>
props.request.targets.map(target => target.target)
Expand Down Expand Up @@ -84,7 +84,7 @@ const handleRemoveTarget = async () => {
</RouterLink>
</div>
<button
v-else
v-else-if="isAdmin"
class="text-blue-500"
:disabled="isSending"
@click="postTransactionFromRequest(request, target)">
Expand Down
13 changes: 12 additions & 1 deletion src/components/requestDetail/RequestTitle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,23 @@ import InputText from '/@/components/shared/InputText.vue'
import { editRequestUsecase } from '/@/features/request/usecase'
import EditButton from '/@/components/shared/EditButton.vue'
import { useToast } from 'vue-toastification'
import { useUserStore } from '/@/stores/user'
import { useRequest } from '/@/features/request/composables'
import { storeToRefs } from 'pinia'
const props = defineProps<{
request: RequestDetail
}>()
const userStore = useUserStore()
const { isRequestCreator } = useRequest(props.request)
const { me } = storeToRefs(userStore)
const toast = useToast()
const hasAuthority = isRequestCreator.value(me.value)
const isEditMode = ref(false)
const editedTitle = ref(props.request.title)
const toggleEditTitle = () => {
if (isEditMode.value) {
editedTitle.value = props.request.title
Expand Down Expand Up @@ -44,6 +52,9 @@ const handleUpdateTitle = async () => {
<SimpleButton v-if="isEditMode" padding="sm" @click="handleUpdateTitle">
完了
</SimpleButton>
<EditButton :is-edit-mode="isEditMode" @click="toggleEditTitle" />
<EditButton
v-if="hasAuthority"
:is-edit-mode="isEditMode"
@click="toggleEditTitle" />
</div>
</template>

0 comments on commit fc6bd65

Please sign in to comment.