Refactoring: move svelte component out of UIElement

This commit is contained in:
Pieter Vander Vennet 2024-09-05 13:17:49 +02:00
parent 53cbcfe1e7
commit 379f472adf
2 changed files with 7 additions and 3 deletions

View file

@ -5,8 +5,11 @@
import { UIEventSource } from "../../../Logic/UIEventSource"
import ToSvelte from "../../Base/ToSvelte.svelte"
import OpeningHoursInput from "../../OpeningHours/OpeningHoursInput"
import PublicHolidaySelector from "../../OpeningHours/PublicHolidaySelector.svelte"
export let value: UIEventSource<string>
export let phSelectorValue = new UIEventSource("")
</script>
<ToSvelte construct={new OpeningHoursInput(value)} />
<ToSvelte construct={new OpeningHoursInput(value, phSelectorValue)} />
<PublicHolidaySelector value={phSelectorValue}/>

View file

@ -21,6 +21,7 @@ export default class OpeningHoursInput extends InputElement<string> {
constructor(
value: UIEventSource<string> = new UIEventSource<string>(""),
phSelectorValue: UIEventSource<string> = new UIEventSource<string>(undefined),
prefix = "",
postfix = ""
) {
@ -88,7 +89,8 @@ export default class OpeningHoursInput extends InputElement<string> {
break
}
}
const phSelectorValue = new UIEventSource<string>(ph ?? "")
phSelectorValue.set(ph ?? "")
// Note: MUST be bound AFTER the leftover rules!
const rulesFromOhPicker: UIEventSource<OpeningHour[]> = valueWithoutPrefix.sync(
@ -142,7 +144,6 @@ export default class OpeningHoursInput extends InputElement<string> {
this._element = new Combine([
leftoverWarning,
ohPicker,
new SvelteUIElement(PublicHolidaySelector, { value: phSelectorValue }),
])
}