chore: add eslint and fix lint errors

This commit is contained in:
2020-01-25 14:59:14 +01:00
parent e6c87e2f46
commit ef2015f012
36 changed files with 1645 additions and 917 deletions
+22 -22
View File
@@ -2,7 +2,7 @@
<v-flex xs12 sm6 md4 lg3>
<v-card>
<v-card-title>
<span v-text="$tc(title, model.length)"/>
<span v-text="$tc(title, model.length)" />
</v-card-title>
<v-list>
<v-list-item v-for="item in model" :key="item">
@@ -11,10 +11,10 @@
<template v-slot:activator="{ on }">
<v-icon v-on="on">mdi-delete-outline</v-icon>
</template>
<span v-text="$t('filters.remove')"/>
<span v-text="$t('filters.remove')" />
</v-tooltip>
</v-list-item-action>
<v-list-item-title v-html="item"/>
<v-list-item-title v-html="item" />
</v-list-item>
</v-list>
</v-card>
@@ -22,24 +22,24 @@
</template>
<script>
export default {
props: {
model: {
type: Array,
required: true
},
title: {
type: String,
required: true
},
type: {
type: String,
required: true
},
toggleIgnore: {
type: Function,
required: true
}
export default {
props: {
model: {
type: Array,
required: true
},
title: {
type: String,
required: true
},
type: {
type: String,
required: true
},
toggleIgnore: {
type: Function,
required: true
}
};
}
}
</script>
+120 -92
View File
@@ -4,18 +4,45 @@
<v-layout row wrap>
<v-flex xs12>
<v-card>
<v-container
fluid
grid-list-md
>
<v-container fluid grid-list-md>
<v-layout row wrap v-if="!loading && data">
<list :model="data.bands" title="filters.band" type="band" :toggleIgnore="toggleIgnore" v-if="data.bands"/>
<list
:model="data.bands"
title="filters.band"
type="band"
:toggleIgnore="toggleIgnore"
v-if="data.bands"
/>
<v-flex xs12 sm6 md4 lg3>
<v-layout column>
<list :model="data.states" title="filters.state" type="state" :toggleIgnore="toggleIgnore" v-if="data.states"/>
<list :model="data.municipalities" title="filters.municipality" type="municipality" :toggleIgnore="toggleIgnore" v-if="data.municipalities"/>
<list :model="data.cities" title="filters.city" type="city" :toggleIgnore="toggleIgnore" v-if="data.cities"/>
<list :model="data.danceHalls" title="filters.hall" type="danceHall" :toggleIgnore="toggleIgnore" v-if="data.danceHalls"/>
<list
:model="data.states"
title="filters.state"
type="state"
:toggleIgnore="toggleIgnore"
v-if="data.states"
/>
<list
:model="data.municipalities"
title="filters.municipality"
type="municipality"
:toggleIgnore="toggleIgnore"
v-if="data.municipalities"
/>
<list
:model="data.cities"
title="filters.city"
type="city"
:toggleIgnore="toggleIgnore"
v-if="data.cities"
/>
<list
:model="data.danceHalls"
title="filters.hall"
type="danceHall"
:toggleIgnore="toggleIgnore"
v-if="data.danceHalls"
/>
</v-layout>
</v-flex>
</v-layout>
@@ -35,93 +62,94 @@
</template>
<script>
import {
fetchFilters,
toggleIgnoreBand,
toggleIgnoreCity,
toggleIgnoreDanceHall,
toggleIgnoreMunicipality,
toggleIgnoreState,
} from "~/utils/graph-client";
import { ref } from '@vue/composition-api'
import { useMutations } from '@u3u/vue-hooks'
import {
fetchFilters,
toggleIgnoreBand,
toggleIgnoreCity,
toggleIgnoreDanceHall,
toggleIgnoreMunicipality,
toggleIgnoreState
} from '~/utils/graph-client'
import List from "./List";
import { useMutation, useQuery } from '../../../plugins/apollo'
import { ref } from '@vue/composition-api'
import { useAuth } from '../../../plugins/auth'
import { useMutations } from '@u3u/vue-hooks'
import { useTranslation } from '../../../plugins/i18n'
import List from './List'
import { useMutation, useQuery } from '../../../plugins/apollo'
import useAuth from '../../../plugins/auth'
import { useTranslation } from '../../../plugins/i18n'
export default {
components: {
List
},
setup() {
const { setTitle } = useMutations(['setTitle'])
const { t } = useTranslation();
setTitle(t('app.links.filters'))
const { loading: authLoading, isAuthenticated } = useAuth()
const {data, loading, error, refetch} = useQuery(fetchFilters)
const snackbar = ref({ active: false, color: 'success', text: '' })
const [doToggleIgnoreBand, {loading: ignoringBand, error: errorIgnoreBand}] = useMutation(toggleIgnoreBand)
const [doToggleIgnoreDanceHall, {loading: ignoringDanceHall, error: errorIgnoreDanceHall}] = useMutation(toggleIgnoreDanceHall)
const [doToggleIgnoreCity, {loading: ignoringCity, error: errorIgnoreCity}] = useMutation(toggleIgnoreCity)
const [doToggleIgnoreMunicipality, {loading: ignoringMunicipality, error: errorIgnoreMunicipality}] = useMutation(toggleIgnoreMunicipality)
const [doToggleIgnoreState, {loading: ignoringState, error: errorIgnoreState}] = useMutation(toggleIgnoreState)
export default {
components: {
List
},
setup() {
const { setTitle } = useMutations(['setTitle'])
const { t } = useTranslation()
setTitle(t('app.links.filters'))
const { isAuthenticated } = useAuth()
const { data, loading, refetch } = useQuery(fetchFilters)
const snackbar = ref({ active: false, color: 'success', text: '' })
const [doToggleIgnoreBand] = useMutation(toggleIgnoreBand)
const [doToggleIgnoreDanceHall] = useMutation(toggleIgnoreDanceHall)
const [doToggleIgnoreCity] = useMutation(toggleIgnoreCity)
const [doToggleIgnoreMunicipality] = useMutation(toggleIgnoreMunicipality)
const [doToggleIgnoreState] = useMutation(toggleIgnoreState)
const toggleIgnoreSuccess = (name) => {
return () => {
refetch.value();
snackbar.value.color = 'success';
snackbar.value.text = t('filters.success', { name });
snackbar.value.active = true;
}
}
const toggleIgnoreFailed = (name) => {
return () => {
snackbar.value.color = 'error';
snackbar.value.text = t('filters.failure', { name });
snackbar.value.active = true;
}
}
const toggleIgnore = (type, name) => {
switch (type) {
case 'band':
doToggleIgnoreBand({ variables: { name: name } })
.then(toggleIgnoreSuccess(name))
.catch(toggleIgnoreFailed);
break;
case 'danceHall':
doToggleIgnoreDanceHall({ variables: { name: name } })
.then(toggleIgnoreSuccess(name))
.catch(toggleIgnoreFailed);
break;
case 'city':
doToggleIgnoreCity({ variables: { name: name } })
.then(toggleIgnoreSuccess(name))
.catch(toggleIgnoreFailed);
break;
case 'municipality':
doToggleIgnoreMunicipality({ variables: { name: name } })
.then(toggleIgnoreSuccess(name))
.catch(toggleIgnoreFailed);
break;
case 'state':
doToggleIgnoreState({ variables: { name: name } })
.then(toggleIgnoreSuccess(name))
.catch(toggleIgnoreFailed);
break;
}
}
return {
isAuthenticated,
loading,
data,
snackbar,
toggleIgnore
const toggleIgnoreSuccess = name => {
return () => {
refetch.value()
snackbar.value.color = 'success'
snackbar.value.text = t('filters.success', { name })
snackbar.value.active = true
}
}
const toggleIgnoreFailed = name => {
return () => {
snackbar.value.color = 'error'
snackbar.value.text = t('filters.failure', { name })
snackbar.value.active = true
}
}
const toggleIgnore = (type, name) => {
switch (type) {
case 'band':
doToggleIgnoreBand({ variables: { name } })
.then(toggleIgnoreSuccess(name))
.catch(toggleIgnoreFailed)
break
case 'danceHall':
doToggleIgnoreDanceHall({ variables: { name } })
.then(toggleIgnoreSuccess(name))
.catch(toggleIgnoreFailed)
break
case 'city':
doToggleIgnoreCity({ variables: { name } })
.then(toggleIgnoreSuccess(name))
.catch(toggleIgnoreFailed)
break
case 'municipality':
doToggleIgnoreMunicipality({ variables: { name } })
.then(toggleIgnoreSuccess(name))
.catch(toggleIgnoreFailed)
break
case 'state':
doToggleIgnoreState({ variables: { name } })
.then(toggleIgnoreSuccess(name))
.catch(toggleIgnoreFailed)
break
default:
}
}
return {
isAuthenticated,
loading,
data,
snackbar,
toggleIgnore
}
}
}
</script>