From e196f1c60a0427f3b18506c4479191e1ccfae30c Mon Sep 17 00:00:00 2001 From: tykayn Date: Thu, 28 Jan 2021 13:12:24 +0100 Subject: [PATCH 1/2] up store --- nuxt.config.js | 2 +- pages/Horaires.vue | 11 +++++------ store/{index.ts => index.js} | 12 ++++++------ 3 files changed, 12 insertions(+), 13 deletions(-) rename store/{index.ts => index.js} (73%) diff --git a/nuxt.config.js b/nuxt.config.js index 83a2a1b..aa86896 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -1,4 +1,4 @@ -import i18n from './config/i18n' +import i18n from './config/i18n.ts' export default { // Global page headers (https://go.nuxtjs.dev/config-head) diff --git a/pages/Horaires.vue b/pages/Horaires.vue index b64013f..3f68917 100644 --- a/pages/Horaires.vue +++ b/pages/Horaires.vue @@ -2,11 +2,10 @@

Horaires

Vos horaires actuelles

- +
diff --git a/store/index.ts b/store/index.js similarity index 73% rename from store/index.ts rename to store/index.js index 893d863..7c54ea3 100644 --- a/store/index.ts +++ b/store/index.js @@ -10,28 +10,28 @@ export const state = () => ({ formConfig: { name: '', delivery: false, - hours: [], + hours: ['a', 'b'], tags: [], }, }) export const mutations = { - increment(state: any) { + increment(state) { state.counter++ }, - add(state: any, text: any) { + add(state, text) { state.list.push({ text, done: false, }) }, - remove(state: any, { todo }: any) { + remove(state, { todo }) { state.list.splice(state.list.indexOf(todo), 1) }, - setFormField(state: any, { field }: any) { + setFormField(state, { field }) { state.formConfig[state.formConfig.indexOf(field)] = field }, - setTag(state: any, { field }: any) { + setTag(state, { field }) { state.formConfig.tags[state.formConfig.tags.indexOf(field)] = field }, } From 0c84bcd7383d1afdd371f09b7c1221918f6d9a8b Mon Sep 17 00:00:00 2001 From: tykayn Date: Fri, 29 Jan 2021 12:59:44 +0100 Subject: [PATCH 2/2] start using vuex, split tag list in other component --- components/SearchInput.vue | 237 +++++++++++++------------------------ components/TagTable.vue | 115 ++++++++++++++++++ pages/Horaires.vue | 43 +++++-- store/example.js | 18 +++ store/index.js | 41 +++++-- 5 files changed, 276 insertions(+), 178 deletions(-) create mode 100644 components/TagTable.vue create mode 100644 store/example.js diff --git a/components/SearchInput.vue b/components/SearchInput.vue index 6197cc7..7c7f28b 100644 --- a/components/SearchInput.vue +++ b/components/SearchInput.vue @@ -17,8 +17,8 @@ -

Tags de data.elements[0]

-
- elements: {{ data.elements.length }} - - - - - - - - - - - - - - - - - - Vente à emporter - - - Parking vélo - - - Accès Internet - - - borne de recharge électrique sur parking - - - Accès autorisé au public - - - -

Horaires d'ouverture

-
- {{ data.elements[0].tags.opening_hours }} -
- - -
- -
-
-

Comparaison des tags

- - - - - - - - - - - - - -
API OSMAPI addok
- - - - - - - - - - - -
-
-
- {{ name }} -
-
{{ value }}
-
-
-
-
-
-
+    
+

+ Debug info +

+
       select.properties:
       {{ select }}
-    
-
-      data:
-      {{ data }}
-    
-
-      osm_data:
-      {{ osm_data }}
-    
+
+
+      fetchedData OSM:
+      {{ fetchedData.osm_data }}
+    
+ + - diff --git a/components/TagTable.vue b/components/TagTable.vue new file mode 100644 index 0000000..f841e6c --- /dev/null +++ b/components/TagTable.vue @@ -0,0 +1,115 @@ + diff --git a/pages/Horaires.vue b/pages/Horaires.vue index 3f68917..1cb80ae 100644 --- a/pages/Horaires.vue +++ b/pages/Horaires.vue @@ -1,11 +1,34 @@ - + + diff --git a/store/example.js b/store/example.js new file mode 100644 index 0000000..0999c4f --- /dev/null +++ b/store/example.js @@ -0,0 +1,18 @@ +export const state = () => ({ + list: [], +}); + +export const mutations = { + add(state, text) { + state.list.push({ + text, + done: false, + }); + }, + remove(state, { todo }) { + state.list.splice(state.list.indexOf(todo), 1); + }, + toggle(state, todo) { + todo.done = !todo.done; + }, +}; diff --git a/store/index.js b/store/index.js index 7c54ea3..09bce29 100644 --- a/store/index.js +++ b/store/index.js @@ -2,16 +2,20 @@ * see VueX docs */ export const state = () => ({ - counter: 0, - isFetching: false, - searchInput: '', + counter : 0, + isFetching : false, + searchInput : 'librairie interlignes', selectedResult: null, - list: [], - formConfig: { - name: '', + fetchedData : { + osm_data : '', + addok_data: '', + }, + list : [], + formConfig : { + name : '', delivery: false, - hours: ['a', 'b'], - tags: [], + hours : ['a', 'b'], + tags : [], }, }) @@ -26,12 +30,27 @@ export const mutations = { }) }, remove(state, { todo }) { - state.list.splice(state.list.indexOf(todo), 1) + state.list.splice(state.list.indexOf(todo), 1); }, setFormField(state, { field }) { - state.formConfig[state.formConfig.indexOf(field)] = field + state.formConfig[state.formConfig.indexOf(field)] = field; + }, + setFetchedDataOsm(state, { data }) { + state.fetchedData.osm_data = data; + }, + setFetchedDataAddok(state, { data }) { + state.fetchedData.addok_data = data; }, setTag(state, { field }) { - state.formConfig.tags[state.formConfig.tags.indexOf(field)] = field + state.formConfig.tags[state.formConfig.tags.indexOf(field)] = field; + }, + setSelectedResult(state, { data }) { + state.selectedResult = data; + }, + setFetching(state, { data }) { + state.isFetching = data; + }, + setAllTag(state, { tags }) { + state.formConfig.tags = tags; }, }