Added bulk creation modal to cards view

ref #94
This commit is contained in:
Nicolai Ort 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">

View File

@ -1,10 +1,12 @@
<script>
import { _ } from "svelte-i18n";
import store from "../../store";
import AddCardBulkModal from "./AddCardBulkModal.svelte";
import AddCardModal from "./AddCardModal.svelte";
import CardsOverview from "./CardsOverview.svelte";
$: current_cards = [];
export let modal_open = false;
export let bulk_modal_open = false;
</script>
<section class="container p-5">
@ -19,6 +21,14 @@
class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm">
{$_('add-card')}
</button>
<button
on:click={() => {
bulk_modal_open = true;
}}
type="button"
class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm">
{$_('create-bulk-cards')}
</button>
{/if}
</span>
<CardsOverview bind:current_cards />
@ -26,4 +36,5 @@
{#if store.state.jwtinfo.userdetails.permissions.includes('CARD:CREATE')}
<AddCardModal bind:current_cards bind:modal_open />
<AddCardBulkModal bind:current_cards bind:bulk_modal_open />
{/if}

View File

@ -395,5 +395,6 @@
"create-bulk-blanco-cards": "Blankokarten erstellen",
"just-enter-how-many-you-want-and-the-system-will-create-them": "Geb einfach ein, wie viele Blankokarten das System erstellen soll.",
"amount": "Anzahl",
"you-must-create-at-least-one-card-or-cancel": "Du musst mindestens eine Blankokarte erstellen (oder abbrechen)."
"you-must-create-at-least-one-card-or-cancel": "Du musst mindestens eine Blankokarte erstellen (oder abbrechen).",
"create-bulk-cards": "Blankokarten erstellen"
}

View File

@ -391,9 +391,10 @@
"card-added": "Card added",
"create-a-new-card": "Create a new card",
"you-can-provide-a-runner-but-you-dont-have-to": "You can provide a runner, but you don't have to.",
"if-you-want-to-create-multiple-blanco-cards-try-the-add-bulk-button": "If you want to create multiple blanco cards: Try the 'Add bulk' button.",
"if-you-want-to-create-multiple-blanco-cards-try-the-add-bulk-button": "If you want to create multiple blanco cards: Try the 'Add blanco cards' button.",
"create-bulk-blanco-cards": "Create bulk blanco cards",
"just-enter-how-many-you-want-and-the-system-will-create-them": "Just enter how many you want and the system will create them",
"amount": "Amount",
"you-must-create-at-least-one-card-or-cancel": "You must create at least one card (or cancel)."
"you-must-create-at-least-one-card-or-cancel": "You must create at least one card (or cancel).",
"create-bulk-cards": "Add blanco cards"
}