Skip to content

Commit

Permalink
Merge pull request #2391 from jhawthorn/simplify_image_new
Browse files Browse the repository at this point in the history
Simplify "inline" new image form
  • Loading branch information
jhawthorn committed Nov 23, 2017
2 parents 57abb6c + 8fa3f8c commit b584209
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 26 deletions.
8 changes: 8 additions & 0 deletions backend/app/assets/javascripts/spree/backend/images/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Spree.ready(function() {
$('#new_image_link').click(function(event) {
event.preventDefault();

$(this).hide();
$('#new_image').show();
});
});

This file was deleted.

12 changes: 12 additions & 0 deletions backend/app/views/spree/admin/images/_new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%= form_for [:admin, product, image], html: { multipart: true } do |f| %>
<fieldset data-hook="new_image">
<legend align="center"><%= t('spree.new_image') %></legend>

<%= render partial: 'form', locals: { f: f } %>

<div class="form-buttons filter-actions actions" data-hook="buttons">
<%= button t('spree.actions.update') %>
<%= link_to t('spree.actions.cancel'), admin_product_images_url(@product), id: 'cancel_link', class: 'button' %>
</div>
</fieldset>
<% end %>
4 changes: 3 additions & 1 deletion backend/app/views/spree/admin/images/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
<% end %>
<% end %>

<div id="images" data-hook></div>
<div id="new_image" class="hidden">
<%= render 'new', product: @product, image: Spree::Image.new(viewable: @product) %>
</div>

<fieldset>
<legend align="center"><%= t(".upload_images") %></legend>
Expand Down
13 changes: 1 addition & 12 deletions backend/app/views/spree/admin/images/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
<%= form_for [:admin, @product, @image], html: { multipart: true } do |f| %>
<fieldset data-hook="new_image">
<legend align="center"><%= t('spree.new_image') %></legend>

<%= render partial: 'form', locals: { f: f } %>

<div class="form-buttons filter-actions actions" data-hook="buttons">
<%= button t('spree.actions.update') %>
<%= link_to t('spree.actions.cancel'), admin_product_images_url(@product), id: 'cancel_link', class: 'button' %>
</div>
</fieldset>
<% end %>
<%= render 'new', product: @product, image: @image %>

0 comments on commit b584209

Please sign in to comment.