Paging in activity edit view ("Cancel" and "Submit" buttons should work now)
This commit is contained in:
parent
0a42ebc0e4
commit
a14d8da621
2 changed files with 7 additions and 6 deletions
|
|
@ -36,9 +36,7 @@ public class ActivitiesViewController {
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public String viewActivity(@PathVariable String id, @RequestParam String page, Model model) {
|
public String viewActivity(@PathVariable String id, @RequestParam String page, Model model) {
|
||||||
// The activity data will be loaded via JavaScript API calls
|
// The activity data will be loaded via JavaScript API calls
|
||||||
if (page != null) {
|
model.addAttribute("page", page != null ? page : "1");
|
||||||
model.addAttribute("page", page);
|
|
||||||
}
|
|
||||||
return "activities/detail";
|
return "activities/detail";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,8 +44,9 @@ public class ActivitiesViewController {
|
||||||
* Show activity edit page
|
* Show activity edit page
|
||||||
*/
|
*/
|
||||||
@GetMapping("/{id}/edit")
|
@GetMapping("/{id}/edit")
|
||||||
public String editActivity(@PathVariable String id) {
|
public String editActivity(@PathVariable String id, @RequestParam String page, Model model) {
|
||||||
// The activity data will be loaded via JavaScript API calls
|
// The activity data will be loaded via JavaScript API calls
|
||||||
|
model.addAttribute("page", page != null ? page : "1");
|
||||||
return "activities/edit";
|
return "activities/edit";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Submit Buttons -->
|
<!-- Submit Buttons -->
|
||||||
|
<p th:text="${'Page: ' + page}"></p>
|
||||||
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
|
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
|
||||||
<a th:href="@{/activities}" class="btn btn-outline-secondary" id="cancelBtn">
|
<a th:href="@{/activities}" class="btn btn-outline-secondary" id="cancelBtn">
|
||||||
<i class="bi bi-x-circle"></i> Cancel
|
<i class="bi bi-x-circle"></i> Cancel
|
||||||
|
|
@ -165,6 +166,7 @@
|
||||||
<script th:inline="javascript">
|
<script th:inline="javascript">
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
const activityId = window.location.pathname.split('/').slice(-2, -1)[0];
|
const activityId = window.location.pathname.split('/').slice(-2, -1)[0];
|
||||||
|
const page = new URLSearchParams(window.location.search).get('page') || 1;
|
||||||
const form = document.getElementById('editForm');
|
const form = document.getElementById('editForm');
|
||||||
const loadingIndicator = document.getElementById('loadingIndicator');
|
const loadingIndicator = document.getElementById('loadingIndicator');
|
||||||
const editCard = document.getElementById('editCard');
|
const editCard = document.getElementById('editCard');
|
||||||
|
|
@ -229,7 +231,7 @@
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// Update cancel button to go back to activity detail
|
// Update cancel button to go back to activity detail
|
||||||
cancelBtn.href = `/activities/${activityId}`;
|
cancelBtn.href = `/activities/${activityId}?page=${page}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderMap(simplifiedTrack) {
|
function renderMap(simplifiedTrack) {
|
||||||
|
|
@ -295,7 +297,7 @@
|
||||||
|
|
||||||
// Redirect to activity detail page
|
// Redirect to activity detail page
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.href = `/activities/${activityId}`;
|
window.location.href = `/activities/${activityId}?page=${page}`;
|
||||||
}, 1500);
|
}, 1500);
|
||||||
} else {
|
} else {
|
||||||
const errorData = await response.json();
|
const errorData = await response.json();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue