fixes #2206 add album selector on the add photo page

- replace older selector with the new album selector
- moving javascript to a js file
- changed the logic for the first album (now its work with api)
- changed labels in album selector and also added an escape event (to close modal)
This commit is contained in:
Linty
2024-08-19 16:09:50 +02:00
parent 067010db7b
commit 7bd8b7e274
8 changed files with 578 additions and 399 deletions

View File

@@ -114,7 +114,7 @@ else
{
// we need to know the category in which the last photo was added
$query = '
SELECT category_id
SELECT category_id, c.uppercats
FROM '.IMAGES_TABLE.' AS i
JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = i.id
JOIN '.CATEGORIES_TABLE.' AS c ON category_id = c.id
@@ -127,6 +127,8 @@ SELECT category_id
{
$row = pwg_db_fetch_assoc($result);
$selected_category = array($row['category_id']);
$selected_category_name = get_cat_display_name_cache($row['uppercats'], null);
$template->assign('selected_category_name', $selected_category_name);
}
}

View File

@@ -81,6 +81,13 @@ $(function() {
switch_album_creation();
});
}
// Escape event
$(document).on('keyup', function(e) {
if (e.key === "Escape" && addLinkedAlbum.is(":visible")) {
close_album_selector();
}
});
});
/*--------------
@@ -216,11 +223,11 @@ function prefill_results(rank, cats, limit) {
);
} else {
display_div.append(
"<div class='search-result-item already-in' id="+ cat.id + " title='" + str_already_in_related_cats + "'>" +
"<div class='search-result-item already-in' id="+ cat.id + " title='" + str_album_selected + "'>" +
subcat +
"<div class='prefill-results-item' id=" + cat.id + ">" +
"<span class='search-result-path'>" + cat.name +"</span>" +
"<span id="+ cat.id + " class='gallery-icon-plus-circled item-add notClickable' title='" + str_already_in_related_cats + "'></span>" +
"<span id="+ cat.id + " class='gallery-icon-plus-circled item-add notClickable' title='" + str_album_selected + "'></span>" +
"</div>" +
"</div>"
);
@@ -305,10 +312,10 @@ function fill_results(cats) {
}
if (related_categories_ids.includes(cat.id)) {
$(".search-result-item #"+ cat.id +".item-add").addClass("notClickable").attr("title", str_already_in_related_cats).off('click').on("click", function (event) {
$(".search-result-item #"+ cat.id +".item-add").addClass("notClickable").attr("title", str_album_selected).off('click').on("click", function (event) {
event.preventDefault();
});
$("#"+cat.id+".search-result-item").addClass("notClickable").attr("title", str_already_in_related_cats).off('click').on("click", function (event) {
$("#"+cat.id+".search-result-item").addClass("notClickable").attr("title", str_album_selected).off('click').on("click", function (event) {
event.preventDefault();
});
} else {

View File

@@ -0,0 +1,425 @@
/*--------------
Variables
--------------*/
const btnFirstAlbum = $('#btnFirstAlbum');
const modalFirstAlbum = $('#addFirstAlbum');
const closeModalFirstAlbum = $('#closeFirstAlbum');
const inputFirstAlbum = $('#inputFirstAlbum');
const btnAddFirstAlbum = $('#btnAddFirstAlbum');
const firstAlbum = $('.addAlbumEmptyCenter');
const uploadForm = $('#uploadForm');
const addPhotosAS = $('#addPhotosAS');
const btnPhotosAS = $('#btnPhotosAS');
const selectedAlbum = $('#selectedAlbum');
const selectedAlbumName = $('#selectedAlbumName');
const selectedAlbumEdit = $('#selectedAlbumEdit');
const btnAddFiles = $('#addFiles');
const chooseAlbumFirst = $('#chooseAlbumFirst');
const uploaderPhotos = $('#uploader');
/*--------------
On DOM load
--------------*/
$(function () {
// First album event
if (!nb_albums) {
btnFirstAlbum.on('click', function() {
open_new_album_modal();
});
closeModalFirstAlbum.on('click', function() {
close_new_album_modal();
});
btnAddFirstAlbum.on('click', function() {
add_first_album();
});
}
// Open album selector event
btnPhotosAS.on('click', function() {
open_album_selector();
});
selectedAlbumEdit.on('click', function() {
open_album_selector();
});
// Upload logics
$(".dont-show-again").on("click", function() {
$.ajax({
url: "ws.php?format=json&method=pwg.users.preferences.set",
type: "POST",
dataType: "JSON",
data: {
param: 'promote-mobile-apps',
value: false,
},
success: function(res) {
jQuery(".promote-apps").hide();
}
})
});
$("#uploadWarningsSummary a.showInfo").on('click', function() {
$("#uploadWarningsSummary").hide();
$("#uploadWarnings").show();
return false;
});
$("#showPermissions").on('click', function() {
$(this).parent(".showFieldset").hide();
$("#permissions").show();
return false;
});
$("#uploader").pluploadQueue({
// General settings
browse_button : 'addFiles',
container : 'uploadForm',
// runtimes : 'html5,flash,silverlight,html4',
runtimes : 'html5',
// url : '../upload.php',
url : 'ws.php?method=pwg.images.upload&format=json',
chunk_size,
filters : {
// Maximum file size
max_file_size,
// Specify what files to browse for
mime_types: [
{title : "Image files", extensions : formatMode ? format_ext : file_ext}
]
},
// Rename files by clicking on their titles
rename: formatMode,
// Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that)
dragdrop: true,
preinit: {
Init: function (up, info) {
$('#uploader_container').removeAttr("title"); //remove the "using runtime" text
$('#startUpload').on('click', function(e) {
e.preventDefault();
up.start();
});
$('#cancelUpload').on('click', function(e) {
e.preventDefault();
up.stop();
up.trigger('UploadComplete', up.files);
});
}
},
init : {
// update custom button state on queue change
QueueChanged : function(up) {
$('#addFiles').addClass("addFilesButtonChanged");
$('#startUpload').prop('disabled', up.files.length == 0);
$("#addFiles").removeClass('buttonLike').addClass('buttonLike');
if (up.files.length > 0) {
$('.plupload_filelist_footer').show();
$('.plupload_filelist').css("overflow-y", "scroll");
}
if (up.files.length == 0) {
$('#addFiles').removeClass("addFilesButtonChanged");
$("#addFiles").removeClass('buttonLike').addClass('buttonLike');
$('.plupload_filelist_footer').hide();
$('.plupload_filelist').css("overflow-y", "hidden");
}
},
FilesAdded: async function(up, files) {
// Création de la liste avec plupload_id : image_name
fileNames = {};
files.forEach((file) => {
fileNames[file.id] = file.name;
});
if (formatMode) {
// If no original image is specified
if (!haveFormatsOriginal) {
const images_search = await new Promise((res, rej) => {
//ajax qui renvois les id des images dans la gallerie.
$.ajax({
url: "ws.php?format=json&method=pwg.images.formats.searchImage",
type: "POST",
data: {
// category_id: $("select[name=category] option:selected").val(), // id category to modify
category_id: related_categories_ids[0],
filename_list: JSON.stringify(fileNames),
},
success: function(result) {
let data = JSON.parse(result);
res(data.result)
}
})
})
const notFound = [];
const multiple = [];
files.forEach((f) => {
const search = images_search[f.id];
if (search.status == "found")
f.format_of = search.image_id;
else {
if (search.status == "multiple")
multiple.push(f.name);
else
notFound.push(f.name);
up.removeFile(f.id);
}
})
files.filter(f => images_search[f.id].status === "found");
// If a file is not found or found more than one time
if (notFound.length || multiple.length) {
const [multStr, notFoundStr] = [multiple, notFound].map((tab) => {
//Get names
tab = tab.map(f => f.slice(0,f.indexOf('.')))
// Remove duplicates
tab = tab.filter((f,i) => i === tab.indexOf(f))
// Add "and X more" if necessary
if (tab.length > 5) {
tab[5] = str_and_X_others.replace('%d', tab.length - 5);
tab = tab.splice(0,6);
}
return tab;
})
$.alert({
title: str_format_warning,
content : (notFound.length ? `<p>${str_format_warning_notFound.replace('%s', notFoundStr.join(', '))}</p>` : "")
+(multiple.length ? `<p>${str_format_warning_multiple.replace('%s', multStr.join(', '))}</p>` : ""),
...jConfirm_warning_options
})
}
} else { //If an original image is specified
files.forEach((f) => {
f.format_of = originalImageId;
})
}
}
},
UploadProgress: function(up, file) {
$('#uploadingActions .progressbar').width(up.total.percent+'%');
Piecon.setProgress(up.total.percent);
},
BeforeUpload: function(up, file) {
// hide buttons
$('#startUpload, .selectFilesButtonBlock').hide();
$('#uploadingActions').show();
$('.format-mode-group-manager').hide();
// if (!formatMode) {
// var categorySelectedId = $("select[name=category] option:selected").val();
// var categorySelectedPath = $("select[name=category]")[0].selectize.getItem(categorySelectedId).text();
// $('.selectedAlbum').show().find('span').html(categorySelectedPath);
// }
// warn user if she wants to leave page while upload is running
$(window).bind('beforeunload', function() {
return str_upload_in_progress;
});
// no more change on category/level
$("select[name=level]").attr("disabled", "disabled");
// You can override settings before the file is uploaded
var options = {
pwg_token : pwg_token
};
if (formatMode) {
options.format_of = file.format_of;
} else {
// options.category = $("select[name=category] option:selected").val();
options.category = related_categories_ids[0];
// options.level = $("select[name=level] option:selected").val();
options.name = file.name;
}
up.setOption('multipart_params', options);
},
FileUploaded: function(up, file, info) {
// Called when file has finished uploading
//console.log('[FileUploaded] File:', file, "Info:", info);
// hide item line
$('#'+file.id).hide();
let data = JSON.parse(info.response);
$("#uploadedPhotos").parent("fieldset").show();
html = '<a href="admin.php?page=photo-'+data.result.image_id+'" style="position : relative" target="_blank">';
html += '<img src="'+data.result.square_src+'" class="thumbnail" title="'+data.result.name+'">';
if (formatMode) html += '<div class="format-ext-name" title="'+file.name+'"><span>'+file.name.slice(file.name.indexOf('.'))+'</span></div>';
html += '</a> ';
$("#uploadedPhotos").prepend(html);
// do not remove file, or it will reset the progress bar :-/
// up.removeFile(file);
uploadedPhotos.push(parseInt(data.result.image_id));
if (!formatMode)
uploadCategory = data.result.category;
},
Error: function(up, error) {
// Called when file has finished uploading
//console.log('[Error] error: ', error);
var piwigoApiResponse = JSON.parse(error.response);
$(".errors ul").append('<li>'+piwigoApiResponse.message+'</li>');
$(".errors").show();
},
UploadComplete: function(up, files) {
// Called when all files are either uploaded or failed
//console.log('[UploadComplete]');
Piecon.reset();
if (!formatMode) {
$.ajax({
url: "ws.php?format=json&method=pwg.images.uploadCompleted",
type:"POST",
data: {
pwg_token: pwg_token,
image_id: uploadedPhotos.join(","),
category_id: uploadCategory.id,
}
});
}
$("#uploadForm, #permissions, .showFieldset").hide();
const infoText = formatMode?
sprintf(formatsUploaded_label, uploadedPhotos.length, [...new Set(files.map(f => f.format_of))].length)
: sprintf(photosUploaded_label, uploadedPhotos.length)
$(".infos").append('<ul><li>'+infoText+'</li></ul>');
if (!formatMode) {
html = sprintf(
albumSummary_label,
'<a href="admin.php?page=album-'+uploadCategory.id+'">'+uploadCategory.label+'</a>',
parseInt(uploadCategory.nb_photos)
);
$(".infos ul").append('<li>'+html+'</li>');
}
$(".infos").show();
// TODO: use a new method pwg.caddie.empty +
// pwg.caddie.add(uploadedPhotos) instead of relying on huge GET parameter
// (and remove useless code from admin/photos_add_direct.php)
$(".batchLink").attr("href", "admin.php?page=photos_add&section=direct&batch="+uploadedPhotos.join(","));
$(".batchLink").html(sprintf(batch_Label, uploadedPhotos.length));
$(".afterUploadActions").show();
$('#uploadingActions').hide();
// user can safely leave page without warning
$(window).unbind('beforeunload');
}
}
});
});
/*--------------
General functions
--------------*/
function add_related_category(cat_id, cat_name) {
let text = '';
$(cat_name).each(function(i, s) {
if($(s).html()) { text += $(s).html() }
});
related_categories_ids = [cat_id];
selectedAlbumName.hide();
selectedAlbumName.html(text);
selectedAlbumName.fadeIn();
addPhotosAS.hide();
selectedAlbum.fadeIn();
enable_uploader();
close_album_selector();
}
function enable_uploader() {
btnAddFiles.removeAttr('disabled');
chooseAlbumFirst.hide();
uploaderPhotos.show();
}
/*-------------------
First album functions
-------------------*/
function open_new_album_modal() {
inputFirstAlbum.val('');
modalFirstAlbum.fadeIn();
}
function close_new_album_modal() {
modalFirstAlbum.fadeOut();
}
function hide_first_album(cat_name) {
modalFirstAlbum.hide();
firstAlbum.hide();
addPhotosAS.hide();
selectedAlbumName.html(cat_name);
selectedAlbum.show();
enable_uploader();
uploadForm.fadeIn();
}
function add_first_album() {
const params = {
name: inputFirstAlbum.val().toString(),
pwg_token
}
$.ajax({
url: 'ws.php?format=json&method=pwg.categories.add',
method: 'POST',
dataType: 'json',
data: params,
success: function (res) {
if (res.stat === 'ok') {
related_categories_ids = [res.result.id.toString()];
hide_first_album(params.name);
} else {
console.error('An error has occurred');
}
},
error: function() {
console.error('An error has occurred');
}
});
}

