2020-11-15 12:34:47 +09:00
|
|
|
<template>
|
|
|
|
<div v-if="clip" class="_section">
|
|
|
|
<div class="okzinsic _content _panel _vMargin">
|
|
|
|
<div class="description" v-if="clip.description">
|
2020-12-19 10:55:52 +09:00
|
|
|
<Mfm :text="clip.description" :is-note="false" :i="$i"/>
|
2020-11-15 12:34:47 +09:00
|
|
|
</div>
|
2020-11-15 12:47:54 +09:00
|
|
|
<div class="user">
|
|
|
|
<MkAvatar :user="clip.user" class="avatar"/> <MkUserName :user="clip.user" :nowrap="false"/>
|
|
|
|
</div>
|
2020-11-15 12:34:47 +09:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<XNotes class="_content _vMargin" :pagination="pagination" :detail="true"/>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { computed, defineComponent } from 'vue';
|
|
|
|
import { faEllipsisH, faPaperclip, faPencilAlt, faTrashAlt } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import MkContainer from '@/components/ui/container.vue';
|
|
|
|
import XPostForm from '@/components/post-form.vue';
|
|
|
|
import XNotes from '@/components/notes.vue';
|
|
|
|
import * as os from '@/os';
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
|
|
|
MkContainer,
|
|
|
|
XPostForm,
|
|
|
|
XNotes,
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
clipId: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
INFO: computed(() => this.clip ? {
|
|
|
|
title: this.clip.name,
|
|
|
|
icon: faPaperclip,
|
|
|
|
action: {
|
|
|
|
icon: faEllipsisH,
|
|
|
|
handler: this.menu
|
|
|
|
}
|
|
|
|
} : null),
|
|
|
|
clip: null,
|
|
|
|
pagination: {
|
|
|
|
endpoint: 'clips/notes',
|
|
|
|
limit: 10,
|
|
|
|
params: () => ({
|
|
|
|
clipId: this.clipId,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
isOwned(): boolean {
|
2020-12-19 10:55:52 +09:00
|
|
|
return this.$i && this.clip && (this.$i.id === this.clip.userId);
|
2020-11-15 12:34:47 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
clipId: {
|
|
|
|
async handler() {
|
|
|
|
this.clip = await os.api('clips/show', {
|
|
|
|
clipId: this.clipId,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
immediate: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
menu(ev) {
|
|
|
|
os.modalMenu([this.isOwned ? {
|
|
|
|
icon: faPencilAlt,
|
2020-12-26 10:47:36 +09:00
|
|
|
text: this.$ts.edit,
|
2020-11-15 12:34:47 +09:00
|
|
|
action: async () => {
|
|
|
|
const { canceled, result } = await os.form(this.clip.name, {
|
|
|
|
name: {
|
|
|
|
type: 'string',
|
2020-12-26 10:47:36 +09:00
|
|
|
label: this.$ts.name,
|
2020-11-15 12:34:47 +09:00
|
|
|
default: this.clip.name
|
|
|
|
},
|
|
|
|
description: {
|
|
|
|
type: 'string',
|
|
|
|
required: false,
|
|
|
|
multiline: true,
|
2020-12-26 10:47:36 +09:00
|
|
|
label: this.$ts.description,
|
2020-11-15 12:34:47 +09:00
|
|
|
default: this.clip.description
|
|
|
|
},
|
|
|
|
isPublic: {
|
|
|
|
type: 'boolean',
|
2020-12-26 10:47:36 +09:00
|
|
|
label: this.$ts.public,
|
2020-11-15 12:34:47 +09:00
|
|
|
default: this.clip.isPublic
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
os.apiWithDialog('clips/update', {
|
|
|
|
clipId: this.clip.id,
|
|
|
|
...result
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} : undefined, this.isOwned ? {
|
|
|
|
icon: faTrashAlt,
|
2020-12-26 10:47:36 +09:00
|
|
|
text: this.$ts.delete,
|
2020-11-15 12:34:47 +09:00
|
|
|
danger: true,
|
|
|
|
action: async () => {
|
|
|
|
const { canceled } = await os.dialog({
|
|
|
|
type: 'warning',
|
|
|
|
text: this.$t('deleteAreYouSure', { x: this.clip.name }),
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
await os.apiWithDialog('clips/delete', {
|
|
|
|
clipId: this.clip.id,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} : undefined], ev.currentTarget || ev.target);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.okzinsic {
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
> .description {
|
|
|
|
padding: 16px;
|
|
|
|
}
|
2020-11-15 12:47:54 +09:00
|
|
|
|
|
|
|
> .user {
|
|
|
|
$height: 32px;
|
|
|
|
padding: 16px;
|
|
|
|
border-top: solid 1px var(--divider);
|
|
|
|
line-height: $height;
|
|
|
|
|
|
|
|
> .avatar {
|
|
|
|
width: $height;
|
|
|
|
height: $height;
|
|
|
|
}
|
|
|
|
}
|
2020-11-15 12:34:47 +09:00
|
|
|
}
|
|
|
|
</style>
|