From 0c84bcd7383d1afdd371f09b7c1221918f6d9a8b Mon Sep 17 00:00:00 2001 From: tykayn Date: Fri, 29 Jan 2021 12:59:44 +0100 Subject: [PATCH] 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; }, }