Skip to content

Commit

Permalink
#48 [Medias] fix: multiple errors management on send photo action
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-theo committed Jan 27, 2023
1 parent 9cc8f22 commit ab24ff6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion core/tpl/medias_gallery_modal.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// Define relativepath and upload_dir
$relativepath = $module . '/medias';
$uploadDir = $conf->ecm->dir_output . '/' . $relativepath;
$uploadDir = $conf->ecm->dir_output . '/' . $relativepath;
if (is_array($_FILES['userfile']['tmp_name'])) $userfiles = $_FILES['userfile']['tmp_name'];
else $userfiles = array($_FILES['userfile']['tmp_name']);

Expand Down
15 changes: 7 additions & 8 deletions js/modules/mediaGallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,15 @@ window.saturne.mediaGallery.sendPhoto = function( event ) {
let objectSubtype = mediaGallery.find('.from-subtype').length ? mediaGallery.find('.from-subtype').val() : ''
let objectSubdir = mediaGallery.find('.from-subdir').length ? mediaGallery.find('.from-subdir').val() : ''

let token = window.saturne.toolbox.getToken();;
let token = window.saturne.toolbox.getToken();

$('#progressBar').width(0)
$('#progressBarContainer').attr('style', 'display:block')

window.saturne.loader.display($('#progressBarContainer'));

let querySeparator = window.saturne.toolbox.getQuerySeparator(document.URL)
let textToShow = '';

$.each(files, function(index, file) {
let formdata = new FormData();
Expand All @@ -211,6 +212,10 @@ window.saturne.mediaGallery.sendPhoto = function( event ) {
$('#progressBar').animate({
width: progress + '%'
}, 1);
let errorMessage = $(resp).find('.error-medias').val()
let decodedErrorMessage = JSON.parse(errorMessage)

textToShow += decodedErrorMessage.message + '<br>'

if (requestCompleted === totalCount) {
$('.wpeo-loader').removeClass('wpeo-loader');
Expand All @@ -224,13 +229,7 @@ window.saturne.mediaGallery.sendPhoto = function( event ) {
$('#media_gallery').find('.clickable-photo0').addClass('clicked-photo');
}
if ($(resp).find('.error-medias').length) {
let response = $(resp).find('.error-medias').val()
let decoded_response = JSON.parse(response)

let textToShow = '';
textToShow += decoded_response.message

$('.messageErrorSendPhoto').find('.notice-subtitle').text(textToShow)
$('.messageErrorSendPhoto').find('.notice-subtitle').html(textToShow)
$('.messageErrorSendPhoto').removeClass('hidden');
} else {
$('.messageSuccessSendPhoto').removeClass('hidden');
Expand Down
3 changes: 1 addition & 2 deletions js/modules/toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ window.saturne.toolbox = {};
* @return {void}
*/
window.saturne.toolbox.init = function() {
window.saturne.toolbox.event();
};

/**
Expand All @@ -63,7 +62,7 @@ window.saturne.toolbox.getQuerySeparator = function( url ) {
*
* @return {string}
*/
window.saturne.toolbox.window.saturne.toolbox.getToken = function() {
window.saturne.toolbox.getToken = function() {
let token = $('input[name="token"]').val();

return token
Expand Down
2 changes: 1 addition & 1 deletion js/saturne.min.js

Large diffs are not rendered by default.

0 comments on commit ab24ff6

Please sign in to comment.