From f4baec23cf2ffeeff32dd12cfe5bd0b22dad80de Mon Sep 17 00:00:00 2001 From: Nedim Uka Date: Mon, 27 May 2019 15:17:41 +0200 Subject: [PATCH] Fixed bug related to map region edit --- app/controllers/municipalities.js | 5 +++-- app/controllers/neighborhoodMap.js | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/controllers/municipalities.js b/app/controllers/municipalities.js index f64b185..9dbf8c6 100644 --- a/app/controllers/municipalities.js +++ b/app/controllers/municipalities.js @@ -9,9 +9,10 @@ const getMunicipality = async (req, res) => { }; const postMunicipality = async (req, res) => { + const request = await currentRERequest(req); - const nextStepPage = req.query.nextStep || 'naselje'; - const nextStepUrl = `/${nextStepPage}/${request.uniqueId}/${getMunicipalityName(request.region, req.body.municipality)}`; + const nextStepParam = req.query.nextStep ? "?nextStep=" + req.query.nextStep : ""; + const nextStepUrl = `/${'naselje'}/${request.uniqueId}/${getMunicipalityName(request.region, req.body.municipality)}${nextStepParam}`; request.municipality = req.body.municipality; await request.save(); diff --git a/app/controllers/neighborhoodMap.js b/app/controllers/neighborhoodMap.js index 3874459..e88193d 100644 --- a/app/controllers/neighborhoodMap.js +++ b/app/controllers/neighborhoodMap.js @@ -3,7 +3,6 @@ const { currentRERequest } = require('../helpers/url'); const getNeighborhood = async (req, res) => { const municipality = req.params.municipality const nextStep = req.query.nextStep || '/'; - res.render('neighborhoodMap', { nextStep, municipality @@ -25,8 +24,11 @@ const postNeighborhood = async (req, res) => { ] }; await request.save(); - const nextStep = req.query.nextStep || `/povrsina/${request.uniqueId}`; - res.redirect(nextStep); + + const nextStepPage = req.query.nextStep || 'povrsina'; + const nextStepUrl = `/${nextStepPage}/${request.uniqueId}`; + + res.redirect(nextStepUrl); }; module.exports = {