From 8b9e8f0229a21828547c75a4ff5ee1c2b223afe2 Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Fri, 31 Mar 2017 22:05:57 +0100 Subject: [PATCH] #9: Single-file album upload is now working with Bootstrap v4 --- resources/assets/js/albums.js | 16 ++-- .../themes/base/admin/show_album.blade.php | 12 ++- .../base/partials/album_upload_tab.blade.php | 95 ++++++++++--------- 3 files changed, 70 insertions(+), 53 deletions(-) diff --git a/resources/assets/js/albums.js b/resources/assets/js/albums.js index d0e191e..060c74e 100644 --- a/resources/assets/js/albums.js +++ b/resources/assets/js/albums.js @@ -19,18 +19,18 @@ function UploadPhotosViewModel(album_id, queue_token, language, urls) { this.computed = { // a computed getter failedPercentage: function () { - return ((this.imagesFailed() / this.imagesTotal()) * 100).toFixed(2) + '%'; + return ((this.imagesFailed / this.imagesTotal) * 100).toFixed(2) + '%'; }, successfulPercentage: function () { - return ((self.imagesUploaded() / self.imagesTotal()) * 100).toFixed(2) + '%'; + return ((self.imagesUploaded / self.imagesTotal) * 100).toFixed(2) + '%'; } }; this.methods = { // This method is called when an image is uploaded - regardless if it fails or not onUploadCompleted: function () { this.currentStatus = language.upload_status - .replace(':current', (self.imagesUploaded + self.imagesFailed)) - .replace(':total', self.imagesTotal); + .replace(':current', (this.imagesUploaded + this.imagesFailed)) + .replace(':total', this.imagesTotal); if ((this.imagesFailed + this.imagesUploaded) >= this.imagesTotal) { this.isUploadInProgress = false; @@ -52,16 +52,16 @@ function UploadPhotosViewModel(album_id, queue_token, language, urls) { // This method is called when an uploaded image succeeds onUploadSuccessful: function (data, file_name) { if (data.is_successful) { - self.imagesUploaded++; + this.imagesUploaded++; // Don't add to statusMessages() array so user only sees errors /*self.statusMessages.push({ 'message_class': 'text-success', 'message_text': language.image_uploaded.replace(':file_name', file_name) });*/ - self.onUploadCompleted(); + this.onUploadCompleted(); } else { - self.onUploadFailed(data, file_name); + this.onUploadFailed(data, file_name); } }, uploadFile: function uploadImageFile(formObject, imageFile) { @@ -116,7 +116,7 @@ function UploadPhotosViewModel(album_id, queue_token, language, urls) { } // Upload the file - this.uploadFile($(this), file); + this.uploadFile(event.target, file); } // Prevent standard form upload diff --git a/resources/views/themes/base/admin/show_album.blade.php b/resources/views/themes/base/admin/show_album.blade.php index 8130fd1..74a539b 100644 --- a/resources/views/themes/base/admin/show_album.blade.php +++ b/resources/views/themes/base/admin/show_album.blade.php @@ -12,7 +12,7 @@
- @lang('admin.open_album') + @lang('admin.open_album')

{{ $album->name }}

{{ $album->description }}

@@ -361,6 +361,16 @@ //ko.applyBindings(editViewModel, document.getElementById('photos-tab')); //ko.applyBindings(viewModel, document.getElementById('upload-tab')); var appUpload = new Vue(viewModel); + appUpload.$watch('isUploadInProgress', function(value) { + if (value) + { + $('#upload-progress-modal').modal('show'); + } + else if (this.statusMessages.length == 0) + { + $('#upload-progress-modal').modal('hide'); + } + }); }) @endpush \ No newline at end of file diff --git a/resources/views/themes/base/partials/album_upload_tab.blade.php b/resources/views/themes/base/partials/album_upload_tab.blade.php index e39335f..b9e92a2 100644 --- a/resources/views/themes/base/partials/album_upload_tab.blade.php +++ b/resources/views/themes/base/partials/album_upload_tab.blade.php @@ -16,54 +16,23 @@ ])
-
-
-
- {{ csrf_field() }} - - +
+ + {{ csrf_field() }} + + -
- -
- -
- -
- -
- -
-
-

@lang('admin.is_uploading')

-
-
- -
-
- -
-
-

+
+
-
-

- @lang('admin.upload_file_number_failed') -

-

- @lang('admin.upload_file_failed_continue')

- @lang('forms.continue_action') -

- -
    -
  • -
+
+
-
+

@@ -92,4 +61,42 @@
@endif + + {{-- Single-file upload progress modal --}} +
\ No newline at end of file