diff options
author | Raimund Schlüßler <raimund.schluessler@mailbox.org> | 2022-09-19 16:55:20 +0300 |
---|---|---|
committer | Raimund Schlüßler <raimund.schluessler@mailbox.org> | 2022-09-19 17:14:58 +0300 |
commit | d5dca84bae581ede92665f05e10ba9d110db991f (patch) | |
tree | c12ad7937adeaf13f3b5ebb3b533b88724fbf3c6 /src | |
parent | c0d0ae9765fa37deb48098574cf9bcba88d20e72 (diff) |
Move search logic into App component
Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/App.vue | 26 | ||||
-rw-r--r-- | src/main.js | 29 |
2 files changed, 25 insertions, 30 deletions
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 <http://www.gnu.org/licenses/>. 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', '') + }, }, } </script> 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), }) |