Skip to content
Snippets Groups Projects
Commit 38e045bb authored by leandro's avatar leandro
Browse files

ticket V2 11132

parent c9b6bcc3
No related merge requests found
...@@ -77,6 +77,7 @@ const feature_type = { ...@@ -77,6 +77,7 @@ const feature_type = {
async SEND_FEATURE_TYPE({ state, getters, rootGetters }, requestType) { async SEND_FEATURE_TYPE({ state, getters, rootGetters }, requestType) {
const data = { const data = {
'title': state.form.title.value, 'title': state.form.title.value,
'title_optional': state.form.title_optional.value,
'geom_type': state.form.geom_type.value, 'geom_type': state.form.geom_type.value,
'color': state.form.color.value, 'color': state.form.color.value,
'colors_style': state.form.colors_style.value, 'colors_style': state.form.colors_style.value,
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
> >
<!-- Feature Fields --> <!-- Feature Fields -->
<div class="two fields"> <div class="two fields">
<div class="required field"> <div :class="field_title">
<label :for="form.title.id_for_label">{{ form.title.label }}</label> <label :for="form.title.id_for_label">{{ form.title.label }}</label>
<input <input
type="text" type="text"
...@@ -301,6 +301,7 @@ export default { ...@@ -301,6 +301,7 @@ export default {
geom: { geom: {
label: "Localisation", label: "Localisation",
value: null, value: null,
errors: null,
}, },
}, },
}; };
...@@ -317,6 +318,15 @@ export default { ...@@ -317,6 +318,15 @@ export default {
]), ]),
...mapGetters("feature_type", ["feature_type"]), ...mapGetters("feature_type", ["feature_type"]),
field_title(){
if(this.feature_type){
if(this.feature_type.title_optional){
return 'field';
}
}
return 'required field';
},
currentRouteName() { currentRouteName() {
return this.$route.name; return this.$route.name;
}, },
...@@ -471,13 +481,41 @@ export default { ...@@ -471,13 +481,41 @@ export default {
feature_id: this.feature ? this.feature.feature_id : "", feature_id: this.feature ? this.feature.feature_id : "",
}); });
}, },
goBackToProject(message) {
postForm() { this.$router.push({
if (this.form.title.value) { name: "project_detail",
this.form.title.errors = null; params: {
this.$store.dispatch("feature/SEND_FEATURE", this.currentRouteName); slug: this.$store.state.project_slug,
} else { message,
this.form.title.errors = "Veuillez compléter ce champ."; },
});
},
async postForm() {
if (!this.feature_type.title_optional){
if (this.form.title.value && this.form.geom.value) {
this.form.title.errors = null;
await
this.$store.dispatch("feature/SEND_FEATURE")
.then(() => {
this.goBackToProject("Le signalement a été crée");
});
} else {
this.form.title.errors = "Veuillez compléter ce champ.";
this.form.geom.errors = "Veuillez compléter ce champ.";
}
}
else{
if (this.form.geom.value) {
this.form.title.errors = null;
await
this.$store.dispatch("feature/SEND_FEATURE")
.then(() => {
this.goBackToProject("Le signalement a été crée");
});
} else {
this.form.geom.errors = "Veuillez compléter ce champ.";
}
} }
}, },
...@@ -487,7 +525,6 @@ export default { ...@@ -487,7 +525,6 @@ export default {
linestring: "polyline", linestring: "polyline",
polygon: "polygon", polygon: "polygon",
}; };
// console.log(this.feature_type)
var geomType = this.feature_type.geom_type; var geomType = this.feature_type.geom_type;
var drawConfig = { var drawConfig = {
polygon: false, polygon: false,
......
...@@ -71,6 +71,16 @@ ...@@ -71,6 +71,16 @@
<!-- {{ form.color.errors }} --> <!-- {{ form.color.errors }} -->
</div> </div>
</div> </div>
<div class="field">
<div class="ui checkbox">
<input
:name="form.title_optional.html_name"
v-model="form.title_optional.value"
type="checkbox"
/>
<label>{{form.title_optional.label}}</label>
</div>
</div>
<!-- //* s'affiche après sélection d'option de type liste dans type de champ --> <!-- //* s'affiche après sélection d'option de type liste dans type de champ -->
<div <div
...@@ -207,6 +217,13 @@ export default { ...@@ -207,6 +217,13 @@ export default {
html_name: "title", html_name: "title",
value: null, value: null,
}, },
title_optional: {
errors: null,
id_for_label: "title_optional",
html_name: "title_optional",
label: "Titre du signalement optionnel",
value: false,
},
geom_type: { geom_type: {
id_for_label: "geom_type", id_for_label: "geom_type",
label: "Type de géométrie", label: "Type de géométrie",
...@@ -322,6 +339,7 @@ export default { ...@@ -322,6 +339,7 @@ export default {
this.$store.commit("feature_type/UPDATE_FORM", { this.$store.commit("feature_type/UPDATE_FORM", {
color: this.form.color, color: this.form.color,
title: this.form.title, title: this.form.title,
title_optional: this.form.title_optional,
geom_type: this.form.geom_type, geom_type: this.form.geom_type,
colors_style: this.form.colors_style, colors_style: this.form.colors_style,
}); });
......
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