Skip to content

Commit 5d0d8e4

Browse files
committed
Showing options in type data and granularity
1 parent d2977a8 commit 5d0d8e4

File tree

5 files changed

+39
-18
lines changed

5 files changed

+39
-18
lines changed

src/common.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ export const formatToApi = ({
99
if (form) {
1010
for (let formField in form) {
1111
switch (formField) {
12-
case "types":
1312
case "local":
14-
case "granuralities":
1513
if (form[formField] && form[formField].length) {
1614
routerResult[formField] = form[formField];
1715
}
1816
break;
19-
case "periodStart":
2017
case "periodEnd":
18+
case "periodStart":
2119
if (form[formField]) {
2220
routerResult[formField] = formatDate(form[formField]);
2321
}
2422
break;
2523
case "locals":
2624
case "sicksImmunizers":
25+
case "types":
26+
case "granularities":
2727
// Do Nothing
2828
break;
2929
default:

src/components/main-card.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ export const mainCard = {
4949
"periods",
5050
"periodStart",
5151
"periodEnd",
52-
"granurality",
53-
"granuralities"
52+
"granularity",
53+
"granularities"
5454
],
5555
base: "form",
5656
mutation: "UPDATE_FORM"
@@ -133,7 +133,7 @@ export const mainCard = {
133133
store.state.form.period,
134134
store.state.form.periodStart,
135135
store.state.form.periodEnd,
136-
store.state.form.granurality,
136+
store.state.form.granularity,
137137
store.state.tab,
138138
store.state.tabBy
139139
],
@@ -147,6 +147,8 @@ export const mainCard = {
147147
await store.dispatch("updateSicksImmunizers", "sicks")
148148
// Set locals options
149149
store.dispatch("updateLocals", "sicks")
150+
store.dispatch("updateTypes")
151+
store.dispatch("updateGranularities")
150152

151153
// TODO: How years range will work
152154
// TODO: Get states from API

src/components/sub-select.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,10 @@ export const subSelect = {
150150
</n-form-item>
151151
<n-form-item label="Tipo de dado">
152152
<n-select
153-
v-model="type"
153+
v-model:value="type"
154154
:options="types"
155155
style="width: 200px"
156156
placeholder="Selecione Tipo de dado"
157-
multiple
158-
disabled
159157
/>
160158
</n-form-item>
161159
<n-form-item label="Estados">
@@ -201,8 +199,6 @@ export const subSelect = {
201199
:options="granularities"
202200
style="width: 200px"
203201
placeholder="Selecione Granularidade"
204-
multiple
205-
disabled
206202
/>
207203
</n-form-item>
208204
</section>

src/exampleData.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
export const types = [
2+
{ label: 'Cobertura', value: 'Cobertura' },
3+
{ label: 'Abandono', value: 'Abandono' },
4+
{ label: 'Homogeneidade', value: 'Homogeneidade' }
5+
];
6+
7+
export const granularities = [
8+
{ label: 'Municípios', value: 'Municípios' },
9+
{ label: 'Região de saúde', value: 'Região de saúde' },
10+
];
11+
112
export const ufs = [
213
{ label: 'AC', value: 'AC' },
314
{ label: 'AL', value: 'AL' },
@@ -26,5 +37,5 @@ export const ufs = [
2637
{ label: 'SP', value: 'SP' },
2738
{ label: 'SE', value: 'SE' },
2839
{ label: 'TO', value: 'TO' }
29-
]
40+
];
3041

src/store.js

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createStore } from "vuex";
22
import { timestampToYear } from "./utils";
33
import { DataFetcher } from "./data-fetcher";
4-
import { ufs } from "./exampleData";
4+
import { ufs, types, granularities } from "./exampleData";
55

66
const getDefaultState = () => {
77
return {
@@ -19,8 +19,8 @@ const getDefaultState = () => {
1919
periods: null,
2020
periodStart: null,
2121
periodEnd: null,
22-
granurality: null,
23-
granuralities: [],
22+
granularity: null,
23+
granularities: [],
2424
}
2525
}
2626
}
@@ -38,11 +38,23 @@ export default createStore({
3838
const result = await api.request("options");
3939
commit("UPDATE_FORM_SICKSIMMUNIZERS", result[type].map(x => { return { label: x, value: x } }));
4040
},
41+
updateTypes(
42+
{ commit }
43+
) {
44+
let t = types.map(x => x.label).sort();
45+
commit("UPDATE_FORM_OPTIONS", { types: t.map((x) => { return { label: x, value: x } }) });
46+
},
47+
updateGranularities(
48+
{ commit }
49+
) {
50+
let g = granularities.map(x => x.label).sort();
51+
commit("UPDATE_FORM_OPTIONS", { granularities: g.map((x) => { return { label: x, value: x } })});
52+
},
4153
updateLocals(
4254
{ commit }
4355
) {
4456
let locals = ufs.map(x => x.label).sort();
45-
commit("UPDATE_FORM_LOCALS", locals.map((local) => { return { label: local, value: local } }));
57+
commit("UPDATE_FORM_OPTIONS", { locals: locals.map((x) => { return { label: x, value: x } })});
4658
},
4759
async requestBySick(
4860
{ state },
@@ -67,8 +79,8 @@ export default createStore({
6779
state.form.sicksImmunizers = payload;
6880
state.form.sickImmunizer = null;
6981
},
70-
UPDATE_FORM_LOCALS(state, payload) {
71-
state.form.locals = payload;
82+
UPDATE_FORM_OPTIONS(state, payload) {
83+
state.form[Object.keys(payload)[0]] = Object.values(payload)[0];
7284
},
7385
UPDATE_TAB(state, payload) {
7486
state.tab = Object.values(payload)[0];

0 commit comments

Comments
 (0)