From 75ecd7d579733c21c0d07dab8796a0a2a41fda99 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 6 Jun 2016 13:03:12 -0400 Subject: [PATCH] Better UX for max files exceeded --- inc/view_attachment_functions.inc.php | 9 +++++++-- language/en/text.php | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/inc/view_attachment_functions.inc.php b/inc/view_attachment_functions.inc.php index d238c881..d2d82586 100644 --- a/inc/view_attachment_functions.inc.php +++ b/inc/view_attachment_functions.inc.php @@ -254,7 +254,8 @@ function display_dropzone_field($url, $id = 'filedrop') { if (numberOfFiles >= " . $max_files . ") { disabled = true; } - $('." . $id . "-button').attr('disabled', disabled); + + $('." . $id . "button-" . $id . "').attr('disabled', disabled); }); this.on('removedfile', function(file) { // Remove the attachment from the database and the filesystem. @@ -266,7 +267,7 @@ function display_dropzone_field($url, $id = 'filedrop') { if (numberOfFiles >= " . $max_files . ") { disabled = true; } - $('." . $id . "-button').attr('disabled', disabled); + $('." . $id . "button-" . $id . "').attr('disabled', disabled); }); this.on('complete', function(file) { // Stop animating if complete. @@ -281,6 +282,9 @@ function display_dropzone_field($url, $id = 'filedrop') { this.on('uploadprogress', function(file, percentage) { $(file.previewTemplate).find('#percentage').text(percentage + '%'); }); + this.on('error', function(file, errorMessage, xhr) { + $(file.previewTemplate).addClass('alert-danger'); + }); }, paramName: 'attachment', url: '" . $url . "', @@ -297,6 +301,7 @@ function display_dropzone_field($url, $id = 'filedrop') { dictCancelUpload: ".json_encode($hesklang['attachment_cancel']).", dictCancelUploadConfirmation: ".json_encode($hesklang['attachment_confirm_cancel']).", dictRemoveFile: ".json_encode($hesklang['attachment_remove']).", + dictMaxFilesExceeded: ".json_encode($hesklang['attachment_max_exceeded']).", previewTemplate: $('#previews').html(), clickable: '.filedropbutton-".$id."', uploadMultiple: false diff --git a/language/en/text.php b/language/en/text.php index 1d1cbf5e..9aeaee03 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -109,6 +109,7 @@ $hesklang['select_all_title_case'] = 'Select All'; $hesklang['deselect_all_title_case'] = 'Deselect All'; $hesklang['event'] = 'Event'; $hesklang['overdue_ticket_legend'] = 'Overdue ticket'; +$hesklang['attachment_max_exceeded'] = 'This file will not be uploaded becuase you have already uploaded the maximum number of files allowed.'; // ADDED OR MODIFIED IN Mods for HESK 2.5.2 $hesklang['manage_statuses'] = 'Manage Statuses';