Mentions légales du service

Skip to content
Snippets Groups Projects
Commit aafd19c2 authored by VIAUD Nathan's avatar VIAUD Nathan
Browse files

feat: add hints to form inputs

parent e4167d5b
No related branches found
No related tags found
1 merge request!106Resolve "Add hints to form inputs"
Pipeline #914802 passed
Showing with 160 additions and 109 deletions
...@@ -73,7 +73,6 @@ let savedState = ''; ...@@ -73,7 +73,6 @@ let savedState = '';
</script> </script>
<template> <template>
<label class="input-label" :for="id">{{ label }}</label>
<div v-show="url" class="show-input"> <div v-show="url" class="show-input">
<div class="input-file"> <div class="input-file">
<input ref="fileInput" class="file" type="file" :accept="accept" @change="changeImage" /> <input ref="fileInput" class="file" type="file" :accept="accept" @change="changeImage" />
......
...@@ -14,7 +14,7 @@ import BadgesInput from './badges/BadgesInput.vue'; ...@@ -14,7 +14,7 @@ import BadgesInput from './badges/BadgesInput.vue';
import IconPicker from './badges/components/IconPicker.vue'; import IconPicker from './badges/components/IconPicker.vue';
import ConditionInput from './badges/components/ConditionInput.vue'; import ConditionInput from './badges/components/ConditionInput.vue';
import { Input, RepeatInputEvent } from '@/src/shared/interfaces'; import { Input, RepeatInputEvent } from '@/src/shared/interfaces';
import { computed } from 'vue'; import { computed, ref } from 'vue';
const props = defineProps<{ const props = defineProps<{
input: Input; input: Input;
...@@ -39,103 +39,149 @@ const inputId = computed(() => { ...@@ -39,103 +39,149 @@ const inputId = computed(() => {
return props.input.id; return props.input.id;
} }
}); });
//? This is a workaround to focus the WYSIWYG editor when clicking on the label
const htmlInput = ref(null);
function onLabelClick(inputType: string) {
if(inputType !== 'html') return;
htmlInput.value.focusEditor();
}
function showLabel(inputType: string) {
return inputType !== 'checkbox' && inputType !== 'repeat'
}
</script> </script>
<template> <template>
<TextInput <div class="input-group">
v-if="input.type === 'text'" <div
:id="inputId" v-if="input.label && showLabel(input.type)"
:label="input.label" class="input-label"
:placeholder="input.placeholder" >
:input-value="inputValue as string" <label
:inside-card="insideCard" :for="inputId"
@input="emit('input', $event)" @click="onLabelClick(input.type)"
@save-given-state="emit('saveGivenState', $event)" >
/> {{ input.label }}
<HtmlInput </label>
v-if="input.type === 'html'" <i
:id="inputId" v-if="input.hint"
:label="input.label" v-tippy="{
:placeholder="input.placeholder" content: input.hint,
:input-value="inputValue as string" placement: 'right',
:inside-card="insideCard" arrow: true,
@input="emit('input', $event)" arrowType: 'round',
@save-given-state="emit('saveGivenState', $event)" animation: 'fade',
/> }"
<TextAreaInput class="icon-help-circle"
v-if="input.type === 'textarea'" />
:id="inputId" </div>
:label="input.label"
:placeholder="input.placeholder" <TextInput
:input-value="inputValue as string" v-if="input.type === 'text'"
:inside-card="insideCard" :id="inputId"
@input="emit('input', $event)" :label="input.label"
@save-given-state="emit('saveGivenState', $event)" :placeholder="input.placeholder"
/> :input-value="inputValue as string"
<FileInput :inside-card="insideCard"
v-if="input.type === 'file'" @input="emit('input', $event)"
:id="inputId" @save-given-state="emit('saveGivenState', $event)"
:label="input.label" />
:accept="input.accept" <HtmlInput
:input-value="inputValue as string" v-if="input.type === 'html'"
:placeholder="input.placeholder" :id="inputId"
:target-directory="input.targetDirectory" ref="htmlInput"
@input="emit('input', $event)" :label="input.label"
@save-given-state="emit('saveGivenState', $event)" :placeholder="input.placeholder"
/> :input-value="inputValue as string"
<ScoreInput :inside-card="insideCard"
v-if="input.type === 'score'" @input="emit('input', $event)"
:id="inputId" @save-given-state="emit('saveGivenState', $event)"
:label="input.label" />
:input-value="Number(inputValue)" <TextAreaInput
@input="emit('input', $event)" v-if="input.type === 'textarea'"
@save-given-state="emit('saveGivenState', $event)" :id="inputId"
/> :label="input.label"
<CheckBoxInput :placeholder="input.placeholder"
v-if="input.type === 'checkbox'" :input-value="inputValue as string"
:id="inputId" :inside-card="insideCard"
:label="input.label" @input="emit('input', $event)"
:input-value="inputValue as boolean" @save-given-state="emit('saveGivenState', $event)"
@change="emit('check', $event)" />
@save-given-state="emit('saveGivenState', $event)" <FileInput
/> v-if="input.type === 'file'"
<RadioInput :id="inputId"
v-if="input.type === 'radio-group'" :label="input.label"
:id="inputId" :accept="input.accept"
:label="input.label" :input-value="inputValue as string"
:input-value="inputValue as string" :placeholder="input.placeholder"
:pos="pos" :target-directory="input.targetDirectory"
@change="emit('input', $event)" @input="emit('input', $event)"
@save-given-state="emit('saveGivenState', $event)" @save-given-state="emit('saveGivenState', $event)"
/> />
<SelectInput <ScoreInput
v-if="input.type === 'select'" v-if="input.type === 'score'"
:id="inputId" :id="inputId"
:label="input.label" :label="input.label"
:placeholder="input.placeholder" :input-value="Number(inputValue)"
:input-value="inputValue as string" @input="emit('input', $event)"
:options="input.options" @save-given-state="emit('saveGivenState', $event)"
:linked-options="input.linkedOptions" />
@change="emit('input', $event)" <CheckBoxInput
@save-given-state="emit('saveGivenState', $event)" v-if="input.type === 'checkbox'"
/> :id="inputId"
<RepeatInput :label="input.label"
v-if="input.type === 'repeat'" :input-value="inputValue as boolean"
:id="inputId" @change="emit('check', $event)"
:label="input.label" @save-given-state="emit('saveGivenState', $event)"
:input-values="inputValue as string[]" />
:inputs="input.inputs" <RadioInput
:field-index="fieldIndex" v-if="input.type === 'radio-group'"
:add-button="input.addButton" :id="inputId"
@change="emit('repeatInput', $event)" :label="input.label"
@save-given-state="emit('saveGivenState', $event)" :input-value="inputValue as string"
/> :pos="pos"
<BadgesInput v-if="input.type === 'badge'" :input-value="inputValue as string[]" /> @change="emit('input', $event)"
<IconPicker @save-given-state="emit('saveGivenState', $event)"
v-if="input.type === 'icon-picker'" />
:label="input.label" <SelectInput
:input-value="inputValue as string" v-if="input.type === 'select'"
@input="emit('input', $event)" :id="inputId"
/> :label="input.label"
<ConditionInput v-if="input.type === 'badge-conditions'" /> :placeholder="input.placeholder"
:input-value="inputValue as string"
:options="input.options"
:linked-options="input.linkedOptions"
@change="emit('input', $event)"
@save-given-state="emit('saveGivenState', $event)"
/>
<RepeatInput
v-if="input.type === 'repeat'"
:id="inputId"
:label="input.label"
:input-values="inputValue as string[]"
:inputs="input.inputs"
:field-index="fieldIndex"
:add-button="input.addButton"
@change="emit('repeatInput', $event)"
@save-given-state="emit('saveGivenState', $event)"
/>
<BadgesInput v-if="input.type === 'badge'" :input-value="inputValue as string[]" />
<IconPicker
v-if="input.type === 'icon-picker'"
:label="input.label"
:input-value="inputValue as string"
@input="emit('input', $event)"
/>
<ConditionInput v-if="input.type === 'badge-conditions'" />
</div>
</template> </template>
<style lang="scss" scoped >
.input-group {
display: flex;
flex-direction: column;
}
</style>
\ No newline at end of file
...@@ -101,10 +101,13 @@ function focusEditor() { ...@@ -101,10 +101,13 @@ function focusEditor() {
const editor = getTinymce().activeEditor; const editor = getTinymce().activeEditor;
editor.focus(); editor.focus();
} }
defineExpose({
focusEditor
});
</script> </script>
<template> <template>
<label @click="focusEditor">{{ label }}</label>
<Editor <Editor
ref="editor" ref="editor"
v-model="content" v-model="content"
......
...@@ -45,7 +45,6 @@ function onBlur() { ...@@ -45,7 +45,6 @@ function onBlur() {
</script> </script>
<template> <template>
<label :for="id">{{ label }}</label>
<div class="input-score"> <div class="input-score">
<button @click="minus(inputValue)"><i class="icon-minus-circle"></i></button> <button @click="minus(inputValue)"><i class="icon-minus-circle"></i></button>
<input <input
......
...@@ -32,7 +32,6 @@ function onBlur() { ...@@ -32,7 +32,6 @@ function onBlur() {
</script> </script>
<template> <template>
<label class="input-label" :for="id">{{ label }}</label>
<textarea <textarea
:id="id" :id="id"
class="input input-textarea" class="input input-textarea"
......
...@@ -33,7 +33,6 @@ function onBlur() { ...@@ -33,7 +33,6 @@ function onBlur() {
</script> </script>
<template> <template>
<label v-if="label !== ''" class="input-label" :for="id">{{ label }}</label>
<input <input
:id="id" :id="id"
class="input" class="input"
......
<script setup lang="ts"> <script setup lang="ts">
import BadgeItem from '@/src/features/badge/components/BadgeItem.vue'; import BadgeItem from '@/src/features/badge/components/BadgeItem.vue';
import { iconsPath } from '@/src/shared/data';
import { useEditorStore } from '@/src/shared/stores'; import { useEditorStore } from '@/src/shared/stores';
import { computed } from 'vue';
const editorStore = useEditorStore(); const editorStore = useEditorStore();
const props = defineProps<{ defineProps<{
inputValue: string; inputValue: string;
label: string; label: string;
}>(); }>();
...@@ -17,7 +15,6 @@ function openIconModal() { ...@@ -17,7 +15,6 @@ function openIconModal() {
</script> </script>
<template> <template>
<label v-if="label !== ''" class="input-label" :for="label">{{ label }}</label>
<div :id="label" class="container"> <div :id="label" class="container">
<BadgeItem :icon="inputValue" :view-mode="true" :inactive="!inputValue" /> <BadgeItem :icon="inputValue" :view-mode="true" :inactive="!inputValue" />
<button class="btn btn-form" @click="openIconModal"> <button class="btn btn-form" @click="openIconModal">
......
...@@ -24,7 +24,6 @@ function onChange(value: string) { ...@@ -24,7 +24,6 @@ function onChange(value: string) {
<template> <template>
<div class="radio"> <div class="radio">
<label class="group-label" :for="String(pos)">Réponse</label>
<div :id="String(pos)" class="radio-group"> <div :id="String(pos)" class="radio-group">
<div class="radio-btn"> <div class="radio-btn">
<input <input
......
...@@ -35,7 +35,6 @@ function onChange(event: Event) { ...@@ -35,7 +35,6 @@ function onChange(event: Event) {
<template> <template>
<div class="select"> <div class="select">
<label :for="id">{{ label }}</label>
<select :id="id" :value="inputValue" class="select-box" @change="onChange"> <select :id="id" :value="inputValue" class="select-box" @change="onChange">
<option value="">Sélectionnez</option> <option value="">Sélectionnez</option>
<option v-for="(option, index) in getOptions()" :key="index" :value="option">{{ option }}</option> <option v-for="(option, index) in getOptions()" :key="index" :value="option">{{ option }}</option>
......
...@@ -297,9 +297,19 @@ hr { ...@@ -297,9 +297,19 @@ hr {
} }
.input-label { .input-label {
margin-bottom: 0.5rem; display: flex;
gap: .3rem;
margin-bottom: 0.7rem;
font-size: 1rem; font-size: 1rem;
font-family: 'Open Sans', sans-serif; font-family: 'Open Sans', sans-serif;
line-height: 1;
i {
display: flex;
align-items: center;
margin: 0;
color: var(--text-secondary);
}
} }
.form-icon { .form-icon {
......
...@@ -11,4 +11,5 @@ export interface Input { ...@@ -11,4 +11,5 @@ export interface Input {
options?: string[]; options?: string[];
linkedOptions?: string; linkedOptions?: string;
targetDirectory?: string; targetDirectory?: string;
hint?: string;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment