Skip to content

Commit

Permalink
fixed pagination markup by creating link renderer for will_paginate
Browse files Browse the repository at this point in the history
  • Loading branch information
leikind committed Mar 4, 2012
1 parent 8c75d39 commit 0832d04
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 61 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ begin
gem.email = "yuri.leikind@gmail.com"
gem.homepage = "http://github.com/lekind/wice_grid"
gem.authors = ["Yuri Leikind"]
gem.add_development_dependency "will_paginate", ">= 3.0.pre2"
gem.add_development_dependency "will_paginate", ">= 3.0.3"
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
Jeweler::GemcutterTasks.new
Expand Down
31 changes: 15 additions & 16 deletions lib/generators/wice_grid/templates/wice_grid.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,21 @@
width: auto;
}

.wice_grid .pagination{
margin: 0px;
}


.wice_grid_container .pagination {
float: left;
}
.wice_grid_container .pagination_status {
font-weight: bold;
float: right;
}



/*.wice_grid th.filter_icons, .wice_grid th.hide_show_icon {
text-align: right ;
}
Expand Down Expand Up @@ -122,26 +137,10 @@
text-align: center;
}
*/
/*.wice_grid_container .pagination {
float: left;
}
*/
/*.wice_grid_container .pagination_status {
font-weight: bold;
float: right;
}
*/
/*.wice_grid_container .pagination_status .show_all_link a {
text-decoration: none;
font-size: 80%;
}
*/
/*.wice_grid .custom_dropdown_container { position: relative; padding-right: 9px;}
.wice_grid .custom_dropdown_container .toggle_multi_select_icon { position:absolute; top:0; right:0; }
.wice_grid .text_filter_container { position: relative; padding-right: 13px;}
.wice_grid .text_filter_container .negation_checkbox { position:absolute; top:0; right:0; }
*/
/* Saved Queries */
/*
Expand Down
66 changes: 22 additions & 44 deletions lib/generators/wice_grid/templates/wice_grid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ en:
- :year
- :month
- :day
will_paginate:
page_gap: "..."
wice_grid:
show_filter_tooltip: Show filter
hide_filter_tooltip: Hide filter
Expand All @@ -14,8 +12,8 @@ en:
reset_filter_tooltip: Reset
boolean_filter_true_label: "yes"
boolean_filter_false_label: "no"
previous_label: « Previous
next_label: Next »
previous_label: «
next_label: »
# Title of the icon clicking on which will show the calendar to set the FROM date.
date_selector_tooltip_from: From
# Title of the icon clicking on which will show the calendar to set the TO date.
Expand Down Expand Up @@ -53,8 +51,6 @@ is:
- :year
- :month
- :day
will_paginate:
page_gap: "..."
wice_grid:
show_filter_tooltip: Sýna síumöguleika
hide_filter_tooltip: Fela síumoguleika
Expand All @@ -63,8 +59,8 @@ is:
reset_filter_tooltip: Hreinsa
boolean_filter_true_label:
boolean_filter_false_label: Nei
previous_label: « Fyrri síða
next_label: Næsta síða »
previous_label: «
next_label: »
# Title of the icon clicking on which will show the calendar to set the FROM date.
date_selector_tooltip_from: Frá
# Title of the icon clicking on which will show the calendar to set the TO date.
Expand Down Expand Up @@ -102,8 +98,6 @@ nl:
- :year
- :month
- :day
will_paginate:
page_gap: "..."
wice_grid:
show_filter_tooltip: Filter tonen
hide_filter_tooltip: Filter verbergen
Expand All @@ -112,8 +106,8 @@ nl:
reset_filter_tooltip: Terugstellen
boolean_filter_true_label: ja
boolean_filter_false_label: neen
previous_label: « Vorige
next_label: Volgende »
previous_label: «
next_label: »
# Title of the icon clicking on which will show the calendar to set the FROM date.
date_selector_tooltip_from: Vanaf
# Title of the icon clicking on which will show the calendar to set the TO date.
Expand Down Expand Up @@ -150,8 +144,6 @@ fr:
- :year
- :month
- :day
will_paginate:
page_gap: "..."
wice_grid:
show_filter_tooltip: Afficher le filtre
hide_filter_tooltip: Cacher le filtrer
Expand All @@ -160,8 +152,8 @@ fr:
reset_filter_tooltip: Effacer
boolean_filter_true_label: oui
boolean_filter_false_label: non
previous_label: « Page précédente
next_label: Page suivante »
previous_label: «
next_label: »
# Title of the icon clicking on which will show the calendar to set the FROM date.
date_selector_tooltip_from: De
# Title of the icon clicking on which will show the calendar to set the TO date.
Expand Down Expand Up @@ -198,8 +190,6 @@ ru:
- :year
- :month
- :day
will_paginate:
page_gap: "..."
wice_grid:
show_filter_tooltip: Показать фильтр
hide_filter_tooltip: Спрятать фильтр
Expand All @@ -208,8 +198,8 @@ ru:
reset_filter_tooltip: Сброс
boolean_filter_true_label: да
boolean_filter_false_label: нет
previous_label: « Предыдущая
next_label: Следующая »
previous_label: «
next_label: »
# Title of the icon clicking on which will show the calendar to set the FROM date.
date_selector_tooltip_from: С
# Title of the icon clicking on which will show the calendar to set the TO date.
Expand Down Expand Up @@ -247,8 +237,6 @@ pt:
- :year
- :month
- :day
will_paginate:
page_gap: "..."
wice_grid:
show_filter_tooltip: Mostrar o filtro
hide_filter_tooltip: Esconder o filtro
Expand All @@ -257,8 +245,8 @@ pt:
reset_filter_tooltip: Reinicializar
boolean_filter_true_label: sim
boolean_filter_false_label: não
previous_label: « Página precedente
next_label: Página seguinte »
previous_label: «
next_label: »
# Title of the icon clicking on which will show the calendar to set the FROM date.
date_selector_tooltip_from: De
# Title of the icon clicking on which will show the calendar to set the TO date.
Expand Down Expand Up @@ -295,8 +283,6 @@ pt-BR:
- :year
- :month
- :day
will_paginate:
page_gap: "..."
wice_grid:
show_filter_tooltip: Mostrar o filtro
hide_filter_tooltip: Esconder o filtro
Expand All @@ -305,8 +291,8 @@ pt-BR:
reset_filter_tooltip: Reinicializar
boolean_filter_true_label: sim
boolean_filter_false_label: não
previous_label: « Anterior
next_label: Próximo »
previous_label: «
next_label: »
date_selector_tooltip_from: De
date_selector_tooltip_to: a
negation_checkbox_title: Excluir
Expand Down Expand Up @@ -335,8 +321,6 @@ sk:
- :year
- :month
- :day
will_paginate:
page_gap: "..."
wice_grid:
show_filter_tooltip: Zobraziť filter
hide_filter_tooltip: Skryť filter
Expand All @@ -345,8 +329,8 @@ sk:
reset_filter_tooltip: Zrušiť filtre
boolean_filter_true_label: "áno"
boolean_filter_false_label: "nie"
previous_label: « Predchádzajúci
next_label: Následujúci »
previous_label: «
next_label: »
# Title of the icon clicking on which will show the calendar to set the FROM date.
date_selector_tooltip_from: Dátum od
# Title of the icon clicking on which will show the calendar to set the TO date.
Expand Down Expand Up @@ -383,8 +367,6 @@ cz:
- :year
- :month
- :day
will_paginate:
page_gap: "..."
wice_grid:
show_filter_tooltip: Zobrazit filtr
hide_filter_tooltip: Skrýt filtr
Expand All @@ -393,8 +375,8 @@ cz:
reset_filter_tooltip: Zrušit filtr
boolean_filter_true_label: "áno"
boolean_filter_false_label: "ne"
previous_label: « Předešlý
next_label: Následující »
previous_label: «
next_label: »
# Title of the icon clicking on which will show the calendar to set the FROM date.
date_selector_tooltip_from: Dátum od
# Title of the icon clicking on which will show the calendar to set the TO date.
Expand Down Expand Up @@ -431,8 +413,6 @@ de:
- :year
- :month
- :day
will_paginate:
page_gap: "..."
wice_grid:
show_filter_tooltip: Filter einblenden
hide_filter_tooltip: Filter ausblenden
Expand All @@ -441,8 +421,8 @@ de:
reset_filter_tooltip: Reset
boolean_filter_true_label: "Ja"
boolean_filter_false_label: "Nein"
previous_label: « Letzte
next_label: Nächste »
previous_label: «
next_label: »
# Title of the icon clicking on which will show the calendar to set the FROM date.
date_selector_tooltip_from: Von
# Title of the icon clicking on which will show the calendar to set the TO date.
Expand Down Expand Up @@ -479,8 +459,6 @@ zh:
- :year
- :month
- :day
will_paginate:
page_gap: "..."
wice_grid:
show_filter_tooltip: 显示过滤
hide_filter_tooltip: 隐藏过滤
Expand All @@ -489,8 +467,8 @@ zh:
reset_filter_tooltip: 清除过滤
boolean_filter_true_label: ""
boolean_filter_false_label: ""
previous_label: « 前一页
next_label: 下一页 »
previous_label: «
next_label: »
# Title of the icon clicking on which will show the calendar to set the FROM date.
date_selector_tooltip_from:
# Title of the icon clicking on which will show the calendar to set the TO date.
Expand Down
1 change: 1 addition & 0 deletions lib/helpers/wice_grid_view_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ def pagination_panel_content(grid, extra_request_parameters, allow_showing_all_r
:previous_label => NlMessage['previous_label'],
:next_label => NlMessage['next_label'],
:param_name => "#{grid.name}[page]",
:renderer => ::Wice::WillPaginatePaginator,
:params => extra_request_parameters).to_s +
(' <div class="pagination_status">' + html + '</div>').html_safe_if_necessary, js]
end
Expand Down
4 changes: 4 additions & 0 deletions lib/wice_grid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
require 'view_columns.rb'



ActionController::Base.send(:helper_method, :wice_grid_custom_filter_params)

module Wice
Expand Down Expand Up @@ -50,6 +51,9 @@ class WiceGridEngine < ::Rails::Engine
Wice::GridRenderer.send(:include, ::WillPaginate::ViewHelpers)
require 'wice_grid_serialized_query.rb'
end

require 'will_paginate_paginator.rb'

end

rake_tasks do
Expand Down
31 changes: 31 additions & 0 deletions lib/will_paginate_paginator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module Wice
class WillPaginatePaginator < ::WillPaginate::ActionView::LinkRenderer
def html_container(html)
tag(:div,
tag(:ul, html),
container_attributes
)
end

def page_number(page)
if page == current_page
tag(:li, link(page, page, :rel => rel_value(page)), :class => 'active')
else
tag(:li, link(page, page, :rel => rel_value(page)))
end
end

def previous_or_next_page(page, text, classname)
if page
tag(:li, link(text, page))
else
tag(:li, link(text, page), :class => 'disabled')
end
end

def gap
'<li class="disabled"><a href="#">...</a></li>'
end

end
end

0 comments on commit 0832d04

Please sign in to comment.