mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Convert spree/admin/taxonomies from erb to haml
This commit is contained in:
@@ -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>
|
||||
7
app/views/spree/admin/taxonomies/_form.html.haml
Normal file
7
app/views/spree/admin/taxonomies/_form.html.haml
Normal 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
|
||||
@@ -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);
|
||||
|
||||
@@ -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>
|
||||
19
app/views/spree/admin/taxonomies/_list.html.haml
Normal file
19
app/views/spree/admin/taxonomies/_list.html.haml
Normal 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
|
||||
@@ -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 %>
|
||||
7
app/views/spree/admin/taxonomies/_taxon.html.haml
Normal file
7
app/views/spree/admin/taxonomies/_taxon.html.haml
Normal 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 }
|
||||
@@ -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 %>
|
||||
32
app/views/spree/admin/taxonomies/edit.haml
Executable file
32
app/views/spree/admin/taxonomies/edit.haml
Executable 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'
|
||||
@@ -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>
|
||||
11
app/views/spree/admin/taxonomies/index.html.haml
Normal file
11
app/views/spree/admin/taxonomies/index.html.haml
Normal 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'
|
||||
@@ -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 %>
|
||||
15
app/views/spree/admin/taxonomies/new.html.haml
Normal file
15
app/views/spree/admin/taxonomies/new.html.haml
Normal 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'
|
||||
Reference in New Issue
Block a user