KawAnime/components/historyModal.vue

159 lines
3.5 KiB
Vue
Raw Normal View History

<template lang="pug">
2017-09-19 09:12:45 +00:00
v-dialog(lazy, absolute, width='75%', v-model='$store.state.history.modal')
v-btn(secondary, dark, @click='refresh()', slot='activator')
| History
2017-09-03 22:35:39 +00:00
v-card
v-card-title.headline History
v-divider
v-card-text
v-layout(row, wrap, justify-center)
v-expansion-panel(expand, popout, v-if='Object.keys(history).length')
v-expansion-panel-content.item-container(
ripple, lazy,
v-for='item in Object.keys(history).reverse()',
:key='item'
)
2017-09-03 22:35:39 +00:00
.day(slot='header')
| {{ item }}
v-card
v-card-text.lighten-3.info-container
v-layout(row, wrap)
template(v-for='info in history[item]')
v-flex.pl-1.time.entry(xs2, :class='isDelete(info.type)')
| {{ info.time }}
v-flex.type.entry(xs2, :class='isDelete(info.type)')
| {{ info.type }}
v-flex.ellipsis.text.entry(xs7, :class='isDelete(info.type)')
| {{ info.text }}
v-flex.entry(xs1, :class='isDelete(info.type)')
v-icon.delete-entry(v-ripple='true', @click.stop='clearEntry(info, item)')
| clear
v-flex.empty-history(xs4, v-else) No entry yet, go watch some anime ~
v-divider
v-card-actions(style=' padding-right: 20px;')
v-spacer
v-btn.blue--text.darken-1(
flat,
style='width: 100px;',
2017-09-19 09:12:45 +00:00
@click="$store.commit('history/setModal', false)"
) Close
</template>
<script>
export default {
2017-04-30 12:40:01 +00:00
computed: {
2017-09-19 09:12:45 +00:00
history () {
return this.$store.state.history.entries
2017-04-30 16:13:42 +00:00
},
2017-09-19 09:12:45 +00:00
modal () {
return this.$store.state.history.modal
2017-04-30 16:13:42 +00:00
}
},
watch: {
2017-09-19 09:12:45 +00:00
modal () {
2017-04-30 16:13:42 +00:00
console.log(`[${(new Date()).toLocaleTimeString()}]: Refreshing history.`)
2017-09-19 09:12:45 +00:00
this.$store.dispatch('history/get')
2017-04-30 16:13:42 +00:00
}
},
methods: {
2017-05-13 14:38:17 +00:00
isDelete (type) {
return type === 'Delete'
? 'delete'
: 'not-delete'
},
clearEntry (info, item) {
2017-09-19 09:12:45 +00:00
this.$store.dispatch('history/remove', {
date: item,
info
})
},
refresh () {
2017-09-19 09:12:45 +00:00
this.$store.dispatch('history/get')
2017-04-30 12:40:01 +00:00
}
}
}
</script>
2017-04-30 16:13:42 +00:00
<style scoped>
2017-05-13 14:38:17 +00:00
h6, p
{
margin: 0;
}
2017-04-30 16:13:42 +00:00
2017-05-13 14:38:17 +00:00
.ellipsis
{
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
2017-04-30 16:13:42 +00:00
2017-05-13 14:38:17 +00:00
.item-container
{
background-color: rgb(50, 50, 50);
border-bottom: 0 !important;
}
2017-04-30 16:13:42 +00:00
2017-05-13 14:38:17 +00:00
.info-container
{
background-color: rgb(50, 50, 50);
}
2017-04-30 16:13:42 +00:00
2017-05-13 14:38:17 +00:00
.day
{
position: relative;
font-size: 17px;
font-weight: 700;
padding-left: 15px;
2017-09-03 22:35:39 +00:00
background-color: #424242 !important;
2017-05-13 14:38:17 +00:00
}
2017-04-30 16:13:42 +00:00
.entry
{
height: 27px;
padding-top: 1px;
}
2017-05-13 14:38:17 +00:00
.not-delete
{
background-color: rgba(119, 221, 119, 0.62);
border-bottom: 1px solid rgba(119, 221, 119, 0.62);
border-top: 1px solid rgba(119, 221, 119, 0.62);
}
2017-04-30 16:13:42 +00:00
2017-05-13 14:38:17 +00:00
.delete
{
background-color: rgba(216, 24, 24, 0.55);
border-bottom: 1px solid rgba(235, 26, 26, 0.20);
border-top: 1px solid rgba(235, 26, 26, 0.20);
}
2017-04-30 16:13:42 +00:00
2017-05-13 14:38:17 +00:00
.time
{
font-size: 16px;
font-weight: 600;
}
2017-04-30 16:13:42 +00:00
2017-05-13 14:38:17 +00:00
.type
{
font-size: 16px;
font-style: italic;
}
2017-04-30 16:13:42 +00:00
2017-05-13 14:38:17 +00:00
.text
{
font-size: 16px;
font-weight: 700;
}
.delete-entry
{
cursor: pointer;
position: relative;
}
.empty-history
{
font-size: 16px;
}
2017-04-30 16:13:42 +00:00
</style>