Improvements to OH picker

This commit is contained in:
Pieter Vander Vennet 2020-10-21 20:54:15 +02:00
parent 418658a1e8
commit 2795e7c0db
3 changed files with 50 additions and 24 deletions

View file

@ -122,7 +122,8 @@ export default class OpeningHoursPickerTable extends InputElement<OpeningHour[]>
let row = table.rows[i]
for (let j = 0; j < row.cells.length; j++) {
let cell = row.cells[j]
cell?.classList?.remove("oh-timecell-selected")
cell?.classList?.remove("oh-timecell-selected");
row.classList?.remove("oh-timerow-selected");
}
}
}
@ -163,12 +164,17 @@ export default class OpeningHoursPickerTable extends InputElement<OpeningHour[]>
}
offset = -1;
}
row.classList?.add("oh-timerow-selected");
if (iStart <= i && i <= iEnd &&
jStart <= j + offset && j + offset <= jEnd) {
cell?.classList?.add("oh-timecell-selected")
} else {
cell?.classList?.remove("oh-timecell-selected")
cell?.classList?.remove("oh-timecell-selected")
row.classList?.remove("oh-timerow-selected")
}
}

View file

@ -150,16 +150,23 @@ export default class OpeningHoursVisualization extends UIElement {
nextSunday.setDate(nextSunday.getDate() + 7);
const tags = this._source.data;
if(tags._country === undefined){
if (tags._country === undefined) {
return "Loading...";
}
const oh = new opening_hours(tags[this._key], {
lat: tags._lat,
lon: tags._lon,
address: {
country_code: tags._country
}
}, {tag_key: this._key});
let oh = null;
try {
oh = new opening_hours(tags[this._key], {
lat: tags._lat,
lon: tags._lon,
address: {
country_code: tags._country
}
}, {tag_key: this._key});
} catch (e) {
console.log(e);
return "Error: could not visualize these opening hours"
}
if (!oh.getState() && !oh.getUnknown()) {
// POI is currently closed