WIP Form submit added.
This commit is contained in:
@@ -2,7 +2,12 @@ const { currentRealEstate } = require("../helpers/url");
|
|||||||
const { createRealEstate } = require("../helpers/db/realEstate");
|
const { createRealEstate } = require("../helpers/db/realEstate");
|
||||||
const { createKiviOriginal } = require("../helpers/db/kiviOriginal");
|
const { createKiviOriginal } = require("../helpers/db/kiviOriginal");
|
||||||
|
|
||||||
const { AD_CATEGORY, AD_TYPE, AD_AGENCY } = require("../common/enums");
|
const {
|
||||||
|
AD_CATEGORY,
|
||||||
|
FURNISHING_TYPE,
|
||||||
|
ACCESS_ROAD_TYPE,
|
||||||
|
HEATING_TYPE
|
||||||
|
} = require("../common/enums");
|
||||||
const {
|
const {
|
||||||
BASIC_BOOLEAN_PUBLISH,
|
BASIC_BOOLEAN_PUBLISH,
|
||||||
BASIC_SEGMENT_PUBLISH,
|
BASIC_SEGMENT_PUBLISH,
|
||||||
@@ -169,6 +174,10 @@ const postPublishInputs = async (req, res) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//const nextStepPage = req.query.nextStep || "pregled";
|
||||||
|
// const nextStepUrl = `/${nextStepPage}/${searchRequest.id}`;
|
||||||
|
const nextStepUrl = "/unsubscribe/";
|
||||||
|
|
||||||
const balcony = req.body.balcony === "on";
|
const balcony = req.body.balcony === "on";
|
||||||
const elevator = req.body.elevator === "on";
|
const elevator = req.body.elevator === "on";
|
||||||
const newBuilding = req.body.newBuilding === "on";
|
const newBuilding = req.body.newBuilding === "on";
|
||||||
@@ -198,31 +207,32 @@ const postPublishInputs = async (req, res) => {
|
|||||||
const buildingPermit = req.body.buildingPermit === "on";
|
const buildingPermit = req.body.buildingPermit === "on";
|
||||||
|
|
||||||
const furnishingType = req.body.furnishingType;
|
const furnishingType = req.body.furnishingType;
|
||||||
if (!FURNISHING_TYPE[furnishingType]) {
|
//VALIDACIJA TAKO POTVRDITI DA JE ISPRAVNA VRIJEDNOST
|
||||||
|
/* if (!FURNISHING_TYPE[furnishingType]) {
|
||||||
res.render("notFound", { title: " Greška !" });
|
res.render("notFound", { title: " Greška !" });
|
||||||
return;
|
return;
|
||||||
}
|
} */
|
||||||
const accessRoadType = req.body.accessRoadType;
|
const accessRoadType = req.body.accessRoadType;
|
||||||
if (!ACCESS_ROAD_TYPE[accessRoadType]) {
|
/*if (!ACCESS_ROAD_TYPE[accessRoadType]) {
|
||||||
res.render("notFound", { title: " Greška !" });
|
res.render("notFound", { title: " Greška !" });
|
||||||
return;
|
return;
|
||||||
}
|
} */
|
||||||
const heatingType = req.body.heatingType;
|
const heatingType = req.body.heatingType;
|
||||||
if (!HEATING_TYPE[heatingType]) {
|
/*if (!HEATING_TYPE[heatingType]) {
|
||||||
res.render("notFound", { title: " Greška !" });
|
res.render("notFound", { title: " Greška !" });
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
const price = parseFloat(req.body.price);
|
const price = parseFloat(req.body.price) || null;
|
||||||
const area = parseFloat(req.body.area);
|
const area = parseFloat(req.body.area) || null;
|
||||||
const gardenSize = parseFloat(req.body.gardenSize);
|
const gardenSize = parseFloat(req.body.gardenSize) || null;
|
||||||
const numberOfRooms = parseInt(req.body.numberOfRooms);
|
const numberOfRooms = parseInt(req.body.numberOfRooms) || null;
|
||||||
const numberOfFloors = parseInt(req.body.numberOfFloors);
|
const numberOfFloors = parseInt(req.body.numberOfFloors) || null;
|
||||||
const floor = parseInt(req.body.floor);
|
const floor = parseInt(req.body.floor) || null;
|
||||||
const title = req.body.title;
|
const title = req.body.title || "";
|
||||||
const shortDescription = req.body.shortDescription;
|
const shortDescription = req.body.shortDescription || "";
|
||||||
const streetName = req.body.streetName;
|
const streetName = req.body.streetName || "";
|
||||||
const longDescription = req.body.longDescription;
|
const longDescription = req.body.longDescription || "";
|
||||||
|
|
||||||
realEstate.balcony = balcony;
|
realEstate.balcony = balcony;
|
||||||
realEstate.elevator = elevator;
|
realEstate.elevator = elevator;
|
||||||
@@ -267,9 +277,10 @@ const postPublishInputs = async (req, res) => {
|
|||||||
realEstate.streetName = streetName;
|
realEstate.streetName = streetName;
|
||||||
|
|
||||||
realEstate.longDescription = longDescription;
|
realEstate.longDescription = longDescription;
|
||||||
//
|
|
||||||
console.log("postPublishInputs");
|
|
||||||
await realEstate.save();
|
await realEstate.save();
|
||||||
|
|
||||||
|
res.redirect(nextStepUrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -122,6 +122,8 @@ const getFilters = async (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const postFilters = async (req, res) => {
|
const postFilters = async (req, res) => {
|
||||||
|
//
|
||||||
|
console.log("postFilters");
|
||||||
const searchRequest = await currentSearchRequest(req);
|
const searchRequest = await currentSearchRequest(req);
|
||||||
|
|
||||||
if (!searchRequest || !searchRequest.dataValues) {
|
if (!searchRequest || !searchRequest.dataValues) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const currentRealEstate = async req => {
|
|||||||
const realEstateId = req && req.params ? req.params["realEstateId"] : null;
|
const realEstateId = req && req.params ? req.params["realEstateId"] : null;
|
||||||
if (!realEstateId) return null;
|
if (!realEstateId) return null;
|
||||||
|
|
||||||
return await getRealEstateById(realEstateId);
|
return await getRealEstateById(parseInt(realEstateId));
|
||||||
};
|
};
|
||||||
module.exports = {
|
module.exports = {
|
||||||
currentSearchRequest,
|
currentSearchRequest,
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
<br>
|
<br>
|
||||||
<div class="row center-align">
|
<div class="row center-align">
|
||||||
Vaš oglas je spreman za objavu.
|
Vaš oglas je spreman za objavu.
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col s6 push-s3">
|
||||||
|
<a id="submit" href="#" form="publishForm" class="welcome-center-button waves-effect waves-light btn">Objavi oglas</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
@@ -21,11 +21,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="publishEnd" class="col s12">
|
<div id="publishEnd" class="col s12">
|
||||||
<%- include("./publishEnd.ejs") %>
|
<%- include("./publishEnd.ejs") %>
|
||||||
<div class="row">
|
|
||||||
<div class="col s6 push-s3">
|
|
||||||
<a id="submit" href="#" class="welcome-center-button waves-effect waves-light btn">Objavi oglas</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -35,5 +30,10 @@
|
|||||||
<script>
|
<script>
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('.tabs').tabs();
|
$('.tabs').tabs();
|
||||||
|
$("#submit").click( function () {
|
||||||
|
$("#publishForm").submit();
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
Reference in New Issue
Block a user