Skip to content

Commit

Permalink
fix: Use an intermediate page to link to a move id
Browse files Browse the repository at this point in the history
Closes #873
  • Loading branch information
kumy committed Oct 8, 2023
1 parent 61ab1d3 commit 54fcdd5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ function onEachFeature(feature, layer) {
} else {
author = `<em class="user-anonymous">${ author }</em>`;
}
let move_link = "{'geokret_details_by_move_id'|alias:'gkid=%GKID%,moveid=%MOVEID%'}"
.replace('%MOVEID%', feature.properties.move_id)
.replace('%GKID%', "{$geokret->gkid}");
layer.bindPopup(`
<h4>${ moveTypeIcon(feature.properties.move_type) } ${ moveTypeText(feature.properties.move_type) }</h4>
<h5>{t}Move details:{/t}</h5>
Expand All @@ -119,7 +122,7 @@ function onEachFeature(feature, layer) {
<div class="text-center">
<div class="btn-group" role="group">
${ previousMoveButton(feature) }
<a href="#log${ feature.properties.move_id }" class="btn btn-default btn-xs popup-move-navigate" title="{t}Show move{/t}" data-id="${ feature.properties.step }">
<a href="${ move_link }" class="btn btn-default btn-xs popup-move-navigate" title="{t}Show move{/t}" data-id="${ feature.properties.step }">
{t}Show move{/t}
</a>
${ nextMoveButton(feature) }
Expand Down
15 changes: 15 additions & 0 deletions website/app/GeoKrety/Controller/Pages/GeokretDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,19 @@ public function get($f3) {

// TODO check if GeoKret has already been discovered, and display Tracking Code
}

public function geokret_details_by_move_id(\Base $f3) {
$move_id = $f3->get('PARAMS.moveid');
if (!ctype_digit($move_id)) {
\Flash::instance()->addMessage(_('Invalid log_id'), 'danger');
$f3->reroute(sprintf('@geokret_details(@gkid=%s)', $this->geokret->gkid));
}
$move = new Move();
$move->load(['id = ?', $move_id]);
if ($move->dry()) {
\Flash::instance()->addMessage(_('Invalid log_id'), 'danger');
$f3->reroute(sprintf('@geokret_details(@gkid=%s)', $this->geokret->gkid));
}
$f3->reroute(sprintf('@geokret_details_paginate(@gkid=%s,@page=%d)#log%d', $this->geokret->gkid, $move->getMoveOnPage(), $move_id));
}
}
1 change: 1 addition & 0 deletions website/app/authorizations.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ allow @user_update_email_revalidate = *
allow @user_update_email_revalidate_token = *
allow @geokret_details = *
allow @geokret_details_paginate = *
allow @geokret_details_by_move_id = *
allow @photo_gallery = *
allow @photo_gallery_paginate = *
allow @move_create = *
Expand Down
1 change: 1 addition & 0 deletions website/app/routes.ini
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ POST @geokrety_move_edit: /moves/@moveid/edit = \GeoKrety\Controller\MoveCreate-
GET @move_delete: /moves/@moveid/delete [sync] = \GeoKrety\Controller\MoveDelete->get
GET @move_delete: /moves/@moveid/delete [ajax] = \GeoKrety\Controller\MoveDelete->get_ajax
POST @move_delete: /moves/@moveid/delete = \GeoKrety\Controller\MoveDelete->post
GET @geokret_details_by_move_id: /geokrety/@gkid/move/@moveid = \GeoKrety\Controller\GeokretDetails->geokret_details_by_move_id

; Validations
POST @validate_tracking_code: /validate/tracking-code = \GeoKrety\Controller\Validation\TrackingCode->post
Expand Down

0 comments on commit 54fcdd5

Please sign in to comment.