Make place selection possible
This commit is contained in:
@@ -14,10 +14,11 @@ const getGrad = (req,res) => {
|
||||
}
|
||||
|
||||
const postGrad = async (req, res) => {
|
||||
let request = await currentRERequest(req);
|
||||
const request = await currentRERequest(req);
|
||||
const nextStep = req.query.nextStep || `/mjesto/${request.uniqueId}`;
|
||||
request.city = req.body.grad;
|
||||
await request.save();
|
||||
res.send("Result is " + JSON.stringify(request));
|
||||
res.redirect(nextStep)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -14,7 +14,8 @@ const getMjesto = async (req,res) => {
|
||||
|
||||
const postMjesto = async (req, res) => {
|
||||
let request = await currentRERequest(req);
|
||||
request.city = req.body.mjesto;
|
||||
request.place = req.body.mjesto;
|
||||
console.log("AAA ", req.body);
|
||||
await request.save();
|
||||
res.send("Result is " + JSON.stringify(request));
|
||||
}
|
||||
|
||||
@@ -6,11 +6,6 @@ const geographies = [
|
||||
"id":"sarajevo",
|
||||
"olxid": "9",
|
||||
"mjesta":[
|
||||
{
|
||||
"ime":"Mjesto",
|
||||
"id":"mjesto",
|
||||
"olxid":"0"
|
||||
},
|
||||
{
|
||||
"ime":"Hadžići",
|
||||
"id":"hadii",
|
||||
@@ -63,11 +58,6 @@ const geographies = [
|
||||
"id":"unskosanski",
|
||||
"olxid": "9",
|
||||
"mjesta":[
|
||||
{
|
||||
"ime":"Mjesto",
|
||||
"id":"mjesto",
|
||||
"olxid":"0"
|
||||
},
|
||||
{
|
||||
"ime":"Bihać",
|
||||
"id":"biha",
|
||||
@@ -115,11 +105,6 @@ const geographies = [
|
||||
"id":"posavski",
|
||||
"olxid": "15",
|
||||
"mjesta":[
|
||||
{
|
||||
"ime":"Mjesto",
|
||||
"id":"mjesto",
|
||||
"olxid":"0"
|
||||
},
|
||||
{
|
||||
"ime":"Domaljevac",
|
||||
"id":"domaljevac",
|
||||
@@ -147,11 +132,6 @@ const geographies = [
|
||||
"id":"tuzlanski",
|
||||
"olxid": "15",
|
||||
"mjesta":[
|
||||
{
|
||||
"ime":"Mjesto",
|
||||
"id":"mjesto",
|
||||
"olxid":"0"
|
||||
},
|
||||
{
|
||||
"ime":"Banovići",
|
||||
"id":"banovii",
|
||||
@@ -224,11 +204,6 @@ const geographies = [
|
||||
"id":"zenickodobojski",
|
||||
"olxid": "15",
|
||||
"mjesta":[
|
||||
{
|
||||
"ime":"Mjesto",
|
||||
"id":"mjesto",
|
||||
"olxid":"0"
|
||||
},
|
||||
{
|
||||
"ime":"Breza",
|
||||
"id":"breza",
|
||||
@@ -296,11 +271,6 @@ const geographies = [
|
||||
"id":"bosanskopodrinjski",
|
||||
"olxid": "15",
|
||||
"mjesta":[
|
||||
{
|
||||
"ime":"Mjesto",
|
||||
"id":"mjesto",
|
||||
"olxid":"0"
|
||||
},
|
||||
{
|
||||
"ime":"Foča",
|
||||
"id":"foa",
|
||||
@@ -323,11 +293,6 @@ const geographies = [
|
||||
"id":"srednjobosanski",
|
||||
"olxid": "6",
|
||||
"mjesta":[
|
||||
{
|
||||
"ime":"Mjesto",
|
||||
"id":"mjesto",
|
||||
"olxid":"0"
|
||||
},
|
||||
{
|
||||
"ime":"Bugojno",
|
||||
"id":"bugojno",
|
||||
@@ -395,11 +360,6 @@ const geographies = [
|
||||
"id":"hercegovackoneretvanski",
|
||||
"olxid": "7",
|
||||
"mjesta":[
|
||||
{
|
||||
"ime":"Mjesto",
|
||||
"id":"mjesto",
|
||||
"olxid":"0"
|
||||
},
|
||||
{
|
||||
"ime":"Grad Mostar",
|
||||
"id":"gradmostar",
|
||||
@@ -452,11 +412,6 @@ const geographies = [
|
||||
"id":"zapadnohercegovacki",
|
||||
"olxid": "8",
|
||||
"mjesta":[
|
||||
{
|
||||
"ime":"Mjesto",
|
||||
"id":"mjesto",
|
||||
"olxid":"0"
|
||||
},
|
||||
{
|
||||
"ime":"Grude",
|
||||
"id":"grude",
|
||||
@@ -484,11 +439,6 @@ const geographies = [
|
||||
"id":"livanjski",
|
||||
"olxid": "10",
|
||||
"mjesta":[
|
||||
{
|
||||
"ime":"Mjesto",
|
||||
"id":"mjesto",
|
||||
"olxid":"0"
|
||||
},
|
||||
{
|
||||
"ime":"Bosansko Grahovo",
|
||||
"id":"bosanskograhovo",
|
||||
@@ -526,11 +476,6 @@ const geographies = [
|
||||
"id":"banjalučka",
|
||||
"olxid": "14",
|
||||
"mjesta":[
|
||||
{
|
||||
"ime":"Mjesto",
|
||||
"id":"mjesto",
|
||||
"olxid":"0"
|
||||
},
|
||||
{
|
||||
"ime":"Banja Luka",
|
||||
"id":"banjaluka",
|
||||
@@ -643,11 +588,6 @@ const geographies = [
|
||||
"id":"dobojskobijeljinska",
|
||||
"olxid": "15",
|
||||
"mjesta":[
|
||||
{
|
||||
"ime":"Mjesto",
|
||||
"id":"mjesto",
|
||||
"olxid":"0"
|
||||
},
|
||||
{
|
||||
"ime":"Bijeljina",
|
||||
"id":"bijeljina",
|
||||
@@ -745,11 +685,6 @@ const geographies = [
|
||||
"id":"sarajevskozvornicka",
|
||||
"olxid": "16",
|
||||
"mjesta":[
|
||||
{
|
||||
"ime":"Mjesto",
|
||||
"id":"mjesto",
|
||||
"olxid":"0"
|
||||
},
|
||||
{
|
||||
"ime":"Bratunac",
|
||||
"id":"bratunac",
|
||||
@@ -872,11 +807,6 @@ const geographies = [
|
||||
"id":"trebinjskofocanska",
|
||||
"olxid": "17",
|
||||
"mjesta":[
|
||||
{
|
||||
"ime":"Mjesto",
|
||||
"id":"mjesto",
|
||||
"olxid":"0"
|
||||
},
|
||||
{
|
||||
"ime":"Berkovići",
|
||||
"id":"berkovii",
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.addColumn(
|
||||
'RealEstateRequests',
|
||||
'place',
|
||||
Sequelize.STRING
|
||||
);
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.removeColumn(
|
||||
'RealEstateRequests',
|
||||
'place'
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -12,6 +12,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
},
|
||||
email: DataTypes.STRING,
|
||||
city: DataTypes.STRING,
|
||||
place: DataTypes.STRING,
|
||||
}, {});
|
||||
RealEstateRequest.associate = function(models) {
|
||||
// associations can be defined here
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<div class="row center-align">
|
||||
<h2>U kojoj regiji tražite nekretninu?</h2>
|
||||
<h2>U kojem mjestu tražite nekretninu?</h2>
|
||||
</div>
|
||||
|
||||
<form method="POST" id="form-grad">
|
||||
<form method="POST" id="form-mjesto">
|
||||
<div class="row center-align">
|
||||
<ul class="collection with-header">
|
||||
<% for(const grad of gradovi) { %>
|
||||
<li class="collection-item" > <div id="<%= grad.id %>" ><%= grad.ime %><a href="#!" class="secondary-content"><i class="material-icons">send</i></a></div></li>
|
||||
<% for(const mjesto of mjesta) { %>
|
||||
<li class="collection-item" > <div id="<%= mjesto.id %>" ><%= mjesto.ime %><a href="#!" class="secondary-content"><i class="material-icons">send</i></a></div></li>
|
||||
<% } %>
|
||||
</ul>
|
||||
<input type="hidden" name="grad" id="grad" />
|
||||
<input type="hidden" name="mjesto" id="mjesto" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
$(document).ready( () => {
|
||||
$(".collection-item").click( (e) => {
|
||||
const clickedId = $(e.target).attr("id");
|
||||
$("#grad").val(clickedId);
|
||||
$("#form-grad").submit();
|
||||
$("#mjesto").val(clickedId);
|
||||
$("#form-mjesto").submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
5
index.js
5
index.js
@@ -1,6 +1,7 @@
|
||||
const dobrodosli = require('./app/controllers/dobrodosli').getDobrodosli;
|
||||
const { getVrstaNekretnine, postVrstaNekretnine} = require('./app/controllers/vrsta_nekretnine');
|
||||
const { getGrad, postGrad } = require('./app/controllers/grad');
|
||||
const { getMjesto, postMjesto } = require('./app/controllers/mjesto');
|
||||
|
||||
let express = require("express");
|
||||
const path = require("path");
|
||||
@@ -117,6 +118,10 @@ app.post('/vrstanekretnine', postVrstaNekretnine);
|
||||
app.get('/grad/:request_id', getGrad);
|
||||
app.post('/grad/:request_id', postGrad);
|
||||
|
||||
app.get('/mjesto/:request_id', getMjesto);
|
||||
app.post('/mjesto/:request_id', postMjesto);
|
||||
|
||||
|
||||
app.use('/assets', express.static('./app/public'))
|
||||
|
||||
app.listen(port, () => console.log(`Example app listening on port ${port}!`));
|
||||
|
||||
Reference in New Issue
Block a user