Merge branch 'develop'

This commit is contained in:
Pieter Vander Vennet 2020-10-09 21:12:04 +02:00
commit 7eb7f40ead
5 changed files with 24 additions and 15 deletions

View file

@ -27,9 +27,9 @@ export default class OpeningHoursInput extends InputElement<string> {
constructor(value: UIEventSource<string> = new UIEventSource<string>("")) {
super();
const rulesFromOhPicker = value.map(OH.Parse);
const leftoverRules = value.map<string[]>(str => {
console.log("Leftovers?",str)
if (str === undefined) {
return []
}
@ -46,8 +46,11 @@ export default class OpeningHoursInput extends InputElement<string> {
}
return leftOvers;
})
// NOte: MUST be bound AFTER the leftover rules!
const rulesFromOhPicker = value.map(OH.Parse);
const ph = value.map<string>(str => {
console.log("PH RULE?", ph)
if (str === undefined) {
return ""
}
@ -62,6 +65,7 @@ export default class OpeningHoursInput extends InputElement<string> {
this._phSelector = new PublicHolidayInput(ph);
function update() {
console.log("UPdating")
let rules = OH.ToString(rulesFromOhPicker.data);
if (leftoverRules.data.length != 0) {
rules += ";" + leftoverRules.data.join(";")
@ -83,7 +87,7 @@ export default class OpeningHoursInput extends InputElement<string> {
}
return new Combine([
Translations.t.general.opening_hours.not_all_rules_parsed,
new FixedUiElement(leftovers.map(r => `${r}<br/>`).join("") ).SetClass("subtle")
new FixedUiElement(leftovers.map(r => `${r}<br/>`).join("")).SetClass("subtle")
]).Render();
}))

View file

@ -160,7 +160,6 @@ export default class OpeningHoursVisualization extends UIElement {
// ranges[0] are all ranges for monday
const ranges = OpeningHoursVisualization.GetRanges(oh, lastMonday, nextSunday);
console.log(ranges)
if (ranges.map(r => r.length).reduce((a, b) => a + b, 0) == 0) {
// Closed!
const opensAtDate = oh.getNextChange();

View file

@ -907,8 +907,8 @@ export default class Translations {
"nl": "Gesloten"
}),
ph_not_known: new T({
"en": "unknown",
"nl": "niet gekend"
"en": " ",
"nl": " "
}),
ph_closed: new T({
"en": "closed",

View file

@ -47,6 +47,12 @@
"freeform": {
"key": "email"
}
},
{
"render": "{opening_hours_table(opening_hours)}",
"freeform": {
"key": "opening_hours"
}
}
],
"hideUnderlayingFeaturesMinPercentage": 0,

18
test.ts
View file

@ -1,15 +1,15 @@
//*
import OpeningHoursVisualization from "./UI/OhVisualization";
import {UIEventSource} from "./Logic/UIEventSource";
new OpeningHoursVisualization( new UIEventSource<any>({
opening_hours: "2000 Dec 21 10:00-12:00;",
_country: "be",
_lat: "51.2",
_lon: "3.2"
}
), 'opening_hours').AttachTo("maindiv")
import {UIEventSource} from "./Logic/UIEventSource";
import OpeningHoursInput from "./UI/Input/OpeningHours/OpeningHoursInput";
const oh = "Sep 1-Feb 28 Mo-Th 08:00-12:00, 13:30-17:30; Mar 1-Aug 31 Mo-Fr 07:00-12:00, 13:30-17:30; PH off"
const source = new UIEventSource<string>("")
new OpeningHoursInput(source).AttachTo('maindiv')
console.log("SEtting ",oh)
source.setData(oh)
/*/