Moved update card logic to overview
This commit is contained in:
parent
f6985daec7
commit
53b945c72f
@ -7,7 +7,6 @@
|
|||||||
import Toastify from "toastify-js";
|
import Toastify from "toastify-js";
|
||||||
import { createEventDispatcher } from "svelte";
|
import { createEventDispatcher } from "svelte";
|
||||||
export let edit_modal_open;
|
export let edit_modal_open;
|
||||||
export let current_cards;
|
|
||||||
export let runner = {};
|
export let runner = {};
|
||||||
export let editable = {};
|
export let editable = {};
|
||||||
export let original_data = {};
|
export let original_data = {};
|
||||||
@ -30,9 +29,6 @@
|
|||||||
$: enabled = true;
|
$: enabled = true;
|
||||||
$: processed_last_submit = true;
|
$: processed_last_submit = true;
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
function dataUpdated() {
|
|
||||||
dispatch('dataUpdated',);
|
|
||||||
}
|
|
||||||
RunnerService.runnerControllerGetAll().then((val) => {
|
RunnerService.runnerControllerGetAll().then((val) => {
|
||||||
runners = val.map((r) => {
|
runners = val.map((r) => {
|
||||||
return { label: getRunnerLabel(r), value: r };
|
return { label: getRunnerLabel(r), value: r };
|
||||||
@ -75,9 +71,7 @@
|
|||||||
duration: 500,
|
duration: 500,
|
||||||
backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
|
backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
|
||||||
}).showToast();
|
}).showToast();
|
||||||
current_cards[current_cards.findIndex((c) => c.id === id)] = result;
|
dispatch('dataUpdated', {card: result});
|
||||||
current_cards = current_cards;
|
|
||||||
dataUpdated();
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
//
|
//
|
||||||
|
@ -116,6 +116,12 @@
|
|||||||
const table = createSvelteTable(options);
|
const table = createSvelteTable(options);
|
||||||
|
|
||||||
function open_edit_modal(card) {
|
function open_edit_modal(card) {
|
||||||
|
const getRunnerLabel = (option) =>
|
||||||
|
option.firstname +
|
||||||
|
" " +
|
||||||
|
(option.middlename || "") +
|
||||||
|
" " +
|
||||||
|
option.lastname;
|
||||||
if (card.runner?.id) {
|
if (card.runner?.id) {
|
||||||
runner = Object.assign(
|
runner = Object.assign(
|
||||||
{ runner },
|
{ runner },
|
||||||
@ -134,13 +140,19 @@
|
|||||||
|
|
||||||
{#if store.state.jwtinfo.userdetails.permissions.includes("CARD:UPDATE")}
|
{#if store.state.jwtinfo.userdetails.permissions.includes("CARD:UPDATE")}
|
||||||
<CardDetailModal
|
<CardDetailModal
|
||||||
bind:current_cards
|
|
||||||
bind:edit_modal_open
|
bind:edit_modal_open
|
||||||
bind:runner
|
bind:runner
|
||||||
bind:editable
|
bind:editable
|
||||||
bind:original_data
|
bind:original_data
|
||||||
on:dataUpdated={() => {
|
on:dataUpdated={(event) => {
|
||||||
//TODO:
|
current_cards[
|
||||||
|
current_cards.findIndex((c) => c.id === event.detail.card.id)
|
||||||
|
] = event.detail.card;
|
||||||
|
current_cards = current_cards;
|
||||||
|
options.update((options) => ({
|
||||||
|
...options,
|
||||||
|
data: current_cards,
|
||||||
|
}));
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user