@@ -491,8 +777,15 @@ let MyAccountDOM = {
});
});
+ let longPressTriggered = false;
// Au clic sur le PR = l'afficher
- container.querySelector(`#landmark-basic-tools_ID_${landmarkId}`).addEventListener("click", () => {
+ container.querySelector(`#landmark-basic-tools_ID_${landmarkId}`).addEventListener("click", (e) => {
+ if (longPressTriggered) {
+ // Cancel click if it was a long press
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ return;
+ }
if (landmark.properties.visible) {
this.toggleShowLandmark(landmark);
}
@@ -500,6 +793,35 @@ let MyAccountDOM = {
this.toggleShowLandmark(landmark);
});
+ // event appui long
+ let contextMenuTimeout = null;
+ const clearContextMenuTimeout = () => { clearTimeout(contextMenuTimeout); };
+ container.querySelector(`#landmark-basic-tools_ID_${landmarkId}`).addEventListener("pointerdown", () => {
+ longPressTriggered = false;
+ contextMenuTimeout = setTimeout(() => {
+ longPressTriggered = true;
+ container.classList.add("multiple-selected");
+ container.querySelector(".lblMultiSelect .checkbox").checked = true;
+ }, 500);
+ container.addEventListener("pointerup", (e) => {
+ clearContextMenuTimeout();
+ if (longPressTriggered) {
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ }
+ });
+ container.addEventListener("pointermove", clearContextMenuTimeout);
+ });
+
+ container.querySelector(".lblMultiSelect").addEventListener("click", () => {
+ const checkbox = container.querySelector(".lblMultiSelect .checkbox");
+ if (checkbox.checked) {
+ container.classList.add("multiple-selected");
+ } else {
+ container.classList.remove("multiple-selected");
+ }
+ });
+
if (!container) {
console.warn();
return;
diff --git a/src/js/my-account/my-account.js b/src/js/my-account/my-account.js
index 18a8ae12..d2a15578 100644
--- a/src/js/my-account/my-account.js
+++ b/src/js/my-account/my-account.js
@@ -1262,28 +1262,32 @@ ${props.text}`,
* @param {String} dataName - Le nom de la donnée (utilisé pour le nom du fichier)
* @param {String} errorMessage - Message d'erreur en cas d'échec
* @param {Function} shareFunc - Fonction de partage en cas d'erreur
+ * @param {String} format - format d'export si paramétré (export multiple)
*/
- async #exportData(data, dataName, errorMessage, shareFunc) {
+ async #exportData(data, dataName, errorMessage, shareFunc, format = null) {
let documentsName = "Documents";
if (Capacitor.getPlatform() === "ios") {
documentsName = "Fichiers";
}
- const value = await ActionSheet.show({
- style: "buttons",
- title: "Choisissez votre format d'export",
- options: [
- {
- text: "JSON",
- value: "json",
- class: ""
- },
- {
- text: "GPX",
- value: "gpx",
- class: ""
- }
- ]
- });
+ let value = format;
+ if (!value) {
+ value = await ActionSheet.show({
+ style: "buttons",
+ title: "Choisissez votre format d'export",
+ options: [
+ {
+ text: "JSON",
+ value: "json",
+ class: ""
+ },
+ {
+ text: "GPX",
+ value: "gpx",
+ class: ""
+ }
+ ]
+ });
+ }
try {
let formatName;
const existingFileNames = (await Filesystem.readdir({
@@ -1370,9 +1374,9 @@ ${props.text}`,
* Exporte l'itinéraire sous forme d'un fichier à partir de son ID
* @param {Number} routeId
*/
- exportRouteFromID(routeId) {
+ exportRouteFromID(routeId, format = null) {
try {
- this.exportRoute(this.#getRouteFromID(routeId));
+ this.exportRoute(this.#getRouteFromID(routeId), format);
} catch (e) {
console.warn(e);
Toast.show({
@@ -1421,25 +1425,27 @@ ${props.text}`,
* Affiche l'itinéraire s'il est caché, ou le cache s'il est affiché
* @param {*} route
*/
- toggleShowRoute(route) {
+ toggleShowRoute(route, fly = true) {
if (route.visible) {
route.visible = false;
} else {
route.visible = true;
- this.hide();
- let coordinates = [];
- route.data.steps.forEach((step) => {
- coordinates = coordinates.concat(step.geometry.coordinates);
- });
- const bounds = coordinates.reduce((bounds, coord) => {
- return bounds.extend([coord[0], coord[1]]);
- }, new maplibregl.LngLatBounds([coordinates[0][0], coordinates[0][1]], [coordinates[0][0], coordinates[0][1]]));
- if (Location.isTrackingActive()) {
- Location.disableTracking();
+ if (fly) {
+ this.hide();
+ let coordinates = [];
+ route.data.steps.forEach((step) => {
+ coordinates = coordinates.concat(step.geometry.coordinates);
+ });
+ const bounds = coordinates.reduce((bounds, coord) => {
+ return bounds.extend(coord);
+ }, new maplibregl.LngLatBounds(coordinates[0], coordinates[0]));
+ if (Location.isTrackingActive()) {
+ Location.disableTracking();
+ }
+ this.map.fitBounds(bounds, {
+ padding: 100,
+ });
}
- this.map.fitBounds(bounds, {
- padding: 100,
- });
}
this.#updateSources();
}
@@ -1448,11 +1454,11 @@ ${props.text}`,
* Affiche l'itinéraire s'il est caché à partir de son ID
* @param {Number} routeId
*/
- showRouteFromID(routeId) {
+ showRouteFromID(routeId, fly = true) {
try {
const route = this.#getRouteFromID(routeId);
if (!route.visible) {
- this.toggleShowRoute(route);
+ this.toggleShowRoute(route, fly);
}
} catch (e) {
console.warn(e);
@@ -1489,20 +1495,52 @@ ${props.text}`,
* Affiche le point de repère s'il est caché, ou le cache s'il est affiché
* @param {*} landmark
*/
- toggleShowLandmark(landmark) {
+ toggleShowLandmark(landmark, fly = true) {
if (landmark.properties.visible) {
landmark.properties.visible = false;
} else {
landmark.properties.visible = true;
- this.hide();
- if (Location.isTrackingActive()) {
- Location.disableTracking();
+ if (fly) {
+ this.hide();
+ if (Location.isTrackingActive()) {
+ Location.disableTracking();
+ }
+ this.map.flyTo({center: landmark.geometry.coordinates, zoom: 14});
}
- this.map.flyTo({center: landmark.geometry.coordinates, zoom: 14});
}
this.#updateSources();
}
+ /**
+ * Affiche le repère s'il est caché à partir de son ID
+ * @param {Number} landmarkId
+ */
+ showLandmarkFromID(landmarkId, fly = true) {
+ try {
+ const landmark = this.#getLandmarkFromID(landmarkId);
+ if (!landmark.properties.visible) {
+ this.toggleShowLandmark(landmark, fly);
+ }
+ } catch (e) {
+ console.warn(e);
+ }
+ }
+
+ /**
+ * Cache le repère s'il est visible à partir de son ID
+ * @param {Number} landmarkId
+ */
+ hideLandmarkFromID(landmarkId) {
+ try {
+ const landmark = this.#getLandmarkFromID(landmarkId);
+ if (landmark.properties.visible) {
+ this.toggleShowLandmark(landmark);
+ }
+ } catch (e) {
+ console.warn(e);
+ }
+ }
+
/**
* Récupère un itinéraire via son ID
* @param {Number} routeId