-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎁 Allow admins to upload multiple banners
This commit allows the admin to upload multiple banners to the homepage through the dashboard. The homepage will randomly select a banner and then cycle through the uploaded banners. We introduce a new uploader, `Hyku::UploadedFileUploader`, to handle the multiple file uploads and change the concept of banner_image to banner_images. Ref: - #657
- Loading branch information
Showing
13 changed files
with
86 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
module Hyku | ||
class UploadedFileUploader < Hyrax::UploadedFileUploader | ||
end | ||
end |
26 changes: 19 additions & 7 deletions
26
app/views/hyrax/admin/appearances/_banner_image_form.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,31 @@ | ||
<%= simple_form_for @form, url: admin_appearance_path do |f| %> | ||
<div class="panel-body"> | ||
<% require_image = @form.banner_image? ? false : true %> | ||
<%# Upload Banner Image %> | ||
<%= f.input :banner_image, as: :file, wrapper: :vertical_file_input, required: require_image, hint: t('hyrax.admin.appearances.show.forms.banner_image.hint') %> | ||
<% require_image = @form.banner_images.any? ? false : true %> | ||
<%# Upload Banner Images %> | ||
<%= f.input :banner_images, | ||
as: :file, | ||
wrapper: :vertical_file_input, | ||
required: require_image, | ||
hint: t('hyrax.admin.appearances.show.forms.banner_image.hint'), | ||
input_html: { multiple: true, accept: 'image/*' } %> | ||
<%= f.input :banner_image_text, required: true, as: :text, label: 'Banner image alt text' %> | ||
<%= image_tag @form.banner_image.url, class: "img-responsive" if @form.banner_image? %> | ||
<% if @form.banner_images.any? %> | ||
<% @form.banner_images.each do |banner_image| %> | ||
<div class="panel-footer"> | ||
<%= image_tag banner_image.url, class: "img-responsive" %> <br> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
<div class="panel-footer"> | ||
<%= f.submit class: 'btn btn-primary pull-right' %> | ||
</div> | ||
<% end %> | ||
<% if @form.banner_image? %> | ||
<% if @form.banner_images.any? %> | ||
<div class="panel-footer"> | ||
<%= simple_form_for @form.site, url: main_app.site_path(@form.site) do |f| %> | ||
<%= f.submit 'Remove banner image', class: 'btn btn-danger', name: :remove_banner_image %> | ||
<%= f.submit 'Remove all banner images', class: 'btn btn-danger', name: :remove_banner_images %> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters