spree_counties 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 708a8a43498d8990d26655459c17098947c12c53
4
- data.tar.gz: 5fc55898510da378b2425c18ba8a1a87b834b4a3
3
+ metadata.gz: 7cf4050d9bc0bdc13816724a74131104f7b0158a
4
+ data.tar.gz: 557a52a8af1d88e4683ebd1c1f3ad5247cfb6fd7
5
5
  SHA512:
6
- metadata.gz: 28fd00269702db014d7a1b88558d5204a112f7a1f06136c128cc9c6e9e11289a9bec130ff8d48b3354ba3b34728c50bf6f65f7f83a5087c765316680b0d3f275
7
- data.tar.gz: bd27aadc2368a727c26bc1f39f5d1b9943498138944156148abbe1e15858ccebc3d1ecd400c03b9fe1bf1036de63d12531c005558ac3e879d48984fd956a946b
6
+ metadata.gz: 9e4346678663c5c03330d04338f3c69b46853e1187ed44b9c5f94975cf5d91ea195b689425e1f7ca507972d14ded516d29c77c5e9314da2c9addb9296fa644a1
7
+ data.tar.gz: 430f211168dffbe87702fbf79fb99b1d3dd434092e3bec5301b167286f92a6b7eef5e390d9679be24f74a4260ab49484b866dd8a3e19d23b65bacba077f6d2bc
@@ -0,0 +1,31 @@
1
+ module Spree
2
+ module Admin
3
+ class CountiesController < Spree::Admin::ResourceController
4
+ before_action :load_data
5
+
6
+ def index
7
+ respond_with(@collection) do |format|
8
+ format.html
9
+ format.js { render :partial => 'county_list' }
10
+ end
11
+ end
12
+
13
+ protected
14
+
15
+ def collection
16
+ return @collection if @collection.present?
17
+ params[:q] ||= {}
18
+
19
+ @collection = super
20
+ @search = @collection.ransack(params[:q])
21
+ @collection = @search.result
22
+ @collection
23
+ end
24
+
25
+ def load_data
26
+ @states = Spree::State.order(:name)
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(
2
+ :virtual_path => "spree/admin/states/_state_list",
3
+ :name => "add_state_counties_link",
4
+ :insert_top => "td.actions",
5
+ :text => "<%= link_to_with_icon('list', Spree.t(:counties), admin_counties_path({state_id_eq: state.id}), {class: 'btn btn-primary btn-sm', no_text: true}) %>"
6
+ )
@@ -0,0 +1,24 @@
1
+ <div id="new_county" data-hook></div>
2
+
3
+ <table class="table" id='listing_counties' data-hook>
4
+ <thead>
5
+ <tr data-hook="counties_header">
6
+ <th><%= Spree.t(:name) %></th>
7
+ <th class="actions"></th>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <% @counties.each do |county| %>
12
+ <tr id="<%= spree_dom_id county %>" data-hook="counties_row">
13
+ <td><%= county.name %></td>
14
+ <td class="actions actions-2 text-right">
15
+ <%= link_to_edit(county, :no_text => true) if can? :edit, county %>
16
+ <%= link_to_delete(county, :no_text => true) if can? :delete, county %>
17
+ </td>
18
+ </tr>
19
+ <% end %>
20
+ <% if @counties.empty? %>
21
+ <tr><td colspan="3"><%= Spree.t(:none) %></td></tr>
22
+ <% end %>
23
+ </tbody>
24
+ </table>
@@ -0,0 +1,15 @@
1
+ <div data-hook="admin_county_form_fields" class="row">
2
+ <div class="col-md-6">
3
+ <%= f.field_container :name, class: ['form-group'] do %>
4
+ <%= f.label :name, Spree.t(:name) %>
5
+ <%= f.text_field :name, :class => 'form-control' %>
6
+ <% end %>
7
+ </div>
8
+ <div class="col-md-6">
9
+ <%= f.field_container :state, class: ['form-group'] do %>
10
+ <%= f.label :state_id, Spree.t(:state) %>
11
+ <%= f.collection_select(:state_id, @states, :id, :name, { include_blank: Spree.t('match_choices.none') }, { class: 'select2', disabled: (cannot? :edit, Spree::State) }) %>
12
+ <%= f.error_message_on :state %>
13
+ <% end %>
14
+ </div>
15
+ </div>
@@ -0,0 +1,12 @@
1
+ <% content_for :page_title do %>
2
+ <%= Spree.t(:editing_resource, resource: Spree::County.model_name.human) %> / <%= @county.name %>
3
+ <% end %>
4
+
5
+ <%= render :partial => 'spree/admin/shared/error_messages', :locals => { :target => @county } %>
6
+
7
+ <%= form_for [:admin, @county] do |f| %>
8
+ <fieldset>
9
+ <%= render :partial => 'form', :locals => { :f => f } %>
10
+ <%= render :partial => 'spree/admin/shared/edit_resource_links' %>
11
+ </fieldset>
12
+ <% end %>
@@ -0,0 +1,18 @@
1
+ <% content_for :page_title do %>
2
+ <%= plural_resource_name(Spree::County) %>
3
+ <% end %>
4
+
5
+ <% content_for :page_actions do %>
6
+ <%= button_link_to Spree.t(:new_county), new_admin_county_path, { :class => "btn-success", :icon => 'add', :id => 'new_county_link' } %>
7
+ <% end if can? :create, Spree::County %>
8
+
9
+ <div data-hook="state" class="form-group">
10
+ <%= label_tag :state, Spree.t(:state) %>
11
+ <select id="state" class='observe_field select2' data-base-url="<%=admin_counties_path(:format => :js) %>?q[state_id_eq]=" data-update="#county-list">
12
+ <%= options_from_collection_for_select(@states, :id, :name) %>
13
+ </select>
14
+ </div>
15
+
16
+ <div id="county-list" data-hook>
17
+ <%= render :partial => 'county_list'%>
18
+ </div>
@@ -0,0 +1,12 @@
1
+ <%= render :partial => 'spree/admin/shared/error_messages', :locals => { :target => @county } %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= Spree.t(:new_county) %>
5
+ <% end %>
6
+
7
+ <%= form_for [:admin, @county] do |f| %>
8
+ <fieldset>
9
+ <%= render :partial => 'form', :locals => { :f => f } %>
10
+ <%= render :partial => 'spree/admin/shared/new_resource_links' %>
11
+ </fieldset>
12
+ <% end %>
@@ -2,4 +2,14 @@
2
2
  # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
