diff --git a/app/controllers/neighborhoodMap.js b/app/controllers/location.js similarity index 59% rename from app/controllers/neighborhoodMap.js rename to app/controllers/location.js index f3a8e22..185bee9 100644 --- a/app/controllers/neighborhoodMap.js +++ b/app/controllers/location.js @@ -1,28 +1,42 @@ const { currentRERequest } = require("../helpers/url"); -const getNeighborhood = async (req, res) => { +const getLocation = async (req, res) => { const title = "U kojem naselju tražite nekretninu?"; - const municipality = req.params.municipality; const nextStep = req.query.nextStep || "/"; - res.render("neighborhoodMap", { + res.render("location", { nextStep, - municipality, title }); }; -const postNeighborhood = async (req, res) => { +const postLocation = async (req, res) => { let request = await currentRERequest(req); + const northWest = [req.body.west, req.body.north]; const northEast = [req.body.east, req.body.north]; const southEast = [req.body.east, req.body.south]; const southWest = [req.body.west, req.body.south]; - request.bounding_box = { + request.locationInput = + req.body.locationInput && req.body.locationInput.length > 0 + ? req.body.locationInput + : null; + + request.boundingBox = { type: "Polygon", coordinates: [[northWest, northEast, southEast, southWest, northWest]] }; + + let locationInputData; + if (req.body.locationInputData) { + try { + locationInputData = JSON.parse(req.body.locationInputData); + } catch (e) { + locationInputData = null; + } + } + await request.save(); const nextStepPage = req.query.nextStep || "povrsina"; @@ -32,6 +46,6 @@ const postNeighborhood = async (req, res) => { }; module.exports = { - getNeighborhood, - postNeighborhood + getLocation, + postLocation }; diff --git a/app/views/location.ejs b/app/views/location.ejs new file mode 100644 index 0000000..8365cc5 --- /dev/null +++ b/app/views/location.ejs @@ -0,0 +1,96 @@ +<% include partials/navBar %> + +
+
+
+ +
+
+
+
+
+
+
+ Dalje +
+
+ + + + + + +
+ + +