2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<portal to="icon"><fa :icon="faBroadcastTower"/></portal>
|
2020-07-25 01:56:52 +09:00
|
|
|
<portal to="title">{{ $t('announcements') }}</portal>
|
2020-01-30 04:37:25 +09:00
|
|
|
|
|
|
|
<mk-pagination :pagination="pagination" #default="{items}" class="ruryvtyk" ref="list">
|
2020-02-06 14:23:01 +09:00
|
|
|
<section class="_card announcement" v-for="(announcement, i) in items" :key="announcement.id">
|
2020-01-30 04:37:25 +09:00
|
|
|
<div class="_title"><span v-if="$store.getters.isSignedIn && !announcement.isRead">🆕 </span>{{ announcement.title }}</div>
|
|
|
|
<div class="_content">
|
|
|
|
<mfm :text="announcement.text"/>
|
2020-02-16 22:46:51 +09:00
|
|
|
<img v-if="announcement.imageUrl" :src="announcement.imageUrl"/>
|
2020-01-30 04:37:25 +09:00
|
|
|
</div>
|
|
|
|
<div class="_footer" v-if="$store.getters.isSignedIn && !announcement.isRead">
|
2020-08-01 10:02:03 +09:00
|
|
|
<mk-button @click="read(items, announcement, i)" primary><fa :icon="faCheck"/> {{ $t('gotIt') }}</mk-button>
|
2020-01-30 04:37:25 +09:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</mk-pagination>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import { faCheck, faBroadcastTower } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import MkPagination from '../components/ui/pagination.vue';
|
|
|
|
import MkButton from '../components/ui/button.vue';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
metaInfo() {
|
|
|
|
return {
|
|
|
|
title: this.$t('announcements') as string
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
components: {
|
|
|
|
MkPagination,
|
|
|
|
MkButton
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
pagination: {
|
|
|
|
endpoint: 'announcements',
|
|
|
|
limit: 10,
|
|
|
|
},
|
|
|
|
faCheck, faBroadcastTower
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2020-08-01 10:02:03 +09:00
|
|
|
// TODO: これは実質的に親コンポーネントから子コンポーネントのプロパティを変更してるのでなんとかしたい
|
|
|
|
read(items, announcement, i) {
|
|
|
|
console.log(this);
|
|
|
|
Vue.set(items, i, {
|
|
|
|
...announcement,
|
|
|
|
isRead: true,
|
|
|
|
});
|
2020-01-30 04:37:25 +09:00
|
|
|
this.$root.api('i/read-announcement', { announcementId: announcement.id });
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.ruryvtyk {
|
|
|
|
> .announcement {
|
|
|
|
> ._content {
|
|
|
|
> img {
|
|
|
|
display: block;
|
|
|
|
max-height: 300px;
|
|
|
|
max-width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|