PDF from RunnerDetail

ref #62
This commit is contained in:
2021-02-20 16:17:20 +01:00
parent ff15308c03
commit 3b18be5874
3 changed files with 36 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
<script>
import { _ } from "svelte-i18n";
import { getLocaleFromNavigator, _ } from "svelte-i18n";
import lodashIsEqual from "lodash.isequal";
import store from "../../store";
import {
@@ -14,6 +14,7 @@
export let params;
const runner_promise = RunnerService.runnerControllerGetOne(params.runnerid);
$: delete_triggered = false;
$: original_data_pdf = {};
$: original_data = {};
$: editable = {};
$: changes_performed = !lodashIsEqual(original_data, editable);
@@ -26,6 +27,7 @@
changes_performed && isFirstnameValid && isLastnameValid && isEmailValid;
runner_promise.then((data) => {
data_loaded = true;
original_data_pdf = Object.assign(original_data_pdf, data);
original_data = Object.assign(original_data, data);
original_data.group = original_data.group.id;
editable = Object.assign(editable, original_data);
@@ -130,6 +132,35 @@
}}
class="w-full justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-400 text-base font-medium text-white sm:w-auto sm:text-sm">{$_('cancel')}</button>
{/if}
<button
on:click={() => {
const locale = getLocaleFromNavigator();
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([original_data_pdf]),
}
)
.then((response) => response.blob())
.then((blob) => {
const url = window.URL.createObjectURL(blob);
let a = document.createElement('a');
a.href = url;
a.download = 'Sponsoring.pdf';
document.body.appendChild(a);
a.click();
a.remove();
})
.catch((err) => {
console.error(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-contract')}</button>
{#if !delete_triggered}
<button
on:click={() => {

View File

@@ -239,9 +239,7 @@
.then((resp) => {
current_runners = current_runners.filter((obj) => obj.id !== runner.id);
})
.catch((err) => {
// error deleting user
});
.catch((err) => {});
}}
tabindex="0"
class="ml-4 text-red-600 hover:text-red-900 cursor-pointer">{$_('confirm-delete')}</button>
@@ -251,7 +249,7 @@
class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<a
href="./{runner.id}"
class="text-indigo-600 hover:text-indigo-900">{$_('edit')}</a>
class="text-indigo-600 hover:text-indigo-900">{$_('details')}</a>
{#if store.state.jwtinfo.userdetails.permissions.includes('RUNNER:DELETE')}
<button
on:click={() => {