remove obsolete controllers and views

This commit is contained in:
Bilal Catic
2019-09-10 07:42:59 +02:00
parent 7a18a89131
commit 854984029c
5 changed files with 0 additions and 242 deletions

View File

@@ -1,34 +0,0 @@
const { currentRERequest } = require("../helpers/url");
const {
getMunicipalitiesForRegion,
getMunicipalityName
} = require("../helpers/codes");
const getMunicipality = async (req, res) => {
const title = "U kojem mjestu tražite nekretninu?";
let request = await currentRERequest(req);
const municipalities = getMunicipalitiesForRegion(request.region);
res.render("municipality", { municipalities, title });
};
const postMunicipality = async (req, res) => {
const request = await currentRERequest(req);
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();
res.redirect(nextStepUrl);
};
module.exports = {
getMunicipality,
postMunicipality
};

View File

@@ -1,28 +0,0 @@
const { currentRERequest } = require("../helpers/url");
const { getRegions } = require("../helpers/codes");
const regions = getRegions();
const getRegion = (req, res) => {
const title = "U kojoj regiji tražite nekretninu?";
res.render("region", { regions, title });
};
const postRegion = async (req, res) => {
const request = await currentRERequest(req);
const nextStepQueryParam = req.query.nextStep ? "?nextStep=pregled" : "";
const nextStepPage = req.query.nextStep || "mjesto";
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}${nextStepQueryParam}`;
request.region = req.body.region;
request.municipality = null;
await request.save();
res.redirect(nextStepUrl);
};
module.exports = {
getRegion,
postRegion
};

View File

@@ -1,26 +0,0 @@
<!--suppress HtmlUnknownAnchorTarget -->
<% include partials/navBar %>
<form method="POST" id="form-municipality">
<div class="row center-align">
<ul class="collection with-header">
<% for(const municipality of municipalities) { %>
<li class="collection-item">
<div val="<%= municipality.name %>" id="<%= municipality.id %>" onclick="saveAndSubmit(this.id)"><%= municipality.name %>
<a href="#" class="secondary-content">
<i class="material-icons">send</i>
</a>
</div>
</li>
<% } %>
</ul>
<input type="hidden" name="municipality" id="municipality" />
</div>
</form>
<script>
function saveAndSubmit(id, name) {
$("#municipality").val(id);
$("#form-municipality").submit();
}
</script>

View File

@@ -1,127 +0,0 @@
<% include partials/navBar %>
<div class="row center-align">
<div id="floating-panel">
<input id="address" type="textbox" value="">
<input id="submit" type="button" value="Trazi">
</div>
<div id="map"></div>
</div>
<form method="POST" id="form-map-output">
<div class="row center-align">
<div class="col s6 push-s3">
<a id="btnsubmit" href="#" class="welcome-center-button waves-effect waves-light btn">
Dalje
</a>
</div>
</div>
<input type="hidden" name="north" id=north />
<input type="hidden" name="south" id=south />
<input type="hidden" name="east" id=east />
<input type="hidden" name="west" id=west />
</form>
<script>
var map;
var municipality = "<%= municipality%>";
var defaultAddress = document.getElementById('address');
var latLngRestrictions = [];
var BOSNIA_BOUNDS = {
north: 45.70,
south: 41.69,
west: 15.55,
east: 20.77,
};
function initMap() {
var geocoder = new google.maps.Geocoder();
document.getElementById('submit').addEventListener('click', function () {
geocodeAddress(geocoder, map, false, latLngRestrictions);
});
defaultAddress.value = municipality;
geocodeAddress(geocoder, map, true);
$(document).ready(() => {
$("#btnsubmit").click(() => {
var bounds = map.getBounds();
$("#north").val(map.getBounds().getNorthEast().lat());
$("#south").val(map.getBounds().getSouthWest().lat());
$("#east").val(map.getBounds().getNorthEast().lng());
$("#west").val(map.getBounds().getSouthWest().lng());
$("#form-map-output").submit();
});
});
}
function geocodeAddress(geocoder, resultsMap, isInit, geocoderRestrictions) {
var address = document.getElementById('address').value;
let geocoderOptions = geocoderRestrictions
? { 'address': address, 'bounds': geocoderRestrictions }
: { 'address': address }
geocoder.geocode(geocoderOptions, function (results, status) {
if (status === 'OK') {
var bounds = results[0].geometry.bounds;
var resultBounds = new google.maps.LatLngBounds(
results[0].geometry.viewport.getSouthWest(),
results[0].geometry.viewport.getNorthEast()
);
if (isInit) {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 11,
});
resultsMap = map
}
// map.fitBounds(resultBounds);
resultsMap.setCenter(results[0].geometry.location);
if (isInit) {
latLngRestrictions = new google.maps.LatLngBounds(
new google.maps.LatLng(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()),
new google.maps.LatLng(bounds.getNorthEast().lng(), bounds.getNorthEast().lng()));
let latLngRestrictionsa = {
west: bounds.getSouthWest().lng(),
east: bounds.getNorthEast().lng(),
north: bounds.getNorthEast().lat(),
south: bounds.getSouthWest().lat()
}
map.setOptions({
restriction: {
latLngBounds: latLngRestrictionsa,
strictBounds: false,
}
})
} else {
resultsMap.setZoom(17);
}
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAna8ohfV2HBMcxGk_29vqxU5Z_bDickqg&callback=initMap" async
defer></script>
</div>

View File

@@ -1,27 +0,0 @@
<!--suppress HtmlUnknownAnchorTarget -->
<% include partials/navBar %>
<form method="POST" id="form-region">
<div class="row center-align">
<ul class="collection with-header">
<% for(const region of regions) { %>
<li class="collection-item">
<div id="<%= region.id %>" onclick="saveAndSubmit(this.id)"><%= region.name %>
<a href="#" class="secondary-content">
<i class="material-icons">send</i>
</a>
</div>
</li>
<% } %>
</ul>
<input type="hidden" name="region" id="region" />
</div>
</form>
<script>
function saveAndSubmit(id) {
$("#region").val(id);
$("#form-region").submit();
}
</script>