WiP Started kivi original ad view.
This commit is contained in:
@@ -173,6 +173,10 @@ const getPublishInputs = async (req, res) => {
|
|||||||
const postPublishInputs = async (req, res) => {
|
const postPublishInputs = async (req, res) => {
|
||||||
const kiviOriginal = await currentKiviRealEstate(req);
|
const kiviOriginal = await currentKiviRealEstate(req);
|
||||||
|
|
||||||
|
if (!kiviOriginal || !kiviOriginal.kiviAdId) {
|
||||||
|
res.render("notFound", { title: " " });
|
||||||
|
return;
|
||||||
|
}
|
||||||
const realEstate = await findRealEstateByAgencyId(kiviOriginal.kiviAdId);
|
const realEstate = await findRealEstateByAgencyId(kiviOriginal.kiviAdId);
|
||||||
|
|
||||||
if (!realEstate || !realEstate.dataValues) {
|
if (!realEstate || !realEstate.dataValues) {
|
||||||
@@ -181,6 +185,8 @@ const postPublishInputs = async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const nextStepPage = req.query.nextStep || "/uspjesnaobjava";
|
const nextStepPage = req.query.nextStep || "/uspjesnaobjava";
|
||||||
|
//
|
||||||
|
console.log("Req body:", req.body);
|
||||||
|
|
||||||
const balcony = req.body.balcony === "on";
|
const balcony = req.body.balcony === "on";
|
||||||
const elevator = req.body.elevator === "on";
|
const elevator = req.body.elevator === "on";
|
||||||
@@ -292,6 +298,8 @@ const postPublishInputs = async (req, res) => {
|
|||||||
|
|
||||||
kiviOriginal.email = contactEmail;
|
kiviOriginal.email = contactEmail;
|
||||||
|
|
||||||
|
//console.log("realEstate", realEstate);
|
||||||
|
|
||||||
await realEstate.save();
|
await realEstate.save();
|
||||||
|
|
||||||
await kiviOriginal.save();
|
await kiviOriginal.save();
|
||||||
|
|||||||
170
app/controllers/viewRealEstate.js
Normal file
170
app/controllers/viewRealEstate.js
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
const { findRealEstateByAgencyId } = require("../helpers/db/realEstate");
|
||||||
|
const { currentKiviRealEstate } = require("../helpers/url");
|
||||||
|
|
||||||
|
const {
|
||||||
|
BASIC_BOOLEAN_PUBLISH,
|
||||||
|
BASIC_SEGMENT_PUBLISH,
|
||||||
|
ADDITIONAL_BOOLEAN_PUBLISH,
|
||||||
|
ADDITIONAL_SEGMENT_PUBLISH,
|
||||||
|
BASIC_INPUT_PUBLISH,
|
||||||
|
ADDITIONAL_INPUT_PUBLISH
|
||||||
|
} = require("../common/publishEnums");
|
||||||
|
|
||||||
|
const getViewRealEstate = async (req, res) => {
|
||||||
|
const kiviOriginal = await currentKiviRealEstate(req);
|
||||||
|
|
||||||
|
if (!kiviOriginal || !kiviOriginal.kiviAdId) {
|
||||||
|
res.render("notFound", { title: " " });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const realEstate = await findRealEstateByAgencyId(kiviOriginal.kiviAdId);
|
||||||
|
|
||||||
|
if (!realEstate || !realEstate.dataValues) {
|
||||||
|
res.render("notFound", { title: " " });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const pageTitle = "Pregled nekretnine";
|
||||||
|
|
||||||
|
const {
|
||||||
|
price,
|
||||||
|
area,
|
||||||
|
adType,
|
||||||
|
realEstateType,
|
||||||
|
locationLat,
|
||||||
|
locationLong,
|
||||||
|
accessRoadType,
|
||||||
|
heatingType,
|
||||||
|
balcony,
|
||||||
|
newBuilding,
|
||||||
|
elevator,
|
||||||
|
recentlyAdapted,
|
||||||
|
gardenSize,
|
||||||
|
numberOfRooms,
|
||||||
|
numberOfFloors,
|
||||||
|
floor,
|
||||||
|
water,
|
||||||
|
electricity,
|
||||||
|
drainageSystem,
|
||||||
|
registeredInZkBooks,
|
||||||
|
parking,
|
||||||
|
garage,
|
||||||
|
gas,
|
||||||
|
antiTheftDoor,
|
||||||
|
airCondition,
|
||||||
|
phoneConnection,
|
||||||
|
cableTV,
|
||||||
|
internet,
|
||||||
|
basementAttic,
|
||||||
|
storeRoom,
|
||||||
|
videoSurveillance,
|
||||||
|
alarm,
|
||||||
|
suitableForStudents,
|
||||||
|
includingBills,
|
||||||
|
animalsAllowed,
|
||||||
|
pool,
|
||||||
|
exchange,
|
||||||
|
urbanPlanPermit,
|
||||||
|
buildingPermit,
|
||||||
|
furnishingType,
|
||||||
|
shortDescription,
|
||||||
|
streetName,
|
||||||
|
title,
|
||||||
|
longDescription
|
||||||
|
} = realEstate;
|
||||||
|
//Categorize all database values by value type - input, boolean or segment selected
|
||||||
|
const allInputValues = {
|
||||||
|
price,
|
||||||
|
area,
|
||||||
|
gardenSize,
|
||||||
|
numberOfRooms,
|
||||||
|
numberOfFloors,
|
||||||
|
floor,
|
||||||
|
title,
|
||||||
|
shortDescription,
|
||||||
|
streetName,
|
||||||
|
longDescription
|
||||||
|
};
|
||||||
|
const allBooleanValues = {
|
||||||
|
balcony,
|
||||||
|
elevator,
|
||||||
|
newBuilding,
|
||||||
|
recentlyAdapted,
|
||||||
|
water,
|
||||||
|
electricity,
|
||||||
|
drainageSystem,
|
||||||
|
registeredInZkBooks,
|
||||||
|
parking,
|
||||||
|
garage,
|
||||||
|
gas,
|
||||||
|
antiTheftDoor,
|
||||||
|
airCondition,
|
||||||
|
phoneConnection,
|
||||||
|
cableTV,
|
||||||
|
internet,
|
||||||
|
basementAttic,
|
||||||
|
storeRoom,
|
||||||
|
videoSurveillance,
|
||||||
|
alarm,
|
||||||
|
suitableForStudents,
|
||||||
|
includingBills,
|
||||||
|
animalsAllowed,
|
||||||
|
pool,
|
||||||
|
exchange,
|
||||||
|
urbanPlanPermit,
|
||||||
|
buildingPermit
|
||||||
|
};
|
||||||
|
|
||||||
|
const allSegmentSelectedValues = {
|
||||||
|
furnishingType,
|
||||||
|
accessRoadType,
|
||||||
|
heatingType
|
||||||
|
};
|
||||||
|
|
||||||
|
//We need titles of fields ex Balkon, Novogradnja
|
||||||
|
const ALL_BOOLEAN_FIELDS = [
|
||||||
|
...BASIC_BOOLEAN_PUBLISH,
|
||||||
|
...ADDITIONAL_BOOLEAN_PUBLISH
|
||||||
|
];
|
||||||
|
const ALL_INPUT_FIELDS = [
|
||||||
|
...BASIC_INPUT_PUBLISH,
|
||||||
|
...ADDITIONAL_INPUT_PUBLISH
|
||||||
|
];
|
||||||
|
const ALL_SEGMENT_FIELDS = [
|
||||||
|
...BASIC_SEGMENT_PUBLISH,
|
||||||
|
...ADDITIONAL_SEGMENT_PUBLISH
|
||||||
|
];
|
||||||
|
//
|
||||||
|
console.log("ALL BOOLEAN FIELDS:", ALL_BOOLEAN_FIELDS);
|
||||||
|
console.log("All boolean values", allBooleanValues);
|
||||||
|
//On view add page we will show only values that are not - null, or "", or undefined
|
||||||
|
const forShowing = value => {
|
||||||
|
return value !== false && value !== null && value !== "";
|
||||||
|
};
|
||||||
|
//Filter all values to be shown on page or not
|
||||||
|
//For showing on page we also need title ex. "Balkon"
|
||||||
|
const booleanFields = ALL_BOOLEAN_FIELDS.filter(object => {
|
||||||
|
return forShowing(allBooleanValues[object.dbField]);
|
||||||
|
});
|
||||||
|
const inputFields = ALL_INPUT_FIELDS.filter(object => {
|
||||||
|
return forShowing(allInputValues[object.dbField]);
|
||||||
|
});
|
||||||
|
const segmentFields = ALL_SEGMENT_FIELDS.filter(object => {
|
||||||
|
return forShowing(allSegmentSelectedValues[object.dbField]);
|
||||||
|
});
|
||||||
|
|
||||||
|
//console.log("booleanFields", booleanFields);
|
||||||
|
|
||||||
|
res.render("viewRealEstate", {
|
||||||
|
title: pageTitle,
|
||||||
|
booleanFields,
|
||||||
|
inputFields,
|
||||||
|
allInputValues,
|
||||||
|
segmentFields,
|
||||||
|
allSegmentSelectedValues
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
getViewRealEstate
|
||||||
|
};
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
const { getSearchRequest } = require("./db/searchRequest");
|
const { getSearchRequest } = require("./db/searchRequest");
|
||||||
const { getRealEstateById } = require("./db/realEstate");
|
const { getRealEstateById } = require("./db/realEstate");
|
||||||
const { getKiviOriginalById } = require("./db/kiviOriginal");
|
const { getKiviOriginalById } = require("./db/kiviOriginal");
|
||||||
|
const validator = require("validator");
|
||||||
|
|
||||||
const currentSearchRequest = async req => {
|
const currentSearchRequest = async req => {
|
||||||
const searchRequestId =
|
const searchRequestId =
|
||||||
@@ -19,7 +20,7 @@ const currentRealEstate = async req => {
|
|||||||
const currentKiviRealEstate = async req => {
|
const currentKiviRealEstate = async req => {
|
||||||
const kiviRealEstateId =
|
const kiviRealEstateId =
|
||||||
req && req.params ? req.params["kiviRealEstateId"] : null;
|
req && req.params ? req.params["kiviRealEstateId"] : null;
|
||||||
if (!kiviRealEstateId) return null;
|
if (!kiviRealEstateId || !validator.isUUID(kiviRealEstateId)) return null;
|
||||||
|
|
||||||
return await getKiviOriginalById(kiviRealEstateId);
|
return await getKiviOriginalById(kiviRealEstateId);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ const {
|
|||||||
getPublishInputs,
|
getPublishInputs,
|
||||||
postPublishInputs
|
postPublishInputs
|
||||||
} = require("../controllers/publishRealEstate");
|
} = require("../controllers/publishRealEstate");
|
||||||
|
const { getViewRealEstate } = require("../controllers/viewRealEstate");
|
||||||
const {
|
const {
|
||||||
getQueryReview,
|
getQueryReview,
|
||||||
postQueryReview
|
postQueryReview
|
||||||
@@ -45,6 +46,8 @@ router.post("/objavinekretninu", postPublishTypes);
|
|||||||
router.get("/podacionekretnini/:kiviRealEstateId", getPublishInputs);
|
router.get("/podacionekretnini/:kiviRealEstateId", getPublishInputs);
|
||||||
router.post("/podacionekretnini/:kiviRealEstateId", postPublishInputs);
|
router.post("/podacionekretnini/:kiviRealEstateId", postPublishInputs);
|
||||||
|
|
||||||
|
router.get("/preglednekretnine/:kiviRealEstateId", getViewRealEstate);
|
||||||
|
|
||||||
router.get("/lokacija/:searchRequestId", getLocation);
|
router.get("/lokacija/:searchRequestId", getLocation);
|
||||||
router.post("/lokacija/:searchRequestId", postLocation);
|
router.post("/lokacija/:searchRequestId", postLocation);
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--file" id="status"></div>
|
<div class="mdl-textfield mdl-js-textfield mdl-textfield--file" id="status"></div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
/*
|
||||||
var c = "";
|
var c = "";
|
||||||
var filename = "";
|
var filename = "";
|
||||||
|
|
||||||
@@ -67,4 +67,6 @@ var c = "";
|
|||||||
)
|
)
|
||||||
.then(response => $("#status").html('File uploaded successfully: ' + filename));
|
.then(response => $("#status").html('File uploaded successfully: ' + filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
</script>
|
</script>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<br>
|
<br>
|
||||||
<form id="publishForm" method="POST" novalidate enctype="multipart/form-data">
|
<form id="publishForm" method="POST" novalidate >
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<ul class="tabs">
|
<ul class="tabs">
|
||||||
@@ -198,6 +198,9 @@
|
|||||||
} */
|
} */
|
||||||
|
|
||||||
if (!hasErrors) {
|
if (!hasErrors) {
|
||||||
|
//
|
||||||
|
alert("Pokusavam submit formu!");
|
||||||
|
|
||||||
$("#publishForm").submit();
|
$("#publishForm").submit();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
33
app/views/viewRealEstate.ejs
Normal file
33
app/views/viewRealEstate.ejs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<br>
|
||||||
|
<div class="row">
|
||||||
|
<% for (const field of booleanFields){ %>
|
||||||
|
<p>
|
||||||
|
<span><%= field.title %></span>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
<% } %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<div class="row">
|
||||||
|
<% for (const field of inputFields){ %>
|
||||||
|
<p>
|
||||||
|
<span><%= field.title %></span>
|
||||||
|
<span><%= allInputValues[field.dbField] %></span>
|
||||||
|
</p>
|
||||||
|
<% } %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<div class="row">
|
||||||
|
<% for (const field of segmentFields){ %>
|
||||||
|
<p>
|
||||||
|
<span><%= field.title %></span>
|
||||||
|
<% for (const segmentObject of field.values) { %>
|
||||||
|
<% if (allSegmentSelectedValues[field.dbField] === segmentObject.id) { %>
|
||||||
|
<span><%= segmentObject.title %></span>
|
||||||
|
<% } %>>
|
||||||
|
<% } %>
|
||||||
|
</p>
|
||||||
|
<% } %>
|
||||||
|
</div>
|
||||||
11
package-lock.json
generated
11
package-lock.json
generated
@@ -4137,6 +4137,11 @@
|
|||||||
"version": "6.3.0",
|
"version": "6.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||||
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
|
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
|
||||||
|
},
|
||||||
|
"validator": {
|
||||||
|
"version": "10.11.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/validator/-/validator-10.11.0.tgz",
|
||||||
|
"integrity": "sha512-X/p3UZerAIsbBfN/IwahhYaBbY68EN/UQBWHtsbXGT5bfrH/p4NQzUCG1kF/rtKaNpnJ7jAu6NGTdSNtyNIXMw=="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -4951,9 +4956,9 @@
|
|||||||
"integrity": "sha512-PnFM3xiZ+kYmLyTiMgTYmU7ZHkjBZz2/+F0DaALc/uUtVzdCt1wAosvYJ5hFQi/hz8O4zb52FQhHZRC+uVkJ+g=="
|
"integrity": "sha512-PnFM3xiZ+kYmLyTiMgTYmU7ZHkjBZz2/+F0DaALc/uUtVzdCt1wAosvYJ5hFQi/hz8O4zb52FQhHZRC+uVkJ+g=="
|
||||||
},
|
},
|
||||||
"validator": {
|
"validator": {
|
||||||
"version": "10.11.0",
|
"version": "12.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/validator/-/validator-10.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/validator/-/validator-12.2.0.tgz",
|
||||||
"integrity": "sha512-X/p3UZerAIsbBfN/IwahhYaBbY68EN/UQBWHtsbXGT5bfrH/p4NQzUCG1kF/rtKaNpnJ7jAu6NGTdSNtyNIXMw=="
|
"integrity": "sha512-jJfE/DW6tIK1Ek8nCfNFqt8Wb3nzMoAbocBF6/Icgg1ZFSBpObdnwVY2jQj6qUqzhx5jc71fpvBWyLGO7Xl+nQ=="
|
||||||
},
|
},
|
||||||
"vary": {
|
"vary": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
|
|||||||
@@ -53,7 +53,8 @@
|
|||||||
"react-step-wizard": "^5.1.0",
|
"react-step-wizard": "^5.1.0",
|
||||||
"sequelize": "^5.18.4",
|
"sequelize": "^5.18.4",
|
||||||
"sequelize-cli": "^5.5.0",
|
"sequelize-cli": "^5.5.0",
|
||||||
"validate.js": "^0.13.1"
|
"validate.js": "^0.13.1",
|
||||||
|
"validator": "^12.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"nodemon": "^1.19.0"
|
"nodemon": "^1.19.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user