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.
- data/app/helpers/admin/relationships_helper.rb +0 -16
- data/app/helpers/admin/resources_helper.rb +0 -5
- data/app/views/admin/resources/index.html.erb +1 -1
- data/app/views/admin/templates/_has_many.html.erb +1 -1
- data/app/views/admin/templates/_has_n.html.erb +1 -1
- data/lib/generators/templates/public/admin/stylesheets/screen.css +6 -6
- data/lib/typus/format.rb +1 -6
- data/lib/typus/pagination.rb +18 -0
- data/lib/typus/version.rb +1 -1
- data/lib/typus.rb +1 -0
- data/typus.gemspec +1 -1
- metadata +10 -8
- data/app/views/admin/helpers/resources/_pagination.html.erb +0 -27
@@ -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
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
<% if @items.any? -%>
|
16
16
|
<%= table %>
|
17
|
-
<%=
|
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
|
-
<%=
|
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
|
-
|
261
|
+
.pagination { margin: 1.5em auto; text-align: center; }
|
262
262
|
|
263
|
-
|
264
|
-
|
263
|
+
.pagination a { padding: 3px 5px; text-decoration: none; }
|
264
|
+
.pagination a:hover { background: #000; color: #FFF; }
|
265
265
|
|
266
|
-
|
266
|
+
.pagination span.disabled { color: #D3D3D3; margin: 2px; padding: 2px 3px; }
|
267
267
|
|
268
|
-
|
269
|
-
|
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 = "← " + _t("Previous")
|
7
|
+
next_label = _t("Next") + " →"
|
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
data/lib/typus.rb
CHANGED
data/typus.gemspec
CHANGED
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: -
|
4
|
+
hash: -1637175938
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
version: 1.0.0.
|
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:
|
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:
|
30
|
+
hash: 31098121
|
31
31
|
segments:
|
32
|
+
- 3
|
32
33
|
- 0
|
33
|
-
|
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 = ("← " + _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") + " →").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>
|