-
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. Ref: - #657
- Loading branch information
Showing
6 changed files
with
60 additions
and
21 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
32 changes: 21 additions & 11 deletions
32
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,29 @@ | ||
<%= 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? %> | ||
</div> | ||
<div class="panel-footer"> | ||
<%= f.submit class: 'btn btn-primary pull-right' %> | ||
</div> | ||
<% end %> | ||
<% if @form.banner_image? %> | ||
<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 %> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
<% if @form.banner_images.any? %> | ||
<% @form.banner_images.each_with_index do |banner_image, index| %> | ||
<div class="panel-footer"> | ||
<%= simple_form_for @form.site, url: main_app.site_path(@form.site), method: :patch do |f| %> | ||
<%= image_tag banner_image.url, class: "img-responsive" %> <br> | ||
<%# TODO: fix remove %> | ||
<%# <%= hidden_field_tag 'site[remove_banner_image_index]', index %> | ||
<%# <%= f.submit 'Remove banner image', class: 'btn btn-danger' %> | ||
<% 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