From d5dca84bae581ede92665f05e10ba9d110db991f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimund=20Schl=C3=BC=C3=9Fler?= Date: Mon, 19 Sep 2022 15:55:20 +0200 Subject: Move search logic into App component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raimund Schlüßler --- src/App.vue | 26 +++++++++++++++++++++++++- src/main.js | 29 ----------------------------- 2 files changed, 25 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/App.vue b/src/App.vue index 6e043a97..5ccb4521 100644 --- a/src/App.vue +++ b/src/App.vue @@ -35,7 +35,7 @@ License along with this library. If not, see . import AppNavigation from './views/AppNavigation.vue' import client from './services/cdav.js' -import { emit } from '@nextcloud/event-bus' +import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus' import { translate as t } from '@nextcloud/l10n' import NcAppContent from '@nextcloud/vue/dist/Components/NcAppContent.js' import NcContent from '@nextcloud/vue/dist/Components/NcContent.js' @@ -49,12 +49,27 @@ export default { NcAppContent, NcContent, }, + data() { + return { + searchString: '', + } + }, computed: { ...mapGetters({ calendars: 'getTaskCalendars', }), }, + mounted() { + subscribe('nextcloud:unified-search.search', this.filterProxy) + subscribe('nextcloud:unified-search.reset', this.cleanSearch) + }, + beforeUnmount() { + unsubscribe('nextcloud:unified-search.search', this.filterProxy) + unsubscribe('nextcloud:unified-search.reset', this.cleanSearch) + }, async beforeMount() { + this.$store.dispatch('loadCollections') + this.$store.dispatch('loadSettings') // get calendars then get tasks await client.connect({ enableCalDAV: true }) await this.$store.dispatch('fetchCurrentUserPrincipal') @@ -105,6 +120,15 @@ export default { emit('tasks:close-appsidebar') } }, + filterProxy({ query }) { + this.filter(query) + }, + filter(query) { + this.$store.commit('setSearchQuery', query) + }, + cleanSearch() { + this.$store.commit('setSearchQuery', '') + }, }, } diff --git a/src/main.js b/src/main.js index b9968c5f..640a07c5 100644 --- a/src/main.js +++ b/src/main.js @@ -25,7 +25,6 @@ import App from './App.vue' import router from './router.js' import store from './store/store.js' -import { subscribe, unsubscribe } from '@nextcloud/event-bus' import { linkTo } from '@nextcloud/router' import AlertBoxOutline from 'vue-material-design-icons/AlertBoxOutline.vue' @@ -104,33 +103,5 @@ OCA.Tasks.App = new Vue({ el: '.app-tasks', router, store, - data() { - return { - searchString: '', - } - }, - mounted() { - subscribe('nextcloud:unified-search.search', this.filterProxy) - subscribe('nextcloud:unified-search.reset', this.cleanSearch) - }, - beforeMount() { - this.$store.dispatch('loadCollections') - this.$store.dispatch('loadSettings') - }, - beforeDestroy() { - unsubscribe('nextcloud:unified-search.search', this.filterProxy) - unsubscribe('nextcloud:unified-search.reset', this.cleanSearch) - }, - methods: { - filterProxy({ query }) { - this.filter(query) - }, - filter(query) { - this.$store.commit('setSearchQuery', query) - }, - cleanSearch() { - this.$store.commit('setSearchQuery', '') - }, - }, render: h => h(App), }) -- cgit v1.2.3