Implemented bulk creation

ref #94
This commit is contained in:
Nicolai Ort 2021-03-23 19:55:55 +01:00
parent 3cd0468b19
commit 7ad6b73574
3 changed files with 32 additions and 38 deletions

View File

@ -2,9 +2,7 @@
import { _ } from "svelte-i18n";
import { clickOutside } from "../base/outsideclick";
import { focusTrap } from "svelte-focus-trap";
import {
RunnerCardService
} from "@odit/lfk-client-js";
import { RunnerCardService } from "@odit/lfk-client-js";
import Toastify from "toastify-js";
export let bulk_modal_open;
export let current_cards;
@ -12,7 +10,7 @@
el.focus();
}
$: card_count = 0;
$: is_card_count_valid= card_count>0;
$: is_card_count_valid = card_count > 0;
$: processed_last_submit = true;
$: createbtnenabled = is_card_count_valid;
(() => {
@ -29,30 +27,22 @@
}
};
})();
//TODO: Creation logic
function submit() {
if (processed_last_submit === true) {
processed_last_submit = false;
const toast = Toastify({
text: $_("adding-card"),
text: $_("creating-blanco-cards"),
duration: -1,
}).showToast();
let postdata = {
runner,
enabled,
};
RunnerCardService.runnerCardControllerPost(postdata)
RunnerCardService.runnerCardControllerPostBlancoBulk(card_count)
.then((result) => {
runner = 0;
bulk_modal_open = false;
//
Toastify({
text: $_("card-added"),
text: $_("created-blanco-cards"),
duration: 500,
backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
}).showToast();
current_cards.push(result);
current_cards = current_cards;
})
.catch((err) => {
//
@ -118,27 +108,27 @@
<label
for="amount"
class="block text-sm font-medium text-gray-700">{$_('amount')}</label>
<div class="mt-1 flex rounded-md shadow-sm">
<input
autocomplete="off"
class:border-red-500={!is_card_count_valid}
class:focus:border-red-500={!is_card_count_valid}
class:focus:ring-red-500={!is_card_count_valid}
bind:value={card_count}
type="number"
step="1"
name="amount"
class="focus:ring-indigo-500 focus:border-indigo-500 flex-1 block w-full rounded-none rounded-l-md sm:text-sm border-gray-300 border bg-gray-50 text-gray-500 p-2"
placeholder="400" />
<span
class="inline-flex items-center px-3 rounded-r-md border border-gray-300 bg-gray-50 text-gray-500 text-sm">{$_('cards')}</span>
</div>
{#if !is_card_count_valid}
<span
class="flex items-center font-medium tracking-wide text-red-500 text-xs mt-1 ml-1">
{$_('you-must-create-at-least-one-card-or-cancel')}
</span>
{/if}
<div class="mt-1 flex rounded-md shadow-sm">
<input
autocomplete="off"
class:border-red-500={!is_card_count_valid}
class:focus:border-red-500={!is_card_count_valid}
class:focus:ring-red-500={!is_card_count_valid}
bind:value={card_count}
type="number"
step="1"
name="amount"
class="focus:ring-indigo-500 focus:border-indigo-500 flex-1 block w-full rounded-none rounded-l-md sm:text-sm border-gray-300 border bg-gray-50 text-gray-500 p-2"
placeholder="400" />
<span
class="inline-flex items-center px-3 rounded-r-md border border-gray-300 bg-gray-50 text-gray-500 text-sm">{$_('cards')}</span>
</div>
{#if !is_card_count_valid}
<span
class="flex items-center font-medium tracking-wide text-red-500 text-xs mt-1 ml-1">
{$_('you-must-create-at-least-one-card-or-cancel')}
</span>
{/if}
</div>
</div>
</div>

View File

@ -396,5 +396,7 @@
"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).",
"create-bulk-cards": "Blankokarten erstellen"
"create-bulk-cards": "Blankokarten erstellen",
"creating-blanco-cards": "Erstelle Blankokarten",
"created-blanco-cards": "Blankokarten wurden erstellt"
}

View File

@ -396,5 +396,7 @@
"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).",
"create-bulk-cards": "Add blanco cards"
"create-bulk-cards": "Add blanco cards",
"creating-blanco-cards": "Creating blanco cards",
"created-blanco-cards": "Created blanco cards"
}