2020-11-15 04:34:47 +01:00
|
|
|
<template>
|
2021-12-10 08:15:36 +01:00
|
|
|
<MkSpacer :content-max="800">
|
|
|
|
<div v-if="clip">
|
|
|
|
<div class="okzinsic _panel">
|
|
|
|
<div v-if="clip.description" class="description">
|
|
|
|
<Mfm :text="clip.description" :is-note="false" :i="$i"/>
|
|
|
|
</div>
|
|
|
|
<div class="user">
|
|
|
|
<MkAvatar :user="clip.user" class="avatar" :show-indicator="true"/> <MkUserName :user="clip.user" :nowrap="false"/>
|
|
|
|
</div>
|
2020-11-15 04:34:47 +01:00
|
|
|
</div>
|
|
|
|
|
2021-12-10 08:15:36 +01:00
|
|
|
<XNotes :pagination="pagination" :detail="true"/>
|
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
2020-11-15 04:34:47 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { computed, defineComponent } from 'vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
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';
|
|
|
|
import * as symbols from '@/symbols';
|
2020-11-15 04:34:47 +01:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
|
|
|
MkContainer,
|
|
|
|
XPostForm,
|
|
|
|
XNotes,
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
clipId: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 05:54:12 +02:00
|
|
|
[symbols.PAGE_INFO]: computed(() => this.clip ? {
|
2020-11-15 04:34:47 +01:00
|
|
|
title: this.clip.name,
|
2021-04-20 16:22:59 +02:00
|
|
|
icon: 'fas fa-paperclip',
|
2021-12-10 08:15:36 +01:00
|
|
|
bg: 'var(--bg)',
|
|
|
|
actions: [{
|
2021-04-20 20:32:16 +02:00
|
|
|
icon: 'fas fa-ellipsis-h',
|
2020-11-15 04:34:47 +01:00
|
|
|
handler: this.menu
|
2021-12-10 08:15:36 +01:00
|
|
|
}],
|
2020-11-15 04:34:47 +01:00
|
|
|
} : null),
|
|
|
|
clip: null,
|
|
|
|
pagination: {
|
|
|
|
endpoint: 'clips/notes',
|
|
|
|
limit: 10,
|
2022-01-09 19:30:35 +01:00
|
|
|
params: computed(() => ({
|
2020-11-15 04:34:47 +01:00
|
|
|
clipId: this.clipId,
|
2022-01-09 19:30:35 +01:00
|
|
|
}))
|
2020-11-15 04:34:47 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
isOwned(): boolean {
|
2020-12-19 02:55:52 +01:00
|
|
|
return this.$i && this.clip && (this.$i.id === this.clip.userId);
|
2020-11-15 04:34:47 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
clipId: {
|
|
|
|
async handler() {
|
|
|
|
this.clip = await os.api('clips/show', {
|
|
|
|
clipId: this.clipId,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
immediate: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
menu(ev) {
|
2021-08-08 05:19:10 +02:00
|
|
|
os.popupMenu([this.isOwned ? {
|
2021-04-20 16:22:59 +02:00
|
|
|
icon: 'fas fa-pencil-alt',
|
2020-12-26 02:47:36 +01:00
|
|
|
text: this.$ts.edit,
|
2020-11-15 04:34:47 +01:00
|
|
|
action: async () => {
|
|
|
|
const { canceled, result } = await os.form(this.clip.name, {
|
|
|
|
name: {
|
|
|
|
type: 'string',
|
2020-12-26 02:47:36 +01:00
|
|
|
label: this.$ts.name,
|
2020-11-15 04:34:47 +01:00
|
|
|
default: this.clip.name
|
|
|
|
},
|
|
|
|
description: {
|
|
|
|
type: 'string',
|
|
|
|
required: false,
|
|
|
|
multiline: true,
|
2020-12-26 02:47:36 +01:00
|
|
|
label: this.$ts.description,
|
2020-11-15 04:34:47 +01:00
|
|
|
default: this.clip.description
|
|
|
|
},
|
|
|
|
isPublic: {
|
|
|
|
type: 'boolean',
|
2020-12-26 02:47:36 +01:00
|
|
|
label: this.$ts.public,
|
2020-11-15 04:34:47 +01:00
|
|
|
default: this.clip.isPublic
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
os.apiWithDialog('clips/update', {
|
|
|
|
clipId: this.clip.id,
|
|
|
|
...result
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} : undefined, this.isOwned ? {
|
2021-04-20 16:22:59 +02:00
|
|
|
icon: 'fas fa-trash-alt',
|
2020-12-26 02:47:36 +01:00
|
|
|
text: this.$ts.delete,
|
2020-11-15 04:34:47 +01:00
|
|
|
danger: true,
|
|
|
|
action: async () => {
|
2021-11-18 10:45:58 +01:00
|
|
|
const { canceled } = await os.confirm({
|
2020-11-15 04:34:47 +01:00
|
|
|
type: 'warning',
|
|
|
|
text: this.$t('deleteAreYouSure', { x: this.clip.name }),
|
|
|
|
});
|
|
|
|
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;
|
2021-12-10 08:15:36 +01:00
|
|
|
margin-bottom: var(--margin);
|
2020-11-15 04:34:47 +01:00
|
|
|
|
|
|
|
> .description {
|
|
|
|
padding: 16px;
|
|
|
|
}
|
2020-11-15 04:47:54 +01:00
|
|
|
|
|
|
|
> .user {
|
|
|
|
$height: 32px;
|
|
|
|
padding: 16px;
|
2021-04-10 05:40:50 +02:00
|
|
|
border-top: solid 0.5px var(--divider);
|
2020-11-15 04:47:54 +01:00
|
|
|
line-height: $height;
|
|
|
|
|
|
|
|
> .avatar {
|
|
|
|
width: $height;
|
|
|
|
height: $height;
|
|
|
|
}
|
|
|
|
}
|
2020-11-15 04:34:47 +01:00
|
|
|
}
|
|
|
|
</style>
|