-
Notifications
You must be signed in to change notification settings - Fork 354
Expand file tree
/
Copy pathBoard.vue
More file actions
196 lines (179 loc) 路 4.33 KB
/
Copy pathBoard.vue
File metadata and controls
196 lines (179 loc) 路 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!--
- @copyright Copyright (c) 2018 Julius H盲rtl <jus@bitgrid.net>
-
- @author Julius H盲rtl <jus@bitgrid.net>
-
- @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-->
<template>
<div class="board-wrapper">
<Controls :board="board" />
<transition name="fade" mode="out-in">
<div v-if="loading" key="loading" class="emptycontent">
<div class="icon icon-loading" />
<h2>{{ t('deck', 'Loading board') }}</h2>
<p />
</div>
<div v-else-if="board && !loading" key="board" class="board">
<Container lock-axix="y"
orientation="horizontal"
:drag-handle-selector="dragHandleSelector"
@drop="onDropStack">
<Draggable v-for="stack in stacksByBoard" :key="stack.id">
<Stack :stack="stack" />
</Draggable>
</Container>
</div>
<div v-else key="notfound" class="emptycontent">
<div class="icon icon-deck" />
<h2>{{ t('deck', 'Board not found') }}</h2>
<p />
</div>
</transition>
</div>
</template>
<script>
import { Container, Draggable } from 'vue-smooth-dnd'
import { mapState, mapGetters } from 'vuex'
import Controls from '../Controls'
import Stack from './Stack'
export default {
name: 'Board',
components: {
Controls,
Container,
Draggable,
Stack,
},
inject: [
'boardApi',
],
props: {
id: {
type: Number,
default: null,
},
},
data: function() {
return {
loading: true,
}
},
computed: {
...mapState({
board: state => state.currentBoard,
showArchived: state => state.showArchived,
}),
...mapGetters([
'canEdit',
]),
stacksByBoard() {
return this.$store.getters.stacksByBoard(this.board.id)
},
dragHandleSelector() {
return this.canEdit ? null : '.no-drag'
},
},
watch: {
id: 'fetchData',
showArchived() {
this.fetchData()
},
},
created() {
this.fetchData()
},
methods: {
async fetchData() {
this.loading = true
try {
await this.$store.dispatch('loadBoardById', this.id)
await this.$store.dispatch('loadStacks', this.id)
} catch (e) {
console.error(e)
}
this.loading = false
},
onDropStack({ removedIndex, addedIndex }) {
this.$store.dispatch('orderStack', { stack: this.stacksByBoard[removedIndex], removedIndex, addedIndex })
},
createStack() {
const newStack = {
title: 'FooBar',
boardId: this.id,
order: this.stacksByBoard().length,
}
this.$store.dispatch('createStack', newStack)
},
},
}
</script>
<style lang="scss" scoped>
@import '../../css/animations.scss';
$board-spacing: 15px;
$stack-spacing: 10px;
$stack-width: 300px;
.board-wrapper {
position: relative;
width: 100%;
height: 100%;
max-height: calc(100vh - 50px);
}
.board {
margin-left: $board-spacing;
position: relative;
height: calc(100% - 44px);
overflow-x: scroll;
}
/**
* Combined rules to handle proper board scrolling and
* drag and drop behavior
*/
.smooth-dnd-container.horizontal {
display: flex;
align-items: stretch;
.smooth-dnd-draggable-wrapper::v-deep {
display: flex;
height: auto;
.stack {
display: flex;
flex-direction: column;
.smooth-dnd-container.vertical {
flex-grow: 1;
display: flex;
flex-direction: column;
padding: 0;
/**
* Use this to scroll each stack individually
* This currenly has the issue that the popover menu will be cut off
*/
/*
overflow-x: scroll;
height: calc(100vh - 50px - 44px * 2 - 30px);
max-height: calc(100vh - 50px - 44px * 2 - 30px);
*/
}
.smooth-dnd-container.vertical > .smooth-dnd-draggable-wrapper {
overflow: initial;
}
.smooth-dnd-container.vertical .smooth-dnd-draggable-wrapper {
height: auto;
}
}
}
}
</style>