Use reactive variable

This commit is contained in:
rxdn 2022-02-14 20:12:15 +00:00
parent 1674c5552a
commit 97d1391038

View File

@ -33,7 +33,7 @@
{#if activeFormId !== null} {#if activeFormId !== null}
<div class="col-4"> <div class="col-4">
<Button danger={true} type="button" <Button danger={true} type="button"
on:click={() => deleteForm(activeFormId)}>Delete {getActiveFormTitle()}</Button> on:click={() => deleteForm(activeFormId)}>Delete {activeFormTitle}</Button>
</div> </div>
{/if} {/if}
</div> </div>
@ -79,6 +79,7 @@
let newTitle; let newTitle;
let forms = []; let forms = [];
let activeFormId = null; let activeFormId = null;
$: activeFormTitle = activeFormId !== null ? forms.find(f => f.form_id === activeFormId).title : 'Unknown';
let inputCreationData = {}; let inputCreationData = {};
$: windowWidth = 0; $: windowWidth = 0;
@ -179,10 +180,6 @@
forms = res.data || []; forms = res.data || [];
} }
function getActiveFormTitle() {
return activeFormId !== null ? forms.find(f => f.form_id === activeFormId).title : 'Unknown';
}
withLoadingScreen(async () => { withLoadingScreen(async () => {
setDefaultHeaders(); setDefaultHeaders();
await loadForms(); await loadForms();