mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-25 19:00:03 +03:00
fixes #2316 improve album selector validation and keyboard interaction
also add an error in the global batch manager when we perform an album association but without choosing an album
This commit is contained in:
parent
e985ba5183
commit
1eb083bc63
3 changed files with 44 additions and 19 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue