From 2f59fb20215912d60c2f2527bbbf2adb914704ee Mon Sep 17 00:00:00 2001
From: cro
Date: Thu, 19 Dec 2024 16:10:46 +0100
Subject: [PATCH 1/3] add repetition choice in pages/ascent/outdoor/new.vue et
EditCragAscentBtn.vue
---
components/ascentCragRoutes/EditCragAscentBtn.vue | 1 +
pages/ascents/outdoor/new.vue | 1 +
2 files changed, 2 insertions(+)
diff --git a/components/ascentCragRoutes/EditCragAscentBtn.vue b/components/ascentCragRoutes/EditCragAscentBtn.vue
index 540a973d..1c02d0f6 100644
--- a/components/ascentCragRoutes/EditCragAscentBtn.vue
+++ b/components/ascentCragRoutes/EditCragAscentBtn.vue
@@ -26,6 +26,7 @@
:ascent-crag-route="ascentCragRoute"
submit-methode="put"
:callback="successCallback"
+ :repetition=true
/>
diff --git a/pages/ascents/outdoor/new.vue b/pages/ascents/outdoor/new.vue
index 248915cf..48cf2ca4 100644
--- a/pages/ascents/outdoor/new.vue
+++ b/pages/ascents/outdoor/new.vue
@@ -185,6 +185,7 @@
submit-methode="post"
:crag-route="cragRoute"
:callback="ascentAdded"
+ :repetition=true
/>
From 59411b8a3fb722d20402176c0b48672292ad180c Mon Sep 17 00:00:00 2001
From: cro
Date: Thu, 19 Dec 2024 16:48:17 +0100
Subject: [PATCH 2/3] repetition in new view only if already at least one
ascent on this crag route
---
.../ascentCragRoutes/EditCragAscentBtn.vue | 2 +-
components/cragRoutes/CragRouteAscent.vue | 2 +-
pages/ascents/outdoor/new.vue | 24 ++++++++++++++++++-
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/components/ascentCragRoutes/EditCragAscentBtn.vue b/components/ascentCragRoutes/EditCragAscentBtn.vue
index 1c02d0f6..8022af64 100644
--- a/components/ascentCragRoutes/EditCragAscentBtn.vue
+++ b/components/ascentCragRoutes/EditCragAscentBtn.vue
@@ -26,7 +26,7 @@
:ascent-crag-route="ascentCragRoute"
submit-methode="put"
:callback="successCallback"
- :repetition=true
+ :repetition="true"
/>
diff --git a/components/cragRoutes/CragRouteAscent.vue b/components/cragRoutes/CragRouteAscent.vue
index 3907cb99..bed95744 100644
--- a/components/cragRoutes/CragRouteAscent.vue
+++ b/components/cragRoutes/CragRouteAscent.vue
@@ -88,7 +88,7 @@ export default {
.catch((err) => {
this.$root.$emit('alertFromApiError', err, 'ascentCragRouteApi')
})
- .then(() => {
+ .finally(() => {
this.loadingAscents = false
})
}
diff --git a/pages/ascents/outdoor/new.vue b/pages/ascents/outdoor/new.vue
index 48cf2ca4..3eee2e19 100644
--- a/pages/ascents/outdoor/new.vue
+++ b/pages/ascents/outdoor/new.vue
@@ -185,7 +185,7 @@
submit-methode="post"
:crag-route="cragRoute"
:callback="ascentAdded"
- :repetition=true
+ :repetition="ascents.length > 0"
/>
@@ -272,6 +272,8 @@ import AscentCragRouteForm from '~/components/ascentCragRoutes/forms/AscentCragR
import CragRoutes from '~/components/cragRoutes/CragRoutes'
import MyFollowedCrags from '~/components/users/MyFollowedCrags'
import CragRouteDrawer from '~/components/cragRoutes/CragRouteDrawer'
+import AscentCragRouteApi from '~/services/oblyk-api/AscentCragRouteApi'
+import AscentCragRoute from '~/models/AscentCragRoute'
export default {
meta: { orphanRoute: true },
@@ -298,6 +300,7 @@ export default {
grade: null,
loadingGrade: false,
successAdded: false,
+ ascents: [],
mdiTerrain,
mdiPlus,
@@ -395,6 +398,25 @@ export default {
.finally(() => {
this.loadingCragRoute = false
})
+ this.getAscents(cragRouteId)
+ },
+
+ getAscents (cragRouteId) {
+ this.loadingAscents = true
+ this.ascents = []
+ new AscentCragRouteApi(this.$axios, this.$auth)
+ .all(cragRouteId)
+ .then((resp) => {
+ for (const ascent of resp.data) {
+ this.ascents.push(new AscentCragRoute({ attributes: ascent }))
+ }
+ })
+ .catch((err) => {
+ this.$root.$emit('alertFromApiError', err, 'ascentCragRouteApi')
+ })
+ .finally(() => {
+ this.loadingAscents = false
+ })
},
haveCragRoutesResults (results) {
From 08db19390e72c50b2bafaaf89230c27ef424e089 Mon Sep 17 00:00:00 2001
From: cro
Date: Fri, 20 Dec 2024 14:35:15 +0100
Subject: [PATCH 3/3] Restrict ascent form rendering until ascents are loaded.
Call getAscents outside getCragRoute
---
pages/ascents/outdoor/new.vue | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/pages/ascents/outdoor/new.vue b/pages/ascents/outdoor/new.vue
index 3eee2e19..eeac918d 100644
--- a/pages/ascents/outdoor/new.vue
+++ b/pages/ascents/outdoor/new.vue
@@ -181,7 +181,7 @@
{{ $t('components.ascentCragRoute.new', { name: cragRoute.name } ) }}
{
this.haveCragRoutesResults(results)
@@ -398,7 +400,6 @@ export default {
.finally(() => {
this.loadingCragRoute = false
})
- this.getAscents(cragRouteId)
},
getAscents (cragRouteId) {
@@ -426,6 +427,7 @@ export default {
selectCragRoute (cragRoute) {
this.getCragRoute(cragRoute.id)
+ this.getAscents(cragRoute.id)
this.addCragRouteBtn = false
},