Compare commits
3 Commits
5662c3b6da
...
c681570134
Author | SHA1 | Date | |
---|---|---|---|
c681570134 | |||
53b945c72f | |||
f6985daec7 |
@ -7,7 +7,6 @@
|
||||
import Toastify from "toastify-js";
|
||||
import { createEventDispatcher } from "svelte";
|
||||
export let edit_modal_open;
|
||||
export let current_cards;
|
||||
export let runner = {};
|
||||
export let editable = {};
|
||||
export let original_data = {};
|
||||
@ -30,9 +29,6 @@
|
||||
$: enabled = true;
|
||||
$: processed_last_submit = true;
|
||||
const dispatch = createEventDispatcher();
|
||||
function dataUpdated() {
|
||||
dispatch('dataUpdated',);
|
||||
}
|
||||
RunnerService.runnerControllerGetAll().then((val) => {
|
||||
runners = val.map((r) => {
|
||||
return { label: getRunnerLabel(r), value: r };
|
||||
@ -75,9 +71,7 @@
|
||||
duration: 500,
|
||||
backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
|
||||
}).showToast();
|
||||
current_cards[current_cards.findIndex((c) => c.id === id)] = result;
|
||||
current_cards = current_cards;
|
||||
dataUpdated();
|
||||
dispatch('dataUpdated', {card: result});
|
||||
})
|
||||
.catch((err) => {
|
||||
//
|
||||
|
@ -47,18 +47,12 @@
|
||||
}));
|
||||
}
|
||||
);
|
||||
const getRunnerLabel = (option) =>
|
||||
option?.firstname +
|
||||
" " +
|
||||
(option?.middlename || "") +
|
||||
" " +
|
||||
(option?.lastname || "{$_('non-blanko')}");
|
||||
|
||||
const columns = [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: () => "id",
|
||||
filterFn: `equalsString`,
|
||||
accessorKey: "code",
|
||||
header: () => $_("code"),
|
||||
filterFn: `includesString`,
|
||||
},
|
||||
{
|
||||
accessorKey: "runner",
|
||||
@ -81,7 +75,13 @@
|
||||
header: () => $_("action"),
|
||||
cell: (info) => {
|
||||
return renderComponent(TableActions, {
|
||||
detailsLink: `./${info.row.original.id}`,
|
||||
detailsAction: () => {
|
||||
open_edit_modal(
|
||||
current_cards[
|
||||
current_cards.findIndex((r) => r.id == info.row.original.id)
|
||||
]
|
||||
);
|
||||
},
|
||||
deleteAction: () => {
|
||||
active_delete =
|
||||
current_cards[
|
||||
@ -116,6 +116,12 @@
|
||||
const table = createSvelteTable(options);
|
||||
|
||||
function open_edit_modal(card) {
|
||||
const getRunnerLabel = (option) =>
|
||||
option.firstname +
|
||||
" " +
|
||||
(option.middlename || "") +
|
||||
" " +
|
||||
option.lastname;
|
||||
if (card.runner?.id) {
|
||||
runner = Object.assign(
|
||||
{ runner },
|
||||
@ -134,13 +140,19 @@
|
||||
|
||||
{#if store.state.jwtinfo.userdetails.permissions.includes("CARD:UPDATE")}
|
||||
<CardDetailModal
|
||||
bind:current_cards
|
||||
bind:edit_modal_open
|
||||
bind:runner
|
||||
bind:editable
|
||||
bind:original_data
|
||||
on:dataUpdated={() => {
|
||||
//TODO:
|
||||
on:dataUpdated={(event) => {
|
||||
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}
|
||||
|
Loading…
x
Reference in New Issue
Block a user