Skip to content
Snippets Groups Projects
Commit 962dbdc4 authored by Timothee P's avatar Timothee P :sunflower:
Browse files

fix default value on dropdown at feature creation

parent 2e13bab6
No related branches found
No related tags found
1 merge request!16validate forms for feature_edit (attachment & linkedFeatures)
......@@ -30,7 +30,11 @@
v-model="form.title.value"
@blur="updateStore"
/>
{{ form.title.errors }}
<ul id="errorlist" class="errorlist">
<li v-for="error in form.title.errors" :key="error">
{{ error }}
</li>
</ul>
</div>
<div class="required field">
<label :for="form.status.id_for_label">{{
......@@ -41,8 +45,11 @@
:selected="selected_status.name"
:selection.sync="selected_status"
/>
{{ form.status.errors }}
<ul id="errorlist" class="errorlist">
<li v-for="error in form.status.errors" :key="error">
{{ error }}
</li>
</ul>
</div>
</div>
<div class="field">
......@@ -289,7 +296,10 @@ export default {
id_for_label: "status",
html_name: "status",
label: "Statut",
value: "Brouillon",
value: {
value: "draft",
name: "Brouillon",
},
},
description: {
errors: null,
......@@ -329,10 +339,12 @@ export default {
selected_status: {
get() {
console.log(this.form.status.value);
return this.form.status.value;
},
set(newValue) {
this.form.status.value = newValue;
console.log(this.form.status.value);
this.updateStore();
},
},
......@@ -355,15 +367,15 @@ export default {
methods: {
initForm() {
if (this.currentRouteName === "editer-signalement") {
for (let el in this.feature) {
if (el && this.form[el]) {
if (el === "status") {
const value = this.feature[el];
this.form[el].value = this.statusChoices.find(
(el) => el.value === value
for (let key in this.feature) {
if (key && this.form[key]) {
if (key === "status") {
const value = this.feature[key];
this.form[key].value = this.statusChoices.find(
(key) => key.value === value
);
} else {
this.form[el].value = this.feature[el];
this.form[key].value = this.feature[key];
}
}
}
......@@ -472,13 +484,29 @@ export default {
});
},
postForm() {
checkForms() {
if (this.form.title.value) {
this.form.title.errors = null;
this.$store.dispatch("feature/SEND_FEATURE", this.currentRouteName);
} else {
this.form.title.errors = "Veuillez compléter ce champ.";
this.form.title.errors = [];
return this.checkCustomForms(); //* if customForms are ok, validate, if get out function
} else if (
!this.form.title.errors.includes("Veuillez compléter ce champ.") // TODO : Gérer les autres champs
) {
this.form.title.errors.push("Veuillez compléter ce champ.");
document
.getElementById("errorlist")
.scrollIntoView({ block: "end", inline: "nearest" });
}
return false;
},
postForm() {
if (!this.checkForms()) return;
this.$store.dispatch("feature/SEND_FEATURE", this.currentRouteName);
// if (this.form.title.value) {
// this.form.title.errors = null;
// } else {
// this.form.title.errors = "Veuillez compléter ce champ.";
// }
},
onFeatureTypeLoaded() {
......@@ -766,7 +794,8 @@ export default {
featureAPI
.getFeatureAttachments(this.$route.params.slug_signal)
.then((data) => this.addExistingAttachementFormset(data));
} else { //* be sure that previous attachemntFormset has been cleared for creation
} else {
//* be sure that previous attachemntFormset has been cleared for creation
this.$store.commit("feature/CLEAR_ATTACHMENT_FORM");
}
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment