2020-07-10 19:13:11 -06:00
|
|
|
<template>
|
|
|
|
<!-- sectionを利用しているのは、deck.vue側でcolumnに対してfirst-of-typeを効かせるため -->
|
2021-04-17 20:55:44 -06:00
|
|
|
<section class="dnpfarvg _panel _narrow_" :class="{ paged: isMainColumn, naked, active, isStacked, draghover, dragging, dropready }"
|
2020-07-10 19:13:11 -06:00
|
|
|
@dragover.prevent.stop="onDragover"
|
|
|
|
@dragleave="onDragleave"
|
|
|
|
@drop.prevent.stop="onDrop"
|
|
|
|
v-hotkey="keymap"
|
2020-12-26 06:41:00 -07:00
|
|
|
:style="{ '--deckColumnHeaderHeight': deckStore.reactiveState.columnHeaderHeight.value + 'px' }"
|
2020-07-10 19:13:11 -06:00
|
|
|
>
|
|
|
|
<header :class="{ indicated }"
|
|
|
|
draggable="true"
|
|
|
|
@click="goTop"
|
|
|
|
@dragstart="onDragstart"
|
|
|
|
@dragend="onDragend"
|
|
|
|
@contextmenu.prevent.stop="onContextmenu"
|
|
|
|
>
|
2020-12-26 02:33:54 -07:00
|
|
|
<button class="toggleActive _button" @click="toggleActive" v-if="isStacked && !isMainColumn">
|
2021-04-20 08:22:59 -06:00
|
|
|
<template v-if="active"><i class="fas fa-angle-up"></i></template>
|
|
|
|
<template v-else><i class="fas fa-angle-down"></i></template>
|
2020-07-10 19:13:11 -06:00
|
|
|
</button>
|
|
|
|
<div class="action">
|
|
|
|
<slot name="action"></slot>
|
|
|
|
</div>
|
|
|
|
<span class="header"><slot name="header"></slot></span>
|
2021-04-20 08:22:59 -06:00
|
|
|
<button v-if="func" class="menu _button" v-tooltip="func.title" @click.stop="func.handler"><i :class="func.icon || 'fas fa-cog'"></i></button>
|
2020-07-10 19:13:11 -06:00
|
|
|
</header>
|
|
|
|
<div ref="body" v-show="active">
|
|
|
|
<slot></slot>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 05:12:00 -06:00
|
|
|
import { defineComponent } from 'vue';
|
2021-03-23 02:30:14 -06:00
|
|
|
import * as os from '@client/os';
|
2020-12-26 02:33:54 -07:00
|
|
|
import { updateColumn, swapLeftColumn, swapRightColumn, swapUpColumn, swapDownColumn, stackLeftColumn, popRightColumn, removeColumn, swapColumn } from './deck-store';
|
2020-12-26 06:41:00 -07:00
|
|
|
import { deckStore } from './deck-store';
|
2020-07-10 19:13:11 -06:00
|
|
|
|
2020-10-17 05:12:00 -06:00
|
|
|
export default defineComponent({
|
2021-10-14 03:51:15 -06:00
|
|
|
provide: {
|
2021-10-14 07:40:43 -06:00
|
|
|
shouldHeaderThin: true,
|
|
|
|
shouldOmitHeaderTitle: true,
|
2021-10-14 03:51:15 -06:00
|
|
|
},
|
|
|
|
|
2020-07-10 19:13:11 -06:00
|
|
|
props: {
|
|
|
|
column: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
isStacked: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
|
|
|
},
|
2020-12-27 19:56:42 -07:00
|
|
|
func: {
|
|
|
|
type: Object,
|
2020-07-10 19:13:11 -06:00
|
|
|
required: false,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
naked: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
indicated: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2020-12-26 06:41:00 -07:00
|
|
|
deckStore,
|
2020-07-10 19:13:11 -06:00
|
|
|
dragging: false,
|
|
|
|
draghover: false,
|
|
|
|
dropready: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
isMainColumn(): boolean {
|
2020-12-26 02:33:54 -07:00
|
|
|
return this.column.type === 'main';
|
2020-07-10 19:13:11 -06:00
|
|
|
},
|
|
|
|
|
2021-01-13 05:43:06 -07:00
|
|
|
active(): boolean {
|
|
|
|
return this.column.active !== false;
|
|
|
|
},
|
|
|
|
|
2020-07-10 19:13:11 -06:00
|
|
|
keymap(): any {
|
|
|
|
return {
|
2020-10-17 05:12:00 -06: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-10 19:13:11 -06:00
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
active(v) {
|
|
|
|
this.$emit('change-active-state', v);
|
|
|
|
},
|
|
|
|
|
|
|
|
dragging(v) {
|
2020-10-17 05:12:00 -06:00
|
|
|
os.deckGlobalEvents.emit(v ? 'column.dragStart' : 'column.dragEnd');
|
2020-07-10 19:13:11 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2020-12-26 02:33:54 -07:00
|
|
|
os.deckGlobalEvents.on('column.dragStart', this.onOtherDragStart);
|
|
|
|
os.deckGlobalEvents.on('column.dragEnd', this.onOtherDragEnd);
|
2020-07-10 19:13:11 -06:00
|
|
|
},
|
|
|
|
|
2020-10-17 05:12:00 -06:00
|
|
|
beforeUnmount() {
|
2020-12-26 02:33:54 -07:00
|
|
|
os.deckGlobalEvents.off('column.dragStart', this.onOtherDragStart);
|
|
|
|
os.deckGlobalEvents.off('column.dragEnd', this.onOtherDragEnd);
|
2020-07-10 19:13:11 -06:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
onOtherDragStart() {
|
|
|
|
this.dropready = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onOtherDragEnd() {
|
|
|
|
this.dropready = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
toggleActive() {
|
|
|
|
if (!this.isStacked) return;
|
2021-01-13 05:43:06 -07:00
|
|
|
updateColumn(this.column.id, {
|
|
|
|
active: !this.column.active
|
|
|
|
});
|
2020-07-10 19:13:11 -06:00
|
|
|
},
|
|
|
|
|
|
|
|
getMenu() {
|
|
|
|
const items = [{
|
2021-04-20 08:22:59 -06:00
|
|
|
icon: 'fas fa-pencil-alt',
|
2020-12-26 02:33:54 -07:00
|
|
|
text: this.$ts.edit,
|
|
|
|
action: async () => {
|
|
|
|
const { canceled, result } = await os.form(this.column.name, {
|
|
|
|
name: {
|
|
|
|
type: 'string',
|
|
|
|
label: this.$ts.name,
|
|
|
|
default: this.column.name
|
|
|
|
},
|
|
|
|
width: {
|
|
|
|
type: 'number',
|
|
|
|
label: this.$ts.width,
|
|
|
|
default: this.column.width
|
|
|
|
},
|
|
|
|
flexible: {
|
|
|
|
type: 'boolean',
|
|
|
|
label: this.$ts.flexible,
|
|
|
|
default: this.column.flexible
|
2020-07-10 19:13:11 -06:00
|
|
|
}
|
|
|
|
});
|
2020-12-26 02:33:54 -07:00
|
|
|
if (canceled) return;
|
|
|
|
updateColumn(this.column.id, result);
|
2020-07-10 19:13:11 -06:00
|
|
|
}
|
|
|
|
}, null, {
|
2021-04-20 08:22:59 -06:00
|
|
|
icon: 'fas fa-arrow-left',
|
2020-12-25 18:47:36 -07:00
|
|
|
text: this.$ts._deck.swapLeft,
|
2020-07-10 19:13:11 -06:00
|
|
|
action: () => {
|
2020-12-18 18:55:52 -07:00
|
|
|
swapLeftColumn(this.column.id);
|
2020-07-10 19:13:11 -06:00
|
|
|
}
|
|
|
|
}, {
|
2021-04-20 08:22:59 -06:00
|
|
|
icon: 'fas fa-arrow-right',
|
2020-12-25 18:47:36 -07:00
|
|
|
text: this.$ts._deck.swapRight,
|
2020-07-10 19:13:11 -06:00
|
|
|
action: () => {
|
2020-12-18 18:55:52 -07:00
|
|
|
swapRightColumn(this.column.id);
|
2020-07-10 19:13:11 -06:00
|
|
|
}
|
|
|
|
}, this.isStacked ? {
|
2021-04-20 08:22:59 -06:00
|
|
|
icon: 'fas fa-arrow-up',
|
2020-12-25 18:47:36 -07:00
|
|
|
text: this.$ts._deck.swapUp,
|
2020-07-10 19:13:11 -06:00
|
|
|
action: () => {
|
2020-12-18 18:55:52 -07:00
|
|
|
swapUpColumn(this.column.id);
|
2020-07-10 19:13:11 -06:00
|
|
|
}
|
|
|
|
} : undefined, this.isStacked ? {
|
2021-04-20 08:22:59 -06:00
|
|
|
icon: 'fas fa-arrow-down',
|
2020-12-25 18:47:36 -07:00
|
|
|
text: this.$ts._deck.swapDown,
|
2020-07-10 19:13:11 -06:00
|
|
|
action: () => {
|
2020-12-18 18:55:52 -07:00
|
|
|
swapDownColumn(this.column.id);
|
2020-07-10 19:13:11 -06:00
|
|
|
}
|
|
|
|
} : undefined, null, {
|
2021-04-20 08:22:59 -06:00
|
|
|
icon: 'fas fa-window-restore',
|
2020-12-25 18:47:36 -07:00
|
|
|
text: this.$ts._deck.stackLeft,
|
2020-07-10 19:13:11 -06:00
|
|
|
action: () => {
|
2020-12-18 18:55:52 -07:00
|
|
|
stackLeftColumn(this.column.id);
|
2020-07-10 19:13:11 -06:00
|
|
|
}
|
|
|
|
}, this.isStacked ? {
|
2021-04-20 08:22:59 -06:00
|
|
|
icon: 'fas fa-window-maximize',
|
2020-12-25 18:47:36 -07:00
|
|
|
text: this.$ts._deck.popRight,
|
2020-07-10 19:13:11 -06:00
|
|
|
action: () => {
|
2020-12-18 18:55:52 -07:00
|
|
|
popRightColumn(this.column.id);
|
2020-07-10 19:13:11 -06:00
|
|
|
}
|
|
|
|
} : undefined, null, {
|
2021-04-20 08:22:59 -06:00
|
|
|
icon: 'fas fa-trash-alt',
|
2020-12-25 18:47:36 -07:00
|
|
|
text: this.$ts.remove,
|
2020-12-29 17:27:19 -07:00
|
|
|
danger: true,
|
2020-07-10 19:13:11 -06:00
|
|
|
action: () => {
|
2020-12-18 18:55:52 -07:00
|
|
|
removeColumn(this.column.id);
|
2020-07-10 19:13:11 -06:00
|
|
|
}
|
|
|
|
}];
|
|
|
|
|
|
|
|
return items;
|
|
|
|
},
|
|
|
|
|
|
|
|
onContextmenu(e) {
|
2020-12-26 02:33:54 -07:00
|
|
|
os.contextMenu(this.getMenu(), e);
|
2020-07-10 19:13:11 -06:00
|
|
|
},
|
|
|
|
|
|
|
|
goTop() {
|
|
|
|
this.$refs.body.scrollTo({
|
|
|
|
top: 0,
|
|
|
|
behavior: 'smooth'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
onDragstart(e) {
|
|
|
|
e.dataTransfer.effectAllowed = 'move';
|
2020-10-17 05:12:00 -06:00
|
|
|
e.dataTransfer.setData(_DATA_TRANSFER_DECK_COLUMN_, this.column.id);
|
2020-12-26 19:07:26 -07:00
|
|
|
|
|
|
|
// Chromeのバグで、Dragstartハンドラ内ですぐにDOMを変更する(=リアクティブなプロパティを変更する)とDragが終了してしまう
|
|
|
|
// SEE: https://stackoverflow.com/questions/19639969/html5-dragend-event-firing-immediately
|
|
|
|
setTimeout(() => {
|
|
|
|
this.dragging = true;
|
|
|
|
}, 10);
|
2020-07-10 19:13:11 -06:00
|
|
|
},
|
|
|
|
|
|
|
|
onDragend(e) {
|
|
|
|
this.dragging = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
onDragover(e) {
|
|
|
|
// 自分自身がドラッグされている場合
|
|
|
|
if (this.dragging) {
|
|
|
|
// 自分自身にはドロップさせない
|
|
|
|
e.dataTransfer.dropEffect = 'none';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-17 05:12:00 -06:00
|
|
|
const isDeckColumn = e.dataTransfer.types[0] == _DATA_TRANSFER_DECK_COLUMN_;
|
2020-07-10 19:13:11 -06: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 05:12:00 -06:00
|
|
|
os.deckGlobalEvents.emit('column.dragEnd');
|
2020-07-10 19:13:11 -06:00
|
|
|
|
2020-10-17 05:12:00 -06:00
|
|
|
const id = e.dataTransfer.getData(_DATA_TRANSFER_DECK_COLUMN_);
|
2020-07-10 19:13:11 -06:00
|
|
|
if (id != null && id != '') {
|
2020-12-18 18:55:52 -07:00
|
|
|
swapColumn(this.column.id, id);
|
2020-07-10 19:13:11 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.dnpfarvg {
|
2021-04-09 21:40:50 -06:00
|
|
|
--root-margin: 10px;
|
2020-10-17 05:12:00 -06:00
|
|
|
|
2020-07-10 19:13:11 -06:00
|
|
|
height: 100%;
|
2021-03-02 06:57:16 -07:00
|
|
|
overflow: hidden;
|
2020-10-17 05:12:00 -06:00
|
|
|
contain: content;
|
2021-10-14 03:51:15 -06:00
|
|
|
box-shadow: 0 0 8px 0 var(--shadow);
|
2020-07-10 19:13:11 -06: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) {
|
2020-12-26 06:41:00 -07:00
|
|
|
flex-basis: var(--deckColumnHeaderHeight);
|
|
|
|
min-height: var(--deckColumnHeaderHeight);
|
2020-07-10 19:13:11 -06:00
|
|
|
|
|
|
|
> header.indicated {
|
|
|
|
box-shadow: 4px 0px var(--accent) inset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.naked {
|
2020-12-20 01:19:18 -07:00
|
|
|
background: var(--acrylicBg) !important;
|
2021-08-11 07:34:45 -06:00
|
|
|
-webkit-backdrop-filter: var(--blur, blur(10px));
|
|
|
|
backdrop-filter: var(--blur, blur(10px));
|
2020-07-10 19:13:11 -06:00
|
|
|
|
|
|
|
> header {
|
|
|
|
background: transparent;
|
|
|
|
box-shadow: none;
|
|
|
|
|
|
|
|
> button {
|
|
|
|
color: var(--fg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.paged {
|
2020-12-28 01:00:31 -07:00
|
|
|
background: var(--bg) !important;
|
2020-07-10 19:13:11 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
> header {
|
|
|
|
position: relative;
|
|
|
|
display: flex;
|
|
|
|
z-index: 2;
|
2020-12-26 06:41:00 -07:00
|
|
|
line-height: var(--deckColumnHeaderHeight);
|
|
|
|
height: var(--deckColumnHeaderHeight);
|
2020-07-10 19:13:11 -06: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;
|
2021-03-02 06:57:16 -07:00
|
|
|
overflow: hidden;
|
2020-07-10 19:13:11 -06:00
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
> span:only-of-type {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .toggleActive,
|
2021-10-14 08:14:14 -06:00
|
|
|
> .action > ::v-deep(*),
|
2020-10-17 05:12:00 -06:00
|
|
|
> .menu {
|
2020-07-10 19:13:11 -06:00
|
|
|
z-index: 1;
|
2020-12-26 06:41:00 -07:00
|
|
|
width: var(--deckColumnHeaderHeight);
|
|
|
|
line-height: var(--deckColumnHeaderHeight);
|
2020-07-10 19:13:11 -06:00
|
|
|
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 05:12:00 -06:00
|
|
|
> .menu {
|
2020-07-10 19:13:11 -06:00
|
|
|
margin-left: auto;
|
|
|
|
margin-right: -16px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> div {
|
2020-12-26 06:41:00 -07:00
|
|
|
height: calc(100% - var(--deckColumnHeaderHeight));
|
2020-07-10 19:13:11 -06:00
|
|
|
overflow: auto;
|
|
|
|
overflow-x: hidden;
|
|
|
|
-webkit-overflow-scrolling: touch;
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|