Browse Source

Fix #822: Enhancement for preventing upload when data is empty

Kartik Visweswaran 8 years ago
parent
commit
9618ce5019

+ 2 - 1
CHANGE.md

@@ -3,10 +3,11 @@ Change Log: `bootstrap-fileinput`
 
 ## version 4.3.7
 
-**Date:** 24-Dec-2016
+**Date:** 27-Dec-2016
 
 - (enh #816): New property `msgFileTypes` to control descriptions/localizations of file types displayed.
 - (bug #819): Correct init preview auto replace post `uploadSingle` action in thumbnails.
+- (enh #822): Enhancement for preventing upload when data is empty. New property `msgUploadEmpty` has been incorporated.
 
 ## version 4.3.6
 

+ 11 - 2
js/fileinput.js

@@ -2575,6 +2575,9 @@
                 }
                 return true;
             }
+            if (!self.filestack[ind]) {
+                return true;
+            }
             type = type || self.resizeDefaultImageType;
             chkWidth = width > maxWidth;
             chkHeight = height > maxHeight;
@@ -3090,13 +3093,18 @@
             return self.$element;
         },
         upload: function () {
-            var self = this, totLen = self.getFileStack().length, params = {},
+            var self = this, totLen = self.getFileStack().length, params = {}, 
                 i, outData, len, hasExtraData = !$.isEmptyObject(self._getExtraData());
+            if (!self.isUploadable || self.isDisabled) {
+                return;
+            }
             if (self.minFileCount > 0 && self._getFileCount(totLen) < self.minFileCount) {
                 self._noFilesError(params);
                 return;
             }
-            if (!self.isUploadable || self.isDisabled || (totLen === 0 && !hasExtraData)) {
+            if (totLen === 0 && !hasExtraData) {
+                self._resetUpload();
+                self._showUploadError(self.msgUploadEmpty);
                 return;
             }
             self._resetUpload();
@@ -3346,6 +3354,7 @@
         },
         msgUploadAborted: 'The file upload was aborted',
         msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Validation Error',
         msgLoading: 'Loading file {index} of {files} &hellip;',
         msgProgress: 'Loading file {index} of {files} - {name} - {percent}% completed.',

File diff suppressed because it is too large
+ 0 - 0
js/fileinput.min.js


+ 2 - 1
js/locales/LANG.js

@@ -48,7 +48,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'The file upload was aborted',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Validation Error',
         msgLoading: 'Loading file {index} of {files} &hellip;',
         msgProgress: 'Loading file {index} of {files} - {name} - {percent}% completed.',

+ 2 - 1
js/locales/ar.js

@@ -49,7 +49,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'تم إلغاء رفع الملف',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'خطأ التحقق من صحة',
         msgLoading: 'تحميل ملف {index} من {files} &hellip;',
         msgProgress: 'تحميل ملف {index} من {files} - {name} - {percent}% منتهي.',

+ 2 - 1
js/locales/bg.js

@@ -48,7 +48,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'Качите файла, бе прекратена',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'утвърждаване грешка',
         msgLoading: 'Зареждане на файл {index} от общо {files} &hellip;',
         msgProgress: 'Зареждане на файл {index} от общо {files} - {name} - {percent}% завършени.',

+ 2 - 1
js/locales/ca.js

@@ -48,7 +48,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'La càrrega d\'arxius s\'ha cancel·lat',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Error de validació',
         msgLoading: 'Pujant fitxer {index} de {files} &hellip;',
         msgProgress: 'Pujant fitxer {index} de {files} - {name} - {percent}% completat.',

+ 2 - 1
js/locales/cr.js

@@ -49,7 +49,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'Prijenos datoteka je prekinut',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Provjera pogrešaka',
         msgLoading: 'Učitavanje datoteke {index} od {files} &hellip;',
         msgProgress: 'Učitavanje datoteke {index} od {files} - {name} - {percent}% završeno.',

+ 2 - 1
js/locales/cz.js

@@ -48,7 +48,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'Soubor nahrávání byl přerušen',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Chyba ověření',
         msgLoading: 'Nahrávání souboru {index} z {files} &hellip;',
         msgProgress: 'Nahrávání souboru {index} z {files} - {name} - {percent}% dokončeno.',

+ 2 - 1
js/locales/da.js

@@ -48,7 +48,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'Filupload annulleret',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Validering Fejl',
         msgLoading: 'Henter fil {index} af {files} &hellip;',
         msgProgress: 'Henter fil {index} af {files} - {name} - {percent}% f&aelig;rdiggjort.',

+ 2 - 1
js/locales/de.js

@@ -46,7 +46,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'Der Datei-Upload wurde abgebrochen',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Validierungs fehler',
         msgLoading: 'Lade Datei {index} von {files} hoch&hellip;',
         msgProgress: 'Datei {index} von {files} - {name} - zu {percent}% fertiggestellt.',

+ 2 - 1
js/locales/fa.js

@@ -49,7 +49,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'The file upload was aborted',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'خطای اعتبار سنجی',
         msgLoading: 'بارگیری فایل {index} از {files} &hellip;',
         msgProgress: 'بارگیری فایل {index} از {files} - {name} - {percent}% تمام شد.',

+ 2 - 1
js/locales/fi.js

@@ -34,7 +34,8 @@
         msgInvalidFileName: 'Invalid or unsupported characters in file name "{name}".',
         msgInvalidFileType: 'Tiedosto "{name}" on v&auml;&auml;r&auml;n tyyppinen. Ainoastaan tiedostot tyyppi&auml; "{types}" ovat tuettuja.',
         msgInvalidFileExtension: 'Tiedoston "{name}" tarkenne on ep&auml;kelpo. Ainoastaan tarkenteet "{extensions}" ovat tuettuja.',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Tiedoston latausvirhe',
         msgLoading: 'Ladataan tiedostoa {index} / {files} &hellip;',
         msgProgress: 'Ladataan tiedostoa {index} / {files} - {name} - {percent}% valmistunut.',

+ 2 - 1
js/locales/fr.js

@@ -48,7 +48,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'Le téléchargement du fichier a été interrompu',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Erreur de validation',
         msgLoading: 'Transmission du fichier {index} sur {files}&hellip;',
         msgProgress: 'Transmission du fichier {index} sur {files} - {name} - {percent}% faits.',

+ 2 - 1
js/locales/id.js

@@ -49,7 +49,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'Pengunggahan berkas dibatalkan',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Kesalahan validasi',
         msgLoading: 'Memuat {index} dari {files} berkas &hellip;',
         msgProgress: 'Memuat {index} dari {files} berkas - {name} - {percent}% selesai.',

+ 2 - 1
js/locales/it.js

@@ -50,7 +50,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'Il caricamento del file è stata interrotta',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Errore di convalida',
         msgLoading: 'Caricamento file {index} di {files}&hellip;',
         msgProgress: 'Caricamento file {index} di {files} - {name} - {percent}% completato.',

+ 2 - 1
js/locales/ja.js

@@ -55,7 +55,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'ファイルのアップロードが中止されました',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: '検証エラー',
         msgLoading: '{files}個中{index}個目のファイルを読み込み中&hellip;',
         msgProgress: '{files}個中{index}個のファイルを読み込み中 - {name} - {percent}% 完了',

+ 2 - 1
js/locales/nl.js

@@ -48,7 +48,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'Het uploaden van bestanden is afgebroken',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Bevestiging fout',
         msgLoading: 'Bestanden laden {index} van de {files} &hellip;',
         msgProgress: 'Bestanden laden {index} van de {files} - {name} - {percent}% compleet.',

+ 2 - 1
js/locales/pl.js

@@ -48,7 +48,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'Plik przesyłanie zostało przerwane',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Błąd walidacji',
         msgLoading: 'Wczytywanie pliku {index} z {files} &hellip;',
         msgProgress: 'Wczytywanie pliku {index} z {files} - {name} - {percent}% zakończone.',

+ 2 - 1
js/locales/pt.js

@@ -48,7 +48,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'O upload do arquivo foi abortada',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Erro de validação',
         msgLoading: 'A carregar ficheiro {index} de {files} &hellip;',
         msgProgress: 'A carregar ficheiro {index} de {files} - {name} - {percent}% completo.',

+ 2 - 1
js/locales/ro.js

@@ -49,7 +49,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'Fișierul Încărcarea a fost întrerupt',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Eroare de validare',
         msgLoading: 'Se încarcă fișierul {index} din {files} &hellip;',
         msgProgress: 'Se încarcă fișierul {index} din {files} - {name} - {percent}% încărcat.',

+ 2 - 1
js/locales/sk.js

@@ -48,7 +48,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'Súbor nahrávania bol prerušený',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Chyba overenia',
         msgLoading: 'Nahrávanie súboru {index} z {files} &hellip;',
         msgProgress: 'Nahrávanie súboru {index} z {files} - {name} - {percent}% dokončené.',

+ 2 - 1
js/locales/th.js

@@ -48,7 +48,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'อัปโหลดไฟล์ถูกยกเลิก',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'ข้อผิดพลาดในการตรวจสอบ',
         msgLoading: 'กำลังโหลดไฟล์ {index} จาก {files} &hellip;',
         msgProgress: 'กำลังโหลดไฟล์ {index} จาก {files} - {name} - {percent}%',

+ 2 - 1
js/locales/tr.js

@@ -48,7 +48,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'Dosya yükleme iptal edildi',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Doğrulama Hatası',
         msgLoading: 'Dosya yükleniyor {index} / {files} &hellip;',
         msgProgress: 'Dosya yükleniyor {index} / {files} - {name} - %{percent} tamamlandı.',

+ 2 - 1
js/locales/uk.js

@@ -49,7 +49,8 @@
             'object': 'object'
         },
         msgUploadAborted: 'Вивантаження файлу перервана',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: 'Помилка перевірки',
         msgLoading: 'Загрузка файла {index} із {files} &hellip;',
         msgProgress: 'Загрузка файла {index} із {files} - {name} - {percent}% завершено.',

+ 2 - 1
js/locales/zh-TW.js

@@ -50,7 +50,8 @@
             'object': 'object'
         },
         msgUploadAborted: '該文件上傳被中止',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: '驗證錯誤',
         msgLoading: '載入第 {index} 個檔案,共 {files} &hellip;',
         msgProgress: '載入第 {index} 個檔案,共 {files} - {name} - {percent}% 成功.',

+ 2 - 1
js/locales/zh.js

@@ -49,7 +49,8 @@
             'object': 'object'
         },
         msgUploadAborted: '该文件上传被中止',
-        msgUploadThreshold: 'Processing...',
+        msgUploadThreshold: 'Processing...',
+        msgUploadEmpty: 'No valid data available for upload.',
         msgValidationError: '验证错误',
         msgLoading: '加载第 {index} 文件 共 {files} &hellip;',
         msgProgress: '加载第 {index} 文件 共 {files} - {name} - {percent}% 完成.',

Some files were not shown because too many files changed in this diff