View File

@@ -1,3 +1,5 @@
{if isset($ADD_TO_ALBUM) or isset($selected_category_name)}{$can_upload=true}{else}{$can_upload=false}{/if}
{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'}
{combine_script id='jquery.plupload' load='footer' require='jquery' path='themes/default/js/plugins/plupload/plupload.full.min.js'}
{combine_script id='jquery.plupload.queue' load='footer' require='jquery' path='themes/default/js/plugins/plupload/jquery.plupload.queue/jquery.plupload.queue.min.js'}
@@ -22,6 +24,7 @@
{combine_css id='jquery.selectize' path="themes/default/js/plugins/selectize.{$themeconf.colorscheme}.css"}
{combine_script id='piecon' load='footer' path='themes/default/js/plugins/piecon.js'}
{combine_script id='add_photo' load='footer' path='admin/themes/default/js/photos_add_direct.js'}
{html_style}
.addAlbumFormParent { display: none; } /* specific to this page, do not move in theme.css */
@@ -32,48 +35,9 @@
const formatMode = {if $DISPLAY_FORMATS}true{else}false{/if};
const haveFormatsOriginal = {if $HAVE_FORMATS_ORIGINAL}true{else}false{/if};
const originalImageId = haveFormatsOriginal? '{if isset($FORMATS_ORIGINAL_INFO['id'])} {$FORMATS_ORIGINAL_INFO['id']} {else} -1 {/if}' : -1;
{* <!-- CATEGORIES --> *}
if (!formatMode) {
var categoriesCache = new CategoriesCache({
serverKey: '{$CACHE_KEYS.categories}',
serverId: '{$CACHE_KEYS._hash}',
rootUrl: '{$ROOT_URL}'
});
categoriesCache.selectize(jQuery('[data-selectize=categories]'), {
filter: function(categories, options) {
if (categories.length > 0) {
jQuery(".addAlbumEmptyCenter").css( "height", "auto" );
jQuery(".addAlbumFormParent").attr( "style", "display: block !important;" );
}
return categories;
}
});
jQuery('[data-add-album]').pwgAddAlbum({
afterSelect: function() {
jQuery("#uploadForm").show();
jQuery(".addAlbumEmptyCenter").hide();
jQuery(".addAlbumEmptyCenter").css( "height", "auto" );
jQuery(".addAlbumFormParent").attr( "style", "display: block !important;" );
var categorySelectedId = jQuery("select[name=category] option:selected").val();
var categorySelectedPath = jQuery("select[name=category]")[0].selectize.getItem(categorySelectedId).text();
jQuery('.selectedAlbum').show().find('span').html(categorySelectedPath);
jQuery('.selectAlbumBlock').hide();
}
});
Piecon.setOptions({
color: '#ff7700',
background: '#bbb',
shadow: '#fff',
fallback: 'force'
});
}
const nb_albums = {$NB_ALBUMS|escape:javascript};
const chunk_size = '{$chunk_size}kb';
const max_file_size = '{$max_file_size}mb';
var pwg_token = '{$pwg_token}';
var photosUploaded_label = "{'%d photos uploaded'|translate}";
var formatsUploaded_label = "{'%d formats uploaded for %d photos'|translate}";
@@ -84,310 +48,13 @@ var str_ok = "{'Ok'|translate}";
var str_format_warning_multiple = "{'There is multiple image in the database with the following names : %s.'|translate}";
var str_format_warning_notFound = "{'No picture found with the following name : %s.'|translate}";
var str_and_X_others = "{'and %d more'|translate}";
const str_upload_in_progress = "{'Upload in progress'|translate|escape}";
var file_ext = "{$file_exts}";
var format_ext = "{$format_ext}";
var uploadedPhotos = [];
var uploadCategory = null;
let related_categories_ids = {$selected_category|json_encode};
{literal}
jQuery(document).ready(function(){
jQuery(".dont-show-again").on("click", function() {
jQuery.ajax({
url: "ws.php?format=json&method=pwg.users.preferences.set",
type: "POST",
dataType: "JSON",
data: {
param: 'promote-mobile-apps',
value: false,
},
success: function(res) {
jQuery(".promote-apps").hide();
}
})
})
jQuery("#uploadWarningsSummary a.showInfo").click(function() {
jQuery("#uploadWarningsSummary").hide();
jQuery("#uploadWarnings").show();
return false;
});
jQuery("#showPermissions").click(function() {
jQuery(this).parent(".showFieldset").hide();
jQuery("#permissions").show();
return false;
});
jQuery("#uploader").pluploadQueue({
// General settings
browse_button : 'addFiles',
container : 'uploadForm',
// runtimes : 'html5,flash,silverlight,html4',
runtimes : 'html5',
// url : '../upload.php',
url : 'ws.php?method=pwg.images.upload&format=json',
chunk_size: '{/literal}{$chunk_size}{literal}kb',
filters : {
// Maximum file size
max_file_size : '{/literal}{$max_file_size}{literal}mb',
// Specify what files to browse for
mime_types: [
{title : "Image files", extensions : formatMode ? format_ext : file_ext}
]
},
// Rename files by clicking on their titles
rename: formatMode,
// Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that)
dragdrop: true,
preinit: {
Init: function (up, info) {
jQuery('#uploader_container').removeAttr("title"); //remove the "using runtime" text
jQuery('#startUpload').on('click', function(e) {
e.preventDefault();
up.start();
});
jQuery('#cancelUpload').on('click', function(e) {
e.preventDefault();
up.stop();
up.trigger('UploadComplete', up.files);
});
}
},
init : {
// update custom button state on queue change
QueueChanged : function(up) {
jQuery('#addFiles').addClass("addFilesButtonChanged");
jQuery('#startUpload').prop('disabled', up.files.length == 0);
jQuery("#addFiles").removeClass('buttonLike').addClass('buttonLike');
if (up.files.length > 0) {
jQuery('.plupload_filelist_footer').show();
jQuery('.plupload_filelist').css("overflow-y", "scroll");
}
if (up.files.length == 0) {
jQuery('#addFiles').removeClass("addFilesButtonChanged");
jQuery("#addFiles").removeClass('buttonLike').addClass('buttonLike');
jQuery('.plupload_filelist_footer').hide();
jQuery('.plupload_filelist').css("overflow-y", "hidden");
}
},
FilesAdded: async function(up, files) {
// Création de la liste avec plupload_id : image_name
fileNames = {};
files.forEach((file) => {
fileNames[file.id] = file.name;
});
if (formatMode) {
// If no original image is specified
if (!haveFormatsOriginal) {
const images_search = await new Promise((res, rej) => {
//ajax qui renvois les id des images dans la gallerie.
jQuery.ajax({
url: "ws.php?format=json&method=pwg.images.formats.searchImage",
type: "POST",
data: {
category_id: jQuery("select[name=category] option:selected").val(),
filename_list: JSON.stringify(fileNames),
},
success: function(result) {
let data = JSON.parse(result);
res(data.result)
}
})
})
const notFound = [];
const multiple = [];
files.forEach((f) => {
const search = images_search[f.id];
if (search.status == "found")
f.format_of = search.image_id;
else {
if (search.status == "multiple")
multiple.push(f.name);
else
notFound.push(f.name);
up.removeFile(f.id);
}
})
files.filter(f => images_search[f.id].status === "found");
// If a file is not found or found more than one time
if (notFound.length || multiple.length) {
const [multStr, notFoundStr] = [multiple, notFound].map((tab) => {
//Get names
tab = tab.map(f => f.slice(0,f.indexOf('.')))
// Remove duplicates
tab = tab.filter((f,i) => i === tab.indexOf(f))
// Add "and X more" if necessary
if (tab.length > 5) {
tab[5] = str_and_X_others.replace('%d', tab.length - 5);
tab = tab.splice(0,6);
}
return tab;
})
$.alert({
title: str_format_warning,
content : (notFound.length ? `<p>${str_format_warning_notFound.replace('%s', notFoundStr.join(', '))}</p>` : "")
+(multiple.length ? `<p>${str_format_warning_multiple.replace('%s', multStr.join(', '))}</p>` : ""),
...jConfirm_warning_options
})
}
} else { //If an original image is specified
files.forEach((f) => {
f.format_of = originalImageId;
})
}
}
},
UploadProgress: function(up, file) {
jQuery('#uploadingActions .progressbar').width(up.total.percent+'%');
Piecon.setProgress(up.total.percent);
},
BeforeUpload: function(up, file) {
// hide buttons
jQuery('#startUpload, .selectFilesButtonBlock, .selectAlbumBlock').hide();
jQuery('#uploadingActions').show();
jQuery('.format-mode-group-manager').hide();
if (!formatMode) {
var categorySelectedId = jQuery("select[name=category] option:selected").val();
var categorySelectedPath = jQuery("select[name=category]")[0].selectize.getItem(categorySelectedId).text();
jQuery('.selectedAlbum').show().find('span').html(categorySelectedPath);
}
// warn user if she wants to leave page while upload is running
jQuery(window).bind('beforeunload', function() {
return "{/literal}{'Upload in progress'|translate|escape}{literal}";
});
// no more change on category/level
jQuery("select[name=level]").attr("disabled", "disabled");
// You can override settings before the file is uploaded
var options = {
pwg_token : pwg_token
};
if (formatMode) {
options.format_of = file.format_of;
} else {
options.category = jQuery("select[name=category] option:selected").val();
options.level = jQuery("select[name=level] option:selected").val();
options.name = file.name;
}
up.setOption('multipart_params', options);
},
FileUploaded: function(up, file, info) {
// Called when file has finished uploading
//console.log('[FileUploaded] File:', file, "Info:", info);
// hide item line
jQuery('#'+file.id).hide();
let data = jQuery.parseJSON(info.response);
jQuery("#uploadedPhotos").parent("fieldset").show();
html = '<a href="admin.php?page=photo-'+data.result.image_id+'" style="position : relative" target="_blank">';
html += '<img src="'+data.result.square_src+'" class="thumbnail" title="'+data.result.name+'">';
if (formatMode) html += '<div class="format-ext-name" title="'+file.name+'"><span>'+file.name.slice(file.name.indexOf('.'))+'</span></div>';
html += '</a> ';
jQuery("#uploadedPhotos").prepend(html);
// do not remove file, or it will reset the progress bar :-/
// up.removeFile(file);
uploadedPhotos.push(parseInt(data.result.image_id));
if (!formatMode)
uploadCategory = data.result.category;
},
Error: function(up, error) {
// Called when file has finished uploading
//console.log('[Error] error: ', error);
var piwigoApiResponse = jQuery.parseJSON(error.response);
jQuery(".errors ul").append('<li>'+piwigoApiResponse.message+'</li>');
jQuery(".errors").show();
},
UploadComplete: function(up, files) {
// Called when all files are either uploaded or failed
//console.log('[UploadComplete]');
Piecon.reset();
if (!formatMode) {
jQuery.ajax({
url: "ws.php?format=json&method=pwg.images.uploadCompleted",
type:"POST",
data: {
pwg_token: pwg_token,
image_id: uploadedPhotos.join(","),
category_id: uploadCategory.id,
}
});
}
jQuery("#uploadForm, #permissions, .showFieldset").hide();
const infoText = formatMode?
sprintf(formatsUploaded_label, uploadedPhotos.length, [...new Set(files.map(f => f.format_of))].length)
: sprintf(photosUploaded_label, uploadedPhotos.length)
jQuery(".infos").append('<ul><li>'+infoText+'</li></ul>');
if (!formatMode) {
html = sprintf(
albumSummary_label,
'<a href="admin.php?page=album-'+uploadCategory.id+'">'+uploadCategory.label+'</a>',
parseInt(uploadCategory.nb_photos)
);
jQuery(".infos ul").append('<li>'+html+'</li>');
}
jQuery(".infos").show();
// TODO: use a new method pwg.caddie.empty +
// pwg.caddie.add(uploadedPhotos) instead of relying on huge GET parameter
// (and remove useless code from admin/photos_add_direct.php)
jQuery(".batchLink").attr("href", "admin.php?page=photos_add&section=direct&batch="+uploadedPhotos.join(","));
jQuery(".batchLink").html(sprintf(batch_Label, uploadedPhotos.length));
jQuery(".afterUploadActions").show();
jQuery('#uploadingActions').hide();
// user can safely leave page without warning
jQuery(window).unbind('beforeunload');
}
}
});
{/literal}
});
{/footer_script}
<div id="photosAddContent">
@@ -433,7 +100,7 @@ jQuery(document).ready(function(){
</div>
{/if}
{if $ENABLE_FORMATS}
{if $ENABLE_FORMATS and $can_upload}
<div class="format-mode-group-manager">
<label class="switch" onClick="window.location.replace('{$SWITCH_MODE_URL}'); $('.switch .slider').addClass('loading');">
<input type="checkbox" id="toggleFormatMode" {if $DISPLAY_FORMATS}checked{/if}>
@@ -448,7 +115,7 @@ jQuery(document).ready(function(){
<div class="addAlbumEmpty">
<div class="addAlbumEmptyTitle">{'Welcome!'|translate}</div>
<p class="addAlbumEmptyInfos">{'Piwigo requires an album to add photos.'|translate}</p>
<a href="#" data-add-album="category" class="buttonLike">{'Create a first album'|translate}</a>
<a class="buttonLike" id="btnFirstAlbum">{'Create a first album'|translate}</a>
</div>
</div>
{/if}
@@ -468,14 +135,12 @@ jQuery(document).ready(function(){
{if not $DISPLAY_FORMATS}
<fieldset class="selectAlbum">
<legend><span class="icon-folder-open icon-red"></span>{'Drop into album'|@translate}</legend>
<div class="selectedAlbum"{if !isset($ADD_TO_ALBUM)} style="display: none"{/if}><span class="icon-sitemap">{if isset($ADD_TO_ALBUM)}{$ADD_TO_ALBUM}{/if}</span></div>
<div class="selectAlbumBlock"{if isset($ADD_TO_ALBUM)} style="display: none"{/if}>
<span id="albumSelection">
<select data-selectize="categories" data-value="{$selected_category|@json_encode|escape:html}"
data-default="first" name="category" style="width:600px"></select>
</span>
<span class="orChoice">{'... or '|@translate} </span>
<a href="#" data-add-album="category" class="orCreateAlbum icon-plus-circled"> {'create a new album'|@translate}</a>
<div class="selectedAlbum"{if !$can_upload} style="display: none"{/if} id="selectedAlbum">
<span class="icon-sitemap" id="selectedAlbumName">{if isset($ADD_TO_ALBUM)}{$ADD_TO_ALBUM}{elseif isset($selected_category_name)}{$selected_category_name}{/if}</span>
<a class="icon-pencil" id="selectedAlbumEdit"></a>
</div>
<div class="selectAlbumSelector" {if $can_upload} style="display: none"{/if} id="addPhotosAS">
<p class="head-button-1 icon-folder-open" id="btnPhotosAS">{"Select or create an album"|translate}</p>
</div>
</fieldset>
{elseif $HAVE_FORMATS_ORIGINAL}
@@ -507,7 +172,9 @@ jQuery(document).ready(function(){
<fieldset class="selectFiles">
<legend><span class="icon-file-image icon-yellow"></span>{'Select files'|@translate}</legend>
<div class="selectFilesButtonBlock">
<button id="addFiles" class="buttonLike">{if not $DISPLAY_FORMATS}{'Add Photos'|translate}{else}{'Add formats'|@translate}{/if}<i class="icon-plus-circled"></i></button>
<button id="addFiles" class="buttonLike icon-plus-circled" {if !$can_upload}disabled{/if}>
{if not $DISPLAY_FORMATS}{'Add Photos'|translate}{else}{'Add formats'|@translate}{/if}
</button>
<div class="selectFilesinfo">
{if isset($original_resize_maxheight)}
<p class="uploadInfo">{'The picture dimensions will be reduced to %dx%d pixels.'|@translate:$original_resize_maxwidth:$original_resize_maxheight}</p>
@@ -527,10 +194,12 @@ jQuery(document).ready(function(){
</p>
</div>
</div>
<div id="uploader">
<div class="photosUploader" id="uploader" {if !$can_upload}style="display: none;"{/if}>
<p>Your browser doesn't have HTML5 support.</p>
</div>
<div class="selectAlbumFirst" id="chooseAlbumFirst" {if $can_upload}style="display: none;"{/if}>
<p>{"First choose an album, then add your files"|translate}</p>
</div>
</fieldset>
<div id="uploadingActions" style="display:none">
@@ -549,3 +218,28 @@ jQuery(document).ready(function(){
</fieldset>
</div> <!-- photosAddContent -->
<div class="bg-modal" id="addFirstAlbum">
<div class="new-album-modal-content">
<a class="icon-cancel close-modal" id="closeFirstAlbum"></a>
<div class="AddIconContainer">
<span class="AddIcon icon-blue icon-add-album"></span>
</div>
<div class="AddIconTitle">
<span>{'Create your first album'|translate}</span>
</div>
<div class="AddAlbumInputContainer">
<label class="user-property-label AddAlbumLabelUsername">{'Album name'|translate}
<input class="user-property-input" id="inputFirstAlbum">
</label>
</div>
<a class="buttonLike icon-plus" id="btnAddFirstAlbum">{'Create and select'|translate}</a>
</div>
</div>
{include file='include/album_selector.inc.tpl'
title={'Drop into album'|@translate}
searchPlaceholder={'Search'|@translate}
admin_mode=true
}

View File

@@ -3866,7 +3866,11 @@ a#showPermissions:hover {text-decoration: none;}
#uploadForm .plupload_buttons, #uploadForm .plupload_progress { display:none !important; }
#uploadForm #startUpload { margin:5px 0 15px 25px; padding:8px 10px; font-size:1.1em; }
#uploadForm #startUpload:before { margin-right:0.5em;}
#uploadForm #startUpload:before,
#uploadForm #btnPhotosAS:before,
#uploadForm #addFiles:before {
margin-right:0.5em;
}
#uploadForm #addFiles { margin-right:10px; float:left; height: 45.6px;}
#uploadForm #uploadingActions { margin:10px 10px 10px 15px; }
#uploadForm .big-progressbar { vertical-align:middle; display:inline-block; margin-left:10px; }
@@ -6343,38 +6347,22 @@ fieldset#environment legend i[class*="icon-"] {
#permissions, #uploadForm fieldset {border: 0;}
#permissions {display: none!important;}
#permissions {margin-top: 35px; margin-bottom: 20px;}
#uploadForm fieldset:not(:last-child) {margin-bottom: 35px;}
#uploadForm fieldset:last-child {margin-bottom: 20px;}
.originalPicture .info-framed {max-width: 400px;}
.selectAlbumBlock {display: flex; margin-left: 10px; margin-top: 10px;}
/* .selectAlbumBlock span {
margin-top: 15px;
margin-right: 15px;
} */
.selectAlbum {
display: flex;
}
.selectAlbumSelector {
display: flex;
gap: 5px;
}
.icon-plus.cboxElement {
padding: 8px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16); font-size: 15px; margin-bottom: 8px; transition: all 125ms ease-out;
}
.icon-plus.cboxElement:hover {box-shadow: 0 2px 4px rgba(0, 0, 0, 0.16);}
#albumSelection {margin-right: 20px;}
.orCreateAlbum{
margin: 7px 0 9px 20px;
padding: 7px 10px;
background-color: #fafafa;
box-shadow: 0px 2px #00000024;
border-radius: 5px;
font-weight: bold;
color: #777 !important;
display: block;
}
.orCreateAlbum:hover {
text-decoration: none;
color: #3a3a3a;
}
.selectAlbumBlock .orChoice {
margin: 12px 0 0 0;
}
.selectize-control.single .selectize-input {border-radius: 0; font-weight: bold;font-size: 12px;}
.buttonLike {padding: 8px 10px; margin-left: 5px;}
.changeUsername .buttonLike {padding: 1px 10px;}
@@ -6448,15 +6436,24 @@ li.plupload_delete a:hover {background: url("images/cancelhover.svg")!important;
.popinField {margin-top: 30px; }
.popinField.addAlbumFormParent {margin-top: 0;}
.popinFieldLabel {display: block; margin-bottom: 5px;}
.selectedAlbum {margin-top: 10px; margin-left: 5px;}
.selectedAlbum span {
.selectedAlbum {
margin-left: 5px;
display: flex;
align-items: baseline;
gap: 5px;
}
.selectedAlbum #selectedAlbumName {
padding: 10px 12px;
font-weight: bold;
text-align: center;
margin-top: 20px;
border-radius: 7px;
background-color:#f5f5f5
}
.selectedAlbum #selectedAlbumEdit {
font-size: 16px;
cursor: pointer;
}
.selectedAlbum span.icon-sitemap::before, .afterUploadActions a.batchLink.icon-pencil::before, .afterUploadActions a.icon-plus-circled::before {
margin-right: 12px;
}
@@ -7418,6 +7415,59 @@ color:#FF7B00;
margin-right: 5px;
}
.bg-modal {
display: none;
position: fixed;
z-index: 100;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0,0,0,0.7);
}
.close-modal {
color: white;
position: absolute;
right: -40px;
top: -40px;
font-size: 30px;
}
.new-album-modal-content {
display: flex;
flex-direction: column;
background-color: white;
position: absolute;
border-radius: 10px;
left: 50%;
top: 50%;
transform: translate(-50%, -48%);
text-align: left;
padding: 30px;
width: 400px;
}
.new-album-modal-content .buttonLike {
margin: 15px 0 0 0;
align-self: self-end;
}
.new-album-modal-content .AddIconContainer {
align-self: center;
}
.selectAlbumFirst {
height: 250px;
background: #F5F5F5;
display: flex;
align-items: center;
justify-content: center;
font-size: 2em;
font-weight: bold;
margin-top: 25px;
}
@media (max-width: 1450px) {
.promote-text span {

View File

@@ -417,15 +417,6 @@ div.token-input-dropdown ul li.token-input-selected-dropdown-item {background-co
}
/* Album edit */
.orCreateAlbum{
background-color: #333;
color: #777;
}
.orCreateAlbum:hover {
text-decoration: none;
color: #777;
}
.move-cat-container:hover {
background-color: #232323;
}
@@ -960,6 +951,9 @@ li.plupload_delete a:hover {background: url("images/cancelhover.svg")!important;
#uploadForm li.plupload_droptext {background-color: #343434!important; color: #777 !important;}
.addFilesButtonChanged {background-color: #888;}
.addFilesButtonChanged:hover {background-color: #777;}
.selectAlbumFirst {
background: #343434 !important;
}
.categoryBox, .addAlbum {background-color: #333 !important; box-shadow: -1px 1px 2px #1a1a1a;}
.categoryBox.line_cat:hover {
background: #f9852c !important;
@@ -1865,8 +1859,8 @@ li.plupload_delete a:hover {background: url("images/cancelhover.svg")!important;
.selectedAlbum span a{
color: #777 !important;
}
.selectedAlbum span {
background-color: #343434;
.selectedAlbum span:first-child {
background-color: #343434 !important;
}
.AddUserErrors, .update-user-fail, .EditUserErrors, .update-password-fail, .icon-red-error {
@@ -2090,7 +2084,8 @@ ul.jqtree-tree li.jqtree-ghost span.jqtree-line {
}
/* Cat modify description modal */
.desc-modal-content {
.desc-modal-content,
.new-album-modal-content {
background-color: #444;
}

View File

@@ -1374,4 +1374,7 @@ $lang['Add a sub-album to “%s”'] = 'Add a sub-album to “%s”';
$lang['Activate create mode to create and select an album'] = 'Activate create mode to create and select an album';
$lang['Name field must not be empty'] = 'Name field must not be empty';
$lang['Create a root album'] = 'Create a root album';
$lang['Create your first album'] = 'Create your first album';
$lang['First choose an album, then add your files'] = 'First choose an album, then add your files';
$lang['Select or create an album'] = 'Select or create an album';
// Leave this line empty

View File

@@ -1303,7 +1303,7 @@ $lang['Discover'] = 'Découvrir';
$lang['Latest Piwigo news'] = 'Dernière nouvelle de Piwigo';
$lang['Understood, do not show again'] = 'Compris, ne plus afficher';
$lang['%s pixels, %.2f MB'] = '%s pixels, %.2f Mo';
$lang['Upload Formats'] = 'Télécharger des formats';
$lang['Upload Formats'] = 'Ajouter des formats';
$lang['Add formats'] = 'Ajouter des formats';
$lang['No format for this picture'] = 'Il n\'y a pas de format pour cette photo';
$lang['Add another set of formats'] = 'Ajouter un autre lot de formats';
@@ -1374,4 +1374,7 @@ $lang['Add a sub-album to “%s”'] = 'Ajouter un sous-album à “%s”';
$lang['Activate create mode to create and select an album'] = 'Activer le mode création pour créer et sélectionner un album';
$lang['Name field must not be empty'] = 'Le champ nom ne doit pas être vide';
$lang['Create a root album'] = 'Créer un album racine';
$lang['Create your first album'] = 'Créez votre premier album';
$lang['First choose an album, then add your files'] = 'Choisissez d\'abord un album, puis ajoutez vos fichiers';
$lang['Select or create an album'] = 'Sélectionner ou créer un album';
// Leave this line empty