recordselect 3.1.3 → 3.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,12 +6,12 @@ prev_url = url_for(pagination_url_params.merge(:page => page.prev.number, :escap
6
6
  next_url = url_for(pagination_url_params.merge(:page => page.next.number, :escape => false)) if page.next?
7
7
  -%>
8
8
  <ol>
9
- <li class="found"><%= rs_("%d %s found", page.pager.count,
10
- record_select_config.model.to_s.pluralize.titleize.downcase) %></li>
9
+ <li class="found"><%= rs_(:records_found, :count => page.pager.count,
10
+ :model => record_select_config.model.model_name.human(:count => page.pager.count).downcase) %></li>
11
11
  <% if page.prev? -%>
12
12
  <li class="pagination previous">
13
- <%= link_to image_tag('record_select/previous.gif', :alt => rs_('Previous')) + " " + rs_("Previous %d",
14
- page.pager.per_page),
13
+ <%= link_to image_tag('record_select/previous.gif', :alt => rs_(:previous)) + " " + rs_(:previous_items,
14
+ :count => page.pager.per_page),
15
15
  {:url => prev_url},
16
16
  {:href => prev_url, :method => :get, :remote => true} %>
17
17
  </li>
@@ -23,7 +23,7 @@ page.pager.per_page),
23
23
  <% end -%>
24
24
  <% if page.next? -%>
25
25
  <li class="pagination next">
26
- <%= link_to (rs_("Next %d", page.pager.per_page) + " " + image_tag('record_select/next.gif', :alt => rs_('Next'))).html_safe,
26
+ <%= link_to (rs_(:next_items, :count => page.pager.per_page) + " " + image_tag('record_select/next.gif', :alt => rs_(:next))).html_safe,
27
27
  {:url => next_url},
28
28
  {:href => next_url, :method => :get, :remote => true} %>
29
29
  </li>
@@ -0,0 +1,31 @@
1
+ <%
2
+ controller ||= params[:controller]
3
+
4
+ pagination_url_params = params.merge(:controller => controller, :action => :browse, :search => params[:search], :update => 1)
5
+ prev_url = url_for(pagination_url_params.merge(:page => page.prev.number, :escape => false)) if page.prev?
6
+ next_url = url_for(pagination_url_params.merge(:page => page.next.number, :escape => false)) if page.next?
7
+ -%>
8
+ <ol>
9
+ <li class="found"><%= rs_(:records_found, :count => page.pager.count,
10
+ :model => record_select_config.model.model_name.human.downcase) %></li>
11
+ <% if page.prev? -%>
12
+ <li class="pagination previous">
13
+ <%= link_to image_tag('record_select/previous.gif', :alt => rs_(:previous)) + " " + rs_(:previous_items,
14
+ :count => page.pager.per_page),
15
+ {:url => prev_url},
16
+ {:href => prev_url, :method => :get, :remote => true} %>
17
+ </li>
18
+ <% end -%>
19
+ <% page.items.each do |record| -%>
20
+ <li class="record <%= cycle 'odd', 'even' %>" id="rs<%= record.id -%>">
21
+ <%= render_record_in_list(record, controller) %>
22
+ </li>
23
+ <% end -%>
24
+ <% if page.next? -%>
25
+ <li class="pagination next">
26
+ <%= link_to (rs_(:next_items, :count => page.pager.per_page) + " " + image_tag('record_select/next.gif', :alt => rs_(:next))).html_safe,
27
+ {:url => next_url},
28
+ {:href => next_url, :method => :get, :remote => true} %>
29
+ </li>
30
+ <% end -%>
31
+ </ol>
@@ -4,7 +4,7 @@ module RecordSelect
4
4
  # params => [:page, :search]
5
5
  def browse
6
6
  conditions = record_select_conditions
7
- klass = record_select_config.model
7
+ klass = record_select_model
8
8
  @count = klass.count(:conditions => conditions, :include => record_select_includes)
9
9
  pager = ::Paginator.new(@count, record_select_config.per_page) do |offset, per_page|
10
10
  klass.find(:all, :offset => offset,
@@ -34,7 +34,7 @@ module RecordSelect
34
34
  # :method => :post
35
35
  # params => [:id]
36
36
  def select
37
- klass = record_select_config.model
37
+ klass = record_select_model
38
38
  record = klass.find(params[:id])
39
39
  if record_select_config.notify.is_a? Proc
40
40
  record_select_config.notify.call(record)
@@ -65,4 +65,8 @@ module RecordSelect
65
65
  "record_select"
66
66
  end
67
67
  end
68
+
69
+ def record_select_model
70
+ record_select_config.model
71
+ end
68
72
  end
@@ -2,7 +2,12 @@
2
2
  # to localize RS, you need to override this method and route it to your
3
3
  # own system.
4
4
  class Object
5
- def rs_(string_to_localize, *args)
6
- args.empty? ? string_to_localize : (sprintf string_to_localize, *args)
5
+ def rs_(key, options = {})
6
+ unless key.blank?
7
+ text = I18n.translate "#{key}", {:scope => [:record_select], :default => key.is_a?(String) ? key : key.to_s.titleize}.merge(options)
8
+ # text = nil if text.include?('translation missing:')
9
+ end
10
+ text ||= key
11
+ text
7
12
  end
8
13
  end
@@ -0,0 +1,14 @@
1
+ # Provides a simple pass-through localizer for RecordSelect. If you want
2
+ # to localize RS, you need to override this method and route it to your
3
+ # own system.
4
+ class Object
5
+ def rs_(string_to_localize, *args)
6
+ args.empty? ? string_to_localize : (sprintf string_to_localize, *args)
7
+ unless key.blank?
8
+ text = I18n.translate "#{key}", {:scope => [:record_select], :default => key.is_a?(String) ? key : key.to_s.titleize}.merge(options)
9
+ # text = nil if text.include?('translation missing:')
10
+ end
11
+ text ||= key
12
+ text
13
+ end
14
+ end
@@ -2,7 +2,7 @@ module RecordSelect
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- PATCH = 3
5
+ PATCH = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recordselect
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 3
10
- version: 3.1.3
9
+ - 4
10
+ version: 3.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sergio Cambra
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-11-09 00:00:00 Z
20
+ date: 2011-11-11 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -92,6 +92,7 @@ files:
92
92
  - app/views/record_select/_search.html.erb
93
93
  - app/views/record_select/browse.js.erb
94
94
  - app/views/record_select/_browse.html.erb
95
+ - app/views/record_select/_list.html.erb~
95
96
  - app/assets/images/record_select/cross.gif
96
97
  - app/assets/images/record_select/next.gif
97
98
  - app/assets/images/record_select/previous.gif
@@ -110,6 +111,7 @@ files:
110
111
  - lib/record_select/extensions/active_record.rb
111
112
  - lib/record_select/extensions/localization.rb
112
113
  - lib/record_select/extensions/routing_mapper.rb
114
+ - lib/record_select/extensions/localization.rb~
113
115
  - lib/record_select/helpers/record_select_helper.rb
114
116
  - lib/record_select/helpers/record_select_helper.rb~
115
117
  - lib/record_select/version.rb