Skip to content
Snippets Groups Projects
Commit 5d4d8855 authored by leandro's avatar leandro
Browse files

update store feature type

parent 1e6a2824
No related branches found
No related tags found
No related merge requests found
......@@ -217,10 +217,10 @@ export default {
this.$store.commit("feature_type/UPDATE_COLOR_STYLE");
},
},
beforeDestroy(){
this.$store.commit("feature_type/EMPTY_CUSTOM_FORM");
// beforeDestroy(){
// this.$store.commit("feature_type/EMPTY_CUSTOM_FORM");
},
// },
mounted() {
for (let el in this.customForm) {
if (el && this.form[el]) this.form[el].value = this.customForm[el].value;
......
import axios from "axios"
import store from '@/store';
export const RESET = 'RESET';
const feature_type = {
namespaced: true,
state: {
form: {
colors_style: {
value: null,
options: [],
fields: [],
},
color: {
id_for_label: "couleur",
label: "Couleur",
field: {
max_length: 128, // ! Vérifier la valeur dans django
},
html_name: "couleur",
value: "#000000",
const initialState = () => ({
form: {
colors_style: {
value: null,
options: [],
fields: [],
},
color: {
id_for_label: "couleur",
label: "Couleur",
field: {
max_length: 128, // ! Vérifier la valeur dans django
},
title: {
errors: [],
id_for_label: "title",
label: "Titre",
field: {
max_length: 128, // ! Vérifier la valeur dans django
},
html_name: "title",
value: null,
html_name: "couleur",
value: "#000000",
},
title: {
errors: [],
id_for_label: "title",
label: "Titre",
field: {
max_length: 128, // ! Vérifier la valeur dans django
},
geom_type: {
id_for_label: "geom_type",
label: "Type de géométrie",
field: {
choices: ["Ligne", "Point", "Polygone"],
max_length: 128, // ! Vérifier la valeur dans django
},
html_name: "geom_type",
value: "Point",
html_name: "title",
value: null,
},
geom_type: {
id_for_label: "geom_type",
label: "Type de géométrie",
field: {
choices: ["Ligne", "Point", "Polygone"],
max_length: 128, // ! Vérifier la valeur dans django
},
html_name: "geom_type",
value: "Point",
},
colorsStyleList: [],
customForms: [],
current_feature_type_slug: null,
feature_types: [],
},
colorsStyleList: [],
customForms: [],
current_feature_type_slug: null,
feature_types: [],
});
const feature_type = {
namespaced: true,
state: initialState(),
mutations: {
EMPTY_CUSTOM_FORM(state) {
state.customForms = [];
[RESET]: (state) => {
const newState = initialState();
Object.keys(newState).forEach((key) => {
state[key] = newState[key];
});
},
SET_FEATURE_TYPES(state, feature_types) {
state.feature_types = feature_types;
......@@ -83,7 +91,9 @@ const feature_type = {
)
},
actions: {
[RESET]: ({ commit }) => {
commit("RESET_STATE");
},
POST_FEATURE_TYPE({ state }) {
const data = { form: state.form, formset: state.customForms }
console.log("data", data)
......
......@@ -122,7 +122,7 @@
<script>
import frag from "vue-frag";
import { mapGetters, mapState } from "vuex";
import { mapGetters, mapState, mapMutations } from "vuex";
import Dropdown from "@/components/Dropdown.vue";
import FeatureTypeCustomForm from "@/components/feature_type/FeatureTypeCustomForm.vue";
......@@ -183,6 +183,7 @@ export default {
},
},
methods: {
...mapMutations('feature_type', ['RESET']),
definePageType() {
if (this.$router.history.current.name === "ajouter-type-signalement") {
this.action = "create";
......@@ -264,6 +265,10 @@ export default {
}
}
},
beforeDestroy(){
this.RESET();
},
/* checkform() {
let form_idx = $('#id_form-TOTAL_FORMS').val();
for (var i=0; i <= form_idx;i++ ){
......
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