diff --git a/admin/batch_manager_unit.php b/admin/batch_manager_unit.php index abc69c0cc..f16226fe8 100644 --- a/admin/batch_manager_unit.php +++ b/admin/batch_manager_unit.php @@ -345,7 +345,7 @@ SELECT 'STATS' => l10n('Visited %d times', $row['hit']), 'FILE' => l10n('%s', $row['file']), 'related_categories' => $related_categories, - 'related_category_ids' => $related_category_ids, + 'related_category_ids' => json_encode($related_category_ids,JSON_NUMERIC_CHECK), 'U_JUMPTO' => (isset($url_img) and $user['level'] >= $media['image']['level']) ? $url_img : null, 'tag_selection' => $tag_selection, 'U_DOWNLOAD' => 'action.php?id='.$row['id'].'&part=e&pwg_token='.get_pwg_token().'&download', diff --git a/admin/themes/default/js/batchManagerUnit.js b/admin/themes/default/js/batchManagerUnit.js index 26a5c1093..c4ae0f098 100644 --- a/admin/themes/default/js/batchManagerUnit.js +++ b/admin/themes/default/js/batchManagerUnit.js @@ -34,7 +34,7 @@ $(document).ready(function () { }) $(".related-categories-container .breadcrumb-item .remove-item").on("click", function () { - var pictureId = $(this).parents("fieldset").attr("id"); + var pictureId = $(this).parents("fieldset").data("image_id") remove_related_category($(this).attr("id"),pictureId); }) @@ -50,56 +50,52 @@ function fill_results(cats, pictureId) { "" ); var this_related_category_ids = window["related_category_ids_" + pictureId]; - console.log("relatedCAT "+this_related_category_ids); - console.log("catID "+cat.id); - - if (this_related_category_ids.includes(cat.id)) { - $("#"+pictureId+" .search-result-item #"+ cat.id +".item-add").addClass("notClickable").attr("title", str_already_in_related_cats).on("click", function (event) { + var catId = parseInt(cat.id); + if (this_related_category_ids.includes(catId)) { + $(".search-result-item#"+ catId +" .item-add").addClass("notClickable").attr("title", str_already_in_related_cats).on("click", function (event) { event.preventDefault(); }); - $("#"+pictureId+" .search-result-item").addClass("notClickable").attr("title", str_already_in_related_cats).on("click", function (event) { - + $(".search-result-item").addClass("notClickable").attr("title", str_already_in_related_cats).on("click", function (event) { event.preventDefault(); }); } else { - $("#"+pictureId+" .search-result-item#"+ cat.id).on("click", function () { - - add_related_category(cat.id, cat.full_name_with_admin_links, pictureId); + $(".search-result-item#"+ catId+ " .item-add").on("click", function () { + add_related_category(catId, cat.full_name_with_admin_links, pictureId); }); } }); } function remove_related_category(cat_id,pictureId) { + var catId = parseInt(cat_id); var this_related_category_ids = window["related_category_ids_" + pictureId]; - - $("#"+pictureId+" .invisible-related-categories-select option[value="+ cat_id +"]").remove(); + $("#"+pictureId+" .invisible-related-categories-select option[value="+ catId +"]").remove(); $("#"+pictureId+" .invisible-related-categories-select").trigger('change'); - $("#"+pictureId+" #" + cat_id).parent().remove(); + $("#"+pictureId+" #" + catId).parent().remove(); - cat_to_remove_index = this_related_category_ids.indexOf(cat_id); + cat_to_remove_index = this_related_category_ids.indexOf(catId); if (cat_to_remove_index > -1) { this_related_category_ids.splice(cat_to_remove_index, 1); } - check_related_categories(pictureId); } function add_related_category(cat_id, cat_link_path, pictureId) { + var catId = parseInt(cat_id); var this_related_category_ids = window["related_category_ids_" + pictureId]; - if (!this_related_category_ids.includes(cat_id)) { - $(".related-categories-container").append( - "