misskey/src/client/pages/clip.vue

155 lines
3 KiB
Vue
Raw Normal View History

2020-11-15 03:34:47 +00:00
<template>
<div v-if="clip" class="_section">
2021-04-10 09:17:42 +00:00
<div class="okzinsic _content _panel _gap">
2020-11-15 03:34:47 +00:00
<div class="description" v-if="clip.description">
<Mfm :text="clip.description" :is-note="false" :i="$i"/>
2020-11-15 03:34:47 +00:00
</div>
2020-11-15 03:47:54 +00:00
<div class="user">
2021-04-17 14:52:54 +00:00
<MkAvatar :user="clip.user" class="avatar" :show-indicator="true"/> <MkUserName :user="clip.user" :nowrap="false"/>
2020-11-15 03:47:54 +00:00
</div>
2020-11-15 03:34:47 +00:00
</div>
2021-04-10 09:17:42 +00:00
<XNotes class="_content _gap" :pagination="pagination" :detail="true"/>
2020-11-15 03:34:47 +00:00
</div>
</template>
<script lang="ts">
import { computed, defineComponent } from 'vue';
2021-03-23 08:30:14 +00:00
import MkContainer from '@client/components/ui/container.vue';
import XPostForm from '@client/components/post-form.vue';
import XNotes from '@client/components/notes.vue';
import * as os from '@client/os';
2021-04-10 03:54:12 +00:00
import * as symbols from '@client/symbols';
2020-11-15 03:34:47 +00:00
export default defineComponent({
components: {
MkContainer,
XPostForm,
XNotes,
},
props: {
clipId: {
type: String,
required: true
}
},
data() {
return {
2021-04-10 03:54:12 +00:00
[symbols.PAGE_INFO]: computed(() => this.clip ? {
2020-11-15 03:34:47 +00:00
title: this.clip.name,
icon: 'fas fa-paperclip',
2020-11-15 03:34:47 +00:00
action: {
2021-04-20 18:32:16 +00:00
icon: 'fas fa-ellipsis-h',
2020-11-15 03:34:47 +00:00
handler: this.menu
}
} : null),
clip: null,
pagination: {
endpoint: 'clips/notes',
limit: 10,
params: () => ({
clipId: this.clipId,
})
},
};
},
computed: {
isOwned(): boolean {
return this.$i && this.clip && (this.$i.id === this.clip.userId);
2020-11-15 03:34:47 +00: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: 'fas fa-pencil-alt',
2020-12-26 01:47:36 +00:00
text: this.$ts.edit,
2020-11-15 03:34:47 +00:00
action: async () => {
const { canceled, result } = await os.form(this.clip.name, {
name: {
type: 'string',
2020-12-26 01:47:36 +00:00
label: this.$ts.name,
2020-11-15 03:34:47 +00:00
default: this.clip.name
},
description: {
type: 'string',
required: false,
multiline: true,
2020-12-26 01:47:36 +00:00
label: this.$ts.description,
2020-11-15 03:34:47 +00:00
default: this.clip.description
},
isPublic: {
type: 'boolean',
2020-12-26 01:47:36 +00:00
label: this.$ts.public,
2020-11-15 03:34:47 +00:00
default: this.clip.isPublic
}
});
if (canceled) return;
os.apiWithDialog('clips/update', {
clipId: this.clip.id,
...result
});
}
} : undefined, this.isOwned ? {
icon: 'fas fa-trash-alt',
2020-12-26 01:47:36 +00:00
text: this.$ts.delete,
2020-11-15 03:34:47 +00: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 03:47:54 +00:00
> .user {
$height: 32px;
padding: 16px;
border-top: solid 0.5px var(--divider);
2020-11-15 03:47:54 +00:00
line-height: $height;
> .avatar {
width: $height;
height: $height;
}
}
2020-11-15 03:34:47 +00:00
}
</style>