PDF generation from OrgDetail

ref #62
This commit is contained in:
Philipp Dormann 2021-02-20 16:46:12 +01:00
parent 40dda1150c
commit 0a55d73146

View File

@ -3,7 +3,7 @@
GroupContactService, GroupContactService,
RunnerOrganizationService, RunnerOrganizationService,
} from "@odit/lfk-client-js"; } from "@odit/lfk-client-js";
import { _ } from "svelte-i18n"; import { getLocaleFromNavigator, _ } from "svelte-i18n";
import Toastify from "toastify-js"; import Toastify from "toastify-js";
import store from "../../store"; import store from "../../store";
import ConfirmOrgDeletion from "./ConfirmOrgDeletion.svelte"; import ConfirmOrgDeletion from "./ConfirmOrgDeletion.svelte";
@ -35,14 +35,14 @@
} }
} }
value.address_checked = value.address.address1 !== null; value.address_checked = value.address.address1 !== null;
if(value.address_checked===false){ if (value.address_checked === false) {
value.address = { value.address = {
address1: "", address1: "",
address2: "", address2: "",
city: "", city: "",
postalcode: "", postalcode: "",
country: "" country: "",
} };
} }
editable = Object.assign(editable, value); editable = Object.assign(editable, value);
editable = editable; editable = editable;
@ -82,7 +82,6 @@
if (postdata.address_checked === false) { if (postdata.address_checked === false) {
postdata.address = null; postdata.address = null;
} }
console.log(postdata)
postdata.contact = postdata.contact === "null" ? null : postdata.contact; postdata.contact = postdata.contact === "null" ? null : postdata.contact;
RunnerOrganizationService.runnerOrganizationControllerPut( RunnerOrganizationService.runnerOrganizationControllerPut(
original_object.id, original_object.id,
@ -119,6 +118,34 @@
<div class="mb-8 text-3xl font-extrabold leading-tight"> <div class="mb-8 text-3xl font-extrabold leading-tight">
{original_object.name} {original_object.name}
<span data-id="org_actions_${editable.id}"> <span data-id="org_actions_${editable.id}">
<button
on:click={async () => {
const locale = getLocaleFromNavigator();
const runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners(original_object.id);
fetch(
`https://dev.lauf-fuer-kaya.de/documents/contracts?locale=${locale}&download=true&key=${config.documentserver_key}`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(runners),
}
)
.then((response) => 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();
})
.catch((err) => {});
}}
type="button"
class="w-full justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-gray-600 text-base font-medium text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 sm:ml-3 sm:w-auto sm:text-sm">{$_('generate-sponsoring-contracts')}</button>
{#if store.state.jwtinfo.userdetails.permissions.includes('RUNNER:IMPORT')} {#if store.state.jwtinfo.userdetails.permissions.includes('RUNNER:IMPORT')}
<button <button
on:click={() => { on:click={() => {