Fix dissappearing unparsed rules
This commit is contained in:
parent
62785aa4c4
commit
499666a88e
2 changed files with 16 additions and 12 deletions
|
@ -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(";")
|
||||||
|
|
18
test.ts
18
test.ts
|
@ -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)
|
||||||
|
|
||||||
|
|
||||||
/*/
|
/*/
|
||||||
|
|
Loading…
Reference in a new issue