Started edit ad option.
This commit is contained in:
@@ -82,6 +82,15 @@ const getPublishInputs = async (req, res) => {
|
|||||||
title,
|
title,
|
||||||
longDescription
|
longDescription
|
||||||
} = realEstate;
|
} = realEstate;
|
||||||
|
|
||||||
|
const { email } = kiviOriginal;
|
||||||
|
//If email is not empty - has string value, then proces of publishing has been conducted alredy
|
||||||
|
//That means user is editing existing real estate ad not publishing new one
|
||||||
|
let editingRealEstate = false;
|
||||||
|
if (email) {
|
||||||
|
editingRealEstate = true;
|
||||||
|
}
|
||||||
|
|
||||||
const category = AD_CATEGORY[realEstateType] || AD_CATEGORY.FLAT;
|
const category = AD_CATEGORY[realEstateType] || AD_CATEGORY.FLAT;
|
||||||
|
|
||||||
// TODO: Maybe this is slow, pay attention to this
|
// TODO: Maybe this is slow, pay attention to this
|
||||||
@@ -172,7 +181,11 @@ const getPublishInputs = async (req, res) => {
|
|||||||
basicInputValues,
|
basicInputValues,
|
||||||
additionalInputInputs,
|
additionalInputInputs,
|
||||||
additionalInputValues,
|
additionalInputValues,
|
||||||
validate: validate
|
validate: validate,
|
||||||
|
email,
|
||||||
|
locationLat: locationLat || 0,
|
||||||
|
locationLong: locationLong || 0,
|
||||||
|
editingRealEstate
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ const generateNewAdPublishEmail = (
|
|||||||
<br />
|
<br />
|
||||||
<div>Pregledajte Vaš oglas na sljedećem linku: <a href="${realEstate.url}" rel="noreferrer">${realEstate.title}</a><div>
|
<div>Pregledajte Vaš oglas na sljedećem linku: <a href="${realEstate.url}" rel="noreferrer">${realEstate.title}</a><div>
|
||||||
<br/>
|
<br/>
|
||||||
<div>Ako želite izmijeniti detalje oglasa, <a href="#">izmjenite ovdje.</a></div>
|
<div>Ako želite izmijeniti detalje oglasa, <a href="${APP_URL}/podacionekretnini/${kiviOriginal.kiviAdId}">izmjenite ovdje.</a></div>
|
||||||
<div>Ako želite izbrisati Vaš oglas iz Kivi baze, <a href="${APP_URL}/obrisioglas/${kiviOriginal.kiviAdId}">izbrišite ovdje.</a></div>
|
<div>Ako želite izbrisati Vaš oglas iz Kivi baze, <a href="${APP_URL}/obrisioglas/${kiviOriginal.kiviAdId}">izbrišite ovdje.</a></div>
|
||||||
<br/>
|
<br/>
|
||||||
<div>Hvala na ukazanom povjerenju!</div>
|
<div>Hvala na ukazanom povjerenju!</div>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
id="email"
|
id="email"
|
||||||
name="email"
|
name="email"
|
||||||
type="email"
|
type="email"
|
||||||
|
value="<%= email !== undefined ? email : ""%>"
|
||||||
>
|
>
|
||||||
<div class="messages"></div>
|
<div class="messages"></div>
|
||||||
<label for="email">Email</label>
|
<label for="email">Email</label>
|
||||||
@@ -17,7 +18,14 @@
|
|||||||
<br>
|
<br>
|
||||||
<div class="row center-align">
|
<div class="row center-align">
|
||||||
<div class="col s6 push-s3">
|
<div class="col s6 push-s3">
|
||||||
<a id="submit" href="#" form="publishForm" class="welcome-center-button waves-effect waves-light btn">Objavi oglas</a>
|
<a id="submit" href="#" form="publishForm" class="welcome-center-button waves-effect waves-light btn">
|
||||||
|
<% if(editingRealEstate) { %>
|
||||||
|
Snimi izmjene
|
||||||
|
<% } else { %>
|
||||||
|
Objavi oglas
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,9 @@
|
|||||||
let places;
|
let places;
|
||||||
let geocoder;
|
let geocoder;
|
||||||
let marker =false; //Initialy no marker on map
|
let marker =false; //Initialy no marker on map
|
||||||
|
|
||||||
|
const editingRealEstate = <%- editingRealEstate %>;
|
||||||
|
|
||||||
|
|
||||||
function locateMe() {
|
function locateMe() {
|
||||||
if (navigator.geolocation) {
|
if (navigator.geolocation) {
|
||||||
@@ -101,6 +104,13 @@
|
|||||||
autocomplete.addListener("place_changed", onPlaceChanged);
|
autocomplete.addListener("place_changed", onPlaceChanged);
|
||||||
pacSelectFirst(inputElement);
|
pacSelectFirst(inputElement);
|
||||||
addLocateMeButton(map);
|
addLocateMeButton(map);
|
||||||
|
|
||||||
|
//Move map and marker to already selected position if in editing mode
|
||||||
|
if( editingRealEstate===true) {
|
||||||
|
console.log('Editujem mapu!');
|
||||||
|
setMarkerToLocation(map);
|
||||||
|
}
|
||||||
|
|
||||||
//Add event listener to position marker on map
|
//Add event listener to position marker on map
|
||||||
google.maps.event.addListener(map, 'click', positionMarker);
|
google.maps.event.addListener(map, 'click', positionMarker);
|
||||||
|
|
||||||
@@ -114,13 +124,31 @@
|
|||||||
map: map,
|
map: map,
|
||||||
draggable: true
|
draggable: true
|
||||||
});
|
});
|
||||||
google.maps.event.addListener(marker, 'dragend', function(event){
|
//google.maps.event.addListener(marker, 'dragend', function(event){
|
||||||
markerLocation();
|
// markerLocation();
|
||||||
});
|
// });
|
||||||
} else{
|
} else{
|
||||||
marker.setPosition(clickedLocation);
|
marker.setPosition(clickedLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function setMarkerToLocation(map) {
|
||||||
|
const ESTATE_COORDINATES = {
|
||||||
|
lat: <%= locationLat %>,
|
||||||
|
lng: <%= locationLong %>
|
||||||
|
};
|
||||||
|
|
||||||
|
marker = new google.maps.Marker({
|
||||||
|
position: ESTATE_COORDINATES,
|
||||||
|
map: map,
|
||||||
|
draggable: true
|
||||||
|
});
|
||||||
|
// google.maps.event.addListener(marker, 'dragend', function(event){
|
||||||
|
// markerLocation();
|
||||||
|
// });
|
||||||
|
//Zooming map to current location
|
||||||
|
map.setCenter(ESTATE_COORDINATES);
|
||||||
|
map.setZoom(13);
|
||||||
|
}
|
||||||
|
|
||||||
function addLocateMeButton(map) {
|
function addLocateMeButton(map) {
|
||||||
var parent = document.createElement("div");
|
var parent = document.createElement("div");
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
<br>
|
<br>
|
||||||
|
<% if(editingRealEstate) { %>
|
||||||
|
<div>Editujem oglas!</div>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
<form id="publishForm" method="POST" novalidate >
|
<form id="publishForm" method="POST" novalidate >
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
|
|||||||
Reference in New Issue
Block a user