fix: Include single sample photo in save operation when no photos selected

This commit is contained in:
Martin Grigoryan 2025-10-31 11:45:04 +04:00
parent 03771e3ca8
commit 6ec0c2062e

View File

@ -1842,14 +1842,22 @@ $(document).ready(function () {
$(this).find(".save-loading").show();
});
let photoList = $('#photoSelector option').map(function () {
return this.value?.split('/')?.pop();
}).get();
if (!photoList.length) {
let path = $('#samplePhoto').attr("src")?.split('/')?.pop();
if (path) photoList = [path];
}
$.ajax({
url: "save_parts_photo_iddatadb.php",
method: "POST",
data: JSON.stringify({
iddatadb: $("#partsModal").data("iddatadb"),
photoList: $('#photoSelector option').map(function () {
return this.value?.split('/')?.pop();
}).get(),
photoList,
partIds: $('#partsTableBody tr').map(function () {
return $(this).data("part-id");
}).get(),