Convert spree/admin/states from erb to haml

This commit is contained in:
luisramos0
2019-09-17 16:53:10 +01:00
parent e1c3d2442a
commit bd2045cad7
10 changed files with 77 additions and 104 deletions

View File

@@ -1,14 +0,0 @@
<div data-hook="admin_state_form_fields" class="row">
<div class="alpha six columns">
<%= f.field_container :name do %>
<%= f.label :name, Spree.t(:name) %>
<%= f.text_field :name, :class => 'fullwidth' %>
<% end %>
</div>
<div class="omega six columns">
<%= f.field_container :abbr do %>
<%= f.label :abbr, Spree.t(:abbreviation) %>
<%= f.text_field :abbr, :class => 'fullwidth' %>
<% end %>
</div>
</div>

View File

@@ -0,0 +1,9 @@
.row
.alpha.six.columns
= f.field_container :name do
= f.label :name, t("spree.name")
= f.text_field :name, class: 'fullwidth'
.omega.six.columns
= f.field_container :abbr do
= f.label :abbr, t("spree.abbreviation")
= f.text_field :abbr, class: 'fullwidth'

View File

@@ -1,31 +0,0 @@
<div id="new_state" data-hook></div>
<table class="index" id='listing_states' data-hook>
<colgroup>
<col style="width: 70%" />
<col style="width: 15%" />
<col style="width: 15%" />
</colgroup>
<thead>
<tr data-hook="states_header">
<th><%= Spree.t(:name) %></th>
<th><%= Spree.t(:abbreviation) %></th>
<th class="actions"></th>
</tr>
</thead>
<tbody>
<% @states.each do |state| %>
<tr id="<%= spree_dom_id state %>" data-hook="states_row" class="<%= cycle('odd', 'even')%>">
<td><%= state.name %></td>
<td class="align-center"><%= state.abbr %></td>
<td class="actions">
<%= link_to_with_icon 'icon-edit', Spree.t(:edit), edit_admin_country_state_url(@country, state), :no_text => true %>
<%= link_to_delete state, :no_text => true %>
</td>
</tr>
<% end %>
<% if @states.empty? %>
<tr><td colspan="3"><%= Spree.t(:none) %></td></tr>
<% end %>
</tbody>
</table>

View File

@@ -0,0 +1,24 @@
#new_state
%table#listing_states.index
%colgroup
%col{:style => "width: 70%"}/
%col{:style => "width: 15%"}/
%col{:style => "width: 15%"}/
%thead
%tr
%th= t("spree.name")
%th= t("spree.abbreviation")
%th.actions
%tbody
- @states.each do |state|
- tr_class = cycle('odd', 'even')
- tr_id = spree_dom_id(state)
%tr{class: tr_class, id: tr_id}
%td= state.name
%td.align-center= state.abbr
%td.actions
= link_to_with_icon 'icon-edit', t("spree.edit"), edit_admin_country_state_url(@country, state), no_text: true
= link_to_delete state, no_text: true
- if @states.empty?
%tr
%td{colspan: "3"}= t("spree.none")

View File

@@ -1,20 +0,0 @@
<%= render :partial => 'spree/admin/shared/configuration_menu' %>
<% content_for :page_title do %>
<%= Spree.t(:editing_state) %> <i class="icon-arrow-right"></i> <%= @state.name %>
<% end %>
<% content_for :page_actions do %>
<li>
<%= button_link_to Spree.t(:back_to_states_list), spree.admin_country_states_url(@country), :icon => 'icon-arrow-left' %>
</li>
<% end %>
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @state } %>
<%= form_for [:admin, @country, @state] do |f| %>
<fieldset class="no-border-top">
<%= render :partial => 'form', :locals => { :f => f } %>
<%= render :partial => 'spree/admin/shared/edit_resource_links' %>
</fieldset>
<% end %>

View File

@@ -0,0 +1,16 @@
= render partial: 'spree/admin/shared/configuration_menu'
- content_for :page_title do
= t("spree.editing_state")
%i.icon-arrow-right
= @state.name
- content_for :page_actions do
%li
= button_link_to t("spree.back_to_states_list"), spree.admin_country_states_url(@country), icon: 'icon-arrow-left'
= render partial: 'spree/shared/error_messages', locals: { target: @state }
= form_for [:admin, @country, @state] do |f|
%fieldset.no-border-top
= render partial: 'form', locals: { f: f }
= render partial: 'spree/admin/shared/edit_resource_links'

View File

@@ -1,24 +0,0 @@
<%= render :partial => 'spree/admin/shared/configuration_menu' %>
<% content_for :page_title do %>
<%= Spree.t(:states) %>
<% end %>
<% content_for :page_actions do %>
<li id="new_state_link">
<%= button_link_to Spree.t(:new_state), new_admin_country_state_url(@country), { :remote => true, :icon => 'icon-plus', :id => 'new_state_link' } %>
</li>
<% end %>
<div data-hook="country" class="field row">
<%= label_tag :country, Spree.t(:country) %>
<select id="country" class='observe_field select2 fullwidth' data-base-url="<%=admin_states_path(:format => :js) %>?country_id=" data-update="#state-list">
<%= options_from_collection_for_select(@countries, :id, :name, @country.id) %>
</select>
</div>
<%= image_tag 'select2-spinner.gif', :plugin => 'spree', :style => 'display:none;', :id => 'busy_indicator' %>
<div id="state-list" data-hook>
<%= render :partial => 'state_list'%>
</div>

View File

@@ -0,0 +1,16 @@
= render partial: 'spree/admin/shared/configuration_menu'
- content_for :page_title do
= t("spree.states")
- content_for :page_actions do
%li#new_state_link
= button_link_to t("spree.new_state"), new_admin_country_state_url(@country), { remote: true, icon: 'icon-plus', id: 'new_state_link' }
.field.row
= label_tag :country, t("spree.country")
- databaseurl = "#{admin_states_path(format: :js)}?country_id="
%select#country.observe_field.select2.fullwidth{"data-base-url": databaseurl, "data-update": "#state-list"}
= options_from_collection_for_select(@countries, :id, :name, @country.id)
= image_tag 'select2-spinner.gif', plugin: 'spree', style: 'display:none;', id: 'busy_indicator'
#state-list
= render partial: 'state_list'

View File

@@ -1,15 +0,0 @@
<%= render :partial => 'spree/admin/shared/configuration_menu' %>
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @state } %>
<% content_for :page_title do %>
<%= Spree.t(:new_state) %>
<% end %>
<%= form_for [:admin, @country, @state] do |f| %>
<fieldset>
<legend><%= Spree.t(:new_state) %></legend>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= render :partial => 'spree/admin/shared/new_resource_links' %>
</fieldset>
<% end %>

View File

@@ -0,0 +1,12 @@
= render partial: 'spree/admin/shared/configuration_menu'
= render partial: 'spree/shared/error_messages', locals: { target: @state }
- content_for :page_title do
= t("spree.new_state")
= form_for [:admin, @country, @state] do |f|
%fieldset
%legend= t("spree.new_state")
= render partial: 'form', locals: { f: f }
= render partial: 'spree/admin/shared/new_resource_links'