parent
6b7e984817
commit
76a01f9f47
6 changed files with 42 additions and 18 deletions
frontend/src
components
mixins
|
@ -423,13 +423,17 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
start = this.map.getCoordinateFromPixel(start)
|
const startPoint = this.map?.getCoordinateFromPixel(start)
|
||||||
end = this.map.getCoordinateFromPixel(end)
|
const endPoint = this.map?.getCoordinateFromPixel(end)
|
||||||
|
if (!(startPoint && endPoint)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const [startLon, startLat, endLon, endLat] = [
|
const [startLon, startLat, endLon, endLat] = [
|
||||||
Math.min(start[0], end[0]),
|
Math.min(startPoint[0], endPoint[0]),
|
||||||
Math.min(start[1], end[1]),
|
Math.min(startPoint[1], endPoint[1]),
|
||||||
Math.max(start[0], end[0]),
|
Math.max(startPoint[0], endPoint[0]),
|
||||||
Math.max(start[1], end[1]),
|
Math.max(startPoint[1], endPoint[1]),
|
||||||
]
|
]
|
||||||
|
|
||||||
this.locationQuery = {
|
this.locationQuery = {
|
||||||
|
|
|
@ -38,7 +38,9 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
const scaledCoords = [
|
const scaledCoords = [
|
||||||
|
// @ts-ignore
|
||||||
this.scaledPointerCoordinates(...this.selectionBox[0]),
|
this.scaledPointerCoordinates(...this.selectionBox[0]),
|
||||||
|
// @ts-ignore
|
||||||
this.scaledPointerCoordinates(...this.selectionBox[1]),
|
this.scaledPointerCoordinates(...this.selectionBox[1]),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -71,7 +73,9 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
scaledPointerCoordinates(x: number, y: number): number[] {
|
scaledPointerCoordinates(x: number, y: number): number[] {
|
||||||
|
// @ts-ignore
|
||||||
const offsetLeft = this.$refs.overlay?.getBoundingClientRect().left || 0
|
const offsetLeft = this.$refs.overlay?.getBoundingClientRect().left || 0
|
||||||
|
// @ts-ignore
|
||||||
const offsetTop = this.$refs.overlay?.getBoundingClientRect().top || 0
|
const offsetTop = this.$refs.overlay?.getBoundingClientRect().top || 0
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -80,8 +84,20 @@ export default {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
setSelectionBoxCoordinates(event: MouseEvent) {
|
getXY(event: MouseEvent | TouchEvent): number[] {
|
||||||
const coords = [event.clientX, event.clientY]
|
if (event instanceof MouseEvent) {
|
||||||
|
return [event.clientX, event.clientY]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event instanceof TouchEvent) {
|
||||||
|
return [event.touches[0].clientX, event.touches[0].clientY]
|
||||||
|
}
|
||||||
|
|
||||||
|
return []
|
||||||
|
},
|
||||||
|
|
||||||
|
setSelectionBoxCoordinates(event: MouseEvent | TouchEvent) {
|
||||||
|
const coords = this.getXY(event)
|
||||||
let newBox = JSON.parse(JSON.stringify(this.selectionBox)) as number[][]
|
let newBox = JSON.parse(JSON.stringify(this.selectionBox)) as number[][]
|
||||||
|
|
||||||
if (newBox.length === 1 || !newBox[1]) {
|
if (newBox.length === 1 || !newBox[1]) {
|
||||||
|
@ -94,13 +110,13 @@ export default {
|
||||||
this.selectionBox = newBox
|
this.selectionBox = newBox
|
||||||
},
|
},
|
||||||
|
|
||||||
onOverlayDragStart(event: MouseEvent) {
|
onOverlayDragStart(event: MouseEvent | TouchEvent) {
|
||||||
this.selectionBox = []
|
this.selectionBox = []
|
||||||
this.setSelectionBoxCoordinates(event)
|
this.setSelectionBoxCoordinates(event)
|
||||||
this.overlayDragging = true
|
this.overlayDragging = true
|
||||||
},
|
},
|
||||||
|
|
||||||
onOverlayDragEnd(event: MouseEvent) {
|
onOverlayDragEnd(event: MouseEvent | TouchEvent) {
|
||||||
if (this.selectionBox.length < 1) {
|
if (this.selectionBox.length < 1) {
|
||||||
this.selectionBox = []
|
this.selectionBox = []
|
||||||
return
|
return
|
||||||
|
@ -117,14 +133,16 @@ export default {
|
||||||
this.$emit(
|
this.$emit(
|
||||||
'select',
|
'select',
|
||||||
[
|
[
|
||||||
|
// @ts-ignore
|
||||||
this.scaledPointerCoordinates(...this.selectionBox[0]),
|
this.scaledPointerCoordinates(...this.selectionBox[0]),
|
||||||
|
// @ts-ignore
|
||||||
this.scaledPointerCoordinates(...this.selectionBox[1])
|
this.scaledPointerCoordinates(...this.selectionBox[1])
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onOverlayMove(event: MouseEvent) {
|
onOverlayMove(event: MouseEvent | TouchEvent) {
|
||||||
if (!this.overlayDragging || this.selectionBox.length < 1) {
|
if (!this.overlayDragging || this.selectionBox.length < 1) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,12 +254,14 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
initDateRange(value: LocationQuery) {
|
initDateRange(value: LocationQuery) {
|
||||||
this.enableDateRange = !!(value.startDate && value.endDate)
|
this.enableDateRange = !!(value?.startDate && value?.endDate)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initDateRange(this.value)
|
if (this.value) {
|
||||||
|
this.initDateRange(this.value)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
|
|
|
@ -22,7 +22,7 @@ export default {
|
||||||
return new Date(Math.floor(date.getTime() / 60000) * 60000)
|
return new Date(Math.floor(date.getTime() / 60000) * 60000)
|
||||||
},
|
},
|
||||||
|
|
||||||
toLocalString(date: Date | string | number | null): string {
|
toLocalString(date: Date | string | number | null | undefined): string {
|
||||||
const d = this.normalizeDate(date)
|
const d = this.normalizeDate(date)
|
||||||
if (!d) {
|
if (!d) {
|
||||||
return ''
|
return ''
|
||||||
|
|
|
@ -30,7 +30,9 @@ export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
scaledPointerCoordinates(event: MouseEvent): number[] {
|
scaledPointerCoordinates(event: MouseEvent): number[] {
|
||||||
|
// @ts-ignore
|
||||||
const offsetLeft = this.$refs.overlay?.getBoundingClientRect().left || 0
|
const offsetLeft = this.$refs.overlay?.getBoundingClientRect().left || 0
|
||||||
|
// @ts-ignore
|
||||||
const offsetTop = this.$refs.overlay?.getBoundingClientRect().top || 0
|
const offsetTop = this.$refs.overlay?.getBoundingClientRect().top || 0
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -55,7 +57,6 @@ export default {
|
||||||
|
|
||||||
onOverlayDragStart(event: MouseEvent) {
|
onOverlayDragStart(event: MouseEvent) {
|
||||||
this.setSelectionBoxCoordinates(event)
|
this.setSelectionBoxCoordinates(event)
|
||||||
this.overlayDragging = true
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onOverlayDragEnd(event: MouseEvent) {
|
onOverlayDragEnd(event: MouseEvent) {
|
||||||
|
@ -70,12 +71,10 @@ export default {
|
||||||
) {
|
) {
|
||||||
this.selectionBox = []
|
this.selectionBox = []
|
||||||
}
|
}
|
||||||
|
|
||||||
this.overlayDragging = false
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onOverlayMove(event: MouseEvent) {
|
onOverlayMove(event: MouseEvent) {
|
||||||
if (!this.overlayDragging || this.selectionBox.length < 1) {
|
if (this.selectionBox.length < 1) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,7 @@ export default {
|
||||||
$route(newRoute: { fullPath: string }, oldRoute: { fullPath: string }) {
|
$route(newRoute: { fullPath: string }, oldRoute: { fullPath: string }) {
|
||||||
const oldQuery = this.parseQuery(oldRoute.fullPath)
|
const oldQuery = this.parseQuery(oldRoute.fullPath)
|
||||||
const newQuery = this.parseQuery(newRoute.fullPath)
|
const newQuery = this.parseQuery(newRoute.fullPath)
|
||||||
|
// @ts-ignore
|
||||||
if (this.isQueryChanged({oldValue: oldQuery, newValue: newQuery})) {
|
if (this.isQueryChanged({oldValue: oldQuery, newValue: newQuery})) {
|
||||||
this.query = newQuery
|
this.query = newQuery
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue