2018-06-25 18:29:57 +02:00
|
|
|
<template>
|
2018-07-04 18:20:28 +02:00
|
|
|
<div>
|
2018-11-25 17:43:54 +01:00
|
|
|
<Alert
|
|
|
|
type="error"
|
|
|
|
:text="$t('reportDialog.unableToSend')"
|
|
|
|
:onDismiss="dismissError"
|
|
|
|
v-if="hasError"
|
|
|
|
></Alert>
|
2018-08-28 14:49:21 +02:00
|
|
|
<v-bottom-sheet v-model="isActive" id="reportCardSheet">
|
2018-07-04 18:20:28 +02:00
|
|
|
<v-card>
|
|
|
|
<v-container fluid>
|
|
|
|
<v-layout row wrap>
|
2018-07-26 13:55:08 +02:00
|
|
|
<ReportTile
|
|
|
|
v-for="type in REPORT_TYPES_ORDER"
|
|
|
|
:type="type"
|
|
|
|
:imageSrc="REPORT_TYPES[type].image"
|
|
|
|
:label="$t(REPORT_TYPES[type].label)"
|
|
|
|
:save="saveReport"
|
|
|
|
:key="type"
|
|
|
|
>
|
|
|
|
</ReportTile>
|
2018-07-04 18:20:28 +02:00
|
|
|
</v-layout>
|
|
|
|
</v-container>
|
|
|
|
</v-card>
|
|
|
|
</v-bottom-sheet>
|
|
|
|
</div>
|
2018-06-25 18:29:57 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-10-25 16:50:38 +02:00
|
|
|
import { REPORT_TYPES_ORDER } from '@/constants';
|
|
|
|
import REPORT_TYPES from '@/report-types';
|
2018-06-25 18:29:57 +02:00
|
|
|
|
2018-11-07 23:18:45 +01:00
|
|
|
import Alert from '@/components/Alert.vue';
|
2018-06-25 18:29:57 +02:00
|
|
|
import ReportTile from './ReportTile.vue';
|
|
|
|
|
|
|
|
export default {
|
2018-07-21 20:00:37 +02:00
|
|
|
beforeDestroy() {
|
|
|
|
window.removeEventListener('keydown', this.hideReportDialogOnEsc);
|
|
|
|
},
|
2018-06-25 18:29:57 +02:00
|
|
|
components: {
|
2018-11-07 23:18:45 +01:00
|
|
|
Alert,
|
2018-06-25 18:29:57 +02:00
|
|
|
ReportTile,
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
isActive: {
|
|
|
|
get() {
|
|
|
|
return this.value;
|
|
|
|
},
|
|
|
|
set(val) {
|
2018-07-21 20:00:37 +02:00
|
|
|
if (val === false) {
|
|
|
|
this.onHide();
|
|
|
|
}
|
2018-06-25 18:29:57 +02:00
|
|
|
this.$emit('input', val);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2018-07-26 09:14:14 +02:00
|
|
|
hasError: false,
|
2018-06-25 18:29:57 +02:00
|
|
|
REPORT_TYPES,
|
2018-07-10 15:19:24 +02:00
|
|
|
REPORT_TYPES_ORDER,
|
2018-06-25 18:29:57 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2018-11-07 23:18:45 +01:00
|
|
|
dismissError() {
|
|
|
|
this.hasError = false;
|
|
|
|
},
|
2018-07-21 20:00:37 +02:00
|
|
|
hideReportDialogOnEsc(event) {
|
|
|
|
let isEscape = false;
|
|
|
|
if ('key' in event) {
|
|
|
|
isEscape = (event.key === 'Escape' || event.key === 'Esc');
|
|
|
|
} else {
|
|
|
|
isEscape = (event.keyCode === 27);
|
|
|
|
}
|
|
|
|
if (isEscape) {
|
|
|
|
this.isActive = false;
|
|
|
|
}
|
|
|
|
},
|
2018-06-25 18:29:57 +02:00
|
|
|
saveReport(type) {
|
2018-07-21 20:00:37 +02:00
|
|
|
this.isActive = false;
|
2018-07-26 09:05:22 +02:00
|
|
|
const report = {
|
2018-06-26 11:39:43 +02:00
|
|
|
type,
|
2018-07-21 20:00:37 +02:00
|
|
|
lat: this.latLng[0],
|
|
|
|
lng: this.latLng[1],
|
2018-07-26 09:05:22 +02:00
|
|
|
};
|
|
|
|
return this.$store.dispatch('saveReport', report)
|
|
|
|
.catch((exc) => {
|
|
|
|
console.error(exc);
|
2018-07-26 09:14:14 +02:00
|
|
|
this.hasError = true;
|
2018-07-26 09:05:22 +02:00
|
|
|
this.$store.dispatch('saveUnsentReport', { report });
|
|
|
|
});
|
2018-06-25 18:29:57 +02:00
|
|
|
},
|
|
|
|
},
|
2018-07-21 20:00:37 +02:00
|
|
|
mounted() {
|
|
|
|
window.addEventListener('keydown', this.hideReportDialogOnEsc);
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
value: Boolean,
|
|
|
|
latLng: Array,
|
|
|
|
onHide: Function,
|
|
|
|
},
|
2018-06-25 18:29:57 +02:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.overlayDialog {
|
|
|
|
z-index: 1003 !important;
|
|
|
|
}
|
|
|
|
</style>
|
2018-06-30 23:24:06 +02:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.dialog__content {
|
|
|
|
z-index: 1002 !important;
|
|
|
|
}
|
|
|
|
</style>
|