g_already_grid 1.0.5

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/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .* # Ignore all dotfiles...
2
+ !.gitignore # except for .gitignore
3
+ pkg/*
data/History.txt ADDED
@@ -0,0 +1,31 @@
1
+ 1.0.5 2009-10-27
2
+
3
+ * Added :clickable option to avoid creating link to show from table rows.
4
+
5
+
6
+ 1.0.4 2009-03-26
7
+
8
+ * Refactored to utilize the REST path helper resolution available in Guilded 0.1.9
9
+ * Added multi level scoped by option
10
+ * Added namespace option
11
+
12
+
13
+ == 1.0.3 2009-03-18
14
+
15
+ * Fixed issue with sorting links not obeying polymorphism
16
+
17
+
18
+ == 1.0.1
19
+
20
+ * Fixed issue with scoping and shallow default setup
21
+
22
+
23
+ == 1.0.0 2009-03-13
24
+
25
+ * Fixed problem with grid when collection passed to it is nil or empty
26
+ * Added :empty_msg option to override the default empty message
27
+
28
+
29
+ == 1.0.0 2009-03-12
30
+
31
+ * Initial release (ported form plugin)
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2009 C. Jason Harrelson (midas)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,84 @@
1
+ = g_already_grid
2
+
3
+ http://github.com/midas/g_already_grid/tree/master
4
+
5
+
6
+ == DESCRIPTION:
7
+
8
+ A Guilded (http://github.com/midas/guilded/tree/master) Rails component that generates a rich grid control from an
9
+ ActiveRecord collection.
10
+
11
+
12
+ == FEATURES:
13
+
14
+ * Easily generate a rich grid from an ActiveRecord collection
15
+ * Can integrate with mislav-will_paginate to provide paging controls
16
+ * Can generate sorting links in headers
17
+ * Can do a check box column for multi-selecting
18
+ * Automatically renders a check all and adds check all behavior if check box column option
19
+
20
+
21
+ == INSTALL:
22
+
23
+ sudo gem install midas-g_already_grid
24
+
25
+ In Rails environemnt.rb file:
26
+
27
+ config.gem 'midas-g_already_grid', :version => '1.0.2', :lib => 'g_already_grid', :source => 'http://gems.github.com'
28
+
29
+ Generate:
30
+
31
+ script/generate already_grid_assets_generator
32
+
33
+
34
+ == USAGE:
35
+
36
+ Simplest case:
37
+
38
+ <%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active] %>
39
+
40
+ Add sorting (by name column only):
41
+
42
+ <%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active], :sort => [:name] %>
43
+
44
+ Add scoping for nested models (deeply nested):
45
+
46
+ <%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active], :sort => [:name],
47
+ :scoped_by => @account %>
48
+
49
+ Add shallow argument to use shallow nesting:
50
+
51
+ <%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active], :sort => [:name],
52
+ :scoped_by => @account, :shallow => true %>
53
+
54
+
55
+ == REQUIREMENTS:
56
+
57
+ * Rails >= 2.2.0
58
+ * Guilded >= 0.1.4 (http://github.com/midas/guilded/tree/master)
59
+
60
+
61
+ == LICENSE:
62
+
63
+ (The MIT License)
64
+
65
+ Copyright (c) 2009 C. Jason Harrelson (midas)
66
+
67
+ Permission is hereby granted, free of charge, to any person obtaining
68
+ a copy of this software and associated documentation files (the
69
+ 'Software'), to deal in the Software without restriction, including
70
+ without limitation the rights to use, copy, modify, merge, publish,
71
+ distribute, sublicense, and/or sell copies of the Software, and to
72
+ permit persons to whom the Software is furnished to do so, subject to
73
+ the following conditions:
74
+
75
+ The above copyright notice and this permission notice shall be
76
+ included in all copies or substantial portions of the Software.
77
+
78
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
79
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
80
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
81
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
82
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
83
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
84
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "g_already_grid"
8
+ gem.summary = %Q{A Guilded Rails component that generates a rich grid control from an ActiveRecord.}
9
+ gem.description = %Q{A Guilded Rails component that generates a rich grid control from an ActiveRecord.}
10
+ gem.email = "jason@lookforwardenterprises.com"
11
+ gem.homepage = "http://github.com/midas/g_already_grid"
12
+ gem.authors = ["C. Jason Harrelson (midas)"]
13
+ gem.add_development_dependency "shoulda", ">= 2.10.2"
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/*_test.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/*_test.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+ task :test => :check_dependencies
41
+
42
+ task :default => :test
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ if File.exist?('VERSION')
47
+ version = File.read('VERSION')
48
+ else
49
+ version = ""
50
+ end
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "test #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.5
@@ -0,0 +1,62 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{g_already_grid}
8
+ s.version = "1.0.5"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["C. Jason Harrelson (midas)"]
12
+ s.date = %q{2009-10-27}
13
+ s.description = %q{A Guilded Rails component that generates a rich grid control from an ActiveRecord.}
14
+ s.email = %q{jason@lookforwardenterprises.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ "History.txt",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "g_already_grid.gemspec",
26
+ "lib/g_already_grid.rb",
27
+ "lib/g_already_grid/templates/guilded.already_grid.html.erb",
28
+ "lib/g_already_grid/view_helpers.rb",
29
+ "rails_generators/already_grid_assets/already_grid_assets_generator.rb",
30
+ "rails_generators/already_grid_assets/templates/default.css",
31
+ "rails_generators/already_grid_assets/templates/gridHeadBg.gif",
32
+ "rails_generators/already_grid_assets/templates/gridSort.gif",
33
+ "rails_generators/already_grid_assets/templates/gridSortAsc.gif",
34
+ "rails_generators/already_grid_assets/templates/gridSortDesc.gif",
35
+ "rails_generators/already_grid_assets/templates/guilded.already_grid.js",
36
+ "rails_generators/already_grid_assets/templates/guilded.already_grid.min.js",
37
+ "rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.js",
38
+ "rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.min.js",
39
+ "script/console",
40
+ "script/destroy",
41
+ "script/generate",
42
+ "tasks/rspec.rake"
43
+ ]
44
+ s.homepage = %q{http://github.com/midas/g_already_grid}
45
+ s.rdoc_options = ["--charset=UTF-8"]
46
+ s.require_paths = ["lib"]
47
+ s.rubygems_version = %q{1.3.5}
48
+ s.summary = %q{A Guilded Rails component that generates a rich grid control from an ActiveRecord.}
49
+
50
+ if s.respond_to? :specification_version then
51
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
+ s.specification_version = 3
53
+
54
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
55
+ s.add_development_dependency(%q<shoulda>, [">= 2.10.2"])
56
+ else
57
+ s.add_dependency(%q<shoulda>, [">= 2.10.2"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<shoulda>, [">= 2.10.2"])
61
+ end
62
+ end
@@ -0,0 +1,67 @@
1
+ <div class="<%= options[:grid_class] %>" id="<%= options[:id] %>">
2
+ <table cellspacing="0" cellpadding="0">
3
+ <thead>
4
+ <tr>
5
+ <% if options[:checkboxes] %>
6
+ <th class="chkBox"><input type="checkbox" class="<%= options[:check_all_class] %>" /></th>
7
+ <% end %>
8
+ <% unless options[:actions].empty? %><th>Actions</th><% end %>
9
+ <% options[:col_titles].each_with_index do |col, i| %>
10
+ <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] ) : col %></th>
11
+ <% end %>
12
+ <th class="right"></th>
13
+ </tr>
14
+ </thead>
15
+ <tbody>
16
+ <% ar_col.each do |record| %>
17
+ <% record_array = Array.new << record %>
18
+ <tr class="<%= cycle( 'even', 'odd' ) %>">
19
+ <% if options[:checkboxes] %>
20
+ <td class="chkBox"><input type="checkbox" class="<%= options[:checkbox_class] %>" name="<%= record.class.to_s.tableize %>[<%= record.id %>]" /></td>
21
+ <% 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
+ <% options[:cols].each do |col|
31
+ translate_method = "translate_#{col}".to_sym
32
+
33
+ if options[:polymorphic_as] && col.to_s.include?( options[:polymorphic_as].to_s )
34
+ col_name = col.to_s.gsub( /#{options[:polymorphic_as]}_/, "" )
35
+ col_val = record.send( options[:polymorphic_as].to_sym ).send( col_name.to_sym )
36
+ else
37
+ col_val = record.send( col.to_sym )
38
+ end
39
+
40
+ if col_val.is_a?( Time )
41
+ record_val = col_val.to_formatted_s( options[:date_format].to_sym )
42
+ elsif respond_to?( translate_method )
43
+ record_val = send( translate_method, col_val )
44
+ else
45
+ record_val = col_val.to_s
46
+ end %>
47
+ <td>
48
+ <% cell_args = path_helpers[:show_rest_args] + record_array %>
49
+ <% if options[:actions].empty? && options[:clickable] == true %>
50
+ <%= link_to( record_val, @controller.send( path_helpers[:show_rest_helper], *cell_args ) ) %>
51
+ <% else %>
52
+ <%= link_to( record_val, "javascript:void(0)" ) %>
53
+ <% end %>
54
+ </td>
55
+ <% end %>
56
+ <td class="right"></td>
57
+ <% end %>
58
+ </tbody>
59
+ <tfoot>
60
+ <tr>
61
+ <td colspan="<%= options[:total_columns].to_s %>">
62
+ <% if do_paginate %><p><%= will_paginate( ar_col ) %></p><p><%= page_entries_info( ar_col ) %></p><% end %>
63
+ </td>
64
+ </tr>
65
+ </tfoot>
66
+ </table>
67
+ </div>
@@ -0,0 +1,158 @@
1
+ module GAlreadyGrid
2
+ module ViewHelpers
3
+
4
+ # GUIlded element. This is a grid that is utilizing the already grid jQuery plugin. It is
5
+ # a progressively enhanced table.
6
+ #
7
+ # *parameters*
8
+ # ar_col:: (required) An ActiveRecord collection.
9
+ # options:: As follows.
10
+ #
11
+ # *options*
12
+ # id:: (required) The id of the element. Must be unique on the page.
13
+ # cols:: (required) An array of column names to include in the table. Each position of
14
+ # the array can be a symbol, string, or hash with 1 entry. The hash entry is the
15
+ # database field name as a key and the name to use in the gird as the value. Each
16
+ # key and value in the hash can be a symbol or string.
17
+ # skin:: The name of the skin to use for this Guilded element. Defaults to default => which is default.css.
18
+ # exclude_css:: A boolean indicating if Guilded should create a stylesheet inlcude tag for
19
+ # this element. Defaults to false.
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
+ # paginate:: A boolean indicating whether to output pagination controls. Defaults to
25
+ # true. Utilizes will_paginate plugin features.
26
+ # polymorphic_type:: The type of this polymorphic record. Should be a string representing the class name.
27
+ # polymorphic_as:: The as used for the polymorphic type. Can be a symbol or string.
28
+ # namespace::
29
+ # scoped_by::
30
+ # shallow::
31
+ # clickable:: Set to false in order to avoid rows linking to show action.
32
+ #
33
+ def g_already_grid( ar_col, *args )
34
+ options = args.extract_options!
35
+ raise ArgumentError, "'cols' option required" unless options.include?( :cols )
36
+ raise ArgumentError, "'cols' option must be an array of columns" unless options[:cols].is_a? Array
37
+
38
+ Guilded::Guilder.instance.add( :already_grid, options, [ 'jquery/jquery-already_grid-0.1.min.js' ] )
39
+
40
+ return "<span class=\"list-empty-msg\">#{options[:empty_msg] || 'No matching records'}</span>" if ar_col.nil? || ar_col.empty?
41
+
42
+ options[:grid_class] ||= 'already-grid'
43
+ options[:checkbox_class] ||= "chk"
44
+ options[:check_all_class] ||= "checkAll"
45
+ options[:date_format] ||= :default
46
+ options[:del_confirmation] ||= 'Are you sure you would like to delete this record?'
47
+ options[:clickable] = true if options[:clickable].nil?
48
+
49
+ options[:cols], options[:col_titles] = Guilded::Rails::Helpers.resolve_field_methods_and_titles( options[:cols], ar_col[0] )
50
+ path_helpers = Guilded::Rails::Helpers.resolve_rest_path_helpers( ar_col, options )
51
+
52
+ scoped_by = options.delete( :scoped_by )
53
+
54
+ # Resolve sorting
55
+ if options[:sort]
56
+ if options[:sort].is_a?( Array )
57
+ sort_by = options[:sort].map { |a| a.to_sym }
58
+ elsif options[:sort].is_a?( Symbol ) || options[:sort].is_a?( String )
59
+ sort_by = Array.new << options[:sort].to_sym
60
+ else
61
+ throw "Option 'sort' must be a string, symbol or an array of strings or symbols."
62
+ end
63
+ end
64
+ sort_by = Array.new unless sort_by
65
+
66
+ if options[:actions].is_a?( TrueClass )
67
+ options[:actions] = [ :show, :edit, :delete ]
68
+ elsif options[:actions].nil?
69
+ options[:actions] = []
70
+ end
71
+
72
+ # Resolve pagination
73
+ do_paginate = true
74
+ begin
75
+ if options[:paginate] == false || options[:paginate] == 'false'
76
+ do_paginate = false
77
+ end
78
+ rescue => e
79
+ if e.is_a? NoMethodError # This just means no will_paginate methods are present.
80
+ do_paginate = false
81
+ else
82
+ throw e
83
+ end
84
+ end
85
+
86
+ options[:checkboxes] = true if options[:checkboxes].nil?
87
+
88
+ total_columns = options[:cols].size
89
+ total_columns = total_columns + 1 if options[:checkboxes]
90
+ total_columns = total_columns + 1 unless options[:actions].empty?
91
+ options[:total_columns] = total_columns
92
+
93
+ vars = {
94
+ :options => options, :ar_col => ar_col, :do_paginate => do_paginate, :sort_by => sort_by, :path_helpers => path_helpers
95
+ }
96
+
97
+ path = File.dirname(__FILE__)
98
+ full_path = "#{path}/templates/guilded.already_grid.html.erb"
99
+ self.render( :file => full_path, :use_full_path => false, :locals => vars )
100
+ end
101
+
102
+ private
103
+
104
+ # Creates a link to sort this column of a table. Utilizes the link_to helper,
105
+ # but resolves sort by, direction and adds correct CSS classes for UI elements to
106
+ # be displayed.
107
+ #
108
+ # *parameters*
109
+ # name:: The text to use for the link
110
+ # method:: The actual name of this column's field.
111
+ # path:: (Symbol) The name of the path method to call from routing.
112
+ # options:: see link_to helper.
113
+ #
114
+ def sortable_header( name, method, path, scoping_args, options={} )
115
+
116
+ is_sorted_link = ( method.to_s == params[:order].to_s )
117
+
118
+ if is_sorted_link
119
+ if params[:direction] == "ASC"
120
+ options.merge! :class => "sort-asc"
121
+ elsif params[:direction] == "DESC"
122
+ options.merge! :class => "sort-desc"
123
+ end
124
+ end
125
+
126
+ direction = "ASC"
127
+ direction = "DESC" if params[:direction] == "ASC"
128
+
129
+ sort_options = { :order => method, :direction => direction }
130
+ sort_options.merge!( :filter => params[:filter] ) if params[:filter]
131
+ unsorted_options = { :order => method, :direction => 'ASC' } # always sort ascending on first sort
132
+ unsorted_options.merge!( :filter => params[:filter] ) if params[:filter]
133
+
134
+ path = path.to_sym unless path.is_a?( Symbol )
135
+ path_args = Array.new + scoping_args
136
+
137
+ if is_sorted_link
138
+ # Handle the currently sorted by link
139
+ path_args << sort_options
140
+ path = @controller.send( path, *path_args )
141
+ else
142
+ # Handle the the other currently unsorted by links (we will always sort in
143
+ # an ASC direction the first time)
144
+ path_args << unsorted_options
145
+ path = @controller.send( path, *path_args )
146
+ end
147
+ #end
148
+
149
+ # Load the params to an args array to send to the link_to helper
150
+ args = Array.new
151
+ args << name << path << options
152
+
153
+ link_to( *args )
154
+
155
+ end
156
+
157
+ end
158
+ end
@@ -0,0 +1,12 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'g_already_grid/view_helpers'
5
+
6
+ module GAlreadyGrid
7
+ VERSION = '1.0.5'
8
+ end
9
+
10
+ if defined?( ActionView::Base )
11
+ ActionView::Base.send( :include, GAlreadyGrid::ViewHelpers ) unless ActionView::Base.include?( GAlreadyGrid::ViewHelpers )
12
+ end
@@ -0,0 +1,22 @@
1
+ class AlreadyGridAssetsGenerator < Rails::Generator::Base
2
+ def initialize(runtime_args, runtime_options = {})
3
+ super
4
+ end
5
+
6
+ def manifest
7
+ record do |m|
8
+ m.file "guilded.already_grid.js", "public/javascripts/guilded.already_grid.js"
9
+ m.file "guilded.already_grid.min.js", "public/javascripts/guilded.already_grid.min.js"
10
+ m.directory "public/javascripts/jquery"
11
+ m.file "jquery-already_grid-0.1.js", "public/javascripts/jquery/jquery-already_grid-0.1.js"
12
+ m.file "jquery-already_grid-0.1.min.js", "public/javascripts/jquery/jquery-already_grid-0.1.min.js"
13
+ m.directory "public/stylesheets/guilded/already_grid"
14
+ m.directory "public/stylesheets/guilded/already_grid/default"
15
+ m.file "default.css", "public/stylesheets/guilded/already_grid/default.css"
16
+ m.file "gridHeadBg.gif", "public/stylesheets/guilded/already_grid/default/gridHeadBg.gif"
17
+ m.file "gridSort.gif", "public/stylesheets/guilded/already_grid/default/gridSort.gif"
18
+ m.file "gridSortAsc.gif", "public/stylesheets/guilded/already_grid/default/gridSortAsc.gif"
19
+ m.file "gridSortDesc.gif", "public/stylesheets/guilded/already_grid/default/gridSortDesc.gif"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,61 @@
1
+ .already-grid table {
2
+ width:100%;
3
+ position:relative;
4
+ top:0;
5
+ border-collapse:collapse !important;
6
+ }
7
+ .already-grid table thead {
8
+ text-align:left;
9
+ color:#636363;
10
+ background:url(/stylesheets/guilded/already_grid/default/gridHeadBg.gif) #e9e9e9 repeat-x;
11
+ font-weight:normal;
12
+ }
13
+ .already-grid table thead th {
14
+ padding:0.6em 0.75em;
15
+ border-top:1px solid #c2c2c2;
16
+ border-bottom:1px solid #c2c2c2;
17
+ border-right:1px solid #c2c2c2;
18
+ border-left-color:#c2c2c2;
19
+ white-space:nowrap;
20
+ font-size:0.7em;
21
+ }
22
+ .already-grid table tbody tr:hover a { color:#585858; }
23
+ .already-grid table tbody td {
24
+ border-bottom: 1px solid #e5e7f2;
25
+ border-right: 1px solid #e5e7f2;
26
+ font-size: 0.8em;
27
+ white-space: nowrap
28
+ }
29
+ .already-grid table tbody td a {
30
+ display: block;
31
+ padding: 0.5em 0.75em;
32
+ }
33
+ .already-grid table tfoot td {
34
+ padding: 0.75em;
35
+ text-align: center;
36
+ color: #898989;
37
+ font-size: 0.75em;
38
+ }
39
+ .already-grid table tbody .odd { background:#f0f5fa; }
40
+ .already-grid table tbody .selected { background:#029dd7; }
41
+ .already-grid table tbody .selected td a { color: white; }
42
+
43
+ .already-grid table th a {
44
+ color:#636363;
45
+ text-decoration: underline;
46
+ background: url(/stylesheets/guilded/already_grid/default/gridSort.gif) right no-repeat;
47
+ display: block;
48
+ padding-right: 10px;
49
+ }
50
+
51
+ .already-grid table th a:hover {color:black;}
52
+
53
+ .already-grid table .sort-asc {
54
+ background: url(/stylesheets/guilded/already_grid/default/gridSortAsc.gif) right no-repeat;
55
+ display: block;
56
+ }
57
+
58
+ .already-grid table .sort-desc {
59
+ background: url(/stylesheets/guilded/already_grid/default/gridSortDesc.gif) right no-repeat;
60
+ display: block;
61
+ }
@@ -0,0 +1,15 @@
1
+ /* Guilded Already Grid 1.0.0
2
+ * Copyright (c) 2009 C. Jason Harrelson (midas)
3
+ * Guilded Flash Growler is licensed under the terms of the MIT License */
4
+
5
+ g.alreadyGridInit = function( options )
6
+ {
7
+ if( g.beforeAlreadyGridInit )
8
+ g.beforeAlreadyGridInit( options );
9
+
10
+ var grid = $j( '#' + options.id );
11
+ grid.alreadyGrid( options );
12
+
13
+ if( g.afterAlreadyGridInit )
14
+ g.afterAlreadyGridInit( options );
15
+ };
@@ -0,0 +1,4 @@
1
+ /* Guilded Already 1.0.0
2
+ * Copyright (c) 2009 C. Jason Harrelson (midas)
3
+ * Guilded Flash Growler is licensed under the terms of the MIT License */
4
+ g.alreadyGridInit=function(options){if(g.beforeAlreadyGridInit)g.beforeAlreadyGridInit(options);var grid=$j('#'+options.id);grid.alreadyGrid(options);if(g.afterAlreadyGridInit)g.afterAlreadyGridInit(options);};
@@ -0,0 +1,66 @@
1
+ (function($){
2
+
3
+ jQuery.fn.alreadyGrid = function( /* Object literal */ options )
4
+ {
5
+ opts = $j.extend( $j.fn.alreadyGrid.defaults, options );
6
+
7
+ // Set up check box events
8
+ checkAllBox = $j( '.' + opts.check_all_class );
9
+ checkboxes = $j( '.' + opts.checkbox_class );
10
+ $j( 'document' ).ready( updateSelecteds );
11
+ checkAllBox.click( checkAllClicked );
12
+ checkboxes.click( checkboxClicked );
13
+
14
+ return jQuery;
15
+ }
16
+
17
+ /* *************** public *************** */
18
+
19
+ jQuery.fn.alreadyGrid.defaults =
20
+ {
21
+ paginate: true,
22
+ checkboxes: false,
23
+ checkbox_class: 'chk',
24
+ check_all_class: 'checkAll'
25
+ };
26
+
27
+ /* *************** private *************** */
28
+
29
+ checkAllClicked = function( /* jquery Event */ e )
30
+ {
31
+ if( $j( this ).is(':checked') )
32
+ {
33
+ //$j( '.' + opts.checkbox_class ).click();
34
+ checkboxes.attr( 'checked', true );
35
+ checkboxes.parent().parent().addClass( 'selected' );
36
+ }
37
+ else
38
+ {
39
+ checkboxes.attr( 'checked', false );
40
+ checkboxes.parent().parent().removeClass( 'selected' );
41
+ }
42
+ };
43
+
44
+ checkboxClicked = function( /* jquery Event */ e )
45
+ {
46
+ if( $j( this ).is(':checked') )
47
+ $j( this ).parent().parent().addClass( 'selected' );
48
+ else
49
+ {
50
+ $j( this ).parent().parent().removeClass( 'selected' );
51
+ if( checkAllBox.is(':checked') )
52
+ {
53
+ checkAllBox.attr( 'checked', false );
54
+ }
55
+ }
56
+ };
57
+
58
+ /* Used after load to update selected based on check boxes when the
59
+ * grid loads. */
60
+ updateSelecteds = function( /* jquery Event */ e )
61
+ {
62
+ var checkboxes = $j( "." + opts.checkbox_class + "[checked]");
63
+ checkboxes.parent().parent().addClass( 'selected' );
64
+ };
65
+
66
+ })(jQuery);
@@ -0,0 +1,66 @@
1
+ (function($){
2
+
3
+ jQuery.fn.alreadyGrid = function( /* Object literal */ options )
4
+ {
5
+ opts = $j.extend( $j.fn.alreadyGrid.defaults, options );
6
+
7
+ // Set up check box events
8
+ checkAllBox = $j( '.' + opts.check_all_class );
9
+ checkboxes = $j( '.' + opts.checkbox_class );
10
+ $j( 'document' ).ready( updateSelecteds );
11
+ checkAllBox.click( checkAllClicked );
12
+ checkboxes.click( checkboxClicked );
13
+
14
+ return jQuery;
15
+ }
16
+
17
+ /* *************** public *************** */
18
+
19
+ jQuery.fn.alreadyGrid.defaults =
20
+ {
21
+ paginate: true,
22
+ checkboxes: false,
23
+ checkbox_class: 'chk',
24
+ check_all_class: 'checkAll'
25
+ };
26
+
27
+ /* *************** private *************** */
28
+
29
+ checkAllClicked = function( /* jquery Event */ e )
30
+ {
31
+ if( $j( this ).is(':checked') )
32
+ {
33
+ //$j( '.' + opts.checkbox_class ).click();
34
+ checkboxes.attr( 'checked', true );
35
+ checkboxes.parent().parent().addClass( 'selected' );
36
+ }
37
+ else
38
+ {
39
+ checkboxes.attr( 'checked', false );
40
+ checkboxes.parent().parent().removeClass( 'selected' );
41
+ }
42
+ };
43
+
44
+ checkboxClicked = function( /* jquery Event */ e )
45
+ {
46
+ if( $j( this ).is(':checked') )
47
+ $j( this ).parent().parent().addClass( 'selected' );
48
+ else
49
+ {
50
+ $j( this ).parent().parent().removeClass( 'selected' );
51
+ if( checkAllBox.is(':checked') )
52
+ {
53
+ checkAllBox.attr( 'checked', false );
54
+ }
55
+ }
56
+ };
57
+
58
+ /* Used after load to update selected based on check boxes when the
59
+ * grid loads. */
60
+ updateSelecteds = function( /* jquery Event */ e )
61
+ {
62
+ var checkboxes = $j( "." + opts.checkbox_class + "[checked]");
63
+ checkboxes.parent().parent().addClass( 'selected' );
64
+ };
65
+
66
+ })(jQuery);
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/g_already_grid.rb'}"
9
+ puts "Loading g_already_grid gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
data/tasks/rspec.rake ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/**/*_spec.rb']
21
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: g_already_grid
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.5
5
+ platform: ruby
6
+ authors:
7
+ - C. Jason Harrelson (midas)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-27 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: shoulda
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.10.2
24
+ version:
25
+ description: A Guilded Rails component that generates a rich grid control from an ActiveRecord.
26
+ email: jason@lookforwardenterprises.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.rdoc
34
+ files:
35
+ - .gitignore
36
+ - History.txt
37
+ - README.rdoc
38
+ - Rakefile
39
+ - VERSION
40
+ - g_already_grid.gemspec
41
+ - lib/g_already_grid.rb
42
+ - lib/g_already_grid/templates/guilded.already_grid.html.erb
43
+ - lib/g_already_grid/view_helpers.rb
44
+ - rails_generators/already_grid_assets/already_grid_assets_generator.rb
45
+ - rails_generators/already_grid_assets/templates/default.css
46
+ - rails_generators/already_grid_assets/templates/gridHeadBg.gif
47
+ - rails_generators/already_grid_assets/templates/gridSort.gif
48
+ - rails_generators/already_grid_assets/templates/gridSortAsc.gif
49
+ - rails_generators/already_grid_assets/templates/gridSortDesc.gif
50
+ - rails_generators/already_grid_assets/templates/guilded.already_grid.js
51
+ - rails_generators/already_grid_assets/templates/guilded.already_grid.min.js
52
+ - rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.js
53
+ - rails_generators/already_grid_assets/templates/jquery-already_grid-0.1.min.js
54
+ - script/console
55
+ - script/destroy
56
+ - script/generate
57
+ - tasks/rspec.rake
58
+ - LICENSE
59
+ has_rdoc: true
60
+ homepage: http://github.com/midas/g_already_grid
61
+ licenses: []
62
+
63
+ post_install_message:
64
+ rdoc_options:
65
+ - --charset=UTF-8
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ requirements: []
81
+
82
+ rubyforge_project:
83
+ rubygems_version: 1.3.5
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: A Guilded Rails component that generates a rich grid control from an ActiveRecord.
87
+ test_files: []
88
+