Implement radio flag type
This commit is contained in:
parent
41565729fd
commit
49664c3dfe
2 changed files with 64 additions and 44 deletions
|
|
@ -101,8 +101,8 @@
|
|||
{/if}
|
||||
{#if !flag.found}
|
||||
{#each values as v, index}
|
||||
<div class="input-group" class:mt-1={index != 0}>
|
||||
{#if !flag.choices}
|
||||
{#if !flag.choices}
|
||||
<div class="input-group" class:mt-1={index != 0}>
|
||||
{#if flag.type == 'number'}
|
||||
<input
|
||||
type="number"
|
||||
|
|
@ -136,45 +136,63 @@
|
|||
title="{flag.placeholder}"
|
||||
></textarea>
|
||||
{/if}
|
||||
{:else}
|
||||
<select
|
||||
class="form-select"
|
||||
id="sol_{flag.type}{flag.id}_{index}"
|
||||
bind:value={values[index]}
|
||||
>
|
||||
{#each Object.keys(flag.choices) as l}
|
||||
<option value={l}>{flag.choices[l]}</option>
|
||||
{/each}
|
||||
</select>
|
||||
{/if}
|
||||
{#if flag.choices_cost > 0}
|
||||
<Button
|
||||
color="success"
|
||||
type="button"
|
||||
on:click={wantchoices}
|
||||
disabled={wcsubmitted}
|
||||
title="Cliquez pour échanger ce champ de texte par une liste de choix. L'opération vous coûtera {flag.choices_cost * $settings.wchoiceCurrentCoefficient} points."
|
||||
>
|
||||
{#if wcsubmitted}
|
||||
<Spinner size="sm" class="me-2" />
|
||||
{/if}
|
||||
<Icon name="tasks" />
|
||||
Liste de propositions ({flag.choices_cost * $settings.wchoiceCurrentCoefficient} {flag.choices_cost * $settings.wchoiceCurrentCoefficient===1?"point":"points"})
|
||||
</Button>
|
||||
{:else if flag.separator && !flag.nb_lines && index == values.length - 1}
|
||||
<Button
|
||||
color="success"
|
||||
type="button"
|
||||
title="Ajouter un élément."
|
||||
on:click={addItem}
|
||||
>
|
||||
<Icon name="plus" />
|
||||
</Button>
|
||||
{/if}
|
||||
{#if flag.unit}
|
||||
<span class="input-group-text">{flag.unit}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{#if flag.unit}
|
||||
<span class="input-group-text">{flag.unit}</span>
|
||||
{/if}
|
||||
{#if flag.choices_cost > 0}
|
||||
<Button
|
||||
color="success"
|
||||
type="button"
|
||||
on:click={wantchoices}
|
||||
disabled={wcsubmitted}
|
||||
title="Cliquez pour échanger ce champ de texte par une liste de choix. L'opération vous coûtera {flag.choices_cost * $settings.wchoiceCurrentCoefficient} points."
|
||||
>
|
||||
{#if wcsubmitted}
|
||||
<Spinner size="sm" class="me-2" />
|
||||
{/if}
|
||||
<Icon name="tasks" />
|
||||
Liste de propositions ({flag.choices_cost * $settings.wchoiceCurrentCoefficient} {flag.choices_cost * $settings.wchoiceCurrentCoefficient===1?"point":"points"})
|
||||
</Button>
|
||||
{:else if flag.separator && !flag.nb_lines && index == values.length - 1}
|
||||
<Button
|
||||
color="success"
|
||||
type="button"
|
||||
title="Ajouter un élément."
|
||||
on:click={addItem}
|
||||
>
|
||||
<Icon name="plus" />
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
{:else if flag.type == 'radio'}
|
||||
{#each Object.keys(flag.choices) as l, i}
|
||||
<div class="form-check">
|
||||
<input
|
||||
id="sol_{flag.type}{flag.id}_{index}_{i}"
|
||||
type="radio"
|
||||
value={l}
|
||||
bind:group={values[index]}
|
||||
class="form-check-input"
|
||||
>
|
||||
<label
|
||||
class="form-check-label"
|
||||
for="sol_{flag.type}{flag.id}_{index}_{i}"
|
||||
>
|
||||
{flag.choices[l]}
|
||||
</label>
|
||||
</div>
|
||||
{/each}
|
||||
{:else}
|
||||
<select
|
||||
class="form-select"
|
||||
id="sol_{flag.type}{flag.id}_{index}"
|
||||
bind:value={values[index]}
|
||||
>
|
||||
{#each Object.keys(flag.choices) as l}
|
||||
<option value={l}>{flag.choices[l]}</option>
|
||||
{/each}
|
||||
</select>
|
||||
{/if}
|
||||
{/each}
|
||||
{#if flag.help}
|
||||
<small class="form-text text-muted">{flag.help}</small>
|
||||
|
|
|
|||
Reference in a new issue