2018-06-05 15:36:21 +03:00
|
|
|
<template>
|
2018-06-08 05:17:22 +03:00
|
|
|
<div class="dnpfarvgbnfmyzbdquhhzyxcmstpdqzs" :class="{ naked, narrow, active, isStacked, draghover, dragging, dropready }"
|
|
|
|
@dragover.prevent.stop="onDragover"
|
|
|
|
@dragenter.prevent="onDragenter"
|
|
|
|
@dragleave="onDragleave"
|
2018-09-01 02:09:21 +03:00
|
|
|
@drop.prevent.stop="onDrop">
|
2018-06-08 02:38:32 +03:00
|
|
|
<header :class="{ indicate: count > 0 }"
|
|
|
|
draggable="true"
|
2018-09-01 02:09:21 +03:00
|
|
|
@click="goTop"
|
2018-06-08 02:38:32 +03:00
|
|
|
@dragstart="onDragstart"
|
|
|
|
@dragend="onDragend"
|
2018-09-01 02:09:21 +03:00
|
|
|
@contextmenu.prevent.stop="onContextmenu">
|
|
|
|
<button class="toggleActive" @click="toggleActive" v-if="isStacked">
|
|
|
|
<template v-if="active">%fa:angle-up%</template>
|
|
|
|
<template v-else>%fa:angle-down%</template>
|
|
|
|
</button>
|
2018-06-05 16:54:03 +03:00
|
|
|
<slot name="header"></slot>
|
2018-06-07 23:04:21 +03:00
|
|
|
<span class="count" v-if="count > 0">({{ count }})</span>
|
2018-09-01 02:09:21 +03:00
|
|
|
<button class="menu" ref="menu" @click.stop="showMenu">%fa:caret-down%</button>
|
2018-06-05 15:36:21 +03:00
|
|
|
</header>
|
2018-06-07 23:48:27 +03:00
|
|
|
<div ref="body" v-show="active">
|
2018-06-05 16:54:03 +03:00
|
|
|
<slot></slot>
|
2018-06-05 15:36:21 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-06-05 23:18:08 +03:00
|
|
|
import Menu from '../../../../common/views/components/menu.vue';
|
2018-06-08 05:46:45 +03:00
|
|
|
import contextmenu from '../../../api/contextmenu';
|
2018-09-05 20:16:08 +03:00
|
|
|
import { countIf } from '../../../../../../prelude/array';
|
2018-06-05 15:36:21 +03:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-06-05 23:18:08 +03:00
|
|
|
props: {
|
2018-06-07 23:48:27 +03:00
|
|
|
column: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
isStacked: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
|
|
|
},
|
2018-06-07 00:13:57 +03:00
|
|
|
name: {
|
|
|
|
type: String,
|
|
|
|
required: false
|
|
|
|
},
|
2018-06-06 13:22:45 +03:00
|
|
|
menu: {
|
|
|
|
type: Array,
|
2018-06-07 22:21:06 +03:00
|
|
|
required: false,
|
|
|
|
default: null
|
2018-06-06 13:22:45 +03:00
|
|
|
},
|
|
|
|
naked: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
narrow: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
2018-06-05 23:18:08 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-06-07 22:21:06 +03:00
|
|
|
inject: {
|
|
|
|
getColumnVm: { from: 'getColumnVm' }
|
|
|
|
},
|
|
|
|
|
2018-06-05 19:54:24 +03:00
|
|
|
data() {
|
|
|
|
return {
|
2018-06-07 23:04:21 +03:00
|
|
|
count: 0,
|
2018-06-08 02:38:32 +03:00
|
|
|
active: true,
|
|
|
|
dragging: false,
|
2018-06-08 05:17:22 +03:00
|
|
|
draghover: false,
|
|
|
|
dropready: false
|
2018-06-05 19:54:24 +03:00
|
|
|
};
|
2018-06-05 15:36:21 +03:00
|
|
|
},
|
2018-06-05 19:54:24 +03:00
|
|
|
|
2018-06-07 23:04:21 +03:00
|
|
|
watch: {
|
2018-06-07 23:48:27 +03:00
|
|
|
active(v) {
|
2018-06-07 23:04:21 +03:00
|
|
|
if (v && this.isScrollTop()) {
|
|
|
|
this.$emit('top');
|
|
|
|
}
|
2018-06-08 05:17:22 +03:00
|
|
|
},
|
|
|
|
dragging(v) {
|
|
|
|
this.$root.$emit(v ? 'deck.column.dragStart' : 'deck.column.dragEnd');
|
2018-06-07 23:04:21 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-06-05 16:54:03 +03:00
|
|
|
provide() {
|
|
|
|
return {
|
2018-06-05 19:54:24 +03:00
|
|
|
column: this,
|
|
|
|
isScrollTop: this.isScrollTop,
|
2018-06-07 23:04:21 +03:00
|
|
|
count: v => this.count = v
|
2018-06-05 16:54:03 +03:00
|
|
|
};
|
|
|
|
},
|
2018-06-05 19:54:24 +03:00
|
|
|
|
2018-06-05 15:36:21 +03:00
|
|
|
mounted() {
|
2018-06-06 19:52:03 +03:00
|
|
|
this.$refs.body.addEventListener('scroll', this.onScroll, { passive: true });
|
2018-06-08 05:17:22 +03:00
|
|
|
this.$root.$on('deck.column.dragStart', this.onOtherDragStart);
|
|
|
|
this.$root.$on('deck.column.dragEnd', this.onOtherDragEnd);
|
2018-06-05 19:54:24 +03:00
|
|
|
},
|
2018-06-08 05:17:22 +03:00
|
|
|
|
2018-06-05 19:54:24 +03:00
|
|
|
beforeDestroy() {
|
|
|
|
this.$refs.body.removeEventListener('scroll', this.onScroll);
|
2018-06-08 05:17:22 +03:00
|
|
|
this.$root.$off('deck.column.dragStart', this.onOtherDragStart);
|
|
|
|
this.$root.$off('deck.column.dragEnd', this.onOtherDragEnd);
|
2018-06-05 19:54:24 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2018-06-08 05:17:22 +03:00
|
|
|
onOtherDragStart() {
|
|
|
|
this.dropready = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onOtherDragEnd() {
|
|
|
|
this.dropready = false;
|
|
|
|
},
|
|
|
|
|
2018-06-07 22:21:06 +03:00
|
|
|
toggleActive() {
|
|
|
|
if (!this.isStacked) return;
|
|
|
|
const vms = this.$store.state.settings.deck.layout.find(ids => ids.indexOf(this.column.id) != -1).map(id => this.getColumnVm(id));
|
2018-09-05 20:16:08 +03:00
|
|
|
if (this.active && countIf(vm => vm.$el.classList.contains('active'), vms) == 1) return;
|
2018-06-07 23:48:27 +03:00
|
|
|
this.active = !this.active;
|
2018-06-07 22:21:06 +03:00
|
|
|
},
|
|
|
|
|
2018-06-05 19:54:24 +03:00
|
|
|
isScrollTop() {
|
2018-06-07 23:48:27 +03:00
|
|
|
return this.active && this.$refs.body.scrollTop == 0;
|
2018-06-05 19:54:24 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
onScroll() {
|
|
|
|
if (this.isScrollTop()) {
|
|
|
|
this.$emit('top');
|
|
|
|
}
|
2018-06-05 16:54:03 +03:00
|
|
|
|
2018-06-05 19:54:24 +03:00
|
|
|
if (this.$store.state.settings.fetchOnScroll !== false) {
|
|
|
|
const current = this.$refs.body.scrollTop + this.$refs.body.clientHeight;
|
|
|
|
if (current > this.$refs.body.scrollHeight - 1) this.$emit('bottom');
|
|
|
|
}
|
2018-06-05 23:18:08 +03:00
|
|
|
},
|
|
|
|
|
2018-06-08 05:46:45 +03:00
|
|
|
getMenu() {
|
2018-06-06 13:22:45 +03:00
|
|
|
const items = [{
|
2018-06-08 05:46:45 +03:00
|
|
|
icon: '%fa:pencil-alt%',
|
|
|
|
text: '%i18n:common.deck.rename%',
|
|
|
|
action: () => {
|
2018-06-07 00:13:57 +03:00
|
|
|
(this as any).apis.input({
|
|
|
|
title: '%i18n:common.deck.rename%',
|
|
|
|
default: this.name,
|
|
|
|
allowEmpty: false
|
|
|
|
}).then(name => {
|
2018-06-07 22:21:06 +03:00
|
|
|
this.$store.dispatch('settings/renameDeckColumn', { id: this.column.id, name });
|
2018-06-07 00:13:57 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}, null, {
|
2018-06-08 05:46:45 +03:00
|
|
|
icon: '%fa:arrow-left%',
|
|
|
|
text: '%i18n:common.deck.swap-left%',
|
|
|
|
action: () => {
|
2018-06-07 22:21:06 +03:00
|
|
|
this.$store.dispatch('settings/swapLeftDeckColumn', this.column.id);
|
2018-06-06 13:22:45 +03:00
|
|
|
}
|
|
|
|
}, {
|
2018-06-08 05:46:45 +03:00
|
|
|
icon: '%fa:arrow-right%',
|
|
|
|
text: '%i18n:common.deck.swap-right%',
|
|
|
|
action: () => {
|
2018-06-07 22:21:06 +03:00
|
|
|
this.$store.dispatch('settings/swapRightDeckColumn', this.column.id);
|
|
|
|
}
|
2018-06-07 22:34:15 +03:00
|
|
|
}, this.isStacked ? {
|
2018-06-08 05:46:45 +03:00
|
|
|
icon: '%fa:arrow-up%',
|
|
|
|
text: '%i18n:common.deck.swap-up%',
|
|
|
|
action: () => {
|
2018-06-07 22:34:15 +03:00
|
|
|
this.$store.dispatch('settings/swapUpDeckColumn', this.column.id);
|
|
|
|
}
|
|
|
|
} : undefined, this.isStacked ? {
|
2018-06-08 05:46:45 +03:00
|
|
|
icon: '%fa:arrow-down%',
|
|
|
|
text: '%i18n:common.deck.swap-down%',
|
|
|
|
action: () => {
|
2018-06-07 22:34:15 +03:00
|
|
|
this.$store.dispatch('settings/swapDownDeckColumn', this.column.id);
|
|
|
|
}
|
|
|
|
} : undefined, null, {
|
2018-06-08 05:46:45 +03:00
|
|
|
icon: '%fa:window-restore R%',
|
|
|
|
text: '%i18n:common.deck.stack-left%',
|
|
|
|
action: () => {
|
2018-06-07 22:21:06 +03:00
|
|
|
this.$store.dispatch('settings/stackLeftDeckColumn', this.column.id);
|
|
|
|
}
|
2018-06-07 22:34:15 +03:00
|
|
|
}, this.isStacked ? {
|
2018-06-08 05:46:45 +03:00
|
|
|
icon: '%fa:window-maximize R%',
|
|
|
|
text: '%i18n:common.deck.pop-right%',
|
|
|
|
action: () => {
|
2018-06-07 22:21:06 +03:00
|
|
|
this.$store.dispatch('settings/popRightDeckColumn', this.column.id);
|
2018-06-06 13:22:45 +03:00
|
|
|
}
|
2018-06-07 22:34:15 +03:00
|
|
|
} : undefined, null, {
|
2018-06-08 05:46:45 +03:00
|
|
|
icon: '%fa:trash-alt R%',
|
|
|
|
text: '%i18n:common.deck.remove%',
|
|
|
|
action: () => {
|
2018-06-07 22:21:06 +03:00
|
|
|
this.$store.dispatch('settings/removeDeckColumn', this.column.id);
|
2018-06-06 13:22:45 +03:00
|
|
|
}
|
|
|
|
}];
|
|
|
|
|
|
|
|
if (this.menu) {
|
|
|
|
items.unshift(null);
|
|
|
|
this.menu.reverse().forEach(i => items.unshift(i));
|
|
|
|
}
|
|
|
|
|
2018-06-08 05:46:45 +03:00
|
|
|
return items;
|
|
|
|
},
|
|
|
|
|
|
|
|
onContextmenu(e) {
|
|
|
|
contextmenu((this as any).os)(e, this.getMenu());
|
|
|
|
},
|
|
|
|
|
|
|
|
showMenu() {
|
2018-06-05 23:18:08 +03:00
|
|
|
this.os.new(Menu, {
|
|
|
|
source: this.$refs.menu,
|
|
|
|
compact: false,
|
2018-06-08 05:46:45 +03:00
|
|
|
items: this.getMenu()
|
2018-06-05 23:18:08 +03:00
|
|
|
});
|
2018-06-08 02:38:32 +03:00
|
|
|
},
|
|
|
|
|
2018-09-01 02:09:21 +03:00
|
|
|
goTop() {
|
|
|
|
this.$refs.body.scrollTo({
|
|
|
|
top: 0,
|
|
|
|
behavior: 'smooth'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2018-06-08 02:38:32 +03:00
|
|
|
onDragstart(e) {
|
|
|
|
e.dataTransfer.effectAllowed = 'move';
|
|
|
|
e.dataTransfer.setData('mk-deck-column', this.column.id);
|
|
|
|
this.dragging = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onDragend(e) {
|
|
|
|
this.dragging = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
onDragover(e) {
|
|
|
|
// 自分自身がドラッグされている場合
|
|
|
|
if (this.dragging) {
|
|
|
|
// 自分自身にはドロップさせない
|
|
|
|
e.dataTransfer.dropEffect = 'none';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const isDeckColumn = e.dataTransfer.types[0] == 'mk-deck-column';
|
|
|
|
|
|
|
|
e.dataTransfer.dropEffect = isDeckColumn ? 'move' : 'none';
|
|
|
|
},
|
|
|
|
|
|
|
|
onDragenter() {
|
|
|
|
if (!this.dragging) this.draghover = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onDragleave() {
|
|
|
|
this.draghover = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
onDrop(e) {
|
|
|
|
this.draghover = false;
|
2018-06-08 05:17:22 +03:00
|
|
|
this.$root.$emit('deck.column.dragEnd');
|
2018-06-08 02:38:32 +03:00
|
|
|
|
|
|
|
const id = e.dataTransfer.getData('mk-deck-column');
|
|
|
|
if (id != null && id != '') {
|
|
|
|
this.$store.dispatch('settings/swapDeckColumn', {
|
|
|
|
a: this.column.id,
|
|
|
|
b: id
|
|
|
|
});
|
|
|
|
}
|
2018-06-05 19:54:24 +03:00
|
|
|
}
|
2018-06-05 15:36:21 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-09-28 09:34:34 +03:00
|
|
|
.dnpfarvgbnfmyzbdquhhzyxcmstpdqzs
|
2018-06-05 23:18:08 +03:00
|
|
|
$header-height = 42px
|
|
|
|
|
2018-06-07 02:41:58 +03:00
|
|
|
width 330px
|
2018-06-07 22:21:06 +03:00
|
|
|
min-width 330px
|
2018-06-05 15:36:21 +03:00
|
|
|
height 100%
|
2018-09-26 14:28:13 +03:00
|
|
|
background var(--face)
|
2018-06-05 15:36:21 +03:00
|
|
|
border-radius 6px
|
2018-09-22 14:11:13 +03:00
|
|
|
//box-shadow 0 2px 16px rgba(#000, 0.1)
|
2018-06-05 15:36:21 +03:00
|
|
|
overflow hidden
|
|
|
|
|
2018-06-08 02:38:32 +03:00
|
|
|
&.draghover
|
2018-09-26 14:19:35 +03:00
|
|
|
box-shadow 0 0 0 2px var(--primaryAlpha08)
|
2018-06-08 05:17:22 +03:00
|
|
|
|
2018-06-08 02:38:32 +03:00
|
|
|
&.dragging
|
2018-09-26 14:19:35 +03:00
|
|
|
box-shadow 0 0 0 2px var(--primaryAlpha04)
|
2018-06-08 05:17:22 +03:00
|
|
|
|
|
|
|
&.dropready
|
|
|
|
*
|
|
|
|
pointer-events none
|
2018-06-08 02:38:32 +03:00
|
|
|
|
2018-06-07 23:48:27 +03:00
|
|
|
&:not(.active)
|
2018-06-07 22:21:06 +03:00
|
|
|
flex-basis $header-height
|
|
|
|
min-height $header-height
|
|
|
|
|
|
|
|
&:not(.isStacked).narrow
|
2018-06-07 02:41:58 +03:00
|
|
|
width 285px
|
2018-06-07 22:21:06 +03:00
|
|
|
min-width 285px
|
2018-06-06 13:22:45 +03:00
|
|
|
|
|
|
|
&.naked
|
2018-09-28 09:34:34 +03:00
|
|
|
background var(--deckAcrylicColumnBg)
|
2018-06-06 13:22:45 +03:00
|
|
|
|
|
|
|
> header
|
|
|
|
background transparent
|
|
|
|
box-shadow none
|
|
|
|
|
|
|
|
if !isDark
|
|
|
|
> button
|
|
|
|
color #bbb
|
|
|
|
|
2018-06-05 15:36:21 +03:00
|
|
|
> header
|
2018-09-01 02:09:21 +03:00
|
|
|
display flex
|
2018-06-05 15:36:21 +03:00
|
|
|
z-index 1
|
2018-06-05 23:18:08 +03:00
|
|
|
line-height $header-height
|
2018-06-05 15:36:21 +03:00
|
|
|
padding 0 16px
|
2018-06-06 23:14:37 +03:00
|
|
|
font-size 14px
|
2018-09-27 08:52:10 +03:00
|
|
|
color var(--faceHeaderText)
|
2018-09-26 14:28:13 +03:00
|
|
|
background var(--faceHeader)
|
2018-06-05 15:36:21 +03:00
|
|
|
box-shadow 0 1px rgba(#000, 0.15)
|
2018-06-08 02:05:25 +03:00
|
|
|
cursor pointer
|
2018-06-05 15:36:21 +03:00
|
|
|
|
2018-06-07 22:21:06 +03:00
|
|
|
&, *
|
|
|
|
user-select none
|
|
|
|
|
2018-06-08 02:38:32 +03:00
|
|
|
*:not(button)
|
|
|
|
pointer-events none
|
|
|
|
|
2018-06-05 19:54:24 +03:00
|
|
|
&.indicate
|
2018-09-26 14:19:35 +03:00
|
|
|
box-shadow 0 3px 0 0 var(--primary)
|
2018-06-05 19:54:24 +03:00
|
|
|
|
2018-06-05 23:18:08 +03:00
|
|
|
> span
|
|
|
|
[data-fa]
|
|
|
|
margin-right 8px
|
|
|
|
|
2018-06-07 23:04:21 +03:00
|
|
|
> .count
|
|
|
|
margin-left 4px
|
|
|
|
opacity 0.5
|
|
|
|
|
2018-09-01 02:09:21 +03:00
|
|
|
> .toggleActive
|
|
|
|
> .menu
|
2018-06-05 23:18:08 +03:00
|
|
|
width $header-height
|
|
|
|
line-height $header-height
|
2018-06-08 02:05:25 +03:00
|
|
|
font-size 16px
|
2018-09-27 08:32:48 +03:00
|
|
|
color var(--faceTextButton)
|
2018-06-05 23:18:08 +03:00
|
|
|
|
|
|
|
&:hover
|
2018-09-27 08:32:48 +03:00
|
|
|
color var(--faceTextButtonHover)
|
2018-06-05 23:18:08 +03:00
|
|
|
|
|
|
|
&:active
|
2018-09-28 09:34:34 +03:00
|
|
|
color var(--faceTextButtonActive)
|
2018-06-05 23:18:08 +03:00
|
|
|
|
2018-09-01 02:09:21 +03:00
|
|
|
> .toggleActive
|
|
|
|
margin-left -16px
|
|
|
|
|
|
|
|
> .menu
|
|
|
|
margin-left auto
|
|
|
|
margin-right -16px
|
|
|
|
|
2018-06-05 15:36:21 +03:00
|
|
|
> div
|
2018-06-05 23:29:31 +03:00
|
|
|
height "calc(100% - %s)" % $header-height
|
2018-06-05 15:36:21 +03:00
|
|
|
overflow auto
|
2018-06-05 15:44:02 +03:00
|
|
|
overflow-x hidden
|
2018-06-05 15:36:21 +03:00
|
|
|
|
|
|
|
</style>
|