map next and previous
parent
06ad0503ae
commit
010a7f4d59
|
|
@ -8,6 +8,8 @@ export async function handler(request, response) {
|
|||
'/lots/?error=noNextLotIdFound');
|
||||
return;
|
||||
}
|
||||
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') + '/lots/' + nextLotId.toString());
|
||||
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/lots/' +
|
||||
nextLotId.toString());
|
||||
}
|
||||
export default handler;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,9 @@ export async function handler(
|
|||
}
|
||||
|
||||
response.redirect(
|
||||
configFunctions.getProperty('reverseProxy.urlPrefix') + '/lots/' + nextLotId.toString()
|
||||
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/lots/' +
|
||||
nextLotId.toString()
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
import type { Request, Response } from 'express';
|
||||
export declare function handler(request: Request, response: Response): Promise<void>;
|
||||
export default handler;
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
import * as configFunctions from '../../helpers/functions.config.js';
|
||||
import { getNextMapId } from '../../helpers/lotOccupancyDB/getNextMapId.js';
|
||||
export async function handler(request, response) {
|
||||
const mapId = Number.parseInt(request.params.mapId, 10);
|
||||
const nextMapId = await getNextMapId(mapId);
|
||||
if (nextMapId === undefined) {
|
||||
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/maps/?error=noNextMapIdFound');
|
||||
return;
|
||||
}
|
||||
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/maps/' +
|
||||
nextMapId.toString());
|
||||
}
|
||||
export default handler;
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
import type { Request, Response } from 'express'
|
||||
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
|
||||
import { getNextMapId } from '../../helpers/lotOccupancyDB/getNextMapId.js'
|
||||
|
||||
export async function handler(
|
||||
request: Request,
|
||||
response: Response
|
||||
): Promise<void> {
|
||||
const mapId = Number.parseInt(request.params.mapId, 10)
|
||||
|
||||
const nextMapId = await getNextMapId(mapId)
|
||||
|
||||
if (nextMapId === undefined) {
|
||||
response.redirect(
|
||||
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/maps/?error=noNextMapIdFound'
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
response.redirect(
|
||||
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/maps/' +
|
||||
nextMapId.toString()
|
||||
)
|
||||
}
|
||||
|
||||
export default handler
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
import type { Request, Response } from 'express';
|
||||
export declare function handler(request: Request, response: Response): Promise<void>;
|
||||
export default handler;
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
import * as configFunctions from '../../helpers/functions.config.js';
|
||||
import { getPreviousMapId } from '../../helpers/lotOccupancyDB/getPreviousMapId.js';
|
||||
export async function handler(request, response) {
|
||||
const mapId = Number.parseInt(request.params.mapId, 10);
|
||||
const previousMapId = await getPreviousMapId(mapId);
|
||||
if (previousMapId === undefined) {
|
||||
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/maps/?error=noPreviousMapIdFound');
|
||||
return;
|
||||
}
|
||||
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/maps/' +
|
||||
previousMapId.toString());
|
||||
}
|
||||
export default handler;
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
import type { Request, Response } from 'express'
|
||||
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
|
||||
import { getPreviousMapId } from '../../helpers/lotOccupancyDB/getPreviousMapId.js'
|
||||
|
||||
export async function handler(
|
||||
request: Request,
|
||||
response: Response
|
||||
): Promise<void> {
|
||||
const mapId = Number.parseInt(request.params.mapId, 10)
|
||||
|
||||
const previousMapId = await getPreviousMapId(mapId)
|
||||
|
||||
if (previousMapId === undefined) {
|
||||
response.redirect(
|
||||
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/maps/?error=noPreviousMapIdFound'
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
response.redirect(
|
||||
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/maps/' +
|
||||
previousMapId.toString()
|
||||
)
|
||||
}
|
||||
|
||||
export default handler
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
export declare function getNextMapId(mapId: number | string): Promise<number | undefined>;
|
||||
export default getNextMapId;
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
export async function getNextMapId(mapId) {
|
||||
const database = await acquireConnection();
|
||||
const result = database
|
||||
.prepare(`select mapId
|
||||
from Maps
|
||||
where recordDelete_timeMillis is null
|
||||
and mapName > (select mapName from Maps where mapId = ?)
|
||||
order by mapName
|
||||
limit 1`)
|
||||
.get(mapId);
|
||||
database.release();
|
||||
if (result === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return result.mapId;
|
||||
}
|
||||
export default getNextMapId;
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function getNextMapId(
|
||||
mapId: number | string
|
||||
): Promise<number | undefined> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const result: {
|
||||
mapId: number
|
||||
} = database
|
||||
.prepare(
|
||||
`select mapId
|
||||
from Maps
|
||||
where recordDelete_timeMillis is null
|
||||
and mapName > (select mapName from Maps where mapId = ?)
|
||||
order by mapName
|
||||
limit 1`
|
||||
)
|
||||
.get(mapId)
|
||||
|
||||
database.release()
|
||||
|
||||
if (result === undefined) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return result.mapId
|
||||
}
|
||||
|
||||
export default getNextMapId
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
export declare function getPreviousMapId(mapId: number | string): Promise<number | undefined>;
|
||||
export default getPreviousMapId;
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
export async function getPreviousMapId(mapId) {
|
||||
const database = await acquireConnection();
|
||||
const result = database
|
||||
.prepare(`select mapId from Maps
|
||||
where recordDelete_timeMillis is null
|
||||
and mapName < (select mapName from Maps where mapId = ?)
|
||||
order by mapName desc
|
||||
limit 1`)
|
||||
.get(mapId);
|
||||
database.release();
|
||||
if (result === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return result.mapId;
|
||||
}
|
||||
export default getPreviousMapId;
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function getPreviousMapId(
|
||||
mapId: number | string
|
||||
): Promise<number | undefined> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const result: {
|
||||
mapId: number
|
||||
} = database
|
||||
.prepare(
|
||||
`select mapId from Maps
|
||||
where recordDelete_timeMillis is null
|
||||
and mapName < (select mapName from Maps where mapId = ?)
|
||||
order by mapName desc
|
||||
limit 1`
|
||||
)
|
||||
.get(mapId)
|
||||
|
||||
database.release()
|
||||
|
||||
if (result === undefined) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return result.mapId
|
||||
}
|
||||
|
||||
export default getPreviousMapId
|
||||
|
|
@ -2,6 +2,8 @@ import { Router } from 'express';
|
|||
import * as permissionHandlers from '../handlers/permissions.js';
|
||||
import handler_search from '../handlers/maps-get/search.js';
|
||||
import handler_view from '../handlers/maps-get/view.js';
|
||||
import handler_next from '../handlers/maps-get/next.js';
|
||||
import handler_previous from '../handlers/maps-get/previous.js';
|
||||
import handler_new from '../handlers/maps-get/new.js';
|
||||
import handler_edit from '../handlers/maps-get/edit.js';
|
||||
import handler_doCreateMap from '../handlers/maps-post/doCreateMap.js';
|
||||
|
|
@ -11,6 +13,8 @@ export const router = Router();
|
|||
router.get('/', handler_search);
|
||||
router.get('/new', permissionHandlers.updateGetHandler, handler_new);
|
||||
router.get('/:mapId', handler_view);
|
||||
router.get('/:mapId/next', handler_next);
|
||||
router.get('/:mapId/previous', handler_previous);
|
||||
router.get('/:mapId/edit', permissionHandlers.updateGetHandler, handler_edit);
|
||||
router.post('/doCreateMap', permissionHandlers.updatePostHandler, handler_doCreateMap);
|
||||
router.post('/doUpdateMap', permissionHandlers.updatePostHandler, handler_doUpdateMap);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ import * as permissionHandlers from '../handlers/permissions.js'
|
|||
import handler_search from '../handlers/maps-get/search.js'
|
||||
|
||||
import handler_view from '../handlers/maps-get/view.js'
|
||||
import handler_next from '../handlers/maps-get/next.js'
|
||||
import handler_previous from '../handlers/maps-get/previous.js'
|
||||
|
||||
import handler_new from '../handlers/maps-get/new.js'
|
||||
import handler_edit from '../handlers/maps-get/edit.js'
|
||||
|
||||
|
|
@ -24,6 +27,10 @@ router.get(
|
|||
|
||||
router.get('/:mapId', handler_view as RequestHandler)
|
||||
|
||||
router.get('/:mapId/next', handler_next as RequestHandler)
|
||||
|
||||
router.get('/:mapId/previous', handler_previous as RequestHandler)
|
||||
|
||||
router.get(
|
||||
'/:mapId/edit',
|
||||
permissionHandlers.updateGetHandler,
|
||||
|
|
|
|||
|
|
@ -21,14 +21,33 @@
|
|||
<%= map.mapName || "(No Name)" %>
|
||||
</h1>
|
||||
|
||||
<% if (user.userProperties.canUpdate) { %>
|
||||
<div class="level is-fixed-bottom is-mobile has-background-white has-shadow is-hidden-print">
|
||||
<div class="level-left">
|
||||
<span class="level-item has-text-weight-bold">
|
||||
<%= map.mapName || "(No Name)" %>
|
||||
</span>
|
||||
|
||||
<div class="level is-fixed-bottom is-mobile has-background-white has-shadow is-hidden-print">
|
||||
<div class="level-left">
|
||||
<span class="level-item has-text-weight-bold">
|
||||
<%= map.mapName || "(No Name)" %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="level-right">
|
||||
<div class="level-item">
|
||||
<a class="button is-link is-outlined has-tooltip-left"
|
||||
data-tooltip="Previous <%= configFunctions.getProperty("aliases.map") %>"
|
||||
href="<%= urlPrefix %>/maps/<%= map.mapId %>/previous"
|
||||
accesskey=",">
|
||||
<i class="fas fa-arrow-left" aria-hidden="true"></i>
|
||||
<span class="sr-only">Previous <%= configFunctions.getProperty("aliases.map") %></span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="level-right">
|
||||
<div class="level-item">
|
||||
<a class="button is-link has-tooltip-left"
|
||||
data-tooltip="Next <%= configFunctions.getProperty("aliases.map") %>"
|
||||
href="<%= urlPrefix %>/maps/<%= map.mapId %>/next"
|
||||
accesskey=".">
|
||||
<span>Next</span>
|
||||
<span class="icon"><i class="fas fa-arrow-right" aria-hidden="true"></i></span>
|
||||
</a>
|
||||
</div>
|
||||
<% if (user.userProperties.canUpdate) { %>
|
||||
<div class="level-item">
|
||||
<a class="button is-primary"
|
||||
href="<%= urlPrefix %>/maps/<%= map.mapId %>/edit"
|
||||
|
|
@ -37,9 +56,9 @@
|
|||
<span>Switch to Edit Mode</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-block is-block">
|
||||
|
|
|
|||
Loading…
Reference in New Issue