diff --git a/src/components/orgs/OrgDetail.svelte b/src/components/orgs/OrgDetail.svelte index 21798b06..905956a4 100644 --- a/src/components/orgs/OrgDetail.svelte +++ b/src/components/orgs/OrgDetail.svelte @@ -10,6 +10,7 @@ import ImportRunnerModal from "../runners/ImportRunnerModal.svelte"; import PromiseError from "../base/PromiseError.svelte"; import Select from "svelte-select"; + import GenerateSponsoringContracts from "../runners/GenerateSponsoringContracts.svelte"; $: delete_triggered = false; $: address_valid_or_none = (isAddress1Valid && iszipcodevalid && iscityvalid) || @@ -26,7 +27,8 @@ $: isAddress1Valid = editable.address?.address1?.trim().length !== 0; $: iszipcodevalid = editable.address?.postalcode?.trim().length !== 0; $: iscityvalid = editable.address?.city?.trim().length !== 0; - $: sponsoring_contracts_download_open = false; + $: sponsoring_contracts_show = true; + $: generate_orgs = [original_object]; const getContactLabel = (option) => option.firstname + " " + (option.middlename || "") + " " + option.lastname; const promise = RunnerOrganizationService.runnerOrganizationControllerGetOne( @@ -60,14 +62,6 @@ }); let modal_open = false; let delete_org = {}; - document.addEventListener("click", function (e) { - if ( - e.target.parentNode?.parentNode?.id != "sponsoring:dropdown" && - e.target.parentNode?.parentNode?.id != "sponsoring:dropdown:menu" - ) { - sponsoring_contracts_download_open = false; - } - }); function deleteOrganization() { RunnerOrganizationService.runnerOrganizationControllerRemove( original_object.id, @@ -115,55 +109,6 @@ } } export let import_modal_open = false; - async function generateSponsoringContract(locale) { - sponsoring_contracts_download_open = false; - const runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners( - original_object.id - ); - const toast = Toastify({ - text: $_("generating-pdf"), - duration: -1, - }).showToast(); - fetch( - `${config.baseurl}/documents/contracts?locale=${locale}&download=true&key=${config.documentserver_key}`, - { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(runners), - } - ) - .then((response) => { - if (response.status != "200") { - toast.hideToast(); - Toastify({ - text: $_("pdf-generation-failed"), - duration: 3500, - backgroundColor: - "linear-gradient(90deg, hsla(281, 37%, 45%, 1) 0%, hsla(1, 62%, 48%, 1) 100%)", - }).showToast(); - } else { - return response.blob(); - } - }) - .then((blob) => { - const url = window.URL.createObjectURL(blob); - let a = document.createElement("a"); - a.href = url; - a.download = "Sponsorings_" + original_object.name + ".pdf"; - document.body.appendChild(a); - a.click(); - a.remove(); - toast.hideToast(); - Toastify({ - text: $_("pdf-successfully-generated"), - duration: 3500, - backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)", - }).showToast(); - }) - .catch((err) => {}); - } {original_object.name} -
-
- -
- {#if sponsoring_contracts_download_open} -
- -
- {/if} -
+ {#if store.state.jwtinfo.userdetails.permissions.includes('RUNNER:IMPORT')} - - {#if sponsoring_contracts_download_open} -
- -
- {/if} - - {/if} +