Commit 2f771136 authored by Kevin Robert's avatar Kevin Robert
Browse files

UNAPLLYREC-7 : Correction affichage. Ajout du champ 'required' et du champ...

UNAPLLYREC-7 : Correction affichage. Ajout du champ 'required' et du champ 'shortLabel' sur la question ouverte.
parent c1821120
......@@ -13,6 +13,16 @@ public class OpenQuestion extends Item {
*/
private String question = StringUtils.EMPTY;
/**
* La réponse est-elle obligatoire.
*/
private boolean required = false;
/**
* Le label court.
*/
protected String shortLabel = StringUtils.EMPTY;
/**
* Constructeur vide.
*/
......@@ -26,6 +36,7 @@ public class OpenQuestion extends Item {
openQuestionItemAPI.setQuestion(question);
openQuestionItemAPI.setType(type);
openQuestionItemAPI.setReference(reference);
openQuestionItemAPI.setRequired(required);
return openQuestionItemAPI;
}
......@@ -36,4 +47,20 @@ public class OpenQuestion extends Item {
public void setQuestion(String question) {
this.question = question;
}
public Boolean getRequired() {
return required;
}
public void setRequired(Boolean required) {
this.required = required;
}
public String getShortLabel() {
return shortLabel;
}
public void setShortLabel(String shortLabel) {
this.shortLabel = shortLabel;
}
}
......@@ -311,7 +311,7 @@ components:
example: btn--medium
OpenQuestionItemAPI:
allOf:
- $ref: '#/components/schemas/ItemAPI'
- $ref: '#/components/schemas/QuestionAPI'
- type: object
properties:
question:
......
......@@ -106,7 +106,7 @@ export default class ItemEdit extends Vue {
}
public get hasShortLabel() {
return this.item.type === 'radio' || this.item.type === 'checkbox';
return this.item.type === 'radio' || this.item.type === 'checkbox' || this.item.type === 'openquestion';
}
public get definedConditions() {
......
......@@ -3,10 +3,12 @@ import { mixins } from 'vue-class-component';
import ItemMixin from '@/components/screen-item/items/item-edit.mixin';
import OaInput from '@/components/forms/input/oa-input.vue';
import OaCheckbox from "@/components/forms/checkbox/oa-checkbox.vue";
@Component({
components: {
OaInput,
OaCheckbox
}
})
export default class OpenQuestionEdit extends mixins(ItemMixin) {
......
<template>
<div>
<oa-input :label="$t('screen.item.openquestion.label')" :value="item.question" required="true" @update="editItem({ question: $event })" />
<oa-checkbox
:label="$t('screen.item.common.required')"
:value="item.required"
required="true"
@update="editItem({ required: $event })"
/>
</div>
</template>
......
......@@ -13,6 +13,12 @@
@click="addNewItem('checkbox')"
:title="$t('screen.toolbar.buttons.checkbox')"
></oa-button>
<oa-button
variant="icon"
icon-name="form-textbox"
@click="addNewItem('openquestion')"
:title="$t('screen.toolbar.buttons.openquestion')"
></oa-button>
<oa-button variant="icon" icon-name="text-box" @click="addNewItem('message')" :title="$t('screen.toolbar.buttons.message')"></oa-button>
<oa-button variant="icon" icon-name="image" @click="addNewItem('picture')" :title="$t('screen.toolbar.buttons.picture')"></oa-button>
<oa-button
......@@ -21,12 +27,6 @@
@click="addNewItem('button')"
:title="$t('screen.toolbar.buttons.button')"
></oa-button>
<oa-button
variant="icon"
icon-name="form-textbox"
@click="addNewItem('openquestion')"
:title="$t('screen.toolbar.buttons.openquestion')"
></oa-button>
</div>
</template>
......
......@@ -8,7 +8,7 @@ export default class OpenQuestion extends AbstractFrontComponent {
constructor() {
super();
let initValue = this.item.answer ? this.item.answer : '';
this.$store.commit('addAnswer', new OpenAnswer(this.item.reference, [initValue]));
this.$store.commit('addAnswer', new OpenAnswer(this.item.reference, [initValue], this.item.required));
}
public get question(): any {
......
<template>
<div>
<fieldset id="question-0" class="form__fieldset">
<legend class="form__legend">{{ item.question }}</legend>
<legend class="form__legend">{{ item.question }}<span v-if="item.required"> (*)</span></legend>
<textarea @change="updateAnswer" :value="item.answer"></textarea>
</fieldset>
</div>
......
......@@ -15,9 +15,9 @@ export class SelectAnswer implements IAnswerFront {
}
export class OpenAnswer implements IAnswerFront {
constructor(public questionReference: string, public answer?: string[]) {}
constructor(public questionReference: string, public answer?: string[], public required?: boolean) {}
validate(): boolean {
return true;
return !this.required || (this.required && this.answer.length > 0 && this.answer[0] !== '');
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment