g_already_grid 1.0.8 → 1.0.9

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/History.txt CHANGED
@@ -1,8 +1,15 @@
1
+ == 1.0.9 2010-05-17
2
+
3
+ * Removed the :actions option as it is rarely used and noisy to the code base.
4
+ * Added a :proc_path option help in overriding link path for each grid row.
5
+
6
+
1
7
  == 1.0.8 2010-05-09
2
8
 
3
9
  * Updated the generator to be Rails 3 compliant.
4
10
  * Updated component to work with Rails 3.
5
11
 
12
+
6
13
  == 1.0.7 2009-10-27
7
14
 
8
15
  * Added a use_polymorphic_path option to the grid view helper to enable the polymorphic path helper to determine the path of
@@ -10,6 +17,7 @@
10
17
  to generate show links that are correctly pathed to the specific type (not the base class).
11
18
  * Added :use_sti_base_index option to allow the base STI class' index to be used in lieu of the specific STI class.
12
19
 
20
+
13
21
  == 1.0.5 2009-10-27
14
22
 
15
23
  * Added :clickable option to avoid creating link to show from table rows.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.8
1
+ 1.0.9
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{g_already_grid}
8
- s.version = "1.0.8"
8
+ s.version = "1.0.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["C. Jason Harrelson (midas)"]
12
- s.date = %q{2010-05-09}
12
+ s.date = %q{2010-05-17}
13
13
  s.description = %q{A Guilded Rails component that generates a rich grid control from an ActiveRecord.}
14
14
  s.email = %q{jason@lookforwardenterprises.com}
