aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorLuc Donnet2012-03-01 09:33:45 +0100
committerLuc Donnet2012-03-01 09:33:45 +0100
commita3c86f6713d87f9b8bb3e2164a9ae32ccd11b005 (patch)
tree15e38365be8aa9c1a3ff64edb35445dbaa71672d /app
parent1bf6eb00189e124674a70cb7216fb002f12b79ca (diff)
downloadchouette-core-a3c86f6713d87f9b8bb3e2164a9ae32ccd11b005.tar.bz2
Refactor lines index view
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/lines.css.scss2
-rw-r--r--app/assets/stylesheets/pagination.css.scss51
-rw-r--r--app/controllers/lines_controller.rb5
-rw-r--r--app/models/referential.rb6
-rw-r--r--app/views/lines/_line.erb6
-rw-r--r--app/views/lines/index.html.erb27
6 files changed, 81 insertions, 16 deletions
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 %>