chore: add eslint and fix lint errors
This commit is contained in:
@@ -4,36 +4,47 @@
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12>
|
||||
<v-text-field
|
||||
v-model="origin"
|
||||
:label="$t('origins.origin')"
|
||||
:placeholder="$t('origins.geolocation')"
|
||||
v-model="origin"
|
||||
:label="$t('origins.origin')"
|
||||
:placeholder="$t('origins.geolocation')"
|
||||
>
|
||||
<v-tooltip top slot="append-outer">
|
||||
<template v-slot:activator="{ on }">
|
||||
<v-icon v-on="on" v-on:click="fetchAddress()">mdi-crosshairs-gps</v-icon>
|
||||
<v-icon v-on="on" v-on:click="fetchAddress()"
|
||||
>mdi-crosshairs-gps</v-icon
|
||||
>
|
||||
</template>
|
||||
<span v-text="$t('origins.fetchAddress')"/>
|
||||
<span v-text="$t('origins.fetchAddress')" />
|
||||
</v-tooltip>
|
||||
<v-tooltip top slot="prepend">
|
||||
<template v-slot:activator="{ on }">
|
||||
<v-icon v-on="on" :disabled="!origin" v-on:click="saveOrigin(origin)">mdi-bookmark-plus-outline</v-icon>
|
||||
<v-icon
|
||||
v-on="on"
|
||||
:disabled="!origin"
|
||||
v-on:click="saveOrigin(origin)"
|
||||
>mdi-bookmark-plus-outline</v-icon
|
||||
>
|
||||
</template>
|
||||
<span v-text="$t('origins.save')"/>
|
||||
<span v-text="$t('origins.save')" />
|
||||
</v-tooltip>
|
||||
</v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-layout row wrap v-for="origin in data.origins" :key="origin" v-if="data && data.origins">
|
||||
<v-flex xs12>
|
||||
<v-tooltip top slot="prepend">
|
||||
<template v-slot:activator="{ on }">
|
||||
<v-icon v-on="on" v-on:click="removeOrigin(origin)">mdi-delete-outline</v-icon>
|
||||
</template>
|
||||
<span v-text="$t('origins.remove')"/>
|
||||
</v-tooltip>
|
||||
<span>{{origin}}</span>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<template v-if="data && data.origins">
|
||||
<v-layout row wrap v-for="origin in data.origins" :key="origin">
|
||||
<v-flex xs12>
|
||||
<v-tooltip top slot="prepend">
|
||||
<template v-slot:activator="{ on }">
|
||||
<v-icon v-on="on" v-on:click="removeOrigin(origin)"
|
||||
>mdi-delete-outline
|
||||
</v-icon>
|
||||
</template>
|
||||
<span v-text="$t('origins.remove')" />
|
||||
</v-tooltip>
|
||||
<span>{{ origin }}</span>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</template>
|
||||
</v-container>
|
||||
<v-snackbar
|
||||
v-model="snackbar.active"
|
||||
@@ -46,55 +57,60 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
findOrigins,
|
||||
saveOrigin,
|
||||
removeOrigin,
|
||||
fetchAddress,
|
||||
} from "../../../utils/graph-client";
|
||||
import { useLazyQuery, 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 { ref } from '@vue/composition-api'
|
||||
import { useMutations } from '@u3u/vue-hooks'
|
||||
import {
|
||||
fetchAddress,
|
||||
findOrigins,
|
||||
removeOrigin,
|
||||
saveOrigin
|
||||
} from '../../../utils/graph-client'
|
||||
import { useLazyQuery, useMutation, useQuery } from '../../../plugins/apollo'
|
||||
import useAuth from '../../../plugins/auth'
|
||||
import { useTranslation } from '../../../plugins/i18n'
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const { setTitle } = useMutations(['setTitle'])
|
||||
const { t } = useTranslation();
|
||||
setTitle(t('app.links.origins'))
|
||||
const { loading: authLoading, isAuthenticated } = useAuth()
|
||||
const {data, loading, error, refetch} = useQuery(findOrigins)
|
||||
const snackbar = ref({ active: false, color: 'success', text: '' })
|
||||
const [doSaveOrigin, {loading: savingOrigin, error: errorSaveOrigin}] = useMutation(saveOrigin)
|
||||
const [doRemoveOrigin, {loading: removingOrigin, error: errorRemoveOrigin}] = useMutation(removeOrigin)
|
||||
const [doFetchAddress, {data: address, loading: fetchingAddress, error: errorFetchingAddress}] = useLazyQuery(fetchAddress)
|
||||
const origin = ref('')
|
||||
const fetchAddressFn = () => {
|
||||
if (window.navigator) {
|
||||
window.navigator.geolocation.getCurrentPosition(pos => {
|
||||
doFetchAddress({variables: {latlng: pos.coords.latitude + "," + pos.coords.longitude}})
|
||||
.then(() => {
|
||||
origin.value = address.value.address;
|
||||
})
|
||||
export default {
|
||||
setup() {
|
||||
const { setTitle } = useMutations(['setTitle'])
|
||||
const { t } = useTranslation()
|
||||
setTitle(t('app.links.origins'))
|
||||
const { isAuthenticated } = useAuth()
|
||||
const { data, loading, refetch } = useQuery(findOrigins)
|
||||
const snackbar = ref({ active: false, color: 'success', text: '' })
|
||||
const [doSaveOrigin] = useMutation(saveOrigin)
|
||||
const [doRemoveOrigin] = useMutation(removeOrigin)
|
||||
const [doFetchAddress, { data: address }] = useLazyQuery(fetchAddress)
|
||||
const origin = ref('')
|
||||
const fetchAddressFn = () => {
|
||||
if (window.navigator) {
|
||||
window.navigator.geolocation.getCurrentPosition(pos => {
|
||||
doFetchAddress({
|
||||
variables: {
|
||||
latlng: `${pos.coords.latitude},${pos.coords.longitude}`
|
||||
}
|
||||
}).then(() => {
|
||||
origin.value = address.value.address
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
const saveOriginFn = o => doSaveOrigin({variables: { origin: o }}).then(() => {
|
||||
}
|
||||
const saveOriginFn = o =>
|
||||
doSaveOrigin({ variables: { origin: o } }).then(() => {
|
||||
refetch.value()
|
||||
origin.value = ''
|
||||
})
|
||||
const removeOriginFn = o => doRemoveOrigin({variables: { origin: o }}).then(() => refetch.value())
|
||||
return {
|
||||
isAuthenticated,
|
||||
loading,
|
||||
data,
|
||||
snackbar,
|
||||
origin,
|
||||
saveOrigin: saveOriginFn,
|
||||
removeOrigin: removeOriginFn,
|
||||
fetchAddress: fetchAddressFn
|
||||
}
|
||||
const removeOriginFn = o =>
|
||||
doRemoveOrigin({ variables: { origin: o } }).then(() => refetch.value())
|
||||
return {
|
||||
isAuthenticated,
|
||||
loading,
|
||||
data,
|
||||
snackbar,
|
||||
origin,
|
||||
saveOrigin: saveOriginFn,
|
||||
removeOrigin: removeOriginFn,
|
||||
fetchAddress: fetchAddressFn
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user