ui: When enter is pressed on vector flag, add an item
This commit is contained in:
parent
7cdca440e6
commit
630c065825
1 changed files with 7 additions and 1 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
Icon,
|
Icon,
|
||||||
Spinner,
|
Spinner,
|
||||||
} from 'sveltestrap';
|
} from 'sveltestrap';
|
||||||
|
import { tick } from 'svelte';
|
||||||
|
|
||||||
import { settings } from '../stores/settings.js';
|
import { settings } from '../stores/settings.js';
|
||||||
|
|
||||||
|
|
@ -35,6 +36,10 @@
|
||||||
|
|
||||||
let wcsubmitted = false;
|
let wcsubmitted = false;
|
||||||
async function wantchoices() {
|
async function wantchoices() {
|
||||||
|
if (!confirm("Êtes-vous sûr de vouloir utiliser " + (flag.choices_cost * $settings.wchoiceCurrentCoefficient) + " points pour avoir une liste de propositions à la place de ce champ de texte à compléter ?")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wcsubmitted = true;
|
wcsubmitted = true;
|
||||||
|
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
|
|
@ -125,6 +130,7 @@
|
||||||
bind:value={values[index]}
|
bind:value={values[index]}
|
||||||
placeholder={flag.placeholder}
|
placeholder={flag.placeholder}
|
||||||
title={flag.placeholder}
|
title={flag.placeholder}
|
||||||
|
on:keydown={(e) => {if (flag.separator && e.keyCode === 13) { e.preventDefault(); addItem(); tick().then(() => { document.getElementById('sol_' + flag.type + '' + flag.id + '_' + (values.length - 1)).focus(); }); return false;}}}
|
||||||
>
|
>
|
||||||
{:else}
|
{:else}
|
||||||
<textarea
|
<textarea
|
||||||
|
|
@ -150,7 +156,7 @@
|
||||||
{#if wcsubmitted}
|
{#if wcsubmitted}
|
||||||
<Spinner size="sm" class="me-2" />
|
<Spinner size="sm" class="me-2" />
|
||||||
{/if}
|
{/if}
|
||||||
<Icon name="tasks" />
|
<Icon name="list-task" />
|
||||||
Liste de propositions ({flag.choices_cost * $settings.wchoiceCurrentCoefficient} {flag.choices_cost * $settings.wchoiceCurrentCoefficient===1?"point":"points"})
|
Liste de propositions ({flag.choices_cost * $settings.wchoiceCurrentCoefficient} {flag.choices_cost * $settings.wchoiceCurrentCoefficient===1?"point":"points"})
|
||||||
</Button>
|
</Button>
|
||||||
{:else if flag.separator && !flag.nb_lines && index == values.length - 1}
|
{:else if flag.separator && !flag.nb_lines && index == values.length - 1}
|
||||||
|
|
|
||||||
Reference in a new issue