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

View file

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

View file

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

View file

@ -47,6 +47,12 @@
"freeform": { "freeform": {
"key": "email" "key": "email"
} }
},
{
"render": "{opening_hours_table(opening_hours)}",
"freeform": {
"key": "opening_hours"
}
} }
], ],
"hideUnderlayingFeaturesMinPercentage": 0, "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>({ import {UIEventSource} from "./Logic/UIEventSource";
opening_hours: "2000 Dec 21 10:00-12:00;", import OpeningHoursInput from "./UI/Input/OpeningHours/OpeningHoursInput";
_country: "be",
_lat: "51.2", 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"
_lon: "3.2"
} const source = new UIEventSource<string>("")
), 'opening_hours').AttachTo("maindiv") new OpeningHoursInput(source).AttachTo('maindiv')
console.log("SEtting ",oh)
source.setData(oh)
/*/ /*/