Added bulk creation modal to cards view

ref #94
This commit is contained in:
2021-03-23 18:41:00 +01:00
parent 8a32569a3b
commit f46ccb610e
4 changed files with 22 additions and 15 deletions

View File

@@ -5,9 +5,8 @@
import {
RunnerCardService
} from "@odit/lfk-client-js";
import Select from "svelte-select";
import Toastify from "toastify-js";
export let modal_open;
export let bulk_modal_open;
export let current_cards;
function focus(el) {
el.focus();
@@ -15,17 +14,12 @@
$: card_count = 0;
$: is_card_count_valid= card_count>0;
$: processed_last_submit = true;
RunnerService.runnerControllerGetAll().then((val) => {
runners = val.map((r) => {
return { label: getRunnerLabel(r), value: r };
});
});
$: createbtnenabled = is_card_count_valid;
(() => {
document.onkeydown = (e) => {
e = e || window.event;
if (e.key === "Escape") {
modal_open = false;
bulk_modal_open = false;
}
if (e.keyCode === 13) {
if (createbtnenabled === true) {
@@ -50,7 +44,7 @@
RunnerCardService.runnerCardControllerPost(postdata)
.then((result) => {
runner = 0;
modal_open = false;
bulk_modal_open = false;
//
Toastify({
text: $_("card-added"),
@@ -72,13 +66,13 @@
}
</script>
{#if modal_open}
{#if bulk_modal_open}
<div
class="fixed z-10 inset-0 overflow-y-auto"
use:focusTrap
use:clickOutside
on:click_outside={() => {
modal_open = false;
bulk_modal_open = false;
}}>
<div
class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
@@ -161,7 +155,7 @@
</button>
<button
on:click={() => {
modal_open = false;
bulk_modal_open = false;
}}
type="button"
class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm">