diff options
| author | Luc Donnet | 2012-03-01 09:33:45 +0100 |
|---|---|---|
| committer | Luc Donnet | 2012-03-01 09:33:45 +0100 |
| commit | a3c86f6713d87f9b8bb3e2164a9ae32ccd11b005 (patch) | |
| tree | 15e38365be8aa9c1a3ff64edb35445dbaa71672d | |
| parent | 1bf6eb00189e124674a70cb7216fb002f12b79ca (diff) | |
| download | chouette-core-a3c86f6713d87f9b8bb3e2164a9ae32ccd11b005.tar.bz2 | |
Refactor lines index view
| -rw-r--r-- | Gemfile | 7 | ||||
| -rw-r--r-- | Gemfile.lock | 33 | ||||
| -rw-r--r-- | app/assets/stylesheets/lines.css.scss | 2 | ||||
| -rw-r--r-- | app/assets/stylesheets/pagination.css.scss | 51 | ||||
| -rw-r--r-- | app/controllers/lines_controller.rb | 5 | ||||
| -rw-r--r-- | app/models/referential.rb | 6 | ||||
| -rw-r--r-- | app/views/lines/_line.erb | 6 | ||||
| -rw-r--r-- | app/views/lines/index.html.erb | 27 | ||||
| -rw-r--r-- | config/initializers/ninoxe.rb | 4 | ||||
| -rw-r--r-- | config/initializers/squeel.rb | 12 | ||||
| -rw-r--r-- | config/locales/lines.yml | 4 | ||||
| -rw-r--r-- | config/locales/networks.yml | 2 | ||||
| -rw-r--r-- | db/schema.rb | 18 | ||||
| -rw-r--r-- | spec/spec_helper.rb | 3 |
14 files changed, 131 insertions, 49 deletions
@@ -49,9 +49,12 @@ gem 'jquery-rails' gem 'formtastic' gem 'inherited_resources' +gem 'will_paginate', '~> 3.0' +gem 'ransack' +gem 'squeel' -gem 'chouette-ninoxe', :git => 'git://chouette.dryade.priv/ninoxe' -#gem 'chouette-ninoxe', :path => '/home/luc/projects/ninoxe' +#gem 'chouette-ninoxe', :git => 'git://chouette.dryade.priv/ninoxe' +gem 'chouette-ninoxe', :path => '/home/luc/projects/ninoxe' group :development do gem 'autotest-rails' diff --git a/Gemfile.lock b/Gemfile.lock index f91756bb4..dd20a98b4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,14 +1,4 @@ GIT - remote: git://chouette.dryade.priv/ninoxe - revision: 43d9b18e35b62004b5f5f86ba4679d6592b3454c - specs: - chouette-ninoxe (0.0.8) - GeoRuby - activerecord - composite_primary_keys - geokit - -GIT remote: git://github.com/dryade/activerecord-jdbc-adapter.git revision: 5b45a0a417e146e92db8c57b5c600cdeb9e957bf specs: @@ -53,6 +43,15 @@ GIT user_interface (0.0.1) rails (~> 3.1.0) +PATH + remote: /home/luc/projects/ninoxe + specs: + chouette-ninoxe (0.0.8) + GeoRuby + activerecord + composite_primary_keys + geokit + GEM remote: http://rubygems.org/ specs: @@ -193,6 +192,8 @@ GEM nokogiri (1.5.0) nokogiri (1.5.0-java) pg (0.11.0) + polyamorous (0.5.0) + activerecord (~> 3.0) polyglot (0.3.3) rack (1.3.6) rack-cache (1.1) @@ -219,6 +220,10 @@ GEM rdoc (~> 3.4) thor (~> 0.14.6) rake (0.9.2.2) + ransack (0.6.0) + actionpack (~> 3.0) + activerecord (~> 3.0) + polyamorous (~> 0.5.0) rdoc (3.12) json (~> 1.4) remarkable (4.0.0.alpha4) @@ -264,6 +269,10 @@ GEM rack (~> 1.0) tilt (~> 1.1, != 1.3.0) sqlite3 (1.3.5) + squeel (0.9.5) + activerecord (~> 3.0) + activesupport (~> 3.0) + polyamorous (~> 0.5.0) term-ansicolor (1.0.7) thor (0.14.6) tilt (1.3.3) @@ -279,6 +288,7 @@ GEM jruby-rack (>= 1.0.0) rake (>= 0.8.7) rubyzip (>= 0.9.4) + will_paginate (3.0.3) xpath (0.1.4) nokogiri (~> 1.3) yard (0.7.4) @@ -313,6 +323,7 @@ DEPENDENCIES pg (~> 0.11.0) pickle! rails (= 3.1.3) + ransack remarkable (~> 4.0.0.alpha4) remarkable_activerecord (~> 4.0.0.alpha4) rspec @@ -320,6 +331,8 @@ DEPENDENCIES sass-rails (~> 3.1.5) shoulda! sqlite3 + squeel uglifier (>= 1.0.3) user_interface! warbler + will_paginate (~> 3.0) diff --git a/app/assets/stylesheets/lines.css.scss b/app/assets/stylesheets/lines.css.scss index 165689f3b..2ba770492 100644 --- a/app/assets/stylesheets/lines.css.scss +++ b/app/assets/stylesheets/lines.css.scss @@ -1,7 +1,7 @@ // Place all the styles related to the lines controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ -@mixin div_for_object { +@mixin div_for_object { margin-bottom: 20px; .color { diff --git a/app/assets/stylesheets/pagination.css.scss b/app/assets/stylesheets/pagination.css.scss new file mode 100644 index 000000000..53937fcb6 --- /dev/null +++ b/app/assets/stylesheets/pagination.css.scss @@ -0,0 +1,51 @@ +.pagination { + background: white; + cursor: default; + + > a, > span, > em{ + padding: 0.2em 0.5em; + display: block; + float: left; + margin-right: 1px; + } + + > .disabled{ + color: #999999; + border: 1px solid #dddddd; + } + + > .current{ + font-style: normal; + font-weight: bold; + background: #2e6ab1; + color: white; + border: 1px solid #2e6ab1; + } + + > a{ + text-decoration: none; + color: #105cb6; + border: 1px solid #9aafe5; + &:hover, &:focus{ + color: #000033; + border-color: #000033; + } + } + + .page_info{ + padding: 0.4em 0.6em + } + + &:after{ + content: "."; + display: block; + height: 0; + clear: both; + visibility: hidden;} + + * html & { + height: 1%;} + + *:first-child+html & { + overflow: hidden;} +}
\ No newline at end of file diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb index a5be8ca44..6968618b8 100644 --- a/app/controllers/lines_controller.rb +++ b/app/controllers/lines_controller.rb @@ -7,8 +7,9 @@ class LinesController < ChouetteController protected - def collection - @lines ||= referential.lines.order_by [[sort_column.to_sym, sort_direction.to_sym]] + def collection + @q = Chouette::Line.search(params[:q]) + @lines ||= @q.result(:distinct => true).paginate(:page => params[:page], :per_page => 10) end def sort_column diff --git a/app/models/referential.rb b/app/models/referential.rb index a329bf950..b08f6be4c 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -6,15 +6,15 @@ class Referential < ActiveRecord::Base before_destroy :destroy_schema def lines - Chouette::Line.all + Chouette::Line.scoped end def networks - Chouette::Network.all + Chouette::Network.scoped end def companies - Chouette::Company.all + Chouette::Company.scoped end private diff --git a/app/views/lines/_line.erb b/app/views/lines/_line.erb index f594c7f9d..2a8fe4683 100644 --- a/app/views/lines/_line.erb +++ b/app/views/lines/_line.erb @@ -6,6 +6,10 @@ <% end %> <%= link_to line.name, [@referential, line] %> <div class="info"> - + <p><%= link_to_if( line.network, line.network.name, referential_network_path(@referential, line.network), :title => "Réseau : #{line.network.name}" ) %> | <%= link_to_if( line.company, line.company.name, referential_company_path(@referential, line.company), :title => "Transporteur : #{line.company.name}" ) %> </p> + <p> + <%= link_to "Modifier", edit_referential_line_path(@referential, line), :class => "edit" %> | + <%= link_to "Supprimer", referential_line_path(@referential, line), :method => :delete, :confirm => t('lines.actions.destroy_confirm'), :class => "remove" %> + </p> </div> <% end %> diff --git a/app/views/lines/index.html.erb b/app/views/lines/index.html.erb index e8f795a98..a8fb79d0f 100644 --- a/app/views/lines/index.html.erb +++ b/app/views/lines/index.html.erb @@ -1,17 +1,26 @@ -<div class="order"> - Trier par - <%= link_to_order "Code", "code" %> | - <%= link_to_order "Priorité", "priority" %> | - <%= link_to_order "Nom", "name" %> -</div> - <%= title_tag t('lines.index.title') %> -<%= render :partial => "line", :collection => @lines %> +<%= search_form_for @q, :url => referential_lines_path(@referential), :html => {:method => :get} do |f| %> + <%= f.label :name_or_number_cont %> + <%= f.text_field :name_or_number_cont %> + <%= f.submit %> +<% end %> + +<div class="digg_pagination"> + <%= will_paginate @lines %> + <div class="page_info"> + <%= render :partial => "line", :collection => @lines %> + </div> + <%= will_paginate @lines %> +</div> <% content_for :sidebar do %> <ul class="actions"> - <li><%= link_to t('lines.actions.new'), new_referential_line_path(@referential), :class => "add" %></li> + <li><%= link_to t('lines.actions.new'), new_referential_line_path(@referential), :class => "add" %></li> <br> </ul> +<ul> + +</ul> + <% end %> diff --git a/config/initializers/ninoxe.rb b/config/initializers/ninoxe.rb index 9a4c2d7ec..3c26e41f4 100644 --- a/config/initializers/ninoxe.rb +++ b/config/initializers/ninoxe.rb @@ -1,4 +1,8 @@ +Chouette::ActiveRecord.establish_chouette_connection = false + + class Chouette::Line + def self.model_name name = "Line" def name.name diff --git a/config/initializers/squeel.rb b/config/initializers/squeel.rb new file mode 100644 index 000000000..aa3f2ff02 --- /dev/null +++ b/config/initializers/squeel.rb @@ -0,0 +1,12 @@ +Squeel.configure do |config| + # To load hash extensions (to allow for AND (&), OR (|), and NOT (-) against + # hashes of conditions) + config.load_core_extensions :hash + + # To load symbol extensions (for a subset of the old MetaWhere functionality, + # via ARel predicate methods on Symbols: :name.matches, etc) + # config.load_core_extensions :symbol + + # To load both hash and symbol extensions + # config.load_core_extensions :hash, :symbol +end diff --git a/config/locales/lines.yml b/config/locales/lines.yml index f2099eccf..486c13b36 100644 --- a/config/locales/lines.yml +++ b/config/locales/lines.yml @@ -27,8 +27,8 @@ fr: title: Ligne %{line} index: title: Lignes - activerecord: - models: + activerecord: + models: line: Lignes attributes: line: diff --git a/config/locales/networks.yml b/config/locales/networks.yml index e03fdfe5b..efe748364 100644 --- a/config/locales/networks.yml +++ b/config/locales/networks.yml @@ -31,7 +31,7 @@ fr: title: "Réseaux" activerecord: models: - network: Réseaux + network: Réseau attributes: network: registrationnumber: "Identifiant" diff --git a/db/schema.rb b/db/schema.rb index 29d57a1df..4b3e892f5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -31,16 +31,6 @@ ActiveRecord::Schema.define(:version => 20120214101645) do add_index "company", ["objectid"], :name => "company_objectid_key", :unique => true add_index "company", ["registrationnumber"], :name => "company_registrationnumber_key", :unique => true - create_table "geometry_columns", :id => false, :force => true do |t| - t.string "f_table_catalog", :limit => 256, :null => false - t.string "f_table_schema", :limit => 256, :null => false - t.string "f_table_name", :limit => 256, :null => false - t.string "f_geometry_column", :limit => 256, :null => false - t.integer "coord_dimension", :null => false - t.integer "srid", :null => false - t.string "type", :limit => 30, :null => false - end - create_table "line", :force => true do |t| t.integer "ptnetworkid", :limit => 8 t.integer "companyid", :limit => 8 @@ -85,12 +75,4 @@ ActiveRecord::Schema.define(:version => 20120214101645) do t.datetime "updated_at" end - create_table "spatial_ref_sys", :id => false, :force => true do |t| - t.integer "srid", :null => false - t.string "auth_name", :limit => 256 - t.integer "auth_srid" - t.string "srtext", :limit => 2048 - t.string "proj4text", :limit => 2048 - end - end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bb5f59026..1fd4d6894 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,7 +3,10 @@ ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' + +# Add this to load Capybara integration: require 'capybara/rspec' +require 'capybara/rails' # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. |
