Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 41 additions & 17 deletions src/components/board/GanttView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,6 @@ const DAYS_PER_UNIT = {
}

const GANTT_VIEW_MODES = [
{
name: 'Hour',
padding: '7d',
step: '1h',
snap_at: '1h',
date_format: 'YYYY-MM-DD HH:',
lower_text: 'HH',
upper_text: (d, ld, lang) =>
!ld || d.getDate() !== ld.getDate()
? Intl.DateTimeFormat(lang || 'en', { month: 'short', day: 'numeric' }).format(d)
: '',
thick_line(date) {
return date.getDay() === 1
},
upper_text_frequency: 24,
},
{
name: 'Day',
padding: '14d',
Expand All @@ -123,6 +107,22 @@ const GANTT_VIEW_MODES = [
return date.getDay() === 1
},
},
{
name: 'Hour',
padding: '7d',
step: '1h',
snap_at: '1h',
date_format: 'YYYY-MM-DD HH:',
lower_text: 'HH',
upper_text: (d, ld, lang) =>
!ld || d.getDate() !== ld.getDate()
? Intl.DateTimeFormat(lang || 'en', { month: 'short', day: 'numeric' }).format(d)
: '',
thick_line(date) {
return date.getDay() === 1
},
upper_text_frequency: 24,
},
{
name: 'Week',
padding: '1m',
Expand Down Expand Up @@ -207,6 +207,31 @@ export default {
if (!card.duedate && !card.startdate) {
undatedCards.push(card)
} else {
// gantt renders everything at once so large date ranges cause performance issues on render
// therefore we limit the timeframe of visible tasks
const duedate = new Date(card.duedate)
switch (this.currentViewMode) {
case 'Hour':
if (duedate < new Date() - 2 * 24 * 3600 * 1000) {
return
}
break
case 'Day':
if (duedate < new Date() - 30 * 24 * 3600 * 1000) {
return
}
break
case 'Week':
if (duedate < new Date() - 90 * 24 * 3600 * 1000) {
return
}
break
case 'Month':
if (duedate < new Date() - 365 * 24 * 3600 * 1000) {
return
}
break
}
ganttTasks.push(this.cardToGanttTask(card, index))
}
})
Expand Down Expand Up @@ -343,7 +368,6 @@ export default {
})

this._patchBarDuration()
this.ganttInstance.change_view_mode(this.currentViewMode)
this.fitColumnsToWidth()
},
async updateTaskDate(task, start, end) {
Expand Down
Loading