From ba485f87c50075dcdcca1f7e5f3db48f45eba1fa Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 21 Jan 2021 21:07:49 +0100 Subject: [PATCH] Prettier --- src/boot/axios.ts | 3 +-- src/boot/filter.ts | 4 +--- src/boot/login.ts | 19 +++++++------------ src/plugins/balance/plugin.ts | 4 +--- src/plugins/user/store/user.ts | 6 ++---- src/utils/permission.ts | 5 +---- 6 files changed, 13 insertions(+), 28 deletions(-) diff --git a/src/boot/axios.ts b/src/boot/axios.ts index 4742f04..bd631e8 100644 --- a/src/boot/axios.ts +++ b/src/boot/axios.ts @@ -45,8 +45,7 @@ export default boot>(({ Vue, store, router }) => { query: { redirect: router.currentRoute.fullPath } }); } else if (e.response && e.response.status == 401) { - if (router.currentRoute.name !== 'login') - return store.dispatch('session/clearCurrent'); + if (router.currentRoute.name !== 'login') return store.dispatch('session/clearCurrent'); } } return Promise.reject(error); diff --git a/src/boot/filter.ts b/src/boot/filter.ts index 0d97566..f97513a 100644 --- a/src/boot/filter.ts +++ b/src/boot/filter.ts @@ -3,9 +3,7 @@ import { formatDateTime } from 'src/utils/datetime'; export default boot(({ Vue }) => { Vue.filter('date', formatDateTime); - Vue.filter('time', (date: Date, seconds = false) => - formatDateTime(date, false, true, seconds) - ); + Vue.filter('time', (date: Date, seconds = false) => formatDateTime(date, false, true, seconds)); Vue.filter('dateTime', (date: Date, seconds = false, weekday = false) => formatDateTime(date, true, true, seconds, weekday) ); diff --git a/src/boot/login.ts b/src/boot/login.ts index 06e718a..f9c8d61 100644 --- a/src/boot/login.ts +++ b/src/boot/login.ts @@ -24,15 +24,14 @@ export default boot>(({ router, store }) => { // Check if special permissions are required if ( to.matched.every((record: RouteRecord) => { - if (!('meta' in record) || !('permissions' in record.meta)) - return true; + if (!('meta' in record) || !('permissions' in record.meta)) return true; if (record.meta) { if ((<{ permissions: FG.Permission[] }>record.meta).permissions) { - return (<{ permissions: FG.Permission[] }>( - record.meta - )).permissions.every((permission: string) => { - return store.state.user.currentPermissions.includes(permission); - }); + return (<{ permissions: FG.Permission[] }>record.meta).permissions.every( + (permission: string) => { + return store.state.user.currentPermissions.includes(permission); + } + ); } } }) @@ -42,11 +41,7 @@ export default boot>(({ router, store }) => { next({ name: 'login', query: { redirect: to.fullPath } }); } } else { - if ( - to.name == 'login' && - store.state.user.currentUser && - !to.params['logout'] - ) { + if (to.name == 'login' && store.state.user.currentUser && !to.params['logout']) { // Called login while already logged in void next({ name: 'dashboard' }); } else { diff --git a/src/plugins/balance/plugin.ts b/src/plugins/balance/plugin.ts index f84d72c..9dc8353 100644 --- a/src/plugins/balance/plugin.ts +++ b/src/plugins/balance/plugin.ts @@ -10,9 +10,7 @@ const plugin: FG_Plugin.Plugin = { requiredModules: ['User'], requiredBackendModules: ['balance'], version: '0.0.1', - store: new Map>([ - ['balance', balance] - ]), + store: new Map>([['balance', balance]]), widgets: [ { priority: 0, diff --git a/src/plugins/user/store/user.ts b/src/plugins/user/store/user.ts index 3c813f4..8f1e785 100644 --- a/src/plugins/user/store/user.ts +++ b/src/plugins/user/store/user.ts @@ -25,15 +25,13 @@ const state: UserStateInterface = { roles: [], permissions: [], currentUser: loadUserFromLocalStorage(), - currentPermissions: - SessionStorage.getItem('currentPermissions') || [], + currentPermissions: SessionStorage.getItem('currentPermissions') || [], loading: 0 }; const mutations: MutationTree = { setCurrentUser(state, data: FG.User) { - if (typeof data.birthday === 'string') - data.birthday = new Date(data.birthday); + if (typeof data.birthday === 'string') data.birthday = new Date(data.birthday); SessionStorage.set('currentUser', data); state.currentUser = data; }, diff --git a/src/utils/permission.ts b/src/utils/permission.ts index f005ab7..763ca2a 100644 --- a/src/utils/permission.ts +++ b/src/utils/permission.ts @@ -1,10 +1,7 @@ import { Store } from 'vuex'; import { StateInterface } from 'src/store'; -export function hasPermission( - permission: string, - store: Store -) { +export function hasPermission(permission: string, store: Store) { return store.state.user.currentPermissions.includes(permission); }