2
0
mirror of https://github.com/tenrok/vue-ganttastic.git synced 2026-06-25 11:00:33 +03:00

fix: highlight days (highlightedDays) when precision equal 'day'

This commit is contained in:
2021-11-22 11:09:07 +03:00
parent df16cc569c
commit 07f20cad35
2 changed files with 24 additions and 7 deletions
+23 -6
View File
@@ -10,11 +10,7 @@
:class="[ :class="[
'g-grid-line', 'g-grid-line',
{ 'g-grid-line-last': index === allChildPoints.length - 1 }, { 'g-grid-line-last': index === allChildPoints.length - 1 },
{ { 'g-grid-line-highlighted': isHighlighted(childPoint) }
'g-grid-line-highlighted':
(precision === 'day' && highlightedHours.includes(childPoint)) ||
(precision === 'month' && highlightedDays.includes(childPoint))
}
]" ]"
:style="{ width: `${gridSize}px` }" :style="{ width: `${gridSize}px` }"
/> />
@@ -46,7 +42,7 @@ export default {
while (start.isBefore(end)) { while (start.isBefore(end)) {
switch (this.precision) { switch (this.precision) {
case 'day': case 'day':
res.push(start.hour()) res.push(start.format('YYYY-MM-DD H'))
start.add(1, 'hour') start.add(1, 'hour')
break break
case 'month': case 'month':
@@ -57,6 +53,27 @@ export default {
} }
return res return res
} }
},
methods: {
isHighlighted(point) {
switch (this.precision) {
case 'day':
if (
this.highlightedDays.includes(
moment(point, 'YYYY-MM-DD').format('YYYY-MM-DD')
)
) {
return true
} else {
return this.highlightedHours.includes(
moment(point, 'YYYY-MM-DD H').get('hour')
)
}
case 'month':
return this.highlightedDays.includes(point)
}
}
} }
} }
</script> </script>
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@tenrok/vue-ganttastic", "name": "@tenrok/vue-ganttastic",
"version": "0.10.19", "version": "0.10.20",
"description": "A simple and customizable Gantt chart component for Vue.js", "description": "A simple and customizable Gantt chart component for Vue.js",
"keywords": [ "keywords": [
"gantt", "gantt",