15
15
  s.extra_rdoc_files = [
@@ -4,7 +4,7 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  require 'g_already_grid/view_helpers'
5
5
 
6
6
  module GAlreadyGrid
7
- VERSION = '1.0.8'
7
+ VERSION = '1.0.9'
8
8
  end
9
9
 
10
10
  if defined?( ActionView::Base )
@@ -5,7 +5,6 @@
5
5
  <% if options[:checkboxes] %>
6
6
  <th class="chkBox"><input type="checkbox" class="<%= options[:check_all_class] %>" /></th>
7
7
  <% end %>
8
- <% unless options[:actions].empty? %><th>Actions</th><% end %>
9
8
  <% options[:col_titles].each_with_index do |col, i| %>
10
9
  <th><%= sort_by.include?( options[:cols][i].to_sym ) ? sortable_header( col, options[:cols][i], path_helpers[:index_rest_helper], path_helpers[:index_rest_args], controller, options ) : col %></th>
11
10
  <% end %>
@@ -19,14 +18,6 @@
19
18
  <% if options[:checkboxes] %>
20
19
  <td class="chkBox"><input type="checkbox" class="<%= options[:checkbox_class] %>" name="<%= record.class.to_s.tableize %>[<%= record.id %>]" /></td>
21
20
  <% end %>
22
- <% unless options[:actions].empty? %>
23
- <td>
24
- <%= link_to 'show', controller.send( path_helpers[:show_rest_helper], *(path_helpers[:show_rest_args] + record_array) ) if options[:actions].include?( :show ) %>
25
- <%= link_to 'edit', controller.send( path_helpers[:edit_rest_helper], *(path_helpers[:edit_rest_args] + record_array) ) if options[:actions].include?( :edit ) %>
26
- <%= link_to( 'del', controller.send( path_helpers[:delete_rest_helper], *(path_helpers[:edit_rest_args] + record_array) ),
27
- :method => :delete, :confirm => options[:del_confirmation] ) if options[:actions].include?( :edit ) %>
28
- </td>
29
- <% end %>
30
21
  <% options[:cols].each do |col|
31
22
  translate_method = "translate_#{col}".to_sym
32
23
 
@@ -46,13 +37,9 @@
46
37
  end %>
47
38
  <td>
48
39
  <% cell_args = path_helpers[:show_rest_args] + record_array %>
49
- <% if options[:actions].empty? && options[:clickable] == true %>
50
- <% if options[:use_polymorphic_path] == true
51
- cell_args.insert( 0, options[:namespace] ) -%>
52
- <%= link_to record_val, controller.polymorphic_path( cell_args ) %>
53
- <% else -%>
54
- <%= link_to( record_val, controller.send( path_helpers[:show_rest_helper], *cell_args ) ) %>
55
- <% end -%>
40
+ <% if options[:clickable] == true %>
41
+ <% cell_args.insert( 0, options[:namespace] ) unless options[:namespace].blank? -%>
42
+ <%= link_to( record_val, path_proc.call( *cell_args ) ) %>
56
43
  <% else %>
57
44
  <%= link_to( record_val, "javascript:void(0)" ) %>
58
45
  <% end %>
@@ -62,11 +49,7 @@
62
49
  <% end %>
63
50
  </tbody>
64
51
  <tfoot>
65
- <tr>
66
- <td colspan="<%= options[:total_columns].to_s %>">
67
- <% if do_paginate %><p><%= will_paginate( ar_col ) %></p><p><%= page_entries_info( ar_col ) %></p><% end %>
68
- </td>
69
- </tr>
52
+ <%= g_already_grid_footer_contents( ar_col, options ) %>
70
53
  </tfoot>
71
54
  </table>
72
55
  </div>
@@ -18,15 +18,10 @@ module GAlreadyGrid
18
18
  # +exclude_css+ A boolean indicating if Guilded should create a stylesheet inlcude tag for
19
19
  # this element. Defaults to false.
20
20
  # +empty_msg+ a message to display when the ar_col is empty or nil. Defaults to 'No matching records'.
21
- # +actions+ Action links to include in the action column of grid. A boolean or Array of symbols. When
22
- # boolean, if true, add show, edit and delete actions. When boolean, if false, hide actions column.
23
- # When Array of symbols, add only actions present in array.
24
21
  # +paginate+ A boolean indicating whether to output pagination controls. Defaults to
25
22
  # true. Utilizes will_paginate plugin features.
26
23
  # +polymorphic_type+ The type of this polymorphic record. Should be a string representing the class name.
27
24
  # +polymorphic_as+ The as used for the polymorphic type. Can be a symbol or string.
28
- # +use_polymorphic_path+ When true, uses the polymorphic path helper to determine the AR objects path from it's type (STI),
29
- # otherwise, does not. Defaults to false.
30
25
  # +use_sti_base_index+ When true, use the STI base class' index path instead of the specific descendant AR object's.
31
26
  # +namespace+ A string or symbol that is the namespace this collection is under.
32
27
  # +scoped_by+ The active record object that the objects in the ar_col is scoped by.
@@ -76,12 +71,6 @@ module GAlreadyGrid
76
71
  end
77
72
  sort_by = Array.new unless sort_by
78
73
 
79
- if options[:actions].is_a?( TrueClass )
80
- options[:actions] = [ :show, :edit, :delete ]
81
- elsif options[:actions].nil?
82
- options[:actions] = []
83
- end
84
-
85
74
  # Resolve pagination
86
75
  do_paginate = true
87
76
  begin
@@ -97,16 +86,23 @@ module GAlreadyGrid
97
86
  end
98
87
 
99
88
  options[:checkboxes] = true if options[:checkboxes].nil?
100
-
101
- controller = self if Rails.version.split('.').first.to_i > 2
89
+
90
+ controller = self if Rails.version.split('.').first.to_i > 2
91
+ if options[:path_proc]
92
+ path_proc = options[:path_proc]
93
+ else
94
+ path_proc = Proc.new { |*args| controller.polymorphic_path( args ) }
95
+ end
96
+
102
97
  total_columns = options[:cols].size
103
98
  total_columns = total_columns + 1 if options[:checkboxes]
104
- total_columns = total_columns + 1 unless options[:actions].empty?
105
99
  options[:total_columns] = total_columns
100
+ options[:do_paginate] = do_paginate
101
+ options[:path_helpers] = path_helpers
106
102
 
107
103
  vars = {
108
- :options => options, :ar_col => ar_col, :do_paginate => do_paginate, :sort_by => sort_by, :path_helpers => path_helpers,
109
- :controller => controller
104
+ :options => options, :ar_col => ar_col, :sort_by => sort_by, :path_helpers => path_helpers,
105
+ :controller => controller, :path_proc => path_proc
110
106
  }
111
107
 
112
108
  @g_already_grid_options = options
@@ -114,6 +110,15 @@ module GAlreadyGrid
114
110
  full_path = "#{path}/templates/guilded.already_grid.html.erb"
115
111
  self.render( :file => full_path, :use_full_path => false, :locals => vars )
116
112
  end
113
+
114
+ def g_already_grid_footer_contents( ar_col, options={} )
115
+ footer = "<tr><td colspan=\"#{options[:total_columns].to_s}\">"
116
+ if options[:do_paginate]
117
+ footer << "<p>#{will_paginate( ar_col )}</p><p>#{page_entries_info( ar_col )}</p>"
118
+ end
119
+ footer << "</td></tr>"
120
+ raw footer
121
+ end
117
122
 
118
123
  private
119
124
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 8
9
- version: 1.0.8
8
+ - 9
9
+ version: 1.0.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - C. Jason Harrelson (midas)
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-09 00:00:00 -05:00
17
+ date: 2010-05-17 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency