aguids-positionable 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -110,7 +110,10 @@ You might not even need to touch this helper as there is even a higher level hel
110
110
  positionable_links(record)
111
111
  positionable_buttons(record)
112
112
 
113
- Both these helpers would output links/buttons for the move method if the record is on the list, or the insert methods otherwise.
113
+ Both these helpers would output links/buttons for the move method if the record is on the list, or the insert methods otherwise. If you would like to internationalize the links and buttons generated, just define translations for the actions under the positionable namespace:
114
+
115
+ positionable:
116
+ move_to_top: 'Top'
114
117
 
115
118
  ### ActiveRecord Named Scopes
116
119
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -29,15 +29,15 @@ module PositionableHelper
29
29
  def positionable_move(resource, list, interface)
30
30
  tag = "<ul class=\"positionable_#{interface}s\">"
31
31
  if resource.first?(list)
32
- tag << send("positionable_disabled_#{interface}", 'Move to top')
33
- tag << send("positionable_disabled_#{interface}", 'Move up')
32
+ tag << send("positionable_disabled_#{interface}", 'move_to_top')
33
+ tag << send("positionable_disabled_#{interface}", 'move_up')
34
34
  else
35
35
  tag << send("positionable_working_#{interface}", 'move_to_top', resource, list)
36
36
  tag << send("positionable_working_#{interface}", 'move_up', resource, list)
37
37
  end
38
38
  if resource.last?(list)
39
- tag << send("positionable_disabled_#{interface}", 'Move down')
40
- tag << send("positionable_disabled_#{interface}", 'Move to bottom')
39
+ tag << send("positionable_disabled_#{interface}", 'move_down')
40
+ tag << send("positionable_disabled_#{interface}", 'move_to_bottom')
41
41
  else
42
42
  tag << send("positionable_working_#{interface}", 'move_down', resource, list)
43
43
  tag << send("positionable_working_#{interface}", 'move_to_bottom', resource, list)
@@ -53,18 +53,22 @@ module PositionableHelper
53
53
  end
54
54
 
55
55
  def positionable_disabled_link(message)
56
- "<li class=\"positionable_disabled\">#{message}</li>"
56
+ "<li class=\"positionable_disabled\">#{positionable_internationalize(message)}</li>"
57
57
  end
58
58
 
59
59
  def positionable_working_link(action, resource, list)
60
- '<li>' << link_to(action.titleize, send("#{action}_path",resource,list), :method => :put) << '</li>'
60
+ '<li>' << link_to(positionable_internationalize(action), send("#{action}_path",resource,list), :method => :put) << '</li>'
61
61
  end
62
62
 
63
63
  def positionable_disabled_button(message)
64
- "<li>" << button_to(message, '/', :disabled => true) << "</li>"
64
+ "<li>" << button_to(positionable_internationalize(message), '/', :disabled => true) << "</li>"
65
65
  end
66
66
 
67
67
  def positionable_working_button(action, resource, list)
68
- "<li>" << button_to(action.titleize, send("#{action}_path",resource,list), :method => :put) << "</li>"
68
+ "<li>" << button_to(positionable_internationalize(action), send("#{action}_path",resource,list), :method => :put) << "</li>"
69
+ end
70
+
71
+ def positionable_internationalize(message)
72
+ I18n.t("positionable.#{message}", :default => message.titleize)
69
73
  end
70
74
  end
@@ -31,14 +31,14 @@ module Positionable
31
31
  self.positionable ||= Positionable::Wrapper.new
32
32
  self.positionable << options
33
33
 
34
- named_scope :ascending, lambda { |list_name|
35
- { :order => self.positionable.lists[list_name][:column] }
34
+ named_scope :ascending, lambda { |*list_name|
35
+ { :order => self.positionable.lists[list_name.first || :default][:column] }
36
36
  }
37
- named_scope :descending, lambda { |list_name|
38
- { :order => "#{self.positionable.lists[list_name][:column]} DESC" }
37
+ named_scope :descending, lambda { |*list_name|
38
+ { :order => "#{self.positionable.lists[list_name.first || :default][:column]} DESC" }
39
39
  }
40
- named_scope :conditions, lambda { |list_name|
41
- { :conditions => self.positionable.lists[list_name][:conditions] }
40
+ named_scope :conditions, lambda { |*list_name|
41
+ { :conditions => self.positionable.lists[list_name.first || :default][:conditions] }
42
42
  }
43
43
 
44
44
  class_eval <<-EOV
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{positionable}
5
- s.version = "0.2.1"
5
+ s.version = "0.2.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Felipe Doria"]
9
- s.date = %q{2009-07-10}
9
+ s.date = %q{2009-07-11}
10
10
  s.email = %q{felipe.doria@gmail.com}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
@@ -26,14 +26,14 @@ class PositionableHelperTest < ActionView::TestCase
26
26
 
27
27
  test "positionable links should disable move up and move to top if first?" do
28
28
  html = positionable_links(@item, :client)
29
- assert_match '<li class="positionable_disabled">Move to top', html
30
- assert_match '<li class="positionable_disabled">Move up', html
29
+ assert_match /<li class="positionable_disabled">Move to top/i, html
30
+ assert_match /<li class="positionable_disabled">Move up/i, html
31
31
  end
32
32
 
33
33
  test "positionable links should disable move down and move to bottom if last?" do
34
34
  html = positionable_links(@item, :client)
35
- assert_match '<li class="positionable_disabled">Move to bottom', html
36
- assert_match '<li class="positionable_disabled">Move down', html
35
+ assert_match /<li class="positionable_disabled">Move to bottom/i, html
36
+ assert_match /<li class="positionable_disabled">Move down/i, html
37
37
  end
38
38
 
39
39
  test "positionable links should return links for up and top if not first?" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aguids-positionable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Doria
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-10 00:00:00 -07:00
12
+ date: 2009-07-11 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15