diff --git a/admin/batch_manager_global.php b/admin/batch_manager_global.php index d36d5c44e..8e7e9681a 100644 --- a/admin/batch_manager_global.php +++ b/admin/batch_manager_global.php @@ -164,28 +164,33 @@ DELETE if ('associate' == $action) { - associate_images_to_categories( - $collection, - $_POST['associate'] - ); - - $_SESSION['page_infos'] = array( - l10n('Information data registered in database') - ); - - // let's refresh the page because we the current set might be modified - if ('no_album' == $page['prefilter']) + if (empty($_POST['associate'])) { - $redirect = true; - } - - else if ('no_virtual_album' == $page['prefilter']) - { - $category_info = get_cat_info($_POST['associate']); - if (empty($category_info['dir'])) + $page['errors'][] = l10n('Select at least one album'); + } else { + associate_images_to_categories( + $collection, + $_POST['associate'] + ); + + $_SESSION['page_infos'] = array( + l10n('Information data registered in database') + ); + + // let's refresh the page because we the current set might be modified + if ('no_album' == $page['prefilter']) { $redirect = true; } + + else if ('no_virtual_album' == $page['prefilter']) + { + $category_info = get_cat_info($_POST['associate']); + if (empty($category_info['dir'])) + { + $redirect = true; + } + } } } diff --git a/admin/themes/default/js/album_selector.js b/admin/themes/default/js/album_selector.js index 89a7a31e3..d46363438 100644 --- a/admin/themes/default/js/album_selector.js +++ b/admin/themes/default/js/album_selector.js @@ -1,5 +1,12 @@ let activeAlbumSelector = null; +$(window).on('keypress', function(e) { + const haveAlbumSelector = $('#addLinkedAlbum').is(':visible'); + if (haveAlbumSelector && e.key === "Enter") { + e.preventDefault(); + } +}); + /** * Album selector instance * @param {Array} selectedCategoriesIds - Array of IDs for elements already selected. @@ -28,6 +35,7 @@ class AlbumSelector { #current_cat; #title; #searchPlaceholder; + #loading_add; /** * Selector for AlbumSelector @@ -100,6 +108,7 @@ class AlbumSelector { this.#title = modalTitle === '' ? str_album_modal_title : modalTitle; this.#searchPlaceholder = modalSearchPlaceholder === '' ? str_album_modal_placeholder : modalSearchPlaceholder; + this.#loading_add = false; this.#init(); } @@ -198,6 +207,12 @@ class AlbumSelector { if (e.key === "Escape" && AlbumSelector.selectors.addLinkedAlbum.is(":visible")) { this.#close_album_selector(); } + + if (e.key === 'Enter' && AlbumSelector.selectors.addLinkedAlbum.is(":visible")) { + if ($('#linkedAddNewAlbum').is(':visible')) { + AlbumSelector.selectors.linkedAddNewAlbum.trigger(`click${instanceAb}`); + } + } }); // event empty search input @@ -340,6 +355,7 @@ class AlbumSelector { this.#searchCat = {}; this.#currentSelectedId = ''; this.#put_to_root = false; + this.#loading_add = false; this.#destroyEvent(); @@ -659,6 +675,8 @@ class AlbumSelector { } #add_new_album(cat_id) { + if (this.#loading_add) return; + this.#loading_add = true; const cat_name = AlbumSelector.selectors.linkedAlbumInput.val(); const cat_position = $("input[name=position]:checked").val(); const api_params = { diff --git a/admin/themes/default/js/batchManagerGlobal.js b/admin/themes/default/js/batchManagerGlobal.js index 3b8d5eb09..c546ad84f 100644 --- a/admin/themes/default/js/batchManagerGlobal.js +++ b/admin/themes/default/js/batchManagerGlobal.js @@ -228,7 +228,9 @@ function selectDelDerivNone() { $(window).on('keypress', function(e) { const selected = $("select[name='selectAction']").val(); const haveTextarea = $(`#action_${selected} textarea`).length; - if (e.key === "Enter" && selected != -1 && !haveTextarea) { + const haveAlbumSelector = $('#addLinkedAlbum').is(':visible'); + + if (e.key === "Enter" && selected != -1 && !haveTextarea && !haveAlbumSelector) { e.preventDefault(); $('#applyAction').trigger('click'); }