Better OHViz

This commit is contained in:
pietervdvn 2021-03-22 02:34:31 +01:00
parent bc9b46a84f
commit a4445eed3e

View file

@ -264,10 +264,11 @@ export default class OpeningHoursVisualization extends UIElement {
const isToday = (new Date().getDay() + 6) % 7 === i; const isToday = (new Date().getDay() + 6) % 7 === i;
let weekday = OpeningHoursVisualization.weekdays[i].Render(); let weekday = OpeningHoursVisualization.weekdays[i].Render();
let dateToShow = ""
if (!isWeekstable) { if (!isWeekstable) {
const day = new Date(lastMonday) const day = new Date(lastMonday)
day.setDate(day.getDate() + i); day.setDate(day.getDate() + i);
weekday = " " + day.getDate() + "/" + (day.getMonth() + 1); dateToShow = "" + day.getDate() + "/" + (day.getMonth() + 1);
} }
let innerContent: string[] = []; let innerContent: string[] = [];
@ -282,7 +283,7 @@ export default class OpeningHoursVisualization extends UIElement {
for (const range of dayRanges) { for (const range of dayRanges) {
if (!range.isOpen && !range.isSpecial) { if (!range.isOpen && !range.isSpecial) {
innerContent.push( innerContent.push(
new FixedUiElement(range.comment).SetClass("ohviz-day-off").Render()) new FixedUiElement(range.comment ?? dateToShow).SetClass("ohviz-day-off").Render())
continue; continue;
} }
@ -294,7 +295,7 @@ export default class OpeningHoursVisualization extends UIElement {
const width = (100 * (range.endDate - range.startDate) / 1000) / (latestclose - earliestOpen); const width = (100 * (range.endDate - range.startDate) / 1000) / (latestclose - earliestOpen);
const startPercentage = (100 * startpoint / availableArea); const startPercentage = (100 * startpoint / availableArea);
innerContent.push( innerContent.push(
new FixedUiElement(range.comment).SetStyle(`left:${startPercentage}%; width:${width}%`).SetClass("ohviz-range").Render()) new FixedUiElement(range.comment ?? dateToShow).SetStyle(`left:${startPercentage}%; width:${width}%`).SetClass("ohviz-range").Render())
} }
// Add line for 'now' // Add line for 'now'