-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBoard.vue
276 lines (261 loc) · 8.48 KB
/
Board.vue
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<template>
<q-page class="q-layout-padding overflow-hidden">
<div v-if="startedSprint" class="fit">
<!-- Row wrapper for block with Sprint information -->
<div class="row full-width justify-between items-center q-pa-sm">
<!-- Sprint name -->
<BlockHeaderInfo :title="startedSprint.title"
:info="$q.screen.gt.md && startedSprint.goal ? startedSprint.goal : undefined "/>
<!-- Sprint remaining text -->
<div
v-if="$q.screen.gt.sm"
class="col text-h6 small text-secondary text-right q-pr-md">
<q-icon name="mdi-timer-sand"/>
<span :title="sprintRange"> {{ daysRemainingText }} </span>
</div>
<!-- Sprint manage buttons -->
<div class="col-auto">
<q-btn-group :outline="this.$q.screen.gt.sm">
<StartCompleteSprintButton :sprint="startedSprint" size="md"/>
<q-btn
outline
color="secondary"
label="Edit sprint"
class="xs-hide sm-hide"
@click="editSprintDialog(startedSprint)"
/>
</q-btn-group>
</div>
</div>
<q-card
square
bordered
:class="`q-mt-sm-none q-mt-md-md ${ $q.dark.isActive ? 'bg-grey-10' : '' }`">
<!-- Scroll for all columns -->
<q-scroll-area
visible
ref="scrollArea"
:class="`${$q.screen.lt.md ? 'q-pl-xs q-pr-sm': ''}`"
style="height: calc(100vh - 11em);">
<div :class="`fit ${ $q.screen.lt.md ? 'column' : 'row' }
justify-start items-stretch content-center issue_state_column_list`">
<!-- Issue state column -->
<div
v-for="state in issueStates"
:key="state.id"
class="col q-pa-xs full-width text-center">
<!-- Printable HEAD of column -->
<div class="q-py-xs text-center text-uppercase">
{{ state.title }}
<span> {{ issuesByStateAmount(state.id) }}</span>
<q-icon v-if="state.is_done"
name="mdi-check"
color="positive"
class="q-ml-sm"/>
</div>
<!-- Issues block -->
<div class="full-width full-height">
<q-scroll-area
:delay="1200"
class="q-pl-xs q-pr-sm overflow-hidden"
:style="`${ $q.screen.lt.md ? 'height: 40vh' : 'height: 75vh'}`">
<draggable
:value="issuesByState(state.id)"
:handle="$q.screen.lt.sm ? '.handle' : false"
v-bind="dragOptions"
@change="handleIssueStateChanging($event, state.id)"
class="fit overflow-hidden-y no-scroll">
<transition-group
type="transition"
name="flip-list"
tag="div"
class="fit"
style="min-height: 37vh">
<IssueBoard
v-for="issue in issuesByState(state.id)"
:key="issue.id"
:issue="issue"/>
</transition-group>
</draggable>
</q-scroll-area>
</div>
</div>
</div>
</q-scroll-area>
</q-card>
</div>
<NoStartedSprintNotification v-else/>
</q-page>
</template>
<script>
import NoStartedSprintNotification from 'src/components/elements/NoStartedSprintNotification'
import StartCompleteSprintButton from 'src/components/buttons/StartCompleteSprintButton'
import SprintEditDialog from 'src/components/dialogs/SprintEditDialog'
import IssueEditDialog from 'src/components/dialogs/IssueEditDialog'
import { unWatch } from 'src/services/util'
import { date } from 'quasar'
import draggable from 'vuedraggable'
import { SPRINT_REMAINING_UNIT, DATE_MASK } from 'src/services/masks'
import { editIssueData } from 'src/pages/mixins/editIssueData'
import IssueBoard from 'src/components/elements/IssueBoard'
import { loading } from 'src/pages/mixins/loading'
import BlockHeaderInfo from 'src/components/elements/BlockHeaderInfo'
import { CoreActionsMixin } from 'src/services/actions/core'
export default {
name: 'BoardView',
components: {
BlockHeaderInfo,
NoStartedSprintNotification,
StartCompleteSprintButton,
// eslint-disable-next-line vue/no-unused-components
IssueEditDialog,
// eslint-disable-next-line vue/no-unused-components
SprintEditDialog,
IssueBoard,
draggable
},
mixins: [
CoreActionsMixin,
editIssueData,
loading
],
data () {
return {
dragOptions: {
animation: 200,
group: 'issues',
disabled: false,
ghostClass: 'ghost'
}
}
},
computed: {
startedSprint () {
/** Return started sprint data is_started and not is_completed */
return this.$store.getters['core/SPRINT_STARTED_BY_CURRENT_PROJECT']
},
sprintRange () {
/** Return text dates like 10.10.2022 - 10.20.2022 */
const startedAt = date.formatDate(this.startedSprint.started_at, DATE_MASK)
const finishedAt = date.formatDate(this.startedSprint.finished_at, DATE_MASK)
return `${startedAt} - ${finishedAt}`
},
daysAmount () {
/** Days amount for the current SPrint
* We use it for calculating in daysRemainingText */
return date.getDateDiff(
this.startedSprint.finished_at,
this.startedSprint.started_at,
SPRINT_REMAINING_UNIT
)
},
daysRemaining () {
/** Days remaining till the end of Sprint
* We use it for calculating in daysRemainingText */
return date.getDateDiff(
this.startedSprint.finished_at,
new Date(),
SPRINT_REMAINING_UNIT
)
},
daysRemainingText () {
/** We use it to show ex: 10 days remaining */
switch (true) {
case this.daysRemaining > this.daysAmount:
return 'Will start...'
case this.daysRemaining > 0:
return `${this.daysRemaining} days${this.$q.screen.gt.md ? ' remaining' : ''}`
case this.daysRemaining <= 0:
return `0 days${this.$q.screen.gt.md ? ' remaining' : ''}`
default:
throw new Error('Unexpected days remaining value')
}
}
},
methods: {
issuesByState (stateId) {
return this.$store.getters['core/SPRINT_ISSUES_BY_CURRENT_PROJECT_AND_STATE_ID'](stateId)
},
issuesByStateAmount (stateId) {
return this.issuesByState(stateId).length
},
handleIssueAdded (event, issueStateId) {
/** Handling added in Issues State **/
const updatedElement = unWatch(event.added.element)
updatedElement.state_category = issueStateId
this.showProgress()
this.updateIssueState(updatedElement)
.finally(() => this.hideProgress())
},
handleCommonMoved (issuesList, event) {
/** Handle moving - common function **/
const immutableList = unWatch(issuesList)
immutableList
.splice(event.moved.newIndex, 0, immutableList
.splice(event.moved.oldIndex, 1)[0])
const ordering = []
immutableList.forEach((issue, index) => {
ordering.push(
{
id: issue.id,
ordering: index
}
)
})
return { list: immutableList, ordering }
},
handleStateMoved (event, stateId) {
/** Handling moving inside of state **/
const issuesList = this.issuesByState(stateId)
const handled = this.handleCommonMoved(issuesList, event)
this.showProgress()
this.updateIssuesOrdering(handled.ordering)
.finally(() => this.hideProgress())
},
handleIssueStateChanging (event, issueStateId) {
/** Handling moving inside of states **/
const isAdded = ('added' in event)
const isRemoved = ('removed' in event)
const isMoved = ('moved' in event)
switch (true) {
case isAdded:
this.handleIssueAdded(event, issueStateId)
break
case isRemoved:
break
case isMoved:
this.handleStateMoved(event, issueStateId)
break
default:
throw new Error('This error should not occurred')
}
},
editSprintDialog (item) {
this.$q.dialog({
dark: this.$q.dark.isActive,
component: SprintEditDialog,
id: item.id,
title: item.title,
goal: item.goal,
startedAt: item.started_at,
finishedAt: item.finished_at
})
.onOk((data) => {
this.showProgress()
this.editSprint(data)
.finally(() => this.hideProgress())
})
}
}
}
</script>
<style lang="scss">
.issue_state_column_list > div {
min-height: 10vh!important;
}
.issue_state_column_list > div > div:first-child {
font-size: 1rem;
font-weight: 500;
border-bottom: 1px solid #606060;
}
</style>