Skip to content

Commit

Permalink
[UPDATE] Front: especie - obtém lista famílias no formulário de ediçã…
Browse files Browse the repository at this point in the history
…o da espécie #15
  • Loading branch information
fernao committed Jul 21, 2019
1 parent 17c7501 commit 7eaf3eb
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
10 changes: 8 additions & 2 deletions front/src/modules/especie/components/FormEditarEspecie.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
{{ textoCabecalho }}
</div>
</v-card-title>
<v-text-field
<v-select
v-model="dadosEspecie.familia"
:items="getFamilias"
item-text="nome"
item-value="id"
label="Família"
@change="atualizarCampo('familia', $event) "
/>
Expand Down Expand Up @@ -155,6 +158,7 @@ export default {
...mapGetters({
dadosEspecie: 'especie/especie',
dadosEspecieMetadata: 'especie/getEspecieMetadata',
getFamilias: 'especie/getFamilias',
}),
},
watch: {
Expand All @@ -164,11 +168,13 @@ export default {
},
created() {
this.inicializarDadosEspecie();
this.buscarFamilias();
},
methods: {
...mapActions({
adicionarEspecie: 'especie/adicionarEspecie',
updateEspecie: 'especie/updateEspecie',
buscarFamilias: 'especie/buscarFamilias',
}),
inicializarDadosEspecie() {
this.dadosEditados = {
Expand Down Expand Up @@ -203,5 +209,5 @@ export default {
}
},
},
};
};
</script>
8 changes: 8 additions & 0 deletions front/src/modules/especie/store/actions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as especieHelperAPI from '@/helpers/api/Especie';
import * as familiaHelperAPI from '@/helpers/api/Familia';
import * as types from './types';

export const buscarEspecies = ({ commit }) => {
Expand Down Expand Up @@ -39,3 +40,10 @@ export const adicionarEspecie = async ({ commit }, params) => {
});
return resultado;
};

export const buscarFamilias = ({ commit }, params) => {
familiaHelperAPI.buscarFamilias(params)
.then((response) => {
commit(types.SET_FAMILIAS, response.data);
});
};
1 change: 1 addition & 0 deletions front/src/modules/especie/store/getters.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const especies = state => state.especies;
export const especie = state => state.especie;
export const getEspecieMetadata = state => state.getEspecieMetadata;
export const getFamilias = state => state.familias;
7 changes: 7 additions & 0 deletions front/src/modules/especie/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const state = {
especies: {},
especie: {},
getEspecieMetadata: {},
familias: {},
};

export const mutations = {
Expand All @@ -22,4 +23,10 @@ export const mutations = {
[types.UPDATE_ESPECIE](state, data) {
state.especie = data;
},
[types.SET_FAMILIAS](state,data) {
state.familias = data;
},
[types.GET_FAMILIAS](state,data) {
state.familias = data;
},
};
2 changes: 2 additions & 0 deletions front/src/modules/especie/store/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export const SET_ESPECIE = 'SET_ESPECIE';
export const SET_ESPECIE_METADATA = 'SET_ESPECIE_METADATA';
export const GET_ESPECIE_METADATA = 'GET_ESPECIE_METADATA';
export const UPDATE_ESPECIE = 'UPDATE_ESPECIE';
export const SET_FAMILIAS = 'SET_FAMILIAS';
export const GET_FAMIIAS = 'GET_FAMILIAS';
2 changes: 1 addition & 1 deletion front/src/modules/especie/views/ListarEspecies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
v-slot:items="props"
>
<td>{{ props.index + 1 }}</td>
<td>
<td class="text-xs-left">
<v-btn
flat
small
Expand Down

0 comments on commit 7eaf3eb

Please sign in to comment.