From 1a4260c522bb8bf11c0a7b3033ecd1cd1711f43c Mon Sep 17 00:00:00 2001 From: Tim Eder <tim.eder@ufz.de> Date: Tue, 3 May 2022 14:14:30 +0200 Subject: [PATCH] unified eports in store --- store/appbar.ts | 13 ++++++++++--- store/contacts.ts | 18 ++++++++++++++---- store/files.ts | 1 + store/snackbar.ts | 10 ++++++++-- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/store/appbar.ts b/store/appbar.ts index 0f32913ce..9bc9cccfc 100644 --- a/store/appbar.ts +++ b/store/appbar.ts @@ -47,7 +47,7 @@ export interface IAppbarStore { * * @return {IAppbarStore} the state object */ -export const state = (): IAppbarStore => { +const state = (): IAppbarStore => { return { activeTab: null, cancelBtnDisabled: false, @@ -59,7 +59,7 @@ export const state = (): IAppbarStore => { } } -export const mutations = { +const mutations = { /** * Sets the title of the AppBar * @@ -141,7 +141,7 @@ type StoreContext = { dispatch: (action: string, payload: any) => void } -export const actions = { +const actions = { /** * initializes the Appbar * @@ -452,3 +452,10 @@ export const actions = { context.dispatch('init', state()) } } + +export default { + namespaced: true, + state, + actions, + mutations +} diff --git a/store/contacts.ts b/store/contacts.ts index 697771653..0562c563e 100644 --- a/store/contacts.ts +++ b/store/contacts.ts @@ -46,7 +46,7 @@ interface contactsState { totalPages: number } -export const state = () => ({ +const state = () => ({ contacts: [], contact: null, configurationContacts: [], @@ -54,7 +54,8 @@ export const state = () => ({ pageNumber: 1, pageSize: 20 }) -export const getters = { + +const getters = { searchContacts: (state: contactsState) => { return state.contacts.filter((c: Contact) => !state.configurationContacts.find((rc: Contact) => rc.id === c.id)) }, @@ -68,7 +69,7 @@ export const getters = { } // @ts-ignore -export const actions: { +const actions: { [key: string]: any; $api: Api } = { @@ -126,7 +127,8 @@ export const actions: { return this.$api.contacts.save(contact) } } -export const mutations = { + +const mutations = { setContacts (state: contactsState, contacts: Contact[]) { state.contacts = contacts }, @@ -143,3 +145,11 @@ export const mutations = { state.totalPages = count } } + +export default { + namespaced: true, + state, + getters, + actions, + mutations +} diff --git a/store/files.ts b/store/files.ts index 02e759d71..1b109dd91 100644 --- a/store/files.ts +++ b/store/files.ts @@ -33,6 +33,7 @@ import { Commit } from 'vuex' import { IUploadResult } from '@/services/sms/UploadApi' import { Api } from '@/services/Api' + const state = () => ({}) const getters = {} diff --git a/store/snackbar.ts b/store/snackbar.ts index 92abc39b0..0a2ad298e 100644 --- a/store/snackbar.ts +++ b/store/snackbar.ts @@ -34,14 +34,14 @@ export interface ISnackbarStore { success: string } -export const state = () => { +const state = () => { return { error: '', success: '' } } -export const mutations = { +const mutations = { setError (state: ISnackbarStore, error: string) { state.error = error }, @@ -55,3 +55,9 @@ export const mutations = { state.success = '' } } + +export default { + namespaced: true, + state, + mutations +} -- GitLab