Convert images views from erb to haml

This commit is contained in:
luisramos0
2019-10-15 00:18:32 +01:00
parent ec3c3aa644
commit 04bf5a8742
9 changed files with 92 additions and 121 deletions

View File

@@ -1,18 +0,0 @@
<div data-hook="admin_image_form_fields">
<div class="four columns alpha">
<div data-hook="file" class="field">
<%= f.label Spree.t(:filename) %><br>
<%= f.file_field :attachment %>
</div>
<div data-hook="variant" class="field">
<%= f.label Spree::Variant.model_name.human %><br>
<%= f.select :viewable_id, @variants, {}, {:class => 'select2 fullwidth'} %>
</div>
</div>
<div data-hook="alt_text" class="field omega five columns">
<%= f.label Spree.t(:alt_text) %><br>
<%= f.text_area :alt, :rows => 4, :class => 'fullwidth' %>
</div>
</div>
<div class="clear"></div>

View File

@@ -0,0 +1,16 @@
%div
.four.columns.alpha
.field
= f.label t('spree.filename')
%br/
= f.file_field :attachment
.field
= f.label Spree::Variant.model_name.human
%br/
= f.select :viewable_id, @variants, {}, {class: 'select2 fullwidth'}
.field.omega.five.columns
= f.label t('spree.alt_text')
%br/
= f.text_area :alt, rows: 4, class: 'fullwidth'
.clear

View File

@@ -1,28 +0,0 @@
<%= render :partial => 'spree/admin/shared/product_sub_menu' %>
<%= render :partial => 'spree/admin/shared/product_tabs', :locals => { :current => 'Images' } %>
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @image } %>
<% content_for :page_actions do %>
<li><%= button_link_to Spree.t(:back_to_images_list), admin_product_images_url(@product), :icon => 'icon-arrow-left' %></li>
<% end %>
<%= form_for [:admin, @product, @image], :html => { :multipart => true } do |f| %>
<fieldset data-hook="edit_image">
<legend align="center"><%= @image.attachment_file_name%></legend>
<div data-hook="thumbnail" class="field alpha three columns align-center">
<%= f.label Spree.t(:thumbnail) %><br>
<%= link_to image_tag(@image.attachment.url(:small)), @image.attachment.url(:product) %>
</div>
<div class="nine columns omega">
<%= render :partial => 'form', :locals => { :f => f } %>
</div>
<div class="clear"></div>
<div class="form-buttons filter-actions actions" data-hook="buttons">
<%= button Spree.t('actions.update'), 'icon-refresh' %>
<span class="or"><%= Spree.t(:or) %></span>
<%= link_to Spree.t('actions.cancel'), admin_product_images_url(@product), :id => 'cancel_link', :class => 'button icon-remove' %>
</div>
</fieldset>
<% end %>

View File

@@ -0,0 +1,21 @@
= render partial: 'spree/admin/shared/product_sub_menu'
= render partial: 'spree/admin/shared/product_tabs', locals: { current: 'Images' }
= render partial: 'spree/shared/error_messages', locals: { target: @image }
- content_for :page_actions do
%li= button_link_to t('spree.back_to_images_list'), admin_product_images_url(@product), icon: 'icon-arrow-left'
= form_for [:admin, @product, @image], html: { multipart: true } do |f|
%fieldset
%legend{align: "center"}= @image.attachment_file_name
.field.alpha.three.columns.align-center
= f.label t('spree.thumbnail')
%br/
= link_to image_tag(@image.attachment.url(:small)), @image.attachment.url(:product)
.nine.columns.omega
= render partial: 'form', locals: { f: f }
.clear
.form-buttons.filter-actions.actions
= button t('spree.actions.update'), 'icon-refresh'
%span.or= t('spree.or')
= link_to t('spree.actions.cancel'), admin_product_images_url(@product), id: 'cancel_link', class: 'button icon-remove'

View File

