typus 1.0.0.pre10 → 1.0.0.pre11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,6 @@ module Admin
21
21
  form = build_relate_form
22
22
  end
23
23
 
24
- build_pagination
25
24
  options = { foreign_key => @item.id }
26
25
 
27
26
  render "admin/templates/has_n",
@@ -43,8 +42,6 @@ module Admin
43
42
  form = build_relate_form
44
43
  end
45
44
 
46
- build_pagination
47
-
48
45
  render "admin/templates/has_n",
49
46
  :model_to_relate => @model_to_relate,
50
47
  :model_to_relate_as_resource => @model_to_relate_as_resource,
@@ -54,19 +51,6 @@ module Admin
54
51
 
55
52
  end
56
53
 
57
- def build_pagination
58
- options = { :order => @model_to_relate.typus_order_by, :conditions => set_conditions }
59
- items_count = @resource.find(params[:id]).send(@field).count(:conditions => set_conditions)
60
- items_per_page = @model_to_relate.typus_options_for(:per_page)
61
-
62
- @pager = ::Paginator.new(items_count, items_per_page) do |offset, per_page|
63
- options.merge!({:limit => per_page, :offset => offset})
64
- items = @resource.find(params[:id]).send(@field).all(options)
65
- end
66
-
67
- @items = @pager.page(params[:page])
68
- end
69
-
70
54
  def build_relate_form
71
55
  render "admin/templates/relate_form",
72
56
  :model_to_relate => @model_to_relate,
@@ -46,11 +46,6 @@ module Admin
46
46
  render File.join(path, "display_link_to_previous"), :message => message
47
47
  end
48
48
 
49
- def pagination(*args)
50
- @options = args.extract_options!
51
- render File.join(path, "pagination") if @items.prev || @items.next
52
- end
53
-
54
49
  private
55
50
 
56
51
  def path
@@ -29,7 +29,7 @@
29
29
 
30
30
  <% if @items.any? -%>
31
31
  <%= raw build_list(@resource, @fields, @items) %>
32
- <%= pagination %>
32
+ <%= will_paginate(@items, :renderer => Typus::Pagination) %>
33
33
  <% end %>
34
34
 
35
35
  <% if @items.empty? && !@resource.count.zero? %>
@@ -14,7 +14,7 @@
14
14
 
15
15
  <% if @items.any? -%>
16
16
  <%= table %>
17
- <%= pagination(:anchor => model_to_relate.to_resource) %>
17
+ <%= will_paginate(@items, :renderer => Typus::Pagination, :anchor => model_to_relate.to_resource) %>
18
18
  <% else %>
19
19
  <p><%= _t("There are no %{records}.", :records => model_to_relate.model_name.human.pluralize.downcase) %></p>
20
20
  <% end %>
@@ -9,7 +9,7 @@
9
9
 
10
10
  <% if @items.any? -%>
11
11
  <%= table %>
12
- <%= pagination(:anchor => model_to_relate.to_resource) %>
12
+ <%= will_paginate(@items, :renderer => Typus::Pagination, :anchor => model_to_relate.to_resource) %>
13
13
  <% else %>
14
14
  <p><%= _t("There are no %{records}.", :records => model_to_relate.model_name.human.pluralize.downcase) %></p>
15
15
  <% end %>
@@ -258,15 +258,15 @@ fieldset.buttons { }
258
258
 
259
259
  /* @group Pagination */
260
260
 
261
- #pagination { margin: 1.5em auto; text-align: center; }
261
+ .pagination { margin: 1.5em auto; text-align: center; }
262
262
 
