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>("")) {
|
||||
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(";")
|
||||
|
|
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>({
|
||||
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)
|
||||
|
||||
|
||||
/*/
|
||||
|
|
Loading…
Reference in a new issue