@@ -1,58 +0,0 @@
<%= render :partial => 'spree/admin/shared/product_sub_menu' %>
<%= render :partial => 'spree/admin/shared/product_tabs', :locals => {:current => 'Images'} %>
<% content_for :page_actions do %>
<li><%= link_to_with_icon('icon-plus', Spree.t(:new_image), new_admin_product_image_url(@product), :id => 'new_image_link', :class => 'button') %></li>
<% end %>
<div id="images" data-hook></div>
<% unless @product.images.any? || @product.variant_images.any? %>
<div class="no-objects-found">
<%= Spree.t(:no_images_found) %>.
</div>
<% else %>
<table class="index sortable" data-hook="images_table" data-sortable-link="<%= update_positions_admin_product_images_url(@product) %>">
<colgroup>
<col style="width: 5%">
<col style="width: 10%">
<% if @product.has_variants? %>
<col style="width: 25%">
<% end %>
<col style="width: 45%">
<col style="width: 15%">
</colgroup>
<thead>
<tr data-hook="images_header">
<th colspan="2"><%= Spree.t(:thumbnail) %></th>
<% if @product.has_variants? %>
<th><%= Spree::Variant.model_name.human %></th>
<% end %>
<th><%= Spree.t(:alt_text) %></th>
<th class="actions"></th>
</tr>
</thead>
<tbody>
<% (@product.variant_images).each do |image| %>
<tr id="<%= spree_dom_id image %>" data-hook="images_row" class="<%= cycle('odd', 'even')%>">
<td class="no-border">
<span class="handle"></span>
</td>
<td>
<%= link_to image_tag(image.attachment.url(:mini)), image.attachment.url(:product) %>
</td>
<% if @product.has_variants? %>
<td><%= options_text_for(image) %></td>
<% end %>
<td><%= image.alt %></td>
<td class="actions">
<%= link_to_with_icon 'icon-edit', Spree.t(:edit), edit_admin_product_image_url(@product, image), :no_text => true, :data => {:action => 'edit'} %>
<%= link_to_delete image, { :url => admin_product_image_url(@product, image), :no_text => true } %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>

View File

@@ -0,0 +1,43 @@
= render partial: 'spree/admin/shared/product_sub_menu'
= render partial: 'spree/admin/shared/product_tabs', locals: { current: 'Images'}
- content_for :page_actions do
%li= link_to_with_icon('icon-plus', t('spree.new_image'), new_admin_product_image_url(@product), id: 'new_image_link', class: 'button')
#images
- unless @product.images.any? || @product.variant_images.any?
.no-objects-found
= t('spree.no_images_found')
\.
- else
%table.index.sortable{ "data-sortable-link" => "#{update_positions_admin_product_images_url(@product)}" }
%colgroup
%col{ style: "width: 5%" }/
%col{ style: "width: 10%" }/
- if @product.has_variants?
%col{ style: "width: 25%" }/
%col{ style: "width: 45%" }/
%col{ style: "width: 15%" }/
%thead
%tr
%th{:colspan => "2"}= t('spree.thumbnail')
- if @product.has_variants?
%th= Spree::Variant.model_name.human
%th= t('spree.alt_text')
%th.actions
%tbody
- (@product.variant_images).each do |image|
- tr_class = cycle('odd', 'even')
- tr_id = spree_dom_id(image)
%tr{class: tr_class, id: tr_id }
%td.no-border
%span.handle
%td
= link_to image_tag(image.attachment.url(:mini)), image.attachment.url(:product)
- if @product.has_variants?
%td= options_text_for(image)
%td= image.alt
%td.actions
= link_to_with_icon 'icon-edit', t('spree.edit'), edit_admin_product_image_url(@product, image), no_text: true, data: { action: 'edit'}
= link_to_delete image, { url: admin_product_image_url(@product, image), no_text: true }

View File

@@ -1,15 +0,0 @@
<%= form_for [:admin, @product, @image], :html => { :multipart => true } do |f| %>
<fieldset data-hook="new_image">
<legend align="center"><%= Spree.t(:new_image) %></legend>
<%= render :partial => 'form', :locals => { :f => f } %>
<div class="form-buttons filter-actions actions" data-hook="buttons">
<%= button Spree.t('actions.update'), 'icon-refresh' %>
<span class="or"><%= Spree.t(:or) %></span>
<%= link_to_with_icon 'icon-remove', Spree.t('actions.cancel'), admin_product_images_url(@product), :id => 'cancel_link', :class => 'button' %>
</div>
</fieldset>
<% end %>
<%= javascript_include_tag 'admin/images/new.js' %>

View File

@@ -0,0 +1,10 @@
= form_for [:admin, @product, @image], html: { multipart: true } do |f|
%fieldset
%legend{ align: "center" }= t('spree.new_image')
= render partial: 'form', locals: { f: f }
.form-buttons.filter-actions.actions
= button t('spree.actions.update'), 'icon-refresh'
%span.or= t('spree.or')
= link_to_with_icon 'icon-remove', t('spree.actions.cancel'), admin_product_images_url(@product), id: 'cancel_link', class: 'button'
= javascript_include_tag 'admin/images/new.js'

View File

@@ -209,14 +209,14 @@ feature '
Spree::Image.create(viewable_id: product.master.id, viewable_type: 'Spree::Variant', alt: "position 1", attachment: image, position: 1)
visit spree.admin_product_images_path(product)
expect(page).to have_selector "table[data-hook='images_table'] td img"
expect(page).to have_selector "table.index td img"
expect(product.reload.images.count).to eq 1
accept_alert do
page.find('a.delete-resource').click
end
expect(page).to_not have_selector "table[data-hook='images_table'] td img"
expect(page).to_not have_selector "table.index td img"
expect(product.reload.images.count).to eq 0
end
end