From 3dec3ba4c846b6493b0b0d15a5ef3d2df41599a5 Mon Sep 17 00:00:00 2001 From: Nayor Date: Wed, 8 May 2024 19:46:37 +0200 Subject: [PATCH] feat:#3936 selecting starting and ending waypoints for a route - 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 --- .../generics/inputs/InputDocument.vue | 10 +- src/js/associations-rights-mixin.js | 4 + src/js/constants/Field.js | 16 +++ src/js/constants/documentsProperties.json | 8 ++ src/js/constants/fieldsProperties.json | 14 ++- src/js/vue-plugins/document-utils.js | 2 +- src/translations/ca.json | 5 +- src/translations/de.json | 5 +- src/translations/en.json | 1 + src/translations/es.json | 5 +- src/translations/eu.json | 2 + src/translations/fr.json | 7 +- src/translations/hu.json | 8 +- src/translations/it.json | 5 +- src/translations/ru.json | 5 +- src/translations/sl.json | 7 +- src/translations/zh_CN.json | 5 +- src/views/wiki/edition/RouteEditionView.vue | 106 ++++++++++++++---- .../edition/utils/AssociationsInputRow.vue | 39 +++++-- src/views/wiki/edition/utils/FormField.vue | 5 + src/views/wiki/edition/utils/FormInput.vue | 38 ++++--- 21 files changed, 238 insertions(+), 59 deletions(-) diff --git a/src/components/generics/inputs/InputDocument.vue b/src/components/generics/inputs/InputDocument.vue index 2b4866a8bd..0551c5d7d6 100644 --- a/src/components/generics/inputs/InputDocument.vue +++ b/src/components/generics/inputs/InputDocument.vue @@ -23,7 +23,7 @@ {{ $gettext(type + 's') | uppercaseFirstLetter }}
- +
-
- -
+
@@ -47,6 +56,16 @@ export default { type: String, default: undefined, // default must be undefined. null means explicit no helper }, + + cardsFilter: { + type: Function, + default: () => true, + }, + + optionsFilter: { + type: Function, + default: (doc) => doc, + }, }, computed: { @@ -60,7 +79,7 @@ export default { methods: { showDeleteButton(document) { - return this.canRemove(this.document, document); // ! FIXME import mixin + return this.canRemove(this.document, document); }, }, }; diff --git a/src/views/wiki/edition/utils/FormField.vue b/src/views/wiki/edition/utils/FormField.vue index d2f831864c..539714905d 100644 --- a/src/views/wiki/edition/utils/FormField.vue +++ b/src/views/wiki/edition/utils/FormField.vue @@ -22,6 +22,7 @@ :min="min" :divisor="divisor" :is-expanded="isExpanded" + :prefix="prefix" /> @@ -80,6 +81,10 @@ export default { type: String, default: undefined, }, + prefix: { + type: String, + default: null, + }, }, data() { diff --git a/src/views/wiki/edition/utils/FormInput.vue b/src/views/wiki/edition/utils/FormInput.vue index 74c041f327..2fd281cd22 100644 --- a/src/views/wiki/edition/utils/FormInput.vue +++ b/src/views/wiki/edition/utils/FormInput.vue @@ -18,17 +18,15 @@ -
- +
+
@@ -46,7 +44,8 @@ multiple clear-input-on-toggle :has-error="hasError" - @add="$documentUtils.propagateProperties(document, arguments[0])" + @add="onAdd" + :options-filter="optionsFilter" v-model="object[field.name]" /> @@ -115,7 +114,9 @@ import InputConditionsLevels from './InputConditionsLevels'; import { requireDocumentProperty, requireFieldProperty } from '@/js/properties-mixins'; export default { - components: { InputConditionsLevels }, + components: { + InputConditionsLevels, + }, mixins: [requireFieldProperty, requireDocumentProperty], @@ -148,6 +149,10 @@ export default { type: Number, default: undefined, }, + optionsFilter: { + type: Function, + default: (doc) => doc, + }, }, computed: { @@ -191,5 +196,12 @@ export default { return this.field.error !== null; }, }, + + methods: { + onAdd(child) { + this.$documentUtils.propagateProperties(this.document, arguments[0]); + this.$emit('add', child); + }, + }, };