263
- #pagination a { padding: 3px 5px; text-decoration: none; }
264
- #pagination a:hover { background: #000; color: #FFF; }
263
+ .pagination a { padding: 3px 5px; text-decoration: none; }
264
+ .pagination a:hover { background: #000; color: #FFF; }
265
265
 
266
- #pagination span.disabled { color: #D3D3D3; margin: 2px; padding: 2px 3px; }
266
+ .pagination span.disabled { color: #D3D3D3; margin: 2px; padding: 2px 3px; }
267
267
 
268
- #pagination .left { float: left; }
269
- #pagination .right { float: right; }
268
+ .pagination .left { float: left; }
269
+ .pagination .right { float: right; }
270
270
 
271
271
  /* @end */
272
272
 
data/lib/typus/format.rb CHANGED
@@ -12,12 +12,7 @@ module Typus
12
12
  def generate_html
13
13
  items_count = @resource.count(:joins => @joins, :conditions => @conditions)
14
14
  items_per_page = @resource.typus_options_for(:per_page)
15
-
16
- @pager = ::Paginator.new(items_count, items_per_page) do |offset, per_page|
17
- data(:limit => per_page, :offset => offset)
18
- end
19
-
20
- @items = @pager.page(params[:page])
15
+ @items = data.paginate(:per_page => items_per_page, :page => params[:page])
21
16
  end
22
17
 
23
18
  #--
@@ -0,0 +1,18 @@
1
+ module Typus
2
+
3
+ class Pagination < WillPaginate::ViewHelpers::LinkRenderer
4
+
5
+ def to_html
6
+ previous_label = "&larr; " + _t("Previous")
7
+ next_label = _t("Next") + " &rarr;"
8
+
9
+ html = []
10
+ html << previous_or_next_page(@collection.previous_page, previous_label, 'left')
11
+ html << previous_or_next_page(@collection.next_page, next_label, 'right')
12
+
13
+ html_container(html)
14
+ end
15
+
16
+ end
17
+
18
+ end
data/lib/typus/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Typus
2
- VERSION = "1.0.0.pre10"
2
+ VERSION = "1.0.0.pre11"
3
3
  end
data/lib/typus.rb CHANGED
@@ -15,6 +15,7 @@ autoload :FakeUser, "support/fake_user"
15
15
  module Typus
16
16
 
17
17
  autoload :Configuration, "typus/configuration"
18
+ autoload :Pagination, "typus/pagination"
18
19
  autoload :Resources, "typus/resources"
19
20
 
20
21
  module Authentication
data/typus.gemspec CHANGED
@@ -21,5 +21,5 @@ Gem::Specification.new do |s|
21
21
  s.files = Dir.glob("**/*")
22
22
  s.require_path = "lib"
23
23
 
24
- s.add_dependency 'paginator'
24
+ s.add_dependency 'will_paginate', '~> 3.0.beta'
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typus
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1637175999
4
+ hash: -1637175938
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 0
10
- - pre10
11
- version: 1.0.0.pre10
10
+ - pre11
11
+ version: 1.0.0.pre11
12
12
  platform: ruby
13
13
  authors:
14
14
  - Francesc Esplugas
@@ -20,17 +20,19 @@ date: 2010-10-18 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
- name: paginator
23
+ name: will_paginate
24
24
  prerelease: false
25
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
26
  none: false
27
27
  requirements:
28
- - - ">="
28
+ - - ~>
29
29
  - !ruby/object:Gem::Version
30
- hash: 3
30
+ hash: 31098121
31
31
  segments:
32
+ - 3
32
33
  - 0
33
- version: "0"
34
+ - beta
35
+ version: 3.0.beta
34
36
  type: :runtime
35
37
  version_requirements: *id001
36
38
  description: Awesone admin scaffold generator for Ruby on Rails applications.
@@ -74,7 +76,6 @@ files:
74
76
  - app/views/admin/helpers/dashboard/_resources.html.erb
75
77
  - app/views/admin/helpers/filters/_filters.html.erb
76
78
  - app/views/admin/helpers/resources/_display_link_to_previous.html.erb
77
- - app/views/admin/helpers/resources/_pagination.html.erb
78
79
  - app/views/admin/helpers/search/_search.html.erb
79
80
  - app/views/admin/helpers/sidebar/_sidebar.html.erb
80
81
  - app/views/admin/helpers/table/_table.html.erb
@@ -191,6 +192,7 @@ files:
191
192
  - lib/typus/engine.rb
192
193
  - lib/typus/format.rb
193
194
  - lib/typus/orm/active_record.rb
195
+ - lib/typus/pagination.rb
194
196
  - lib/typus/resources.rb
195
197
  - lib/typus/user.rb
196
198
  - lib/typus/version.rb
@@ -1,27 +0,0 @@
1
- <div id="pagination">
2
-
3
- <div class="left">
4
-
5
- <% previous_text = ("&larr; " + _t("Previous")).html_safe %>
6
-
7
- <% if @items.prev? %>
8
- <%= link_to previous_text, params.merge(:page => @items.prev.number, :anchor => @options[:anchor]) %>
9
- <% else %>
10
- <span class="disabled"><%= previous_text %></span>
11
- <% end %>
12
-
13
- </div>
14
-
15
- <div class="right">
16
-
17
- <% next_text = (_t("Next") + " &rarr;").html_safe %>
18
-
19
- <% if @items.next? %>
20
- <%= link_to next_text, params.merge(:page => @items.next.number, :anchor => @options[:anchor]) %>
21
- <% else %>
22
- <span class="disabled"><%= next_text %></span>
23
- <% end %>
24
-
25
- </div>
26
-
27
- </div>