2020-07-11 04:13:11 +03:00
|
|
|
<template>
|
|
|
|
<!-- sectionを利用しているのは、deck.vue側でcolumnに対してfirst-of-typeを効かせるため -->
|
2020-12-11 15:36:57 +02:00
|
|
|
<section class="dnpfarvg _panel _narrow_" :class="{ paged: isMainColumn, naked, _inContainer_: !isMainColumn, active, isStacked, draghover, dragging, dropready }"
|
2020-07-11 04:13:11 +03:00
|
|
|
@dragover.prevent.stop="onDragover"
|
|
|
|
@dragleave="onDragleave"
|
|
|
|
@drop.prevent.stop="onDrop"
|
|
|
|
v-hotkey="keymap"
|
|
|
|
:style="{ width: `${width}px` }"
|
|
|
|
>
|
|
|
|
<header :class="{ indicated }"
|
|
|
|
draggable="true"
|
|
|
|
@click="goTop"
|
|
|
|
@dragstart="onDragstart"
|
|
|
|
@dragend="onDragend"
|
|
|
|
@contextmenu.prevent.stop="onContextmenu"
|
|
|
|
>
|
|
|
|
<button class="toggleActive _button" @click="toggleActive" v-if="isStacked">
|
2020-10-17 14:12:00 +03:00
|
|
|
<template v-if="active"><Fa :icon="faAngleUp"/></template>
|
|
|
|
<template v-else><Fa :icon="faAngleDown"/></template>
|
2020-07-11 04:13:11 +03:00
|
|
|
</button>
|
|
|
|
<div class="action">
|
|
|
|
<slot name="action"></slot>
|
|
|
|
</div>
|
|
|
|
<span class="header"><slot name="header"></slot></span>
|
2020-10-17 14:12:00 +03:00
|
|
|
<button v-if="!isMainColumn" class="menu _button" ref="menu" @click.stop="showMenu"><Fa :icon="faCaretDown"/></button>
|
2020-07-11 04:13:11 +03:00
|
|
|
</header>
|
|
|
|
<div ref="body" v-show="active">
|
|
|
|
<slot></slot>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 14:12:00 +03:00
|
|
|
import { defineComponent } from 'vue';
|
|
|
|
import { faArrowUp, faArrowDown, faAngleUp, faAngleDown, faCaretDown, faArrowRight, faArrowLeft, faPencilAlt } from '@fortawesome/free-solid-svg-icons';
|
2020-07-11 04:13:11 +03:00
|
|
|
import { faWindowMaximize, faTrashAlt, faWindowRestore } from '@fortawesome/free-regular-svg-icons';
|
2020-10-17 14:12:00 +03:00
|
|
|
import * as os from '@/os';
|
2020-12-19 03:55:52 +02:00
|
|
|
import { renameColumn, swapLeftColumn, swapRightColumn, swapUpColumn, swapDownColumn, stackLeftColumn, popRightColumn, removeColumn, swapColumn } from './deck-store';
|
2020-07-11 04:13:11 +03:00
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
export default defineComponent({
|
2020-07-11 04:13:11 +03:00
|
|
|
props: {
|
|
|
|
column: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
isStacked: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
menu: {
|
|
|
|
type: Array,
|
|
|
|
required: false,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
naked: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
indicated: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
active: true,
|
|
|
|
dragging: false,
|
|
|
|
draghover: false,
|
|
|
|
dropready: false,
|
2020-10-17 14:12:00 +03:00
|
|
|
faArrowUp, faArrowDown, faAngleUp, faAngleDown, faCaretDown,
|
2020-07-11 04:13:11 +03:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
isMainColumn(): boolean {
|
|
|
|
return this.column == null;
|
|
|
|
},
|
|
|
|
|
|
|
|
width(): number {
|
|
|
|
return this.isMainColumn ? 350 : this.column.width;
|
|
|
|
},
|
|
|
|
|
|
|
|
keymap(): any {
|
|
|
|
return {
|
2020-10-17 14:12:00 +03:00
|
|
|
'shift+up': () => this.$parent.$emit('parent-focus', 'up'),
|
|
|
|
'shift+down': () => this.$parent.$emit('parent-focus', 'down'),
|
|
|
|
'shift+left': () => this.$parent.$emit('parent-focus', 'left'),
|
|
|
|
'shift+right': () => this.$parent.$emit('parent-focus', 'right'),
|
2020-07-11 04:13:11 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
active(v) {
|
|
|
|
this.$emit('change-active-state', v);
|
|
|
|
},
|
|
|
|
|
|
|
|
dragging(v) {
|
2020-10-17 14:12:00 +03:00
|
|
|
os.deckGlobalEvents.emit(v ? 'column.dragStart' : 'column.dragEnd');
|
2020-07-11 04:13:11 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
if (!this.isMainColumn) {
|
2020-10-17 14:12:00 +03:00
|
|
|
os.deckGlobalEvents.on('column.dragStart', this.onOtherDragStart);
|
|
|
|
os.deckGlobalEvents.on('column.dragEnd', this.onOtherDragEnd);
|
2020-07-11 04:13:11 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
beforeUnmount() {
|
2020-07-11 04:13:11 +03:00
|
|
|
if (!this.isMainColumn) {
|
2020-10-17 14:12:00 +03:00
|
|
|
os.deckGlobalEvents.off('column.dragStart', this.onOtherDragStart);
|
|
|
|
os.deckGlobalEvents.off('column.dragEnd', this.onOtherDragEnd);
|
2020-07-11 04:13:11 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
onOtherDragStart() {
|
|
|
|
this.dropready = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onOtherDragEnd() {
|
|
|
|
this.dropready = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
toggleActive() {
|
|
|
|
if (!this.isStacked) return;
|
|
|
|
this.active = !this.active;
|
|
|
|
},
|
|
|
|
|
|
|
|
getMenu() {
|
|
|
|
const items = [{
|
|
|
|
icon: faPencilAlt,
|
2020-12-26 03:47:36 +02:00
|
|
|
text: this.$ts.rename,
|
2020-07-11 04:13:11 +03:00
|
|
|
action: () => {
|
2020-10-17 14:12:00 +03:00
|
|
|
os.dialog({
|
2020-12-26 03:47:36 +02:00
|
|
|
title: this.$ts.rename,
|
2020-07-11 04:13:11 +03:00
|
|
|
input: {
|
|
|
|
default: this.column.name,
|
|
|
|
allowEmpty: false
|
|
|
|
}
|
|
|
|
}).then(({ canceled, result: name }) => {
|
|
|
|
if (canceled) return;
|
2020-12-19 03:55:52 +02:00
|
|
|
renameColumn(this.column.id, name);
|
2020-07-11 04:13:11 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}, null, {
|
|
|
|
icon: faArrowLeft,
|
2020-12-26 03:47:36 +02:00
|
|
|
text: this.$ts._deck.swapLeft,
|
2020-07-11 04:13:11 +03:00
|
|
|
action: () => {
|
2020-12-19 03:55:52 +02:00
|
|
|
swapLeftColumn(this.column.id);
|
2020-07-11 04:13:11 +03:00
|
|
|
}
|
|
|
|
}, {
|
|
|
|
icon: faArrowRight,
|
2020-12-26 03:47:36 +02:00
|
|
|
text: this.$ts._deck.swapRight,
|
2020-07-11 04:13:11 +03:00
|
|
|
action: () => {
|
2020-12-19 03:55:52 +02:00
|
|
|
swapRightColumn(this.column.id);
|
2020-07-11 04:13:11 +03:00
|
|
|
}
|
|
|
|
}, this.isStacked ? {
|
|
|
|
icon: faArrowUp,
|
2020-12-26 03:47:36 +02:00
|
|
|
text: this.$ts._deck.swapUp,
|
2020-07-11 04:13:11 +03:00
|
|
|
action: () => {
|
2020-12-19 03:55:52 +02:00
|
|
|
swapUpColumn(this.column.id);
|
2020-07-11 04:13:11 +03:00
|
|
|
}
|
|
|
|
} : undefined, this.isStacked ? {
|
|
|
|
icon: faArrowDown,
|
2020-12-26 03:47:36 +02:00
|
|
|
text: this.$ts._deck.swapDown,
|
2020-07-11 04:13:11 +03:00
|
|
|
action: () => {
|
2020-12-19 03:55:52 +02:00
|
|
|
swapDownColumn(this.column.id);
|
2020-07-11 04:13:11 +03:00
|
|
|
}
|
|
|
|
} : undefined, null, {
|
|
|
|
icon: faWindowRestore,
|
2020-12-26 03:47:36 +02:00
|
|
|
text: this.$ts._deck.stackLeft,
|
2020-07-11 04:13:11 +03:00
|
|
|
action: () => {
|
2020-12-19 03:55:52 +02:00
|
|
|
stackLeftColumn(this.column.id);
|
2020-07-11 04:13:11 +03:00
|
|
|
}
|
|
|
|
}, this.isStacked ? {
|
|
|
|
icon: faWindowMaximize,
|
2020-12-26 03:47:36 +02:00
|
|
|
text: this.$ts._deck.popRight,
|
2020-07-11 04:13:11 +03:00
|
|
|
action: () => {
|
2020-12-19 03:55:52 +02:00
|
|
|
popRightColumn(this.column.id);
|
2020-07-11 04:13:11 +03:00
|
|
|
}
|
|
|
|
} : undefined, null, {
|
|
|
|
icon: faTrashAlt,
|
2020-12-26 03:47:36 +02:00
|
|
|
text: this.$ts.remove,
|
2020-07-11 04:13:11 +03:00
|
|
|
action: () => {
|
2020-12-19 03:55:52 +02:00
|
|
|
removeColumn(this.column.id);
|
2020-07-11 04:13:11 +03:00
|
|
|
}
|
|
|
|
}];
|
|
|
|
|
|
|
|
if (this.menu) {
|
|
|
|
for (const i of this.menu.reverse()) {
|
|
|
|
items.unshift(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return items;
|
|
|
|
},
|
|
|
|
|
|
|
|
onContextmenu(e) {
|
|
|
|
if (this.isMainColumn) return;
|
|
|
|
this.showMenu();
|
|
|
|
},
|
|
|
|
|
|
|
|
showMenu() {
|
2020-10-17 14:12:00 +03:00
|
|
|
os.modalMenu(this.getMenu(), this.$refs.menu);
|
2020-07-11 04:13:11 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
goTop() {
|
|
|
|
this.$refs.body.scrollTo({
|
|
|
|
top: 0,
|
|
|
|
behavior: 'smooth'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
onDragstart(e) {
|
|
|
|
// メインカラムはドラッグさせない
|
|
|
|
if (this.isMainColumn) {
|
|
|
|
e.preventDefault();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
e.dataTransfer.effectAllowed = 'move';
|
2020-10-17 14:12:00 +03:00
|
|
|
e.dataTransfer.setData(_DATA_TRANSFER_DECK_COLUMN_, this.column.id);
|
2020-07-11 04:13:11 +03:00
|
|
|
this.dragging = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onDragend(e) {
|
|
|
|
this.dragging = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
onDragover(e) {
|
|
|
|
// メインカラムにはドロップさせない
|
|
|
|
if (this.isMainColumn) {
|
|
|
|
e.dataTransfer.dropEffect = 'none';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 自分自身がドラッグされている場合
|
|
|
|
if (this.dragging) {
|
|
|
|
// 自分自身にはドロップさせない
|
|
|
|
e.dataTransfer.dropEffect = 'none';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
const isDeckColumn = e.dataTransfer.types[0] == _DATA_TRANSFER_DECK_COLUMN_;
|
2020-07-11 04:13:11 +03:00
|
|
|
|
|
|
|
e.dataTransfer.dropEffect = isDeckColumn ? 'move' : 'none';
|
|
|
|
|
|
|
|
if (!this.dragging && isDeckColumn) this.draghover = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onDragleave() {
|
|
|
|
this.draghover = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
onDrop(e) {
|
|
|
|
this.draghover = false;
|
2020-10-17 14:12:00 +03:00
|
|
|
os.deckGlobalEvents.emit('column.dragEnd');
|
2020-07-11 04:13:11 +03:00
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
const id = e.dataTransfer.getData(_DATA_TRANSFER_DECK_COLUMN_);
|
2020-07-11 04:13:11 +03:00
|
|
|
if (id != null && id != '') {
|
2020-12-19 03:55:52 +02:00
|
|
|
swapColumn(this.column.id, id);
|
2020-07-11 04:13:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.dnpfarvg {
|
|
|
|
$header-height: 42px;
|
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
--section-padding: 10px;
|
|
|
|
|
2020-07-11 04:13:11 +03:00
|
|
|
height: 100%;
|
|
|
|
overflow: hidden;
|
2020-10-17 14:12:00 +03:00
|
|
|
contain: content;
|
2020-07-11 04:13:11 +03:00
|
|
|
|
|
|
|
&.draghover {
|
|
|
|
box-shadow: 0 0 0 2px var(--focus);
|
|
|
|
|
|
|
|
&:after {
|
|
|
|
content: "";
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
z-index: 1000;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
background: var(--focus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.dragging {
|
|
|
|
box-shadow: 0 0 0 2px var(--focus);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.dropready {
|
|
|
|
* {
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&:not(.active) {
|
|
|
|
flex-basis: $header-height;
|
|
|
|
min-height: $header-height;
|
|
|
|
|
|
|
|
> header.indicated {
|
|
|
|
box-shadow: 4px 0px var(--accent) inset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.naked {
|
2020-12-20 10:19:18 +02:00
|
|
|
background: var(--acrylicBg) !important;
|
|
|
|
-webkit-backdrop-filter: blur(10px);
|
|
|
|
backdrop-filter: blur(10px);
|
2020-07-11 04:13:11 +03:00
|
|
|
|
|
|
|
> header {
|
|
|
|
background: transparent;
|
|
|
|
box-shadow: none;
|
|
|
|
|
|
|
|
> button {
|
|
|
|
color: var(--fg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.paged {
|
|
|
|
> div {
|
|
|
|
background: var(--bg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> header {
|
|
|
|
position: relative;
|
|
|
|
display: flex;
|
|
|
|
z-index: 2;
|
|
|
|
line-height: $header-height;
|
2020-10-17 18:54:20 +03:00
|
|
|
height: $header-height;
|
2020-07-11 04:13:11 +03:00
|
|
|
padding: 0 16px;
|
|
|
|
font-size: 0.9em;
|
|
|
|
color: var(--panelHeaderFg);
|
|
|
|
background: var(--panelHeaderBg);
|
|
|
|
box-shadow: 0 1px 0 0 var(--panelHeaderDivider);
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
&, * {
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.indicated {
|
|
|
|
box-shadow: 0 3px 0 0 var(--accent);
|
|
|
|
}
|
|
|
|
|
|
|
|
> .header {
|
|
|
|
display: inline-block;
|
|
|
|
align-items: center;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
> span:only-of-type {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .toggleActive,
|
|
|
|
> .action > *,
|
2020-10-17 14:12:00 +03:00
|
|
|
> .menu {
|
2020-07-11 04:13:11 +03:00
|
|
|
z-index: 1;
|
|
|
|
width: $header-height;
|
|
|
|
line-height: $header-height;
|
|
|
|
font-size: 16px;
|
|
|
|
color: var(--faceTextButton);
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--faceTextButtonHover);
|
|
|
|
}
|
|
|
|
|
|
|
|
&:active {
|
|
|
|
color: var(--faceTextButtonActive);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .toggleActive, > .action {
|
|
|
|
margin-left: -16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .action {
|
|
|
|
z-index: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .action:empty {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
> .menu {
|
2020-07-11 04:13:11 +03:00
|
|
|
margin-left: auto;
|
|
|
|
margin-right: -16px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> div {
|
|
|
|
height: calc(100% - #{$header-height});
|
|
|
|
overflow: auto;
|
|
|
|
overflow-x: hidden;
|
|
|
|
-webkit-overflow-scrolling: touch;
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|