Compare commits
7 Commits
edit-bug-f
...
double-ema
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08a94ca4f8 | ||
|
|
a0f2b044b2 | ||
|
|
7db74acad7 | ||
|
|
56865b4670 | ||
|
|
1a8ac3fba4 | ||
|
|
de3c76315e | ||
|
|
e969a8dc8b |
@@ -1,8 +1,21 @@
|
||||
const { currentRERequest } = require('../helpers/url');
|
||||
const { gardenSizes, getRealEstateTypeEnum } = require('../helpers/enums');
|
||||
const { getRealEstateTypeEnum } = require('../helpers/enums');
|
||||
|
||||
const getGardenSize = (req,res) => {
|
||||
res.render('gardenSize', { gardenSizes });
|
||||
const rangeFrom = {
|
||||
min : 10,
|
||||
max : 3000,
|
||||
value : 0,
|
||||
step : 10
|
||||
}
|
||||
|
||||
const rangeTo = {
|
||||
min : 10,
|
||||
max : 3000,
|
||||
value : 100,
|
||||
step : 10
|
||||
}
|
||||
res.render('gardenSize', { rangeFrom, rangeTo });
|
||||
};
|
||||
|
||||
const postGardenSize = async (req, res) => {
|
||||
@@ -13,7 +26,8 @@ const postGardenSize = async (req, res) => {
|
||||
|
||||
const realEstateType = getRealEstateTypeEnum(request.realEstateType);
|
||||
if (realEstateType && realEstateType.hasGardenSize) {
|
||||
request.gardenSize = req.body.gardensize;
|
||||
request.gardenSizeMin = req.body.from;
|
||||
request.gardenSizeMax = req.body.to;
|
||||
await request.save();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,22 @@
|
||||
const { currentRERequest } = require('../helpers/url');
|
||||
const { prices } = require('../helpers/enums');
|
||||
|
||||
const getPrice = (req,res) => {
|
||||
res.render('price', { prices });
|
||||
const rangeFrom = {
|
||||
min : 1000,
|
||||
max : 250000,
|
||||
value : 0,
|
||||
step : 1000
|
||||
}
|
||||
|
||||
const rangeTo = {
|
||||
min : 1000,
|
||||
max : 250000,
|
||||
value : 50000,
|
||||
step : 1000
|
||||
}
|
||||
|
||||
|
||||
res.render('price', {rangeFrom, rangeTo });
|
||||
};
|
||||
|
||||
const postPrice = async (req, res) => {
|
||||
@@ -11,7 +25,8 @@ const postPrice = async (req, res) => {
|
||||
const nextStepPage = req.query.nextStep || 'pregled';
|
||||
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}`;
|
||||
|
||||
request.price = req.body.price;
|
||||
request.priceMin = req.body.from;
|
||||
request.priceMax = req.body.to;
|
||||
await request.save();
|
||||
|
||||
res.redirect(nextStepUrl);
|
||||
|
||||
@@ -10,7 +10,16 @@ const getQueryReview = async (req,res) => {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { realEstateType, region, municipality, size, gardenSize, price } = request.dataValues;
|
||||
const {
|
||||
realEstateType,
|
||||
region,
|
||||
municipality,
|
||||
sizeMin,
|
||||
sizeMax,
|
||||
gardenSizeMin,
|
||||
gardenSizeMax,
|
||||
priceMin,
|
||||
priceMax } = request.dataValues;
|
||||
|
||||
const realEstateTypeObject = getRealEstateTypeEnum(realEstateType);
|
||||
const enableGardenSizeEdit = realEstateTypeObject ? realEstateTypeObject.hasGardenSize : false;
|
||||
@@ -18,9 +27,9 @@ const getQueryReview = async (req,res) => {
|
||||
const realEstateTypeTitle = realEstateType ? getEnumTypeTitle(realEstateTypes, realEstateType) : null;
|
||||
const regionName = region ? getRegionName(region) : null;
|
||||
const municipalityName = (region && municipality) ? getMunicipalityName(region, municipality) : null;
|
||||
const sizeTitle = size ? getEnumTypeTitle(sizes, size) : null;
|
||||
const gardenSizeTitle = gardenSize ? getEnumTypeTitle(gardenSizes, gardenSize) : null;
|
||||
const priceTitle = price ? getEnumTypeTitle(prices, price) : null;
|
||||
const sizeTitle = sizeMin ? sizeMin + "-" + sizeMax + " m2" : null;
|
||||
const gardenSizeTitle = gardenSizeMin ? gardenSizeMin + "-" + gardenSizeMax + " m2" : null;
|
||||
const priceTitle = priceMin ? priceMin + "-" + priceMax + " KM" : null;
|
||||
|
||||
const uniqueId = request.dataValues.uniqueId ? request.dataValues.uniqueId : '';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const { currentRERequest } = require('../helpers/url');
|
||||
const { isValidEmail } = require('../helpers/email');
|
||||
|
||||
const getQuerySubmit = async (req,res) => {
|
||||
const getQuerySubmit = async (req, res) => {
|
||||
const nextStep = req.query.nextStep;
|
||||
const error = req.query.error;
|
||||
|
||||
@@ -16,14 +16,30 @@ const postQuerySubmit = async (req, res) => {
|
||||
const nextStep = req.query.nextStep || '/ponovo';
|
||||
|
||||
const emailInput = req.body.email;
|
||||
const emailConfirmInput = req.body.confirm;
|
||||
let error = "Greška ! Unesite validan email";
|
||||
|
||||
if (isValidEmail(emailInput)){
|
||||
request.email = req.body.email;
|
||||
await request.save();
|
||||
res.redirect(nextStep);
|
||||
} else {
|
||||
res.redirect('?error=1');
|
||||
if (!isValidEmail(emailInput) || !isValidEmail(emailConfirmInput)) {
|
||||
|
||||
error = "Greška ! Unesite validan email";
|
||||
res.render('querySubmit', {
|
||||
error
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (emailInput !== emailConfirmInput) {
|
||||
|
||||
error = "Greška ! Unešeni emailovi nisu isti";
|
||||
res.render('querySubmit', {
|
||||
error
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
request.email = req.body.email;
|
||||
await request.save();
|
||||
res.redirect(nextStep);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -2,7 +2,21 @@ const { currentRERequest } = require('../helpers/url');
|
||||
const { sizes, getRealEstateTypeEnum } = require('../helpers/enums');
|
||||
|
||||
const getSize = (req,res) => {
|
||||
res.render('size', { sizes });
|
||||
const rangeFrom = {
|
||||
min : 10,
|
||||
max : 250,
|
||||
value : 0,
|
||||
step : 10
|
||||
}
|
||||
|
||||
const rangeTo = {
|
||||
min : 10,
|
||||
max : 250,
|
||||
value : 50,
|
||||
step : 10
|
||||
}
|
||||
|
||||
res.render('size', { rangeFrom, rangeTo });
|
||||
};
|
||||
|
||||
const postSize = async (req, res) => {
|
||||
@@ -13,8 +27,8 @@ const postSize = async (req, res) => {
|
||||
const nextStep = realEstateType && realEstateType.hasGardenSize ? 'okucnica' : 'cijena';
|
||||
const nextStepPage = req.query.nextStep || nextStep;
|
||||
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}`;
|
||||
|
||||
request.size = req.body.size;
|
||||
request.sizeMin = req.body.from;
|
||||
request.sizeMax = req.body.to;
|
||||
await request.save();
|
||||
|
||||
res.redirect(nextStepUrl);
|
||||
|
||||
27
app/migrations/20190529093410-slider-fields.js
Normal file
27
app/migrations/20190529093410-slider-fields.js
Normal file
@@ -0,0 +1,27 @@
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction((t) => {
|
||||
return Promise.all([
|
||||
queryInterface.addColumn('RealEstateRequests', 'sizeRange', {
|
||||
type: Sequelize.STRING
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'gardenSizeRange', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'priceRange', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t })
|
||||
])
|
||||
})
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction((t) => {
|
||||
return Promise.all([
|
||||
queryInterface.removeColumn('RealEstateRequests', 'sizeRange', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'gardenSizeRange', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'priceRange', { transaction: t })
|
||||
])
|
||||
})
|
||||
}
|
||||
};
|
||||
63
app/migrations/20190530101945-range-fields.js
Normal file
63
app/migrations/20190530101945-range-fields.js
Normal file
@@ -0,0 +1,63 @@
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction((t) => {
|
||||
return Promise.all([
|
||||
queryInterface.removeColumn('RealEstateRequests', 'sizeRange', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'gardenSizeRange', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'priceRange', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'size', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'gardenSize', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'price', { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'gardenSizeMin', {
|
||||
type: Sequelize.INTEGER,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'gardenSizeMax', {
|
||||
type: Sequelize.INTEGER,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'sizeMin', {
|
||||
type: Sequelize.INTEGER
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'sizeMax', {
|
||||
type: Sequelize.INTEGER,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'priceMin', {
|
||||
type: Sequelize.INTEGER,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'priceMax', {
|
||||
type: Sequelize.INTEGER
|
||||
}, { transaction: t })
|
||||
])
|
||||
})
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction((t) => {
|
||||
return Promise.all([
|
||||
queryInterface.removeColumn('RealEstateRequests', 'gardenSizeMin', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'gardenSizeMax', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'sizeMin', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'sizeMax', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'priceMin', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'priceMin', { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'priceMax', {
|
||||
type: Sequelize.STRING
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'gardenSizeRange', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'priceRange', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'size', {
|
||||
type: Sequelize.STRING
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'gardenSize', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'price', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t })
|
||||
])
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -12,9 +12,12 @@ module.exports = (sequelize, DataTypes) => {
|
||||
email: DataTypes.STRING,
|
||||
region: DataTypes.STRING,
|
||||
municipality: DataTypes.STRING,
|
||||
size: DataTypes.STRING,
|
||||
gardenSize: DataTypes.STRING,
|
||||
price: DataTypes.STRING,
|
||||
sizeMin: DataTypes.INTEGER,
|
||||
sizeMax: DataTypes.INTEGER,
|
||||
gardenSizeMin: DataTypes.INTEGER,
|
||||
gardenSizeMax: DataTypes.INTEGER,
|
||||
priceMin: DataTypes.INTEGER,
|
||||
priceMax: DataTypes.INTEGER,
|
||||
bounding_box: DataTypes.GEOMETRY('POINT', 4326)
|
||||
}, {});
|
||||
RealEstateRequest.associate = function(models) {
|
||||
|
||||
@@ -3,27 +3,4 @@
|
||||
<h2>Koliko okućnice tražite ?</h2>
|
||||
</div>
|
||||
|
||||
<form method="POST" id="form-gardensize">
|
||||
<div class="row center-align">
|
||||
<ul class="collection with-header">
|
||||
<% for(const gardenSize of gardenSizes) { %>
|
||||
<li class="collection-item" >
|
||||
<div id="<%= gardenSize.id %>" onclick="saveAndSubmit(this.id)"><%= gardenSize.title %>
|
||||
<a href="#" class="secondary-content">
|
||||
<i class="material-icons">send</i>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
<input type="hidden" name="gardensize" id="gardensize" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
function saveAndSubmit(id) {
|
||||
$("#gardensize").val(id);
|
||||
$("#form-gardensize").submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
<% include partials/range %>
|
||||
|
||||
@@ -73,10 +73,10 @@
|
||||
$("#btnsubmit").click(() => {
|
||||
var bounds = map.getBounds();
|
||||
|
||||
$("#north").val(bounds.na.l);
|
||||
$("#south").val(bounds.na.j);
|
||||
$("#east").val(bounds.ia.l);
|
||||
$("#west").val(bounds.ia.j);
|
||||
$("#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();
|
||||
});
|
||||
|
||||
56
app/views/partials/range.ejs
Normal file
56
app/views/partials/range.ejs
Normal file
@@ -0,0 +1,56 @@
|
||||
<form method="POST" id="form-range">
|
||||
|
||||
<div>
|
||||
<div class="row center-align">
|
||||
<h6>Od</h6>
|
||||
</div>
|
||||
<p class="range-field">
|
||||
<input
|
||||
name="from"
|
||||
id="from"
|
||||
type="range"
|
||||
value="<%= rangeFrom.value %>"
|
||||
min="<%= rangeFrom.min %>"
|
||||
max="<%= rangeFrom.max %>"
|
||||
step="<%= rangeFrom.step %>"/>
|
||||
</p>
|
||||
<div class="row center-align">
|
||||
<h6>Do</h6>
|
||||
</div>
|
||||
<p class="range-field">
|
||||
<input
|
||||
name="to"
|
||||
id="to"
|
||||
type="range"
|
||||
value="<%= rangeTo.value %>"
|
||||
min="<%= rangeTo.min %>"
|
||||
max="<%= rangeTo.max %>"
|
||||
step="<%= rangeTo.step %>"/>
|
||||
</p>
|
||||
</div>
|
||||
<div class="col s6 push-s3">
|
||||
<a id="btnsubmit" href="#" class="welcome-center-button waves-effect waves-light btn">
|
||||
Dalje
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(() => {
|
||||
|
||||
$("#btnsubmit").click(() => {
|
||||
var from = $("#from").val();
|
||||
var to = $("#to").val();
|
||||
console.log("From " + from + " " + to);
|
||||
|
||||
if (parseInt(from, 10) >= parseInt(to, 10)) {
|
||||
alert("\"Od\" vrijednost ne smije biti veca od \"Do\" vrijednosti ")
|
||||
return;
|
||||
}
|
||||
|
||||
$("#form-range").submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -3,27 +3,4 @@
|
||||
<h2>Koja Vam okvirna cijena odgovara ?</h2>
|
||||
</div>
|
||||
|
||||
<form method="POST" id="form-price">
|
||||
<div class="row center-align">
|
||||
<ul class="collection with-header">
|
||||
<% for(const price of prices) { %>
|
||||
<li class="collection-item" >
|
||||
<div id="<%= price.id %>" onclick="saveAndSubmit(this.id)"><%= price.title %>
|
||||
<a href="#" class="secondary-content">
|
||||
<i class="material-icons">send</i>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
<input type="hidden" name="price" id="price" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
function saveAndSubmit(id) {
|
||||
$("#price").val(id);
|
||||
$("#form-price").submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
<% include partials/range %>
|
||||
|
||||
@@ -9,13 +9,25 @@
|
||||
<input id="email" name="email" type="email" placeholder="vas.email@mail.com" required size="250" />
|
||||
</div>
|
||||
</div>
|
||||
<% if (error) {%>
|
||||
<div class="row">
|
||||
<div class="col s6 push-s3">
|
||||
<h6 style="color: red">Greška ! Unesite ispravan email</h6>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col s6 push-s3">
|
||||
<h6 id="error-lable-email" style="color: red"><%= error %> </h6>
|
||||
</div>
|
||||
<%}%>
|
||||
</div>
|
||||
|
||||
<div class="row center-align">
|
||||
<div class="col s6 push-s3">
|
||||
<input id="confirm" name="confirm" type="email" placeholder="potvrdite.email@mail.com" required size="250" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col s6 push-s3">
|
||||
<h6 id="error-lable-email-confirm" style="color: red"></h6>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col s6 push-s3">
|
||||
<a id="submit" href="#" class="welcome-center-button waves-effect waves-light btn">
|
||||
@@ -31,13 +43,26 @@
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$(document).ready( () => {
|
||||
$("#submit").click( () => {
|
||||
const emailField = document.getElementById('email');
|
||||
if (emailField.validity.valid){
|
||||
$("#form-submitquery").submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
$(document).ready(() => {
|
||||
$("#submit").click(() => {
|
||||
const emailField = document.getElementById('email');
|
||||
const emailConfirmField = document.getElementById('confirm');
|
||||
const errorMessage = "Greška ! Unedite validan email";
|
||||
$("#error-lable-email").text("");
|
||||
$("#error-lable-email-confirm").text("");
|
||||
|
||||
if (!emailField.validity.valid) {
|
||||
$("#error-lable-email").text(errorMessage);
|
||||
return
|
||||
}
|
||||
|
||||
if (!emailConfirmField.validity.valid) {
|
||||
$("#error-lable-email-confirm").text(errorMessage);
|
||||
return
|
||||
}
|
||||
|
||||
$("#form-submitquery").submit();
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -1,29 +1,6 @@
|
||||
<!--suppress HtmlUnknownAnchorTarget -->
|
||||
<div class="row center-align">
|
||||
<h2>Do koliko kvadrata tražite nekretninu ?</h2>
|
||||
<h2>Od koliko kvadrata tražite nekretninu ?</h2>
|
||||
</div>
|
||||
|
||||
<form method="POST" id="form-size">
|
||||
<div class="row center-align">
|
||||
<ul class="collection with-header">
|
||||
<% for(const size of sizes) { %>
|
||||
<li class="collection-item">
|
||||
<div id="<%= size.id %>" onclick="saveAndSubmit(this.id)"><%= size.title %>
|
||||
<a href="#" class="secondary-content">
|
||||
<i class="material-icons">send</i>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
<input type="hidden" name="size" id="size" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
function saveAndSubmit(id) {
|
||||
$("#size").val(id);
|
||||
$("#form-size").submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
<% include partials/range %>
|
||||
|
||||
Reference in New Issue
Block a user