Merged in feature/MAPG-117-map-selection-page (pull request #91)

MAPG-117 remove admin/maps and place a button to the maps page if admin is logged in
This commit is contained in:
Bence Pőcze 2020-06-09 22:31:40 +00:00
commit 4b0057e3ba
8 changed files with 22 additions and 18 deletions

View File

@ -23,7 +23,6 @@ Container::$routeCollection->group('game', function (MapGuesser\Routing\RouteCol
$routeCollection->post('guess-json', '{mapId}/guess.json', [MapGuesser\Controller\GameFlowController::class, 'evaluateGuess']); $routeCollection->post('guess-json', '{mapId}/guess.json', [MapGuesser\Controller\GameFlowController::class, 'evaluateGuess']);
}); });
Container::$routeCollection->group('admin', function (MapGuesser\Routing\RouteCollection $routeCollection) { Container::$routeCollection->group('admin', function (MapGuesser\Routing\RouteCollection $routeCollection) {
$routeCollection->get('admin.maps', 'maps', [MapGuesser\Controller\MapAdminController::class, 'getMaps']);
$routeCollection->get('admin.mapEditor', 'mapEditor/{mapId}', [MapGuesser\Controller\MapAdminController::class, 'getMapEditor']); $routeCollection->get('admin.mapEditor', 'mapEditor/{mapId}', [MapGuesser\Controller\MapAdminController::class, 'getMapEditor']);
$routeCollection->get('admin.place', 'place.json/{placeId}', [MapGuesser\Controller\MapAdminController::class, 'getPlace']); $routeCollection->get('admin.place', 'place.json/{placeId}', [MapGuesser\Controller\MapAdminController::class, 'getPlace']);
$routeCollection->post('admin.saveMap', 'saveMap/{mapId}/json', [MapGuesser\Controller\MapAdminController::class, 'saveMap']); $routeCollection->post('admin.saveMap', 'saveMap/{mapId}/json', [MapGuesser\Controller\MapAdminController::class, 'saveMap']);

View File

@ -162,6 +162,14 @@ button.red:hover, button.red:focus, a.button.red:hover, a.button.red:focus {
background-color: #7f2929; background-color: #7f2929;
} }
button.yellow, a.button.yellow {
background-color: #e8a349;
}
button.yellow:hover, button.yellow:focus, a.button.yellow:hover, a.button.yellow:focus {
background-color: #c37713;
}
input, select, textarea { input, select, textarea {
background-color: #f9fafb; background-color: #f9fafb;
border: solid #c8d2e1 1px; border: solid #c8d2e1 1px;

View File

@ -27,7 +27,7 @@ div.mapItem>img {
} }
div.mapItem>div.inner { div.mapItem>div.inner {
padding: 8px; padding: 10px 8px;
} }
div.mapItem>div.inner>div.info { div.mapItem>div.inner>div.info {

View File

@ -37,13 +37,6 @@ class MapAdminController implements ISecured
return $user !== null && $user->hasPermission(IUser::PERMISSION_ADMIN); return $user !== null && $user->hasPermission(IUser::PERMISSION_ADMIN);
} }
public function getMaps(): IContent
{
//TODO
return new HtmlContent('admin/maps');
}
public function getMapEditor(): IContent public function getMapEditor(): IContent
{ {
$mapId = (int) $this->request->query('mapId'); $mapId = (int) $this->request->query('mapId');

View File

@ -2,13 +2,22 @@
use MapGuesser\Database\Query\Select; use MapGuesser\Database\Query\Select;
use MapGuesser\Database\RawExpression; use MapGuesser\Database\RawExpression;
use MapGuesser\Interfaces\Authentication\IUser;
use MapGuesser\Interfaces\Database\IResultSet; use MapGuesser\Interfaces\Database\IResultSet;
use MapGuesser\Interfaces\Request\IRequest;
use MapGuesser\Interfaces\Response\IContent; use MapGuesser\Interfaces\Response\IContent;
use MapGuesser\Util\Geo\Bounds; use MapGuesser\Util\Geo\Bounds;
use MapGuesser\Response\HtmlContent; use MapGuesser\Response\HtmlContent;
class MapsController class MapsController
{ {
private IRequest $request;
public function __construct(IRequest $request)
{
$this->request = $request;
}
public function getMaps(): IContent public function getMaps(): IContent
{ {
$select = new Select(\Container::$dbConnection, 'maps'); $select = new Select(\Container::$dbConnection, 'maps');
@ -36,7 +45,8 @@ class MapsController
$maps[] = $map; $maps[] = $map;
} }
$data = ['maps' => $maps]; $user = $this->request->user();
$data = ['maps' => $maps, 'isAdmin' => $user !== null && $user->hasPermission(IUser::PERMISSION_ADMIN)];
return new HtmlContent('maps', $data); return new HtmlContent('maps', $data);
} }

View File

@ -3,7 +3,7 @@
<div class="header small"> <div class="header small">
<div class="grid"> <div class="grid">
<h1> <h1>
<a href="/admin/maps" title="Back to maps"> <a href="/maps" title="Back to playable maps">
<img class="inline" src="/static/img/icon.svg"> <img class="inline" src="/static/img/icon.svg">
<span>MapGuesser</span> <span>MapGuesser</span>
</a> </a>

View File

@ -1,7 +0,0 @@
<?php require ROOT . '/views/templates/main_header.php'; ?>
<?php require ROOT . '/views/templates/header.php'; ?>
<div class="main">
<h2>Maps</h2>
<p>TODO</p>
</div>
<?php require ROOT . '/views/templates/main_footer.php'; ?>

View File

@ -31,6 +31,7 @@
<p class="small justify marginTop"><?= $map['description'] ?></p> <p class="small justify marginTop"><?= $map['description'] ?></p>
</div> </div>
<a class="button fullWidth" href="game/<?= $map['id']; ?>" title="Play map '<?= $map['name'] ?>'">Play this map</a> <a class="button fullWidth" href="game/<?= $map['id']; ?>" title="Play map '<?= $map['name'] ?>'">Play this map</a>
<a class="button yellow fullWidth marginTop" href="admin/mapEditor/<?= $map['id']; ?>" title="Edit map '<?= $map['name'] ?>'">Edit this map</a>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
<?php if (count($maps) < 4): ?> <?php if (count($maps) < 4): ?>