Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/7682/fix management page #7975

Merged
merged 47 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
16a1bf9
Small fix
VasylyshynDmytro Dec 18, 2024
00daa42
Add exception if adres not found, add message if place name, category…
VasylyshynDmytro Dec 19, 2024
08875d0
Fix delete selected places
VasylyshynDmytro Dec 19, 2024
b307a96
Save changes
VasylyshynDmytro Dec 19, 2024
cf8266f
Add to dto new field
VasylyshynDmytro Dec 26, 2024
336a4b4
Defolt
VasylyshynDmytro Dec 27, 2024
e790f77
Delete excessive border
VasylyshynDmytro Dec 27, 2024
ce6282b
test
VasylyshynDmytro Dec 27, 2024
3ab4d8c
fix locations in update
VasylyshynDmytro Dec 30, 2024
d3f25dc
Refactor update function in LocationServiveImpl
VasylyshynDmytro Dec 30, 2024
c88ac52
Fix update discount
VasylyshynDmytro Dec 30, 2024
5603daf
Initional fix for update with image
VasylyshynDmytro Dec 30, 2024
6f8a1c5
Meneger can upload photo if it does not exist
VasylyshynDmytro Dec 30, 2024
ae54819
Fix bug with photo
VasylyshynDmytro Dec 30, 2024
9988de0
The end
VasylyshynDmytro Dec 30, 2024
ce2289b
Refactoring code
VasylyshynDmytro Jan 3, 2025
d40dff4
Add tests for PhotoVOMapper
VasylyshynDmytro Jan 3, 2025
7d657c2
Delete constructor
VasylyshynDmytro Jan 3, 2025
aed8078
Add test
VasylyshynDmytro Jan 3, 2025
49919bd
Init
VasylyshynDmytro Jan 6, 2025
8018377
Init
VasylyshynDmytro Jan 6, 2025
24e7f29
Delete test
VasylyshynDmytro Jan 6, 2025
3bf5b31
Fix js
VasylyshynDmytro Jan 6, 2025
2c27753
Add @SuppressWarnings(unchecked)
VasylyshynDmytro Jan 6, 2025
05493b9
remove @SuppressWarnings(unchecked) insted of this add /**
VasylyshynDmytro Jan 7, 2025
998e43f
Rename test
VasylyshynDmytro Jan 7, 2025
d980a79
Remove //NOSONAR
VasylyshynDmytro Jan 7, 2025
bdec15a
Merge branch 'dev' into bug/7682/fix-management-page
VasylyshynDmytro Jan 8, 2025
3878530
Add tests for package private methods
VasylyshynDmytro Jan 10, 2025
7b9c932
Merge branch 'bug/7682/fix-management-page' of https://github.com/ita…
VasylyshynDmytro Jan 10, 2025
e3b287a
Add test
VasylyshynDmytro Jan 10, 2025
10b0bd2
formatter+checkstyle
VasylyshynDmytro Jan 10, 2025
2fa36d3
Add test
VasylyshynDmytro Jan 10, 2025
d180b01
Add test
VasylyshynDmytro Jan 10, 2025
30ce273
Add test
VasylyshynDmytro Jan 10, 2025
444bc82
Add test
VasylyshynDmytro Jan 10, 2025
7b9ddf0
Add test
VasylyshynDmytro Jan 10, 2025
f3ca096
Add test
VasylyshynDmytro Jan 13, 2025
8f754ad
Delete not useges import
VasylyshynDmytro Jan 13, 2025
89297af
fix
VasylyshynDmytro Jan 13, 2025
e70cd75
Delete dublicated code
VasylyshynDmytro Jan 14, 2025
85c47b3
formatter+checkstyle
VasylyshynDmytro Jan 14, 2025
284f867
Rename messages variable
VasylyshynDmytro Jan 16, 2025
5c6c825
fix HTML
VasylyshynDmytro Jan 16, 2025
1df07e2
fix HTML
VasylyshynDmytro Jan 16, 2025
dfb65db
fix HTML
VasylyshynDmytro Jan 16, 2025
5754503
fix HTML
VasylyshynDmytro Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ public ResponseEntity<PlaceUpdateDto> getPlaceById(@RequestParam("id") Long id)
@PostMapping(consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
@ResponseBody
public GenericResponseDto savePlace(
@RequestPart("addPlaceDto") AddPlaceDto addPlaceDto,
@RequestPart("addPlaceDto") @Valid AddPlaceDto addPlaceDto,
BindingResult bindingResult,
@Parameter(hidden = true) Principal principal,
@RequestPart(required = false) @Nullable MultipartFile[] images,
BindingResult bindingResult) {
@RequestPart(required = false) @Nullable MultipartFile[] images) {
if (!bindingResult.hasErrors()) {
placeService.addPlaceFromUi(addPlaceDto, principal.getName(), images);
}
Expand All @@ -114,13 +114,17 @@ public GenericResponseDto savePlace(
* @param placeUpdateDto of {@link PlaceUpdateDto}
* @return {@link GenericResponseDto}
*/
@PutMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ResponseBody
@PutMapping
public GenericResponseDto updatePlace(@Valid @RequestBody PlaceUpdateDto placeUpdateDto,
BindingResult bindingResult) {
public GenericResponseDto updatePlace(
@RequestPart("placeUpdateDto") @Valid PlaceUpdateDto placeUpdateDto,
BindingResult bindingResult,
@Parameter(hidden = true) Principal principal,
@RequestPart(required = false) @Nullable MultipartFile[] images) {
if (!bindingResult.hasErrors()) {
placeService.update(placeUpdateDto);
placeService.updateFromUI(placeUpdateDto, images, principal.getName());
}

return buildGenericResponseDto(bindingResult);
}

Expand Down
8 changes: 7 additions & 1 deletion core/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,13 @@ greenCity.places.page.add.place=Add Place
greenCity.places.page.add.break.hours=Add break hours
greenCity.places.page.add.discount=Add Discount
greenCity.places.page.delete=Delete Place

greenCity.places.page.add.address=Address is required
greenCity.places.page.add.place.name=Place name is required
greenCity.places.page.add.category=Category is required
greenCity.places.page.add.working.hovers=Opening and closing hours are required for selected days
greenCity.places.page.add.day.hovers=At least one day with opening hours must be selected
greenCity.places.page.hovers.is.incorrect=The difference between opening and closing time must be at least 30 minutes
Copy link

@coderabbitai coderabbitai bot Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Correct typos in message keys and values: "hovers" should be "hours"

The keys and messages use "hovers" instead of "hours". Please correct "hovers" to "hours" for clarity and consistency.

Apply this diff to fix the typos:

-greenCity.places.page.add.working.hovers=Opening and closing hours are required for selected days
-greenCity.places.page.add.day.hovers=At least one day with opening hours must be selected
-greenCity.places.page.hovers.is.incorrect=The difference between opening and closing time must be at least 30 minutes
+greenCity.places.page.add.working.hours=Opening and closing hours are required for selected days
+greenCity.places.page.add.day.hours=At least one day with opening hours must be selected
+greenCity.places.page.hours.is.incorrect=The difference between opening and closing time must be at least 30 minutes
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
greenCity.places.page.add.working.hovers=Opening and closing hours are required for selected days
greenCity.places.page.add.day.hovers=At least one day with opening hours must be selected
greenCity.places.page.hovers.is.incorrect=The difference between opening and closing time must be at least 30 minutes
greenCity.places.page.add.working.hours=Opening and closing hours are required for selected days
greenCity.places.page.add.day.hours=At least one day with opening hours must be selected
greenCity.places.page.hours.is.incorrect=The difference between opening and closing time must be at least 30 minutes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VasylyshynDmytro is the CodeRabbit right?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the CodeRabbit is right? I will change it

greenCity.pages.delete.all.selected=Delete all selected
/*tagspage*/
greenCity.tags.page.h=Manage Tags
greenCity.places.page.add.tag=Add Tag
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/resources/messages_ua.properties
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ greenCity.places.page.add.place=\u0414\u043E\u0434\u0430\u0442\u0438\u0020\u043C
greenCity.places.page.add.break.hours=\u0414\u043E\u0434\u0430\u0439\u0442\u0435\u0020\u0433\u043E\u0434\u0438\u043D\u0438\u0020\u043F\u0435\u0440\u0435\u0440\u0432\u0438
greenCity.places.page.add.discount=\u0414\u043E\u0434\u0430\u0442\u0438\u0020\u0437\u043D\u0438\u0436\u043A\u0443
greenCity.places.page.delete=\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438\u0020\u041C\u0456\u0441\u0446\u0435
greenCity.places.page.add.address=\u041f\u043e\u0442\u0440\u0456\u0431\u043d\u043e\u0020\u0432\u043a\u0430\u0437\u0430\u0442\u0438\u0020\u0430\u0434\u0440\u0435\u0441\u0443
greenCity.places.page.add.place.name=\u041f\u043e\u0442\u0440\u0456\u0431\u043d\u043e\u0020\u0432\u043a\u0430\u0437\u0430\u0442\u0438\u0020\u043d\u0430\u0437\u0432\u0443\u0020\u043c\u0456\u0441\u0446\u044f
greenCity.places.page.add.category=\u041f\u043e\u0442\u0440\u0456\u0431\u043d\u043e\u0020\u0432\u0438\u0431\u0440\u0430\u0442\u0438\u0020\u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u044e
greenCity.places.page.add.working.hovers=\u041f\u043e\u0442\u0440\u0456\u0431\u043d\u043e\u0020\u0432\u043a\u0430\u0437\u0430\u0442\u0438\u0020\u0447\u0430\u0441\u0020\u0432\u0456\u0434\u043a\u0440\u0438\u0442\u0442\u044f\u0020\u0442\u0430\u0020\u0437\u0430\u043a\u0440\u0438\u0442\u0442\u044f\u0020\u0434\u043b\u044f\u0020\u0432\u0438\u0431\u0440\u0430\u043d\u0438\u0445\u0020\u0434\u043d\u0456\u0432
greenCity.places.page.add.day.hovers=\u041d\u0435\u043e\u0431\u0445\u0456\u0434\u043d\u043e\u0020\u0432\u0438\u0431\u0440\u0430\u0442\u0438\u0020\u0445\u043e\u0447\u0430\u0020\u0431\u0020\u043e\u0434\u0438\u043d\u0020\u0434\u0435\u043d\u044c\u0020\u0456\u0437\u0020\u0433\u043e\u0434\u0438\u043d\u0430\u043c\u0438\u0020\u0440\u043e\u0431\u043e\u0442\u0438
greenCity.places.page.hovers.is.incorrect=\u0420\u0456\u0437\u043d\u0438\u0446\u044f\u0020\u043c\u0456\u0436\u0020\u0447\u0430\u0441\u043e\u043c\u0020\u0432\u0456\u0434\u043a\u0440\u0438\u0442\u0442\u044f\u0020\u0442\u0430\u0020\u0437\u0430\u043a\u0440\u0438\u0442\u0442\u044f\u0020\u043f\u043e\u0432\u0438\u043d\u043d\u0430\u0020\u0431\u0443\u0442\u0438\u0020\u043d\u0435\u0020\u043c\u0435\u043d\u0448\u0435\u0020\u0033\u0030\u0020\u0445\u0432\u0438\u043b\u0438\u043d
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Виправте опечатки у ключах повідомлень: "hovers" має бути "hours"

У ключах повідомлень використовується "hovers" замість "hours". Будь ласка, замініть "hovers" на "hours" для підтримки узгодженості.

Застосуйте цей диф для виправлення опечаток:

-greenCity.places.page.add.working.hovers=потрібно вказати час відкриття та закриття для вибраних днів
-greenCity.places.page.add.day.hovers=необхідно вибрати хоча б один день із годинами роботи
-greenCity.places.page.hovers.is.incorrect=Різниця між часом відкриття та закриття повинна бути не менше 30 хвилин
+greenCity.places.page.add.working.hours=потрібно вказати час відкриття та закриття для вибраних днів
+greenCity.places.page.add.day.hours=необхідно вибрати хоча б один день із годинами роботи
+greenCity.places.page.hours.is.incorrect=Різниця між часом відкриття та закриття повинна бути не менше 30 хвилин
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
greenCity.places.page.add.working.hovers=\u041f\u043e\u0442\u0440\u0456\u0431\u043d\u043e\u0020\u0432\u043a\u0430\u0437\u0430\u0442\u0438\u0020\u0447\u0430\u0441\u0020\u0432\u0456\u0434\u043a\u0440\u0438\u0442\u0442\u044f\u0020\u0442\u0430\u0020\u0437\u0430\u043a\u0440\u0438\u0442\u0442\u044f\u0020\u0434\u043b\u044f\u0020\u0432\u0438\u0431\u0440\u0430\u043d\u0438\u0445\u0020\u0434\u043d\u0456\u0432
greenCity.places.page.add.day.hovers=\u041d\u0435\u043e\u0431\u0445\u0456\u0434\u043d\u043e\u0020\u0432\u0438\u0431\u0440\u0430\u0442\u0438\u0020\u0445\u043e\u0447\u0430\u0020\u0431\u0020\u043e\u0434\u0438\u043d\u0020\u0434\u0435\u043d\u044c\u0020\u0456\u0437\u0020\u0433\u043e\u0434\u0438\u043d\u0430\u043c\u0438\u0020\u0440\u043e\u0431\u043e\u0442\u0438
greenCity.places.page.hovers.is.incorrect=\u0420\u0456\u0437\u043d\u0438\u0446\u044f\u0020\u043c\u0456\u0436\u0020\u0447\u0430\u0441\u043e\u043c\u0020\u0432\u0456\u0434\u043a\u0440\u0438\u0442\u0442\u044f\u0020\u0442\u0430\u0020\u0437\u0430\u043a\u0440\u0438\u0442\u0442\u044f\u0020\u043f\u043e\u0432\u0438\u043d\u043d\u0430\u0020\u0431\u0443\u0442\u0438\u0020\u043d\u0435\u0020\u043c\u0435\u043d\u0448\u0435\u0020\u0033\u0030\u0020\u0445\u0432\u0438\u043b\u0438\u043d
greenCity.places.page.add.working.hours=\u041f\u043e\u0442\u0440\u0456\u0431\u043d\u043e\u0020\u0432\u043a\u0430\u0437\u0430\u0442\u0438\u0020\u0447\u0430\u0441\u0020\u0432\u0456\u0434\u043a\u0440\u0438\u0442\u0442\u044f\u0020\u0442\u0430\u0020\u0437\u0430\u043a\u0440\u0438\u0442\u0442\u044f\u0020\u0434\u043b\u044f\u0020\u0432\u0438\u0431\u0440\u0430\u043d\u0438\u0445\u0020\u0434\u043d\u0456\u0432
greenCity.places.page.add.day.hours=\u041d\u0435\u043e\u0431\u0445\u0456\u0434\u043d\u043e\u0020\u0432\u0438\u0431\u0440\u0430\u0442\u0438\u0020\u0445\u043e\u0447\u0430\u0020\u0431\u0020\u043e\u0434\u0438\u043d\u0020\u0434\u0435\u043d\u044c\u0020\u0456\u0437\u0020\u0433\u043e\u0434\u0438\u043d\u0430\u043c\u0438\u0020\u0440\u043e\u0431\u043e\u0442\u0438
greenCity.places.page.hours.is.incorrect=\u0420\u0456\u0437\u043d\u0438\u0446\u044f\u0020\u043c\u0456\u0436\u0020\u0447\u0430\u0441\u043e\u043c\u0020\u0432\u0456\u0434\u043a\u0440\u0438\u0442\u0442\u044f\u0020\u0442\u0430\u0020\u0437\u0430\u043a\u0440\u0438\u0442\u0442\u044f\u0020\u043f\u043e\u0432\u0438\u043d\u043d\u0430\u0020\u0431\u0443\u0442\u0438\u0020\u043d\u0435\u0020\u043c\u0435\u043d\u0448\u0435\u0020\u0033\u0030\u0020\u0445\u0432\u0438\u043b\u0438\u043d


/*tagspage*/
greenCity.tags.page.h=\u041A\u0435\u0440\u0443\u0432\u0430\u043D\u043D\u044F\u0020\u0442\u0435\u0433\u0430\u043C\u0438
Expand Down
210 changes: 159 additions & 51 deletions core/src/main/resources/static/management/places/buttonsAJAX.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@

function clearAllErrorsSpan() {
$('.errorSpan').text('');
$('.errorSpan').text('').hide();
}

function getErrorSpanId(fieldName) {
if (fieldName.includes('openingHoursList[].')) {
fieldName = 'openingHoursList';
}
return 'errorModalSave' + fieldName;
}

let map;
Expand Down Expand Up @@ -59,25 +65,33 @@ $(document).ready(function () {
// Activate tooltip
$('[data-toggle="tooltip"]').tooltip();

// Select/Deselect checkboxes
let checkbox = $('table tbody input[type="checkbox"]');
$("#selectAll").on('click', function () {
if (this.checked) {
checkbox.each(function () {
if (!this.disabled) {
this.checked = true;
}
});
let actionButtons = $('#btnDelete');

function toggleActionButtons() {
let anyChecked = checkbox.filter(':checked').length > 0;
if (anyChecked) {
actionButtons.removeClass('disabled').attr('href', '#deleteAllSelectedModal');
} else {
checkbox.each(function () {
this.checked = false;
});
actionButtons.addClass('disabled').removeAttr('href');
}
}

$("#selectAll").on('click', function () {
let isChecked = this.checked;
checkbox.each(function () {
if (!this.disabled) {
this.checked = isChecked;
}
});
toggleActionButtons();
});

checkbox.on('click', function () {
if (!this.checked) {
$("#selectAll").prop("checked", false);
}
toggleActionButtons();
});

// Add place button (popup)
Expand Down Expand Up @@ -125,62 +139,161 @@ $(document).ready(function () {
event.preventDefault();
clearAllErrorsSpan();

let formData = new FormData(document.getElementById('addPlaceForm'));
let isValid = validateForm();
if (!isValid) {
return;
}

let place;
let formData = new FormData(document.getElementById('addPlaceForm'));
let type = $('#id').val() ? 'PUT' : 'POST';

if (type === 'POST') {
place = {
"placeName": formData.get('name'),
"locationName": formData.get('address'),
"status": formData.get('status'),
"categoryName": formData.get('category')
};
handlePostRequest(formData);
} else {
place = {
"id": formData.get('id'),
"placeName": formData.get('name'),
"locationName": formData.get('address'),
"status": formData.get('status'),
"categoryName": formData.get('category')
};
handlePutRequest(formData);
}
});

place.discountValues = getDiscountValues();
place.openingHoursList = getOpeningHours();
function handlePostRequest(formData) {
const place = {
"placeName": formData.get('name'),
"locationName": formData.get('address'),
"status": formData.get('status'),
"categoryName": formData.get('category'),
"discountValues": getDiscountValues(),
"openingHoursList": getOpeningHours()
};

submitPostFormData('/management/places', 'POST', formData, place);
}

function handlePutRequest(formData) {
const place = {
id: formData.get('id'),
name: formData.get('name'),
location: {
address: formData.get('address'),
lat: formData.get('lat'),
lng: formData.get('lng'),
addressUa: formData.get('addressUa'),
},
category: {
name: formData.get('category'),
},
discountValues: getDiscountValues(),
openingHoursList: getOpeningHours(),
};

submitPutFormData('/management/places', 'PUT', formData, place);
}

function submitPostFormData(url, method, formData, place) {
formData.append('addPlaceDto', JSON.stringify(place));
var file = document.getElementById("creationFile").files[0];
console.log(file);
formData.append("images", file);
const file = document.getElementById("creationFile").files[0];
if (file) {
formData.append("images", file);
}

sendAjaxRequest(url, method, formData);
}

function submitPutFormData(url, method, formData, place) {
formData.append('placeUpdateDto', JSON.stringify(place));
const fileInput = document.getElementById('creationFile');

Array.from(fileInput?.files || []).forEach((file) => {
formData.append('images', file);
});

sendAjaxRequest(url, method, formData);
}

function sendAjaxRequest(url, method, formData) {
$.ajax({
url: '/management/places',
type: type,
url: url,
type: method,
data: formData,
processData: false,
contentType: false,
success: function (data) {
if (Array.isArray(data.errors) && data.errors.length) {
data.errors.forEach(function (el) {
$(document.getElementById(getErrorSpanId(el.fieldName))).text(el.fieldError);
$(document.getElementById(getErrorSpanId(el.fieldName))).text(el.fieldError).show();
});
} else {
location.reload();
}
},
error: function (xhr, status, error) {
console.error(error);
alert('Error');
console.error('XHR Status: ' + xhr.status);
console.error('Error: ' + error);
console.error('Response Text: ' + xhr.responseText);

let errorMessage = `Error status: ${xhr.status} - ${error}`;
if (xhr.responseText) {
try {
const response = JSON.parse(xhr.responseText);
errorMessage += `\nMessage: ${response.message || 'Unknown error'}`;
} catch (e) {
errorMessage += `\nMessage: ${xhr.responseText}`;
}
}

alert(errorMessage);
}
});
});
}

function validateForm() {
let isValid = true;

function getErrorSpanId(fieldName) {
if (fieldName.includes('openingHoursList[].')) {
fieldName = 'openingHoursList';
const requiredFields = [
{ id: 'address', errorId: 'errorModalSavelocation', message: messages["greenCity.places.page.add.address"] },
{ id: 'placeName', errorId: 'errorModalSavename', message: messages["greenCity.places.page.add.place.name"] },
{ id: 'category', errorId: 'errorModalSavecategory', message: messages["greenCity.places.page.add.category"] },
];

requiredFields.forEach(field => {
let value = $(`#${field.id}`).val();
if (!value) {
$(`#${field.errorId}`).text(field.message).show();
isValid = false;
}
});


let openingHoursChecked = false;
$('input[name="day"]:checked').each(function () {
let row = $(this).closest('.form-row');
let openTime = row.find('input[name="openTime"]').val();
let closeTime = row.find('input[name="closeTime"]').val();

if (!openTime || !closeTime) {
$('#errorModalSaveopeningHoursList').text(messages["greenCity.places.page.add.working.hovers"]).show();
isValid = false;
} else {
let openTimeMinutes = timeToMinutes(openTime);
let closeTimeMinutes = timeToMinutes(closeTime);

if (closeTimeMinutes - openTimeMinutes < 30) {
$('#errorModalSaveopeningHoursList').text(messages["greenCity.places.page.hovers.is.incorrect"]).show();
isValid = false;
}
}
openingHoursChecked = true;
});

if (!openingHoursChecked) {
$('#errorModalSaveopeningHoursList').text(messages["greenCity.places.page.add.day.hovers"]).show();
isValid = false;
}
return 'errorModalSave' + fieldName;

return isValid;
}

function timeToMinutes(time) {
let [hours, minutes] = time.split(':').map(Number);
return hours * 60 + minutes;
}

function getDiscountValues() {
Expand Down Expand Up @@ -285,14 +398,10 @@ $(document).ready(function () {
$.get(href, function (place) {
$('#id').val(place.id)
$('#placeName').val(place.name);
$('#lng').val(place.location.lng);
$('#lat').val(place.location.lat);
$('#addressUa').val(place.location.addressUa);
$('#address').val(place.location.address);
$('input[name=latitude]').val(place.location.lat);
$('input[name=longitude]').val(place.location.lng);
deleteMarkers();
let location = {
lat: place.location.lat,
lng: place.location.lng
};
addMarker(location);
place.openingHoursList.forEach(function (day) {
let dayElement = $(`#${day.weekDay}`);
Expand All @@ -310,7 +419,6 @@ $(document).ready(function () {
place.discountValues.forEach(value => {
addDiscountValueForUpdate(value);
});

});
});

Expand Down
Loading
Loading