This repository has been archived by the owner on Nov 15, 2018. It is now read-only.
forked from mscottford/spree_city_zones
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Admin portion of cities working.... cleanup probably needed, but, eno…
…ugh to move on to zone side of things
- Loading branch information
Showing
19 changed files
with
243 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class Admin::CitiesController < Admin::ResourceController | ||
belongs_to :state | ||
before_filter :load_data | ||
|
||
def index | ||
respond_with(@collection) do |format| | ||
format.html | ||
format.js { render :partial => 'city_list.html.erb' } | ||
end | ||
end | ||
|
||
protected | ||
|
||
def location_after_save | ||
admin_country_state_cities_url(@country,@state) | ||
end | ||
|
||
def location_after_create | ||
admin_country_state_cities_url(@country,@state) | ||
end | ||
|
||
def collection | ||
super.order(:name) | ||
end | ||
|
||
def load_data | ||
@countries = Country.order(:name) | ||
@country = Country.find(params[:country_id]) | ||
@states = State.order(:name) | ||
@state = State.find(params[:state_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class City < ActiveRecord::Base | ||
belongs_to :state | ||
validates_presence_of :name | ||
validates_uniqueness_of :name, :scope => [:state_id] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Country.class_eval do | ||
has_many :cities, :through => :states | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
State.class_eval do | ||
has_many :cities | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<table class="index" id='listing_citys'> | ||
<thead> | ||
<tr> | ||
<th><%= t("name") %></th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @cities.each do |city| | ||
state = city.state | ||
country = @state.country | ||
%> | ||
<tr id="<%= dom_id city %>"> | ||
<td><%=city.name %></td> | ||
<td class="actions"> | ||
<%= link_to_with_icon 'edit', t("edit"), edit_admin_country_state_city_url(country, state, city), :class => 'edit' %> | ||
| ||
<%= link_to 'Delete', admin_country_state_city_url(country, state, city), :method => 'delete' %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
<% if @cities.empty? %> | ||
<tr><td colspan="3"><%= t(:none) %></td></tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
<div id="new_city"></div> | ||
<p> | ||
<%= button_link_to t("new_city"), new_admin_country_state_city_url(@country,@state), {:remote => true, | ||
:icon => 'add', | ||
:id => 'new_city'} %> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<%= f.field_container :name do %> | ||
<%= f.label :name, t("name") %><br /> | ||
<%=f.text_field :name %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<%= render :partial => 'admin/shared/configuration_menu' %> | ||
|
||
<h1><%= t("editing_state") %></h1> | ||
|
||
<%= render 'shared/error_messages', :target => @state %> | ||
<%= form_for([:admin,@country,@state,@city], :html => { :method => :put }) do |f| %> | ||
<%= render :partial => "form", :locals => { :f => f } %> | ||
<%= render :partial => "admin/shared/cities_edit_resource_links" %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<%= render :partial => 'admin/shared/configuration_menu' %> | ||
|
||
<h1><%= t("Cities") %></h1> | ||
|
||
<p> | ||
<label for="country"><%= t('country') %></label> | ||
<select id="country" class='observe_field' 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> | ||
</p> | ||
|
||
<p> | ||
<label for="state"><%= t('state') %></label> | ||
<select id="state" class='observe_field' data-base-url="<%=admin_cities_path(:format => :js)%>?country_id=<%= @country.id %>&state_id=" data-update="#city-list"> | ||
<%= options_from_collection_for_select(@states, :id, :name, @state.id) %> | ||
</select> | ||
</p> | ||
|
||
<%= image_tag "spinner.gif", :plugin=>"spree", :style => "display:none", :id => 'busy_indicator' %> | ||
|
||
<div id="city-list"> | ||
<%=render :partial => 'city_list'%> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<%= render :partial => 'admin/shared/configuration_menu' %> | ||
<%= render 'shared/error_messages', :target => @city %> | ||
<%= form_for([:admin,@country,@state,@city]) do |f| %> | ||
<%= render :partial => "form", :locals => { :f => f } %> | ||
<%= render :partial => "admin/shared/cities_new_resource_links" %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<p class="form-buttons"> | ||
<%= button t("update") %> | ||
<%= t("or") %> <%= link_to t("cancel"), admin_country_state_cities_url %> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<p class="form-buttons"> | ||
<%= button t("actions.create") %> | ||
<%= t("or") %> <%= link_to t("actions.cancel"), [:admin,@country,@state,@city] %> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<tr> | ||
<td><%= link_to t("Cities"), admin_country_state_cities_path(Spree::Config[:default_country_id],State.find(:first, :conditions => {:country_id => Spree::Config[:default_country_id], :abbr => 'CA'})) %></td> | ||
<td><%= t("cities_description") %></td> | ||
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
K 25 | ||
svn:wc:ra_dav:version-url | ||
V 54 | ||
/stuff/!svn/ver/7/axialracing.com/trunk/config/locales | ||
END | ||
en.yml | ||
K 25 | ||
svn:wc:ra_dav:version-url | ||
V 61 | ||
/stuff/!svn/ver/7/axialracing.com/trunk/config/locales/en.yml | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
10 | ||
|
||
dir | ||
7 | ||
http://svn.xwcsolutions.com/stuff/axialracing.com/trunk/config/locales | ||
http://svn.xwcsolutions.com/stuff | ||
|
||
|
||
|
||
2011-09-01T04:24:47.489963Z | ||
7 | ||
mlinn | ||
|
||
|
||
svn:special svn:externals svn:needs-lock | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
804588ea-4340-4a75-919c-c824e102a980 | ||
|
||
|
||
|
||
|
||
|
||
|
||
0 | ||
|
||
en.yml | ||
file | ||
|
||
|
||
|
||
|
||
2011-08-24T21:11:13.000000Z | ||
db4b902854e3f164eca50f0beba9bea7 | ||
2011-09-01T04:24:47.489963Z | ||
7 | ||
mlinn | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
213 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Sample localization file for English. Add more files in this directory for other locales. | ||
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. | ||
|
||
en: | ||
hello: "Hello world" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
en: | ||
new_city: "New City" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
Rails.application.routes.draw do | ||
# Add your extension routes here | ||
namespace :admin do | ||
resources :cities, :only => :index | ||
resources :countries do | ||
resources :states do | ||
resources :cities do | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class CreateCities < ActiveRecord::Migration | ||
def self.up | ||
create_table :cities do |t| | ||
t.string :name | ||
t.integer :state_id | ||
|
||
t.timestamps | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :cities | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
class SpreeCityZonesHooks < Spree::ThemeSupport::HookListener | ||
# custom hooks go here | ||
insert_after :admin_configurations_menu, 'shared/cities_admin_configurations_menu' | ||
end |