2023-10-30 13:44:27 +01:00
|
|
|
<script lang="ts">
|
|
|
|
|
/**
|
|
|
|
|
* Opens the 'Opening hours input' in another top level window
|
|
|
|
|
*/
|
|
|
|
|
import { UIEventSource } from "../../../Logic/UIEventSource"
|
2024-09-05 13:17:49 +02:00
|
|
|
import PublicHolidaySelector from "../../OpeningHours/PublicHolidaySelector.svelte"
|
2024-09-05 17:14:47 +02:00
|
|
|
import OHTable from "./OpeningHours/OHTable.svelte"
|
|
|
|
|
import OpeningHoursState from "../../OpeningHours/OpeningHoursState"
|
|
|
|
|
import Popup from "../../Base/Popup.svelte"
|
2025-06-07 14:37:50 +02:00
|
|
|
import Tr from "../../Base/Tr.svelte"
|
|
|
|
|
import Translations from "../../i18n/Translations"
|
2024-09-19 18:01:17 +02:00
|
|
|
import Check from "@babeard/svelte-heroicons/mini/Check"
|
2025-08-03 15:03:17 +02:00
|
|
|
import { CloseButton } from "flowbite-svelte"
|
|
|
|
|
import Cross from "../../../assets/svg/Cross.svelte"
|
|
|
|
|
import XMark from "@babeard/svelte-heroicons/mini/XMark"
|
2023-10-15 00:31:04 +02:00
|
|
|
|
2023-10-30 13:44:27 +01:00
|
|
|
export let value: UIEventSource<string>
|
2024-09-05 17:14:47 +02:00
|
|
|
export let args: string
|
|
|
|
|
let prefix = ""
|
|
|
|
|
let postfix = ""
|
|
|
|
|
if (args) {
|
|
|
|
|
try {
|
|
|
|
|
const data = JSON.stringify(args)
|
|
|
|
|
if (data["prefix"]) {
|
|
|
|
|
prefix = data["prefix"]
|
|
|
|
|
}
|
|
|
|
|
if (data["postfix"]) {
|
|
|
|
|
postfix = data["postfix"]
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error("Could not parse arguments")
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-15 00:31:04 +02:00
|
|
|
|
2024-10-08 13:49:59 +02:00
|
|
|
const state = new OpeningHoursState(value, prefix, postfix)
|
2024-09-05 17:14:47 +02:00
|
|
|
let expanded = new UIEventSource(false)
|
2025-08-03 15:03:17 +02:00
|
|
|
|
2025-08-13 23:06:38 +02:00
|
|
|
function abort() {
|
2025-08-03 15:03:17 +02:00
|
|
|
expanded.set(false)
|
|
|
|
|
}
|
2024-09-05 17:14:47 +02:00
|
|
|
</script>
|
2024-10-19 14:44:55 +02:00
|
|
|
|
2024-09-05 17:14:47 +02:00
|
|
|
<Popup bodyPadding="p-0" shown={expanded}>
|
|
|
|
|
<OHTable value={state.normalOhs} />
|
2025-06-18 21:40:01 +02:00
|
|
|
<div class="absolute flex w-full justify-center" style="bottom: -3rem">
|
2025-08-03 15:03:17 +02:00
|
|
|
<button on:click={() => abort()}>
|
2025-08-13 23:06:38 +02:00
|
|
|
<XMark class="m-0 h-6 w-6" />
|
2025-08-03 15:03:17 +02:00
|
|
|
<Tr t={Translations.t.general.cancel} />
|
|
|
|
|
</button>
|
2025-06-18 21:40:01 +02:00
|
|
|
<button class=" primary" on:click={() => expanded.set(false)}>
|
|
|
|
|
<Check class="m-0 h-6 w-6 shrink-0 p-0" color="white" />
|
|
|
|
|
<Tr t={Translations.t.general.confirm} />
|
|
|
|
|
</button>
|
2025-06-07 14:37:50 +02:00
|
|
|
</div>
|
2025-08-13 23:06:38 +02:00
|
|
|
<CloseButton
|
|
|
|
|
class="absolute right-0 top-0 z-10"
|
|
|
|
|
style="margin-top: -1.0rem"
|
|
|
|
|
on:click={() => abort()}
|
|
|
|
|
/>
|
2024-09-05 17:14:47 +02:00
|
|
|
</Popup>
|
2025-04-04 01:51:58 +02:00
|
|
|
|
2025-06-07 14:37:50 +02:00
|
|
|
<button on:click={() => expanded.set(true)}>Pick opening hours</button>
|
2024-09-05 17:14:47 +02:00
|
|
|
<PublicHolidaySelector value={state.phSelectorValue} />
|