From 2fadf0789c47b49e5c47997d6e392faa7da88230 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 31 Aug 2011 16:10:51 +0200 Subject: sorting functionality for models page --- public/arrow_left.png | Bin 0 -> 374 bytes public/arrow_left_inactive.png | Bin 0 -> 364 bytes public/arrow_right.png | Bin 0 -> 386 bytes public/arrow_right_inactive.png | Bin 0 -> 400 bytes views/models_navigation.haml | 31 ++++++++++++++++++------------- views/style.sass | 1 - 6 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 public/arrow_left.png create mode 100644 public/arrow_left_inactive.png create mode 100644 public/arrow_right.png create mode 100644 public/arrow_right_inactive.png diff --git a/public/arrow_left.png b/public/arrow_left.png new file mode 100644 index 0000000..8d18c67 Binary files /dev/null and b/public/arrow_left.png differ diff --git a/public/arrow_left_inactive.png b/public/arrow_left_inactive.png new file mode 100644 index 0000000..52c11bf Binary files /dev/null and b/public/arrow_left_inactive.png differ diff --git a/public/arrow_right.png b/public/arrow_right.png new file mode 100644 index 0000000..7fe64a8 Binary files /dev/null and b/public/arrow_right.png differ diff --git a/public/arrow_right_inactive.png b/public/arrow_right_inactive.png new file mode 100644 index 0000000..496f79e Binary files /dev/null and b/public/arrow_right_inactive.png differ diff --git a/views/models_navigation.haml b/views/models_navigation.haml index d324fce..4b3ba2d 100644 --- a/views/models_navigation.haml +++ b/views/models_navigation.haml @@ -3,15 +3,14 @@ %form{:name => "nav", :action => url_for('/models'), :method => "get", :id => "nav"} %input{:type => :hidden, :name => :sort_by, :id => "sort_by", :value => params[:sort_by]} %input{:type => :hidden, :name => :order, :id => "order", :value => params[:order]} - %input{:type => :hidden, :name => :subjectid, :value => session[:subjectid]} %input{:type => :hidden, :name => :page, :id => "page", :value => params[:page]} Models are sorted by: - - ["id","created_at","name","type"].each do |s| - - idname = s == "created_at" ? "date" : s + - ["id","created_at","name","type"].each do |s| + - idname = s == "created_at" ? "date" : s - if params[:sort_by] == s %div{:id => idname, :class => "active"} - %span="#{idname}" + %span="#{idname.capitalize}" - if params[:order] == "ASC" #up{:class => "link"} %img{:src => "arrow_down.png", :alt => 'in ascending order', :title => 'in ascending order'}/ @@ -19,20 +18,26 @@ #down{:class => "link"} %img{:src => "arrow_up.png", :alt => 'in descending order', :title => 'in descending order'}/ - else - %div{:id => idname, :class => "link"}="#{idname}" + %div{:id => idname, :class => "link"}="#{idname.capitalize} " | - models: - - #prev= "prev" unless @page.to_i == 0 + Models: + - unless @page.to_i == 0 + #prev + %img{:src => "arrow_left.png", :alt => 'previous', :title => 'previous'}/ + -else + %img{:src => "arrow_left_inactive.png", :alt => '', :title => ''}/ - if @models.size < 5*@page+5 - - last = @models.size - - else + - last = @models.size + - else - last = 5*@page+5 - = "(#{5*@page+1}-#{last}/#{@models.size})" - - #next= "next" unless 5*@page.to_i+5 >= @models.size + = "(#{5*@page+1}-#{last}/#{@models.size})" + - unless 5*@page.to_i+5 >= @models.size + #next + %img{:src => "arrow_right.png", :alt => 'next', :title => 'next'}/ + -else + %img{:src => "arrow_right_inactive.png", :alt => '', :title => ''}/ - js = "" - ["id","created_at","name","type"].each do |s| diff --git a/views/style.sass b/views/style.sass index 56eee02..23b157a 100644 --- a/views/style.sass +++ b/views/style.sass @@ -285,6 +285,5 @@ dl display: inline color: #000 font-weight: bold - padding: 0 1px .thin font-weight: 100 -- cgit v1.2.3