Skip to content

Commit

Permalink
feat:c2corg#3936 selecting starting and ending waypoints for a route
Browse files Browse the repository at this point in the history
- Starting points and ending points can be selected using a document input
  - They are stored in specific fields because the association's generic data structure
    isn't designed to add extra informations
  - The entire waypoints are provided in the document object in order to use it easily
  - Only access waypoints are displayed
     - The filter is done after the research
     - Possible improvement: add a filter on the api call
- Main waypoint is now selected by a document input, and the whole object is stored (not just the id)
  - Selected main waypoint is added to waypoints
- Waypoints selection has been moved in the configuration section
  - Allows to show/hide the end waypoint section after route type selection
- When adding a new route with provided waypoints
  - access waypoint are added to starting waypoints
  - main waypoint is guessed using the first non-access point, then the first access point
- All waypoints (start, end and intermediate) are still stored in document's waypoints attribute in order to avoid any data/api breaking changes
- Allow waypoint suppression directly from associationInputRow
  • Loading branch information
Nayor committed May 15, 2024
1 parent 2521e32 commit 3dec3ba
Show file tree
Hide file tree
Showing 21 changed files with 238 additions and 59 deletions.
10 changes: 8 additions & 2 deletions src/components/generics/inputs/InputDocument.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{{ $gettext(type + 's') | uppercaseFirstLetter }}
</div>
<div
v-for="document of promise.data[type + 's'].documents"
v-for="document of promise.data[type + 's'].documents.filter(optionsFilter)"
:key="document.document_id"
@mousedown="toggle(document)"
class="dropdown-item dropdown-item-option columns is-gapless has-cursor-pointer"
Expand Down Expand Up @@ -134,6 +134,10 @@ export default {
type: Boolean,
default: false,
},
optionsFilter: {
type: Function,
default: (doc) => doc,
},
},
data() {
Expand Down Expand Up @@ -162,7 +166,9 @@ export default {
documentTypesWithResults() {
const result = this.promise.data;
return this.documentTypes_.filter((type) => result[type + 's'] && result[type + 's'].documents.length !== 0);
return this.documentTypes_.filter(
(type) => result[type + 's'] && result[type + 's'].documents.filter(this.optionsFilter).length !== 0
);
},
letterTypes() {
Expand Down
4 changes: 4 additions & 0 deletions src/js/associations-rights-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export default {
return child.author.user_id === this.$user.id;
}

if (child.type === 'w' && parent.type === 'r') {
return true;
}

return false;
},
},
Expand Down
16 changes: 16 additions & 0 deletions src/js/constants/Field.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,18 @@ Field.prototype.isVisibleForWaypointTypes = function (waypointTypes) {
return utils.intersectionIsNotNull(this.waypoint_types, waypointTypes);
};

Field.prototype.isVisibleForRouteType = function (routeTypes) {
if (!this.route_types) {
return true;
}

if (!routeTypes) {
return false;
}

return utils.intersectionIsNotNull(this.route_types, routeTypes);
};

Field.prototype.isVisibleFor = function (document) {
if (!this.extraIsVisibleFor(document)) {
return false;
Expand All @@ -319,6 +331,10 @@ Field.prototype.isVisibleFor = function (document) {
return false;
}

if (document.type === 'r' && !this.isVisibleForRouteType(document.route_types)) {
return false;
}

return true;
};

Expand Down
8 changes: 8 additions & 0 deletions src/js/constants/documentsProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,12 @@
]
}
},
{
"id": "ending_waypoints",
"properties": {
"route_types": ["loop", "loop_hut", "traverse", "raid", "expedition"]
}
},
{
"id": "engagement_rating",
"properties": {
Expand Down Expand Up @@ -455,6 +461,7 @@
{ "id": "labande_ski_rating", "properties": { "url": "srat", "activities": ["skitouring"] } },
{ "id": "lift_access" },
{ "id": "main_waypoint_id" },
{ "id": "main_waypoint" },
{ "id": "mixed_rating", "properties": { "url": "mrat", "activities": ["snow_ice_mixed", "ice_climbing"] } },
{ "id": "mtb_down_rating", "properties": { "url": "mbdr", "activities": ["mountain_biking"] } },
{ "id": "mtb_height_diff_portages", "properties": { "url": "mbpush", "activities": ["mountain_biking"] } },
Expand Down Expand Up @@ -501,6 +508,7 @@
}
},
{ "id": "route_types", "properties": { "url": "rtyp" } },
{ "id": "starting_waypoints" },
{ "id": "ski_exposition", "properties": { "url": "sexpo", "activities": ["skitouring"] } },
{ "id": "ski_rating", "properties": { "url": "trat", "activities": ["skitouring"] } },
{ "id": "slackline_height", "properties": { "activities": ["slacklining"] } },
Expand Down
14 changes: 13 additions & 1 deletion src/js/constants/fieldsProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@
"unit": "m",
"helper": "1063027#elevation-up_snow"
},
"ending_waypoints": {
"type": "document",
"documentType": "waypoint",
"multiple": true
},
"engagement_rating": {
"values": "engagement_ratings",
"queryMode": "valuesRangeSlider",
Expand Down Expand Up @@ -541,7 +546,9 @@
"lift_status": {
"values": "lift_status"
},
"main_waypoint_id": {
"main_waypoint": {
"type": "document",
"documentType": "waypoint",
"helper": "1063045#main-waypoint"
},
"maps_info": {
Expand Down Expand Up @@ -881,6 +888,11 @@
"helper": "239491#snowshoe-rating",
"sortable": true
},
"starting_waypoints": {
"type": "document",
"documentType": "waypoint",
"multiple": true
},
"summary": {
"type": "markdown",
"parent": "locales"
Expand Down
2 changes: 1 addition & 1 deletion src/js/vue-plugins/document-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default function install(Vue) {
},

isInArray(array, document) {
return array.filter((item) => item.document_id === document.document_id).length !== 0;
return array.some((item) => item.document_id === document.document_id);
},

addAssociation(document, child) {
Expand Down
5 changes: 4 additions & 1 deletion src/translations/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"Danger rating - low": "Perill feble",
"Danger rating - moderate": "Perill moderat",
"Danger rating - very high": "Perill molt fort",
"Data like orientation, rock type, route type (such as return trip or loop) and route configuration type (such as ridge or gully).": "Dades tècniques, com l'orientació, el tipus de roca o la configuració general de l'itinerari (aresta, pilar, etc.)",
"Data like orientation, rock type, route type (such as return trip or loop), waypoints and route configuration type (such as ridge or gully).": "Dades tècniques, com l'orientació, el tipus de roca, punts de pas o la configuració general de l'itinerari (aresta, pilar, etc.)",
"Delete": {
"yeti": "Eliminar"
},
Expand Down Expand Up @@ -915,6 +915,7 @@
"quality_types": "buit"
},
"empty comment": "comentari buit",
"ending waypoints": "punts d'arribada",
"en": {
"langs": "anglès"
},
Expand Down Expand Up @@ -1180,6 +1181,7 @@
"book_types": "revista"
},
"main_waypoint_id": "ID del punt de pas principal",
"main_waypoint": "Punt de pas principal",
"male": {
"genders": "home"
},
Expand Down Expand Up @@ -1612,6 +1614,7 @@
"stone_ice_fall": {
"event_types": "caiguda de pedra/glaç/serac"
},
"starting waypoints": "punts de partida",
"stories": {
"article_categories": "narracions"
},
Expand Down
5 changes: 4 additions & 1 deletion src/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
"Danger rating - moderate": "Mässig",
"Danger rating - very high": "Sehr gross",
"Danger:": "Stufe :",
"Data like orientation, rock type, route type (such as return trip or loop) and route configuration type (such as ridge or gully).": "Technische Daten, wie Ausrichtung, Gestein oder Aufbau der Route (Kante, Rinne ...)",
"Data like orientation, rock type, route type (such as return trip or loop), waypoints and route configuration type (such as ridge or gully).": "Technische Daten, wie Ausrichtung, Gestein, Wegpunkte oder Aufbau der Route (Kante, Rinne ...)",
"Delete": {
"yeti": "Löschen"
},
Expand Down Expand Up @@ -1160,6 +1160,7 @@
"quality_types": "leer"
},
"empty comment": "leerer Kommentar",
"ending waypoints": "ankunftsorte",
"en": {
"langs": "englisch"
},
Expand Down Expand Up @@ -1447,6 +1448,7 @@
"book_types": "Zeitschrift"
},
"main_waypoint_id": "ID des Hauptwegpunkts",
"main_waypoint": "Hauptwegpunkts",
"male": {
"genders": "männlich"
},
Expand Down Expand Up @@ -1907,6 +1909,7 @@
"stories": {
"article_categories": "Geschichten"
},
"starting waypoints": "startpunkte",
"strava": "Strava",
"strong text": "fetter Text",
"summary": "Überblick",
Expand Down
1 change: 1 addition & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@
"route_types": "loop hut"
},
"main_waypoint_id": "ID of the main waypoint",
"main_waypoint": "Main waypoint",
"maps_info": "Maps info",
"maps_references": "Maps references",
"matress_unstaffed": "Matress if unstaffed",
Expand Down
5 changes: 4 additions & 1 deletion src/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"Danger rating - moderate": "Clasificación de peligro: moderado",
"Danger rating - very high": "Clasificación de peligro: muy alto",
"Danger:": "Peligro :",
"Data like orientation, rock type, route type (such as return trip or loop) and route configuration type (such as ridge or gully).": "Datos técnicos, tal como orientación, tipo de roca, o la configuración general del itinerario (arista, pilar...)",
"Data like orientation, rock type, route type (such as return trip or loop), waypoints and route configuration type (such as ridge or gully).": "Datos técnicos, tal como orientación, tipo de roca, puntos de ruta o la configuración general del itinerario (arista, pilar...)",
"Delete": {
"yeti": "Eliminar"
},
Expand Down Expand Up @@ -815,6 +815,7 @@
"quality_types": "vacío"
},
"empty comment": "comentario vacío",
"ending waypoints": "puntos de llegada",
"en": {
"langs": "inglés"
},
Expand Down Expand Up @@ -1074,6 +1075,7 @@
"book_types": "revista"
},
"main_waypoint_id": "ID del punto de ruta principal",
"main_waypoint": "Punto de ruta principal",
"male": {
"genders": "varón"
},
Expand Down Expand Up @@ -1460,6 +1462,7 @@
"stories": {
"article_categories": "historias"
},
"starting waypoints": "puntos de salida",
"strava": "Strava",
"summary": "Resumen",
"summit": {
Expand Down
2 changes: 2 additions & 0 deletions src/translations/eu.json
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@
"empty": {
"quality_types": "hutsa"
},
"ending waypoints": "iristeko puntuak",
"en": {
"langs": "ingelesa"
},
Expand Down Expand Up @@ -874,6 +875,7 @@
"stories": {
"article_categories": "kontakizuna"
},
"starting waypoints": "abia puntuak",
"strava": "Strava",
"summary": "laburpena",
"summit": {
Expand Down
7 changes: 5 additions & 2 deletions src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
"Danger rating - very high": "Danger très fort",
"Danger:": "Danger :",
"Dashboard": "Tableau de bord",
"Data like orientation, rock type, route type (such as return trip or loop) and route configuration type (such as ridge or gully).": "Données techniques, comme l'orientation, le type de roche ou la configuration générale de l'itinéraire (arête, pilier...)",
"Data like orientation, rock type, route type (such as return trip or loop), waypoints and route configuration type (such as ridge or gully).": "Données techniques, comme l'orientation, le type de roche, le type de route (aller-retour, boucle), les points de passage ou la configuration générale de l'itinéraire (arête, pilier...)",
"Delete": {
"yeti": "Supprimer"
},
Expand Down Expand Up @@ -257,7 +257,7 @@
"Extent": "Couverture",
"FAQ?": "FAQ ?",
"Fauna protection areas": "Faune",
"Fauna protection site:": "Site de protection de la faune :",
"Fauna protection site:": "Site de protection de la faune :",
"Feel free to edit it.": "Éditez-le.",
"Filter on map extent": "Limiter la recherche à la carte visible",
"Filter results": "Filtrer",
Expand Down Expand Up @@ -1033,6 +1033,7 @@
"quality_types": "vide"
},
"empty comment": "commentaire vide",
"ending waypoints": "points d'arrivée",
"en": {
"langs": "anglais"
},
Expand Down Expand Up @@ -1293,6 +1294,7 @@
"route_types": "boucle (approche ou refuge)"
},
"main_waypoint_id": "ID du point de passage principal",
"main_waypoint": "Point de passage principal",
"male": {
"genders": "homme"
},
Expand Down Expand Up @@ -1718,6 +1720,7 @@
"stone_ice_fall": {
"event_types": "chute de pierre/glace/serac"
},
"starting waypoints": "points de départ",
"stories": {
"article_categories": "récits"
},
Expand Down
8 changes: 7 additions & 1 deletion src/translations/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
"Danger rating - low": "Veszélyességi besorolás - alacsony",
"Danger rating - moderate": "Veszélyességi besorolás - mérsékelt",
"Danger rating - very high": "Veszélyességi besorolás - nagyon magas",
"Data like orientation, rock type, route type (such as return trip or loop) and route configuration type (such as ridge or gully).": "Adatok, mint például orientáció, szikla típus, út típus (pl. oda-vissza, vagy körtúra) és út körülmények (pl. gerinc vagy vízmosás).",
"Data like orientation, rock type, route type (such as return trip or loop), waypoints and route configuration type (such as ridge or gully).": "Adatok, mint például orientáció, szikla típus, út típus (pl. oda-vissza, vagy körtúra), útpont és út körülmények (pl. gerinc vagy vízmosás).",
"Delete": {
"yeti": "Törlés"
},
Expand Down Expand Up @@ -900,7 +900,11 @@
"quality_types": "üres"
},
"empty comment": "üres megjegyzés",
"ending waypoints": "érkezési pontok",
"engagement_rating": "elkötelezettség_besorolás",
"en": {
"langs": "angol"
},
"environment": {
"book_types": "környezet"
},
Expand Down Expand Up @@ -1149,6 +1153,7 @@
"book_types": "folyóirat"
},
"main_waypoint_id": "fő_útvonalpont_azonosító",
"main_waypoint": "fő útvonalpont",
"male": {
"genders": "férfi"
},
Expand Down Expand Up @@ -1582,6 +1587,7 @@
"stories": {
"article_categories": "történetek"
},
"starting waypoints": "indulási pontok",
"strava": "Strava",
"strong text": "hangsúlyos szöveg",
"summary": "összefoglaló",
Expand Down
5 changes: 4 additions & 1 deletion src/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
"Danger rating - very high": "Grado molto forte",
"Danger:": "Pericolo:",
"Dashboard": "Pannello interattivo",
"Data like orientation, rock type, route type (such as return trip or loop) and route configuration type (such as ridge or gully).": "Dati tecnici, come l'orientazione, il tipo di roccia o la configurazione dell'itinerario ",
"Data like orientation, rock type, route type (such as return trip or loop), waypoints and route configuration type (such as ridge or gully).": "Dati tecnici, come l'orientazione, il tipo di roccia, tipo di itinerario (andata e ritorno, loop), punto di passaggio o la configurazione dell'itinerario ",
"Delete": {
"yeti": "Cancellare"
},
Expand Down Expand Up @@ -1055,6 +1055,7 @@
"quality_types": "vuoto"
},
"empty comment": "commento vuoto",
"ending waypoints": "punti di arrivo",
"en": {
"langs": "inglese"
},
Expand Down Expand Up @@ -1328,6 +1329,7 @@
"book_types": "rivista"
},
"main_waypoint_id": "ID del punto di passaggio principale",
"main_waypoint": "unto di passaggio principale",
"male": {
"genders": "maschio "
},
Expand Down Expand Up @@ -1775,6 +1777,7 @@
"stories": {
"article_categories": "racconti"
},
"starting waypoints": "punti di partenza",
"strava": "Strava",
"strong text": "testo in grassetto ",
"summary": "Riassunto",
Expand Down
Loading

0 comments on commit 3dec3ba

Please sign in to comment.