From 865bb1f30a0c4567522525fb0be9fd99bd796ecf Mon Sep 17 00:00:00 2001 From: Mateja Date: Sat, 13 Mar 2021 17:56:37 +0100 Subject: Adding boilerplate code. --- resources/js/app.js | 20 ++++++++++++++++++++ resources/js/bootstrap.js | 2 ++ resources/js/components/activities.vue | 9 +++++++++ resources/js/components/call-sign-description.vue | 9 +++++++++ resources/js/components/call-sign-filter.vue | 9 +++++++++ resources/js/components/reservation.vue | 9 +++++++++ resources/js/components/reservations.vue | 9 +++++++++ resources/js/store.js | 15 +++++++++++++++ 8 files changed, 82 insertions(+) create mode 100644 resources/js/components/activities.vue create mode 100644 resources/js/components/call-sign-description.vue create mode 100644 resources/js/components/call-sign-filter.vue create mode 100644 resources/js/components/reservation.vue create mode 100644 resources/js/components/reservations.vue create mode 100644 resources/js/store.js (limited to 'resources/js') diff --git a/resources/js/app.js b/resources/js/app.js index 40c55f6..6c325fa 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -1 +1,21 @@ require('./bootstrap'); + +//import store from './store.js'; +require('./store'); + +import callSignDesc from './components/call-sign-description.vue'; +import callSignFilter from './components/call-sign-filter.vue'; +import activities from './components/activities.vue'; +import reservation from './components/reservation.vue'; +import reservations from './components/reservations.vue'; + +new Vue({ + el: '#vue', + components: { + callSignDesc, + callSignFilter, + activities, + reservation, + reservations + } +}); diff --git a/resources/js/bootstrap.js b/resources/js/bootstrap.js index ffc0a2b..c3456b8 100644 --- a/resources/js/bootstrap.js +++ b/resources/js/bootstrap.js @@ -4,6 +4,8 @@ window.axios = require('axios'); window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; window.Vue = require('vue'); +window.Vuex = require('vuex'); +Vue.use(Vuex); window.$ = window.jQuery = require('jquery'); window.Popper = require('popper.js'); diff --git a/resources/js/components/activities.vue b/resources/js/components/activities.vue new file mode 100644 index 0000000..48e54f5 --- /dev/null +++ b/resources/js/components/activities.vue @@ -0,0 +1,9 @@ + + + diff --git a/resources/js/components/call-sign-description.vue b/resources/js/components/call-sign-description.vue new file mode 100644 index 0000000..48e54f5 --- /dev/null +++ b/resources/js/components/call-sign-description.vue @@ -0,0 +1,9 @@ + + + diff --git a/resources/js/components/call-sign-filter.vue b/resources/js/components/call-sign-filter.vue new file mode 100644 index 0000000..48e54f5 --- /dev/null +++ b/resources/js/components/call-sign-filter.vue @@ -0,0 +1,9 @@ + + + diff --git a/resources/js/components/reservation.vue b/resources/js/components/reservation.vue new file mode 100644 index 0000000..48e54f5 --- /dev/null +++ b/resources/js/components/reservation.vue @@ -0,0 +1,9 @@ + + + diff --git a/resources/js/components/reservations.vue b/resources/js/components/reservations.vue new file mode 100644 index 0000000..48e54f5 --- /dev/null +++ b/resources/js/components/reservations.vue @@ -0,0 +1,9 @@ + + + diff --git a/resources/js/store.js b/resources/js/store.js new file mode 100644 index 0000000..e9249cc --- /dev/null +++ b/resources/js/store.js @@ -0,0 +1,15 @@ +const store = new Vuex.Store({ + state: { + callSign: "all", + data: [] + }, + getters: { + + }, + mutations: { + + }, + actions: { + + } +}); -- cgit v1.2.3 From 2e570c76bda80def3e07ecc3478d8eb95905acbb Mon Sep 17 00:00:00 2001 From: Mateja Date: Sat, 13 Mar 2021 23:57:41 +0100 Subject: Work on call-sign-filter component. --- resources/js/app.js | 13 ++++++++++--- resources/js/bootstrap.js | 10 +++++++--- resources/js/components/call-sign-filter.vue | 22 ++++++++++++++++++++-- resources/js/store.js | 25 +++++++++++++++++++++---- 4 files changed, 58 insertions(+), 12 deletions(-) (limited to 'resources/js') diff --git a/resources/js/app.js b/resources/js/app.js index 6c325fa..360abf8 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -1,16 +1,23 @@ require('./bootstrap'); -//import store from './store.js'; -require('./store'); +import Vue from 'vue'; + +import store from './store.js'; + +//window.Vue = require('vue'); +//window.Vuex = require('vuex'); +//Vue.use(Vuex); -import callSignDesc from './components/call-sign-description.vue'; import callSignFilter from './components/call-sign-filter.vue'; +import callSignDesc from './components/call-sign-description.vue'; + import activities from './components/activities.vue'; import reservation from './components/reservation.vue'; import reservations from './components/reservations.vue'; new Vue({ el: '#vue', + store, components: { callSignDesc, callSignFilter, diff --git a/resources/js/bootstrap.js b/resources/js/bootstrap.js index c3456b8..e5e0ab6 100644 --- a/resources/js/bootstrap.js +++ b/resources/js/bootstrap.js @@ -3,9 +3,13 @@ window._ = require('lodash'); window.axios = require('axios'); window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; -window.Vue = require('vue'); -window.Vuex = require('vuex'); -Vue.use(Vuex); +let token = document.querySelector('meta[name="csrf-token"]'); + +if (token) { + window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; +} else { + console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); +} window.$ = window.jQuery = require('jquery'); window.Popper = require('popper.js'); diff --git a/resources/js/components/call-sign-filter.vue b/resources/js/components/call-sign-filter.vue index 48e54f5..9ad202d 100644 --- a/resources/js/components/call-sign-filter.vue +++ b/resources/js/components/call-sign-filter.vue @@ -1,9 +1,27 @@ diff --git a/resources/js/store.js b/resources/js/store.js index e9249cc..7f5f1df 100644 --- a/resources/js/store.js +++ b/resources/js/store.js @@ -1,15 +1,32 @@ +import Vue from 'vue'; +import Vuex from 'vuex'; +Vue.use(Vuex); + const store = new Vuex.Store({ state: { - callSign: "all", + selectedSign: "all", + callSigns: [], data: [] }, getters: { - + getSelectedSign(state) { + return state.selectedSign; + }, + getSigns(state) { + return state.callSigns; + } }, mutations: { - + fillSigns(state, signs) { + state.callSigns = signs; + } }, actions: { - + getSigns(context) { + let data = ['test', 'TEST', 'TeSt']; + context.commit('fillSigns', data); + } } }); + +export default store; -- cgit v1.2.3 From c3a0c1a40262343e1c7e6ec9a0bba9772054ba6d Mon Sep 17 00:00:00 2001 From: Mateja Date: Sun, 14 Mar 2021 01:13:32 +0100 Subject: Use computed setter in call-sign-filter component. --- resources/js/components/call-sign-filter.vue | 18 ++++++++++-------- resources/js/store.js | 8 +++++++- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'resources/js') diff --git a/resources/js/components/call-sign-filter.vue b/resources/js/components/call-sign-filter.vue index 9ad202d..658b0d2 100644 --- a/resources/js/components/call-sign-filter.vue +++ b/resources/js/components/call-sign-filter.vue @@ -9,18 +9,20 @@ import store from '../store.js'; export default { - data() { - return { - selected: store.state.selectedSign, - //options: store.state.callSigns - } - }, mounted() { - store.dispatch('getSigns'); + store.dispatch('fillSigns'); }, computed: { + selected: { + get() { + return store.getters.getSelectedSign; + }, + set(value) { + store.dispatch('setSelectedSign', value); + } + }, options() { - return store.state.callSigns; + return store.getters.getSigns; } } } diff --git a/resources/js/store.js b/resources/js/store.js index 7f5f1df..33b7469 100644 --- a/resources/js/store.js +++ b/resources/js/store.js @@ -17,12 +17,18 @@ const store = new Vuex.Store({ } }, mutations: { + setSelectedSign(state, sign) { + state.selectedSign = sign; + }, fillSigns(state, signs) { state.callSigns = signs; } }, actions: { - getSigns(context) { + setSelectedSign(context, sign) { + context.commit('setSelectedSign', sign); + }, + fillSigns(context) { let data = ['test', 'TEST', 'TeSt']; context.commit('fillSigns', data); } -- cgit v1.2.3 From 00abd5229c63b570af751406fc322e197c4f51c0 Mon Sep 17 00:00:00 2001 From: Mateja Date: Sun, 14 Mar 2021 14:04:28 +0100 Subject: Better import/export. --- resources/js/app.js | 4 ---- resources/js/components/call-sign-filter.vue | 10 ++++------ resources/js/store.js | 4 +--- 3 files changed, 5 insertions(+), 13 deletions(-) (limited to 'resources/js') diff --git a/resources/js/app.js b/resources/js/app.js index 360abf8..efea4b1 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -4,10 +4,6 @@ import Vue from 'vue'; import store from './store.js'; -//window.Vue = require('vue'); -//window.Vuex = require('vuex'); -//Vue.use(Vuex); - import callSignFilter from './components/call-sign-filter.vue'; import callSignDesc from './components/call-sign-description.vue'; diff --git a/resources/js/components/call-sign-filter.vue b/resources/js/components/call-sign-filter.vue index 658b0d2..07d339d 100644 --- a/resources/js/components/call-sign-filter.vue +++ b/resources/js/components/call-sign-filter.vue @@ -6,23 +6,21 @@ diff --git a/resources/js/store.js b/resources/js/store.js index 6ec3711..669f0bc 100644 --- a/resources/js/store.js +++ b/resources/js/store.js @@ -28,8 +28,8 @@ export default new Vuex.Store({ setSelectedSign(context, sign) { context.commit('setSelectedSign', sign); }, - fillSigns(context) { - axios.get('/special-calls/show').then(response => { + async fillSigns(context) { + await axios.get('/special-calls/show').then(response => { context.commit('fillSigns', response.data); }).catch(error => { console.log(error); -- cgit v1.2.3 From 682803b3a6d39f00aaf64499e1226859e6fda801 Mon Sep 17 00:00:00 2001 From: Mateja Date: Sun, 14 Mar 2021 19:53:12 +0100 Subject: Add label to `call-sign-filter` component. --- resources/js/components/call-sign-filter.vue | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'resources/js') diff --git a/resources/js/components/call-sign-filter.vue b/resources/js/components/call-sign-filter.vue index a19b8a6..8e3228c 100644 --- a/resources/js/components/call-sign-filter.vue +++ b/resources/js/components/call-sign-filter.vue @@ -1,8 +1,11 @@ -- cgit v1.2.3 From 5d79c586b963b1249eb148816a70d1cec618511f Mon Sep 17 00:00:00 2001 From: Mateja Date: Sun, 14 Mar 2021 21:38:01 +0100 Subject: Work on `activities` component. It currently doesn't update on filter change. --- resources/js/components/activities.vue | 26 ++++++++++++++++++++++++-- resources/js/components/call-sign-filter.vue | 1 + resources/js/store.js | 13 +++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) (limited to 'resources/js') diff --git a/resources/js/components/activities.vue b/resources/js/components/activities.vue index 976516f..01e7002 100644 --- a/resources/js/components/activities.vue +++ b/resources/js/components/activities.vue @@ -1,5 +1,5 @@ -- cgit v1.2.3 From 4e6fa681c3f8f01a44a3446f80524842a4f42274 Mon Sep 17 00:00:00 2001 From: Mateja Date: Mon, 15 Mar 2021 23:12:32 +0100 Subject: Update activities on filter change. I had to use kebab-case for event and listen directly on child component. --- resources/js/components/activities.vue | 4 ++-- resources/js/components/call-sign-filter.vue | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'resources/js') diff --git a/resources/js/components/activities.vue b/resources/js/components/activities.vue index 928bae6..2f2cf03 100644 --- a/resources/js/components/activities.vue +++ b/resources/js/components/activities.vue @@ -1,6 +1,6 @@ + + -- cgit v1.2.3 From 074bff2e79d91610a936f329ac8f603049c3b334 Mon Sep 17 00:00:00 2001 From: Mateja Date: Thu, 18 Mar 2021 19:37:53 +0100 Subject: Better styling for `reservation.vue` component. --- resources/js/components/reservation.vue | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'resources/js') diff --git a/resources/js/components/reservation.vue b/resources/js/components/reservation.vue index fbb5fdc..85348bd 100644 --- a/resources/js/components/reservation.vue +++ b/resources/js/components/reservation.vue @@ -1,20 +1,18 @@