3
 
4
4
  en:
5
- hello: "Hello world"
5
+ activerecord:
6
+ attributes:
7
+ spree/county:
8
+ name: Name
9
+ models:
10
+ spree/county:
11
+ one: County
12
+ other: Counties
13
+ spree:
14
+ counties: "Counties"
15
+ new_county: "New county"
@@ -0,0 +1,15 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ es:
5
+ activerecord:
6
+ attributes:
7
+ spree/county:
8
+ name: Nombre
9
+ models:
10
+ spree/county:
11
+ one: Comuna.
12
+ other: Comunas
13
+ spree:
14
+ counties: "Comunas"
15
+ new_county: "Nueva comuna"
data/config/routes.rb CHANGED
@@ -3,4 +3,11 @@ Spree::Core::Engine.routes.draw do
3
3
  namespace :api, :defaults => { :format => 'json' } do
4
4
  resources :counties, :only => [:index, :show]
5
5
  end
6
+
7
+ namespace :admin do
8
+ resources :counties
9
+ resource :states do
10
+ resources :counties
11
+ end
12
+ end
6
13
  end
@@ -2,7 +2,7 @@
2
2
  Gem::Specification.new do |s|
3
3
  s.platform = Gem::Platform::RUBY
4
4
  s.name = 'spree_counties'
5
- s.version = '3.0.0'
5
+ s.version = '3.0.1'
6
6
  s.summary = 'Lets your users pick counties from states list in address\'s step'
7
7
  s.description = 'Add county model to address'
8
8
  s.required_ruby_version = '>= 1.9.3'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_counties
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gonzalo Moreno
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-27 00:00:00.000000000 Z
11
+ date: 2015-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree_core
@@ -181,17 +181,25 @@ files:
181
181
  - app/assets/javascripts/spree/frontend/spree_counties.js.coffee
182
182
  - app/assets/stylesheets/spree/backend/spree_counties.css
183
183
  - app/assets/stylesheets/spree/frontend/spree_counties.css
184
+ - app/controllers/spree/admin/counties_controller.rb
184
185
  - app/controllers/spree/api/counties_controller.rb
185
186
  - app/models/county_ability.rb
186
187
  - app/models/spree/address_decorator.rb
187
188
  - app/models/spree/county.rb
188
189
  - app/models/spree/state_decorator.rb
190
+ - app/overrides/spree/admin/states/index.rb
189
191
  - app/views/spree/address/_form.html.erb
192
+ - app/views/spree/admin/counties/_county_list.html.erb
193
+ - app/views/spree/admin/counties/_form.html.erb
194
+ - app/views/spree/admin/counties/edit.html.erb
195
+ - app/views/spree/admin/counties/index.html.erb
196
+ - app/views/spree/admin/counties/new.html.erb
190
197
  - app/views/spree/admin/shared/_address_form.html.erb
191
198
  - app/views/spree/api/counties/index.v1.rabl
192
199
  - app/views/spree/api/counties/show.v1.rabl
193
200
  - bin/rails
194
201
  - config/locales/en.yml
202
+ - config/locales/es.yml
195
203
  - config/routes.rb
196
204
  - db/migrate/20140729200830_create_spree_counties.rb
197
205
  - db/migrate/20140729203900_add_spree_county_reference_to_spree_address.rb