Skip to content

Commit

Permalink
Corrige le pré-remplissage du parc dans l'édition du matériel
Browse files Browse the repository at this point in the history
  • Loading branch information
polosson committed Feb 23, 2021
1 parent b65f92a commit ed2a3c1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 16 additions & 1 deletion client/src/pages/Material/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default {
id: this.$route.params.id || null,
name: '',
reference: '',
park_id: 1,
park_id: '',
category_id: '',
rental_price: showBilling ? '' : 0,
stock_quantity: '',
Expand Down Expand Up @@ -56,6 +56,9 @@ export default {
parksOptions() {
return store.getters['parks/options'];
},
firstPark() {
return store.getters['parks/firstPark'];
},
categoriesOptions() {
return store.getters['categories/options'];
},
Expand All @@ -65,6 +68,12 @@ export default {
store.dispatch('categories/fetch');

this.fetchMaterial();
this.setDefaultPark();
},
watch: {
firstPark() {
this.setDefaultPark();
},
},
methods: {
fetchMaterial() {
Expand All @@ -86,6 +95,12 @@ export default {
.catch(this.displayError);
},

setDefaultPark() {
if (this.material.id === null) {
this.material.park_id = this.firstPark?.id || '';
}
},

fetchAttributes() {
this.extraAttributes = [];

Expand Down
5 changes: 5 additions & 0 deletions client/src/stores/parks.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export default {
);
return park ? park.name : null;
},

firstPark: (state) => {
const [park] = state.list;
return park;
},
},
mutations: {
init(state, data) {
Expand Down

0 comments on commit ed2a3c1

Please sign in to comment.