Skip to content

Commit

Permalink
removed all traces of the coordinate-picker to make space for a bette…
Browse files Browse the repository at this point in the history
…r system
  • Loading branch information
CommanderStorm committed Jun 25, 2023
1 parent 7787188 commit e129408
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 430 deletions.
2 changes: 1 addition & 1 deletion server/feedback/src/proposed_edits/tmp_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl TempRepo {
let out = Command::new("git")
.current_dir(&self.dir)
.arg("commit")
.arg("--allow-empty") // TODO: remove once the need for empty commits is gone (images+coodinates)
.arg("--allow-empty") // TODO: remove once the need for empty commits is gone (images+coordinates)
.arg("--all") // run git add . before commit
.arg("-m")
.arg(title)
Expand Down
36 changes: 3 additions & 33 deletions webclient/src/components/AppFeedbackModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ function sendForm() {
<div class="content">
<div id="feedback-error">{{ error.message }}</div>
<div class="form-group">
<div id="feedback-coordinate-picker-helptext" class="d-none toast toast-primary">
{{ $t("feedback.coordinatepicker.helptext.enter_serveral") }}<br />
{{ $t("feedback.coordinatepicker.helptext.saved_for_12h") }}<br />
{{ $t("feedback.coordinatepicker.helptext.limitation_to_coordinates") }}
</div>
<label class="form-label" for="feedback-subject"> {{ $t("feedback.subject") }}</label>
<div class="input-group">
<select
Expand All @@ -139,18 +134,9 @@ function sendForm() {
</div>

<div class="form-group">
<div>
<label class="form-label" for="feedback-body">
{{ $t("feedback.message") }}
</label>
<button
id="feedback-coordinate-picker"
v-if="global.feedback.category === 'entry'"
class="btn btn-sm btn-link"
>
{{ $t("feedback.coordinatepicker.title") }}
</button>
</div>
<label class="form-label" for="feedback-body">
{{ $t("feedback.message") }}
</label>
<textarea
class="form-input"
id="feedback-body"
Expand All @@ -173,13 +159,6 @@ function sendForm() {
</p>
</div>

<!-- only visible if called through a view, because then the context of the calling building is availible -->
<div>
<button id="feedback-coordinate-picker" class="btn btn-sm d-none">
{{ $t("feedback.coordinatepicker.title") }}
</button>
</div>

<div class="form-group">
<label class="form-checkbox">
<input type="checkbox" id="feedback-privacy" v-model="privacyChecked" />
Expand Down Expand Up @@ -305,14 +284,5 @@ function sendForm() {
#feedback-body {
min-width: 100%;
}
#feedback-coordinate-picker {
float: right;
margin-top: 0.5em;
}
#feedback-coordinate-picker-helptext {
font-size: 14px;
}
}
</style>
97 changes: 4 additions & 93 deletions webclient/src/components/DetailsFeedbackButton.vue
Original file line number Diff line number Diff line change
@@ -1,105 +1,16 @@
<script setup lang="ts">
import { getLocalStorageWithExpiry } from "@/composables/storage";
import { useDetailsStore } from "@/stores/details";
import { useGlobalStore } from "@/stores/global";
import { useI18n } from "vue-i18n";
import type { Coord } from "@/stores/global";
import { useRoute } from "vue-router";
const { t } = useI18n({ inheritLocale: true, useScope: "global" });
const state = useDetailsStore();
type CurrentEdits = { [index: string]: Coord };
function _getFeedbackSubject(currentEdits: CurrentEdits) {
if (Object.keys(currentEdits).length > 1) {
return `[${state.data?.id} et.al.]: ` + t("feedback.coordinatepicker.edit_coordinates_subject");
}
const subjectPrefix = `[${state.data?.id}]: `;
const subjectMsg =
Object.keys(currentEdits).length === 0 ? "" : t("feedback.coordinatepicker.edit_coordinate_subject");
// The subject backup is only loaded (and supported) when a single
// entry is being edited
if (
state.coord_picker.subject_backup &&
state.coord_picker.backup_id === state.data?.id &&
state.coord_picker.subject_backup !== subjectPrefix
) {
const backup = state.coord_picker.subject_backup;
state.coord_picker.subject_backup = null;
return backup;
}
return subjectPrefix + subjectMsg;
}
function _getFeedbackBody(currentEdits: CurrentEdits) {
if (!state.data) {
return "Data has not been loaded yet but Feedback is open. This is a bug. Please describe how you got here.";
}
// Look up whether there is a backup of the body and extract the section
// that is not the coordinate
let actionMsg = "";
if (state.coord_picker.body_backup && state.coord_picker.backup_id === state.data.id) {
const parts = state.coord_picker.body_backup.split("\n```");
if (parts.length === 1) {
actionMsg = parts[0];
} else {
actionMsg = parts[0] + parts[1].split("```").slice(1).join("\n");
}
state.coord_picker.body_backup = null;
}
if (Object.keys(currentEdits).length === 0) {
// For no edits, don't show a badly formatted message
// (This is "" if there was no backup)
return actionMsg;
}
const defaultActionMsg =
state.data.coords.accuracy === "building"
? t("feedback.coordinatepicker.add_coordinate")
: t("feedback.coordinatepicker.correct_coordinate");
actionMsg = actionMsg || defaultActionMsg;
if (Object.keys(currentEdits).length > 1) {
// The body backup is discarded if more than a single entry
// is being edited (because then it is not supported).
actionMsg = t("feedback.coordinatepicker.edit_multiple_coordinates");
}
let editStr = "";
Object.entries(currentEdits).forEach(([key, value]) => {
editStr += `"${key}": { lat: ${value.coords.lat}, lon: ${value.coords.lon} }\n`;
});
return `${actionMsg}\n\`\`\`yaml\n${editStr}\`\`\``;
}
defineExpose({
openFeedbackForm,
});
function openFeedbackForm(addLocationPicker: EventListener | null = null) {
// The feedback form is opened. This may be prefilled with previously corrected coordinates.
// Maybe get the old coordinates from localstorage
const currentEdits = getLocalStorageWithExpiry<CurrentEdits>("feedback-coords", {});
const body = _getFeedbackBody(currentEdits);
const subject = _getFeedbackSubject(currentEdits);
if (addLocationPicker !== null) {
window.setTimeout(
() => document.getElementById("feedback-coordinate-picker")?.addEventListener("click", addLocationPicker),
100
);
}
useGlobalStore().openFeedback("entry", subject, body);
}
const route = useRoute();
const global = useGlobalStore();
</script>

<template>
<button
class="btn btn-link btn-action btn-sm"
:title="$t('view_view.header.feedback')"
@click="openFeedbackForm()"
@click="global.openFeedback('entry', `[${route.params.id}]: `)"
data-cy="open-feedback-details"
>
<i class="icon icon-flag" />
Expand Down
6 changes: 0 additions & 6 deletions webclient/src/components/DetailsInfoSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ const state = useDetailsStore();
<DetailsPropertyTable />
<div class="toast toast-warning" v-if="state.data?.coords.accuracy === 'building'">
{{ $t("view_view.msg.inaccurate_only_building.primary_msg") }}<br />
<i>
{{ $t("view_view.msg.inaccurate_only_building.help_others_and") }}
<button class="btn btn-sm" @click="addLocationPicker">
{{ $t("view_view.msg.inaccurate_only_building.btn") }}
</button>
</i>
</div>
<div
class="toast toast-warning"
Expand Down
107 changes: 0 additions & 107 deletions webclient/src/components/DetailsInteractiveMap.vue
Original file line number Diff line number Diff line change
@@ -1,109 +1,24 @@
<script setup lang="ts">
import { getLocalStorageWithExpiry, setLocalStorageWithExpiry } from "@/composables/storage";
import type { BackgroundLayerSpecification, Coordinates, ImageSource } from "maplibre-gl";
import { Map, Marker } from "maplibre-gl";
import { AttributionControl, FullscreenControl, GeolocateControl, NavigationControl } from "maplibre-gl";
import { selectedMap, useDetailsStore } from "@/stores/details";
import type { Coord } from "@/stores/global";
import { useGlobalStore } from "@/stores/global";
import { nextTick, ref } from "vue";
import { FloorControl } from "@/modules/FloorControl";
import { webglSupport } from "@/composables/webglSupport";
const map = ref<Map | undefined>(undefined);
const marker = ref<Marker | undefined>(undefined);
const marker2 = ref<Marker | null>(null);
const floorControl = ref<FloorControl>(new FloorControl());
const state = useDetailsStore();
const global = useGlobalStore();
// The coordinate picker keeps backups of the subject and body
// in case someone writes a text and then after that clicks
// the set coordinate button in the feedback form.
// If we no backup has been made then, this would be lost after clicking confirm there.
const coord_picker = ref({
backup_id: null as string | null,
subject_backup: null as string | null,
body_backup: null as string | null,
force_reopen: false,
});
const initialLoaded = ref(false);
const emit = defineEmits<{
(e: "openFeedbackForm", callback: EventListener): void;
}>();
function confirmLocationPicker() {
// add the current edits to the feedback
const currentEdits = getLocalStorageWithExpiry<{ [index: string]: Coord }>("feedback-coords", {});
const location = marker2.value?.getLngLat();
currentEdits[state.data?.id || "undefined"] = {
coords: { lat: location?.lat, lon: location?.lng },
};
// save to local storage with ttl of 12h (garbage-collected on next read)
setLocalStorageWithExpiry("feedback-coords", currentEdits, 12);
marker2.value?.remove();
marker2.value = null;
// A feedback form is only opened when this is the only (and therefore
// first coordinate). If there are more coordinates we can assume
// someone is doing batch edits. They can then use the send button in
// the coordinate counter at the top of the page.
if (Object.keys(currentEdits).length === 1 || state.coord_picker.force_reopen) {
state.coord_picker.force_reopen = false;
emit("openFeedbackForm", () => addLocationPicker());
}
// The helptext (which says thet you can edit multiple coordinates in bulk)
// is also only shown if there is one edit.
if (Object.keys(currentEdits).length === 1) {
document.getElementById("feedback-coordinate-picker-helptext")?.classList.remove("d-none");
}
}
function cancelLocationPicker() {
marker2.value?.remove();
marker2.value = null;
if (state.coord_picker.force_reopen) {
state.coord_picker.force_reopen = false;
emit("openFeedbackForm", () => addLocationPicker());
}
}
defineExpose({
addLocationPicker,
loadInteractiveMap,
});
function addLocationPicker() {
// If this is called from the feedback form using the edit coordinate
// button, we temporarily save the current subject and body, so it is
// not lost when being reopened
if (global.feedback.open) {
coord_picker.value.backup_id = state.data?.id || "undefined";
coord_picker.value.subject_backup = global.feedback.subject;
coord_picker.value.body_backup = global.feedback.body;
coord_picker.value.force_reopen = true; // reopen after confirm
global.temporarilyCloseFeedback();
}
state.map.selected = selectedMap.interactive;
// Verify that there isn't already a marker (could happen if you click 'assign
// a location' multiple times from the 'missing accurate location' toast)
if (marker2.value === null) {
// Coordinates are either taken from the entry, or if there are already
// some in the localStorage use them
const currentEdits = getLocalStorageWithExpiry<{ [index: string]: Coord }>("feedback-coords", {});
const { coords } = currentEdits[state.data?.id || "undefined"] || state.data;
marker2.value = new Marker({
draggable: true,
color: "#ff0000",
});
if (coords.lat !== undefined && coords.lon !== undefined)
marker2.value.setLngLat([coords.lon, coords.lat]).addTo(map.value as Map);
}
}
function loadInteractiveMap(fromUi = false) {
if (!webglSupport) return;
Expand Down Expand Up @@ -346,22 +261,6 @@ function setOverlayImage(imgUrl: string | null, coords: Coordinates | undefined)
</script>

<template>
<div class="toast toast-primary mb-2 location-picker" v-if="marker2">
<div class="columns">
<div class="column col col-sm-12">
{{ $t("view_view.msg.correct_location.msg") }}
</div>
<div class="column col-auto col-sm-12 btns">
<button class="btn btn-sm" @click="cancelLocationPicker">
{{ $t("view_view.msg.correct_location.btn-cancel") }}
</button>
<button class="btn btn-sm" @click="confirmLocationPicker">
<i class="icon icon-check" />
{{ $t("view_view.msg.correct_location.btn-done") }}
</button>
</div>
</div>
</div>
<div
id="interactive-map-container"
:class="{ 'd-none': state.map.selected !== selectedMap.interactive, errormessage: !webglSupport }"
Expand Down Expand Up @@ -397,12 +296,6 @@ function setOverlayImage(imgUrl: string | null, coords: Coordinates | undefined)
// This does not change anything (except using px instead of rem),
// but ensures that roomfinder position calculations are predictable.
padding: 0 8px;
// The marker2 (draggable)
.maplibregl-marker + .maplibregl-marker {
animation: fade-in 0.1s linear 0.05s;
animation-fill-mode: both;
}
}
.toast.location-picker {
Expand Down
24 changes: 0 additions & 24 deletions webclient/src/locales/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@ core_js:
feedback:
cancel: Abbrechen
category: Feedback-Kategorie
coordinatepicker:
add_coordinate: 'Hallo, ich möchte diese Koordinate zum Roomfinder hinzufügen:'
correct_coordinate: 'Hallo, ich möchte diese Koordinate im Roomfinder korrigieren:'
edit_coordinate_subject: Koordinate bearbeiten
edit_coordinates_subject: Koordinaten bearbeiten
edit_multiple_coordinates: 'Hallo, ich möchte diese Koordinaten beim Roomfinder editieren:'
helptext:
enter_serveral: Falls du mehrere Koordinaten gleichzeitig korrigieren willst, kannst du dieses Fenster schließen und weitere Koordinaten editieren.
limitation_to_coordinates: Achtung, das gilt nur für Koordinaten!
saved_for_12h: Wir speichern deine Veränderungen für 12 Stunden bei dir lokal.
title: Koordinate auswählen
delete: Das zugehörige GitHub Issue löschen, sobald es gelöst wurde.
error:
'429': Feedback senden ist aktuell nicht möglich aufgrund von rate-limiting. Bitte versuche es später nochmal oder schreibe eine Mail.
Expand Down Expand Up @@ -184,20 +173,7 @@ view_view:
meta:
details_for: Details für
msg:
coordinate-counter:
delete: Löschen
delete-confirm: Wirklich löschen?
info: Änderungen werden lokal \n für 12h gespeichert
msg-1: Aktuell
msg-2: ausstehende Koordinatenänderung|ausstehende Koordinatenänderungen
send: Senden
correct_location:
btn-cancel: Abbrechen
btn-done: Fertig
msg: Um die richtige Position zu setzen, ziehe den roten Marker über die Karte.
inaccurate_only_building:
btn: Koordinate eintragen
help_others_and: Falls du sie herausfindest, kannst du die
primary_msg: Die angezeigte Position zeigt nur die Position des Gebäude(teils). Die genaue Lage innerhalb des Gebäudes ist uns nicht bekannt.
no_floor_overlay: Für den angezeigten Raum gibt es leider keine Indoor Karte.
roomfinder_modal:
Expand Down
Loading

0 comments on commit e129408

Please sign in to comment.