Now w/ working dialog🎉🎉🎉

ref #94
This commit is contained in:
2021-03-25 19:14:15 +01:00
parent 1a52aaf8d1
commit ae9673070c
2 changed files with 43 additions and 22 deletions

View File

@@ -7,8 +7,9 @@
import Toastify from "toastify-js";
export let edit_modal_open;
export let current_cards;
export let edit_card;
export let runner;
export let runner = {};
export let editable = {};
export let original_data = {};
const getRunnerLabel = (option) =>
option.firstname + " " + (option.middlename || "") + " " + option.lastname;
const filterRunners = (label, filterText, option) =>
@@ -17,10 +18,7 @@
function focus(el) {
el.focus();
}
$: runner = {};
$: runners = [];
$: editable = {};
$: original_data = {};
$: enabled = true;
$: processed_last_submit = true;
RunnerService.runnerControllerGetAll().then((val) => {
@@ -28,15 +26,6 @@
return { label: getRunnerLabel(r), value: r };
});
});
RunnerCardService.runnerCardControllerGetOne(edit_card.id).then((val) => {
runner = Object.assign(
{ runner },
{ label: getRunnerLabel(val.runner), value: val.runner }
);
val.runner = val.runner?.id;
editable = Object.assign(editable, val);
original_data = Object.assign(original_data, val);
});
$: createbtnenabled = !(
JSON.stringify(editable) === JSON.stringify(original_data)
);
@@ -63,6 +52,7 @@
}).showToast();
RunnerCardService.runnerCardControllerPut(original_data.id, editable)
.then((result) => {
let id = original_data.id;
runner = {};
editable = {};
original_data = {};
@@ -72,9 +62,14 @@
text: $_("card-updated"),
duration: 500,
backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
}).showToast();
}).showToast();
console.log(
JSON.stringify(
current_cards
)
);
current_cards[
current_cards.findIndex((c) => c.id === edit_card.id)
current_cards.findIndex((c) => c.id === id)
] = result;
current_cards = current_cards;
})
@@ -89,6 +84,7 @@
}
}
</script>
{#if edit_modal_open}
<div
class="fixed z-10 inset-0 overflow-y-auto"