diff --git a/src/components/orgs/OrgDetail.svelte b/src/components/orgs/OrgDetail.svelte index 8d470942..6fdcd8d6 100644 --- a/src/components/orgs/OrgDetail.svelte +++ b/src/components/orgs/OrgDetail.svelte @@ -12,6 +12,7 @@ import Select from "svelte-select"; import GenerateSponsoringContracts from "../pdf_generation/GenerateSponsoringContracts.svelte"; import GenerateRunnerCards from "../pdf_generation/GenerateRunnerCards.svelte"; + import { tick } from "svelte"; $: delete_triggered = false; $: address_valid_or_none = (isAddress1Valid && iszipcodevalid && iscityvalid) || @@ -20,6 +21,9 @@ let original = ""; let original_object = {}; let contacts = []; + let valueCopy = null; + let areaDom; + let copied = false; export let params; $: editable = {}; $: contact = {}; @@ -31,6 +35,7 @@ $: sponsoring_contracts_show = true; $: cards_show = true; $: generate_orgs = [original_object]; + $: registrationLink = `${config.baseurl}/selfservice/register/${editable.registrationKey}`; const getContactLabel = (option) => option.firstname + " " + (option.middlename || "") + " " + option.lastname; const promise = RunnerOrganizationService.runnerOrganizationControllerGetOne( @@ -98,6 +103,7 @@ postdata ) .then((resp) => { + editable.registrationKey = resp.registrationKey; original_object = Object.assign({}, editable); original = JSON.stringify(original_object); Toastify({ @@ -110,9 +116,46 @@ } else { } } + async function copy() { + if(!editable.registrationKey){ + Toastify({ + text: $_('you-have-to-save-your-changes-to-generate-a-link'), + duration: 500, + backgroundColor: + "linear-gradient(90deg, hsla(281, 37%, 45%, 1) 0%, hsla(1, 62%, 48%, 1) 100%)", + }).showToast(); + return; + } + valueCopy = registrationLink; + await tick(); + areaDom.focus(); + areaDom.select(); + try { + const successful = document.execCommand("copy"); + if (!successful) { + throw new Error(); + } + Toastify({ + text: $_("copied-link-to-clipboard"), + duration: 500, + backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)", + }).showToast(); + copied = true; + } catch (err) { + Toastify({ + text: $_("error-whyile-copying-to-clipboard"), + duration: 500, + backgroundColor: + "linear-gradient(90deg, hsla(281, 37%, 45%, 1) 0%, hsla(1, 62%, 48%, 1) 100%)", + }).showToast(); + } + // we can notifi by event or storage about copy status + valueCopy = null; + } export let import_modal_open = false; +{#if valueCopy != null}{/if} { import_modal_open = false; @@ -132,9 +175,7 @@ - + {#if store.state.jwtinfo.userdetails.permissions.includes('RUNNER:IMPORT')}