Convert spree/admin/taxonomies from erb to haml

This commit is contained in:
luisramos0
2019-09-17 17:18:25 +01:00
parent 2ce56aef2c
commit 2a68d34fb0
13 changed files with 95 additions and 128 deletions

View File

@@ -1,7 +0,0 @@
<div data-hook="admin_inside_taxonomy_form" class="field align-center">
<%= f.field_container :name do %>
<%= f.label :name, Spree.t(:name) %> <span class="required">*</span><br />
<%= error_message_on :taxonomy, :name, :class => 'fullwidth title' %>
<%= text_field :taxonomy, :name %>
<% end %>
</div>

View File

@@ -0,0 +1,7 @@
.field.align-center
= f.field_container :name do
= f.label :name, t("spree.name")
%span.required *
%br/
= error_message_on :taxonomy, :name, class: 'fullwidth title'
= text_field :taxonomy, :name

View File

@@ -1,9 +1,9 @@
<% content_for :head do %>
<%= javascript_tag "var taxonomy_id = #{@taxonomy.id};
var loading = '#{escape_javascript Spree.t(:loading)}';
var new_taxon = '#{escape_javascript Spree.t(:new_taxon)}';
var server_error = '#{escape_javascript Spree.t(:server_error)}';
var taxonomy_tree_error = '#{escape_javascript Spree.t(:taxonomy_tree_error)}';
var loading = '#{escape_javascript t("spree.loading")}';
var new_taxon = '#{escape_javascript t("spree.new_taxon")}';
var server_error = '#{escape_javascript t("spree.server_error")}';
var taxonomy_tree_error = '#{escape_javascript t("spree.taxonomy_tree_error")}';
$(document).ready(function(){
setup_taxonomy_tree(taxonomy_id);

View File

@@ -1,26 +0,0 @@
<table class="index sortable" id='listing_taxonomies' data-hook data-sortable-link="<%= update_positions_admin_taxonomies_url %>">
<colgroup>
<col style="width: 85%">
<col style="width: 15%">
</colgroup>
<thead>
<tr data-hook="taxonomies_header">
<th><%= Spree.t(:name) %></th>
<th class="actions"></th>
</tr>
</thead>
<tbody>
<% @taxonomies.each do |taxonomy| %>
<tr id="<%= spree_dom_id taxonomy %>" data-hook="taxonomies_row" class="<%= cycle('odd', 'even')%>">
<td>
<span class="handle"></span>
<%= taxonomy.name %>
</td>
<td class="actions">
<%= link_to_edit taxonomy.id, :no_text => true %>
<%= link_to_delete taxonomy, :no_text => true %>
</td>
</tr>
<% end %>
</tbody>
</table>

View File

@@ -0,0 +1,19 @@
%table#listing_taxonomies.index.sortable{"data-sortable-link" => update_positions_admin_taxonomies_url}
%colgroup
%col{style: "width: 85%"}/
%col{style: "width: 15%"}/
%thead
%tr
%th= t("spree.name")
%th.actions
%tbody
- @taxonomies.each do |taxonomy|
- tr_class = cycle('odd', 'even')
- tr_id = spree_dom_id(taxonomy)
%tr{class: tr_class, id: tr_id}
%td
%span.handle
= taxonomy.name
%td.actions
= link_to_edit taxonomy.id, no_text: true
= link_to_delete taxonomy, no_text: true

View File

@@ -1,12 +0,0 @@
<% if taxon.children.length != 0 %>
<ul>
<% taxon.children.each do |child| %>
<li id="<%= child.id %>" rel="taxon">
<a style="background-image: url(<%= child.icon.url %>);" href="#"><%= child.name %></a>
<% if child.children.length > 0 %>
<%= render :partial => 'taxon', :locals => { :taxon => child } %>
<% end %>
</li>
<% end %>
</ul>
<% end %>

View File

@@ -0,0 +1,7 @@
- if taxon.children.length != 0
%ul
- taxon.children.each do |child|
%li{id: "#{child.id}", rel: "taxon"}
%a{href: "#", style: "background-image: url(#{child.icon.url});"}= child.name
- if child.children.length > 0
= render partial: 'taxon', locals: { taxon: child }

View File

@@ -1,42 +0,0 @@
<%= render :partial => 'spree/admin/shared/configuration_menu' %>
<%= render :partial => 'js_head' %>
<% content_for :page_title do %>
<%= Spree.t(:taxonomy_edit) %>
<% end %>
<% content_for :page_actions do %>
<li>
<%= button_link_to Spree.t(:back_to_taxonomies_list), spree.admin_taxonomies_path, :icon => 'icon-arrow-left' %>
</li>
<% end %>
<div id="ajax_error" class="errorExplanation" style="display:none;"></div>
<%= form_for [:admin, @taxonomy] do |f| %>
<fieldset class="no-border-top">
<%= render :partial => 'form', :locals => { :f => f } %>
<div>
<%= label_tag nil, Spree.t(:tree) %><br />
<script>
Spree.routes.taxonomy_taxons_path = "<%= spree.api_taxonomy_taxons_path(@taxonomy) %>";
Spree.routes.admin_taxonomy_taxons_path = "<%= spree.admin_taxonomy_taxons_path(@taxonomy) %>";
</script>
<div id="taxonomy_tree" class="tree"></div>
</div>
<div id="progress" style="display:none;">
<%= image_tag 'select2-spinner.gif', :title => 'Spinner', :style => "vertical-align:bottom;" %> <%= Spree.t(:updating) %>..
</div>
<div class="info"><%= Spree.t(:taxonomy_tree_instruction) %></div>
<br>
<div class="filter-actions actions">
<%= button Spree.t('actions.update'), 'icon-refresh' %>
<span class="or"><%= Spree.t(:or) %></span>
<%= button_link_to Spree.t('actions.cancel'), admin_taxonomies_path, :icon => 'icon-remove' %>
</div>
</fieldset>
<% end %>

View File

@@ -0,0 +1,32 @@
= render partial: 'spree/admin/shared/configuration_menu'
= render partial: 'js_head'
- content_for :page_title do
= t("spree.taxonomy_edit")
- content_for :page_actions do
%li
= button_link_to t("spree.back_to_taxonomies_list"), spree.admin_taxonomies_path, icon: 'icon-arrow-left'
#ajax_error.errorExplanation{style: "display:none;"}
= form_for [:admin, @taxonomy] do |f|
%fieldset.no-border-top
= render partial: 'form', locals: { f: f }
%div
= label_tag nil, t("spree.tree")
%br/
:javascript
Spree.routes.taxonomy_taxons_path = "#{spree.api_taxonomy_taxons_path(@taxonomy)}";
Spree.routes.admin_taxonomy_taxons_path = "#{spree.admin_taxonomy_taxons_path(@taxonomy)}";
#taxonomy_tree.tree
#progress{style: "display:none;"}
= image_tag 'select2-spinner.gif', title: 'Spinner', style: "vertical-align:bottom;"
= t("spree.updating")
\..
.info= t("spree.taxonomy_tree_instruction")
%br/
.filter-actions.actions
= button t('spree.actions.update'), 'icon-refresh'
%span.or= t("spree.or")
= button_link_to t('spree.actions.cancel'), admin_taxonomies_path, icon: 'icon-remove'

View File

@@ -1,15 +0,0 @@
<%= render :partial => 'spree/admin/shared/configuration_menu' %>
<% content_for :page_title do %>
<%= Spree.t(:taxonomies) %>
<% end %>
<% content_for :page_actions do %>
<li>
<%= button_link_to Spree.t(:new_taxonomy), spree.new_admin_taxonomy_url, :icon => 'icon-plus', :id => 'admin_new_taxonomy_link' %></p>
</li>
<% end %>
<div id='list-taxonomies' data-hook>
<%= render :partial => 'list' %>
</div>

View File

@@ -0,0 +1,11 @@
= render partial: 'spree/admin/shared/configuration_menu'
- content_for :page_title do
= t("spree.taxonomies")
- content_for :page_actions do
%li
= button_link_to t("spree.new_taxonomy"), spree.new_admin_taxonomy_url, icon: 'icon-plus', id: 'admin_new_taxonomy_link'
#list-taxonomies
= render partial: 'list'

View File

@@ -1,22 +0,0 @@
<%= render :partial => 'spree/admin/shared/configuration_menu' %>
<% content_for :page_title do %>
<%= Spree.t(:new_taxonomy) %>
<% end %>
<% content_for :page_actions do %>
<li>
<%= button_link_to Spree.t(:back_to_taxonomies_list), spree.admin_taxonomies_path, :icon => 'icon-arrow-left' %>
</li>
<% end %>
<%= form_for [:admin, @taxonomy] do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<fieldset class="no-border-top">
<br>
<div class="filter-actions actions" data-hook="buttons">
<%= button Spree.t(:create), 'icon-ok' %>
</div>
</fieldset>
<% end %>

View File

@@ -0,0 +1,15 @@
= render partial: 'spree/admin/shared/configuration_menu'
- content_for :page_title do
= t("spree.new_taxonomy")
- content_for :page_actions do
%li
= button_link_to t("spree.back_to_taxonomies_list"), spree.admin_taxonomies_path, icon: 'icon-arrow-left'
= form_for [:admin, @taxonomy] do |f|
= render partial: 'form', locals: { f: f }
%fieldset.no-border-top
%br/
.filter-actions.actions
= button t("spree.create"), 'icon-ok'