From 0b5f158dd0a6dd4bad8901216973369348606ba7 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Sun, 30 Oct 2016 13:02:41 +0100 Subject: [PATCH] Upload page fixed for multi-uploads. Beautification. --- app/controllers/packages_controller.rb | 2 +- app/views/packages/upload.slim | 51 ++++++++++++++------------ 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/app/controllers/packages_controller.rb b/app/controllers/packages_controller.rb index 36e8f89..3455a60 100644 --- a/app/controllers/packages_controller.rb +++ b/app/controllers/packages_controller.rb @@ -33,7 +33,7 @@ class PackagesController < ApplicationController successful_upload_count = 0 - params[:screenshot][:image].each do |img| + params[:file].each do |img| new_screenshot = @package.screenshots.new(image: img) # Check if the image was valid diff --git a/app/views/packages/upload.slim b/app/views/packages/upload.slim index 44e56d8..b490ef6 100644 --- a/app/views/packages/upload.slim +++ b/app/views/packages/upload.slim @@ -7,35 +7,38 @@ p ' You are about to upload a screenshot for the #{@package.name} ' package. Thanks for your contribution. - - if @package.screenshots.any? - p + + = form_tag(upload_image_path, multipart: true) + + .row + .small-6.columns + input.hidden-inputfile type="file" name="file[]" id="file" multiple=true + label for="file" + a.button id="file-select-button" + = fa_stacked_icon "image", base: "circle-thin" + span id="file-label" + ' Select screenshot file(s) + + .small-6.columns + button.button type="submit" id="file-submit" + = fa_stacked_icon "upload", base: "circle-thin" + ' Start upload + + p + - if @package.screenshots.any? ' Just for your information - these screenshots have already been uploaded. - .small-up-1.medium-up-3.large-up-4.grid-thumbnails - - @package.screenshots.all.each do |ss| - a.black.fancybox href=ss.image.url(:large, timestamp: false) rel='fancybox-thumb' title=ss.caption - = image_tag(ss.image.url(:thumb, timestamp: false), alt: ss.caption, class: 'thumbnail') + .small-up-1.medium-up-3.large-up-4.grid-thumbnails + - @package.screenshots.all.each do |ss| + a.black.fancybox href=ss.image.url(:large, timestamp: false) rel='fancybox-thumb' title=ss.caption + = image_tag(ss.image.url(:thumb, timestamp: false), alt: ss.caption, class: 'thumbnail') - // = render partial: 'packages/grid_thumbnail', locals: { pkg: pkg } + // = render partial: 'packages/grid_thumbnail', locals: { pkg: pkg } - - else - ' There are no screenshots yet for #{@package.name}. + - else + ' There are no screenshots yet for #{@package.name}. Your upload will + ' be the first. - = form_tag(upload_image_path, multipart: true) - - .row - .small-6.columns - input.hidden-inputfile type="file" name="file" id="file" multiple=true - label for="file" - a.button id="file-select-button" - = fa_stacked_icon "image", base: "circle-thin" - span id="file-label" - ' Select screenshot files - - .small-6.columns - button.button type="submit" id="file-submit" - = fa_stacked_icon "upload", base: "circle-thin" - ' Start upload .small-5.columns.bigpanel