ajax_scaffold_generator 3.1.9 → 3.1.10

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/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 3.1.10 ========
2
+
3
+ * Fixed bug with :class_name attribute being ignored
4
+
1
5
  3.1.9 =========
2
6
 
3
7
  * Fixed bug where generator was looking for images that are no longer used (error.gif, warning.gif, information.gif)
@@ -1,201 +1,201 @@
1
- require "rails_generator/generators/components/scaffold/scaffold_generator"
2
-
3
- class AjaxScaffoldingSandbox < ScaffoldingSandbox
4
- def default_input_block
5
- Proc.new { |record, column| "<div class=\"form-element\">\n <label for=\"#{record}_#{column.name}\">#{column.human_name}</label>\n #{input(record, column.name)}\n</div>\n" }
6
- end
7
-
8
- def all_input_tags(record, record_name, options)
9
- input_block = options[:input_block] || default_input_block
10
-
11
- if !options[:exclude].blank?
12
- filtered_content_columns = record.class.content_columns.reject { |column| options[:exclude].include?(column.name) }
13
- else
14
- filtered_content_columns = record.class.content_columns
15
- end
16
-
17
- filtered_content_columns.collect{ |column| input_block.call(record_name, column) }.join("\n")
18
- end
19
-
20
- end
21
-
22
- class ActionView::Helpers::InstanceTag
23
- alias_method :base_to_input_field_tag, :to_input_field_tag
24
-
25
- def to_input_field_tag(field_type, options={})
26
- options[:class] = 'text-input'
27
- base_to_input_field_tag field_type, options
28
- end
29
-
30
- def to_boolean_select_tag(options = {})
31
- options = options.stringify_keys
32
- add_default_name_and_id(options)
33
- tag_text = "<%= select \"#{@object_name}\", \"#{@method_name}\", [[\"True\", true], [\"False\", false]], { :selected => @#{@object_name}.#{@method_name} } %>"
34
- end
35
-
36
- end
37
-
38
- class AjaxScaffoldGenerator < ScaffoldGenerator
39
-
40
- alias_method :base_controller_file_path, :controller_file_path
41
-
42
- def controller_file_path
43
- "/" + base_controller_file_path
44
- end
45
-
46
- def manifest
47
-
48
- record do |m|
49
-
50
- # Check for class naming collisions.
51
- m.class_collisions controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}ControllerTest", "#{controller_class_name}Helper"
52
- m.class_collisions class_path, class_name, "#{singular_name}Test"
53
-
54
- # Model, controller, helper, views, and test directories.
55
- m.directory File.join('test/unit', class_path)
56
- m.directory File.join('test/fixtures', class_path)
57
- m.directory File.join('app/controllers', controller_class_path)
58
- m.directory File.join('app/helpers', controller_class_path)
59
- m.directory File.join('app/views', controller_class_path, controller_file_name)
60
- m.directory File.join('app/views/layouts', controller_class_path)
61
- m.directory File.join('public/images')
62
- m.directory File.join('test/functional', controller_class_path)
63
-
64
- # Model class, unit test, and fixtures.
65
- m.template 'model.rb', File.join('app/models', "#{singular_name}.rb")
66
- m.template 'unit_test.rb', File.join('test/unit', "#{singular_name}_test.rb")
67
- m.template 'fixtures.yml', File.join('test/fixtures', "#{table_name}.yml")
68
-
69
- # Scaffolded forms.
70
- m.complex_template 'form.rhtml',
71
- File.join('app/views',
72
- controller_class_path,
73
- controller_file_name,
74
- '_form.rhtml'),
75
- :insert => 'form_scaffolding.rhtml',
76
- :sandbox => lambda { create_sandbox },
77
- :begin_mark => 'form',
78
- :end_mark => 'eoform',
79
- :mark_id => singular_name
80
-
81
- # Scaffolded partials.
82
- m.template "partial_item.rhtml",
83
- File.join('app/views',
84
- controller_class_path,
85
- controller_file_name,
86
- "_#{singular_name}.rhtml")
87
-
88
- scaffold_partials.each do |name|
89
- m.template "partial_#{name}.rhtml",
90
- File.join('app/views',
91
- controller_class_path,
92
- controller_file_name,
93
- "_#{name}.rhtml")
94
- end
95
-
96
- # Scaffolded views.
97
- scaffold_views.each do |action|
98
- m.template "view_#{action}.rhtml",
99
- File.join('app/views',
100
- controller_class_path,
101
- controller_file_name,
102
- "#{action}.rhtml"),
103
- :assigns => { :action => action }
104
- end
105
-
106
- # RJS templates
107
- scaffold_rjs_templates.each do |template|
108
- m.template "rjs_#{template}.rjs",
109
- File.join('app/views',
110
- controller_class_path,
111
- controller_file_name,
112
- "#{template}.rjs")
113
- end
114
-
115
- # Libraries
116
- scaffold_lib.each do |filename|
117
- m.template "lib_#{filename}.rb",
118
- File.join('lib',
119
- "#{filename}.rb")
120
- end
121
-
122
- # Controller class, functional test, helper, and views.
123
- m.template 'controller.rb',
124
- File.join('app/controllers',
125
- controller_class_path,
126
- "#{controller_file_name}_controller.rb")
127
-
128
- m.template 'functional_test.rb',
129
- File.join('test/functional',
130
- controller_class_path,
131
- "#{controller_file_name}_controller_test.rb")
132
-
133
- m.template 'helper.rb',
134
- File.join('app/helpers',
135
- controller_class_path,
136
- "#{controller_file_name}_helper.rb")
137
-
138
- # Layout and stylesheet.
139
- m.template 'layout.rhtml',
140
- File.join('app/views/layouts',
141
- controller_class_path,
142
- "#{controller_file_name}.rhtml")
143
-
144
- m.template 'ajax_scaffold.css', "public/stylesheets/ajax_scaffold.css"
145
-
146
- scaffold_javascripts.each do |javascript|
147
- m.template javascript, "public/javascripts/#{javascript}"
148
- end
149
-
150
- scaffold_images.each do |image|
151
- m.template image, "public/images/#{image}"
152
- end
153
-
154
- end
155
- end
156
-
157
- protected
158
- # Override with your own usage banner.
159
- def banner
160
- "Usage: #{$0} ajax_scaffold ModelName [ControllerName]"
161
- end
162
-
163
- def scaffold_views
164
- %w( list component )
165
- end
166
-
167
- def scaffold_rjs_templates
168
- %w( create destroy edit new update cancel )
169
- end
170
-
171
- def scaffold_partials
172
- %w( form_messages messages column_headings new_edit pagination_links )
173
- end
174
-
175
- def scaffold_lib
176
- %w( ajax_scaffold )
177
- end
178
-
179
- def scaffold_images
180
- %w( indicator.gif indicator-small.gif add.gif arrow_down.gif arrow_up.gif )
181
- end
182
-
183
- def scaffold_javascripts
184
- %w( ajax_scaffold.js rico_corner.js )
185
- end
186
-
187
- def create_sandbox
188
- sandbox = AjaxScaffoldingSandbox.new
189
- sandbox.singular_name = singular_name
190
- begin
191
- sandbox.model_instance = model_instance
192
- sandbox.instance_variable_set("@#{singular_name}", sandbox.model_instance)
193
- rescue ActiveRecord::StatementInvalid => e
194
- logger.error "Before updating scaffolding from new DB schema, try creating a table for your model (#{class_name})"
195
- raise SystemExit
196
- end
197
- sandbox.suffix = suffix
198
- sandbox
199
- end
200
-
201
- end
1
+ require "rails_generator/generators/components/scaffold/scaffold_generator"
2
+
3
+ class AjaxScaffoldingSandbox < ScaffoldingSandbox
4
+ def default_input_block
5
+ Proc.new { |record, column| "<div class=\"form-element\">\n <label for=\"#{record}_#{column.name}\">#{column.human_name}</label>\n #{input(record, column.name)}\n</div>\n" }
6
+ end
7
+
8
+ def all_input_tags(record, record_name, options)
9
+ input_block = options[:input_block] || default_input_block
10
+
11
+ if !options[:exclude].blank?
12
+ filtered_content_columns = record.class.content_columns.reject { |column| options[:exclude].include?(column.name) }
13
+ else
14
+ filtered_content_columns = record.class.content_columns
15
+ end
16
+
17
+ filtered_content_columns.collect{ |column| input_block.call(record_name, column) }.join("\n")
18
+ end
19
+
20
+ end
21
+
22
+ class ActionView::Helpers::InstanceTag
23
+ alias_method :base_to_input_field_tag, :to_input_field_tag
24
+
25
+ def to_input_field_tag(field_type, options={})
26
+ options[:class] = 'text-input'
27
+ base_to_input_field_tag field_type, options
28
+ end
29
+
30
+ def to_boolean_select_tag(options = {})
31
+ options = options.stringify_keys
32
+ add_default_name_and_id(options)
33
+ tag_text = "<%= select \"#{@object_name}\", \"#{@method_name}\", [[\"True\", true], [\"False\", false]], { :selected => @#{@object_name}.#{@method_name} } %>"
34
+ end
35
+
36
+ end
37
+
38
+ class AjaxScaffoldGenerator < ScaffoldGenerator
39
+
40
+ alias_method :base_controller_file_path, :controller_file_path
41
+
42
+ def controller_file_path
43
+ "/" + base_controller_file_path
44
+ end
45
+
46
+ def manifest
47
+
48
+ record do |m|
49
+
50
+ # Check for class naming collisions.
51
+ m.class_collisions controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}ControllerTest", "#{controller_class_name}Helper"
52
+ m.class_collisions class_path, class_name, "#{singular_name}Test"
53
+
54
+ # Model, controller, helper, views, and test directories.
55
+ m.directory File.join('test/unit', class_path)
56
+ m.directory File.join('test/fixtures', class_path)
57
+ m.directory File.join('app/controllers', controller_class_path)
58
+ m.directory File.join('app/helpers', controller_class_path)
59
+ m.directory File.join('app/views', controller_class_path, controller_file_name)
60
+ m.directory File.join('app/views/layouts', controller_class_path)
61
+ m.directory File.join('public/images')
62
+ m.directory File.join('test/functional', controller_class_path)
63
+
64
+ # Model class, unit test, and fixtures.
65
+ m.template 'model.rb', File.join('app/models', "#{singular_name}.rb")
66
+ m.template 'unit_test.rb', File.join('test/unit', "#{singular_name}_test.rb")
67
+ m.template 'fixtures.yml', File.join('test/fixtures', "#{table_name}.yml")
68
+
69
+ # Scaffolded forms.
70
+ m.complex_template 'form.rhtml',
71
+ File.join('app/views',
72
+ controller_class_path,
73
+ controller_file_name,
74
+ '_form.rhtml'),
75
+ :insert => 'form_scaffolding.rhtml',
76
+ :sandbox => lambda { create_sandbox },
77
+ :begin_mark => 'form',
78
+ :end_mark => 'eoform',
79
+ :mark_id => singular_name
80
+
81
+ # Scaffolded partials.
82
+ m.template "partial_item.rhtml",
83
+ File.join('app/views',
84
+ controller_class_path,
85
+ controller_file_name,
86
+ "_#{singular_name}.rhtml")
87
+
88
+ scaffold_partials.each do |name|
89
+ m.template "partial_#{name}.rhtml",
90
+ File.join('app/views',
91
+ controller_class_path,
92
+ controller_file_name,
93
+ "_#{name}.rhtml")
94
+ end
95
+
96
+ # Scaffolded views.
97
+ scaffold_views.each do |action|
98
+ m.template "view_#{action}.rhtml",
99
+ File.join('app/views',
100
+ controller_class_path,
101
+ controller_file_name,
102
+ "#{action}.rhtml"),
103
+ :assigns => { :action => action }
104
+ end
105
+
106
+ # RJS templates
107
+ scaffold_rjs_templates.each do |template|
108
+ m.template "rjs_#{template}.rjs",
109
+ File.join('app/views',
110
+ controller_class_path,
111
+ controller_file_name,
112
+ "#{template}.rjs")
113
+ end
114
+
115
+ # Libraries
116
+ scaffold_lib.each do |filename|
117
+ m.template "lib_#{filename}.rb",
118
+ File.join('lib',
119
+ "#{filename}.rb")
120
+ end
121
+
122
+ # Controller class, functional test, helper, and views.
123
+ m.template 'controller.rb',
124
+ File.join('app/controllers',
125
+ controller_class_path,
126
+ "#{controller_file_name}_controller.rb")
127
+
128
+ m.template 'functional_test.rb',
129
+ File.join('test/functional',
130
+ controller_class_path,
131
+ "#{controller_file_name}_controller_test.rb")
132
+
133
+ m.template 'helper.rb',
134
+ File.join('app/helpers',
135
+ controller_class_path,
136
+ "#{controller_file_name}_helper.rb")
137
+
138
+ # Layout and stylesheet.
139
+ m.template 'layout.rhtml',
140
+ File.join('app/views/layouts',
141
+ controller_class_path,
142
+ "#{controller_file_name}.rhtml")
143
+
144
+ m.template 'ajax_scaffold.css', "public/stylesheets/ajax_scaffold.css"
145
+
146
+ scaffold_javascripts.each do |javascript|
147
+ m.template javascript, "public/javascripts/#{javascript}"
148
+ end
149
+
150
+ scaffold_images.each do |image|
151
+ m.template image, "public/images/#{image}"
152
+ end
153
+
154
+ end
155
+ end
156
+
157
+ protected
158
+ # Override with your own usage banner.
159
+ def banner
160
+ "Usage: #{$0} ajax_scaffold ModelName [ControllerName]"
161
+ end
162
+
163
+ def scaffold_views
164
+ %w( list component )
165
+ end
166
+
167
+ def scaffold_rjs_templates
168
+ %w( create destroy edit new update cancel )
169
+ end
170
+
171
+ def scaffold_partials
172
+ %w( form_messages messages column_headings new_edit pagination_links )
173
+ end
174
+
175
+ def scaffold_lib
176
+ %w( ajax_scaffold )
177
+ end
178
+
179
+ def scaffold_images
180
+ %w( indicator.gif indicator-small.gif add.gif arrow_down.gif arrow_up.gif )
181
+ end
182
+
183
+ def scaffold_javascripts
184
+ %w( ajax_scaffold.js rico_corner.js )
185
+ end
186
+
187
+ def create_sandbox
188
+ sandbox = AjaxScaffoldingSandbox.new
189
+ sandbox.singular_name = singular_name
190
+ begin
191
+ sandbox.model_instance = model_instance
192
+ sandbox.instance_variable_set("@#{singular_name}", sandbox.model_instance)
193
+ rescue ActiveRecord::StatementInvalid => e
194
+ logger.error "Before updating scaffolding from new DB schema, try creating a table for your model (#{class_name})"
195
+ raise SystemExit
196
+ end
197
+ sandbox.suffix = suffix
198
+ sandbox
199
+ end
200
+
201
+ end
@@ -120,11 +120,11 @@ module AjaxScaffold # :nodoc:
120
120
  end
121
121
 
122
122
  def column_class(column_name, column_value, sort_column, class_name = nil)
123
- class_name = String.new
124
- class_name += "empty " if column_empty?(column_value)
125
- class_name += "sorted " if (!sort_column.nil? && column_name == sort_column)
126
- class_name += "#{class_name} " unless class_name.nil?
127
- class_name
123
+ class_attr = String.new
124
+ class_attr += "empty " if column_empty?(column_value)
125
+ class_attr += "sorted " if (!sort_column.nil? && column_name == sort_column)
126
+ class_attr += "#{class_name} " unless class_name.nil?
127
+ class_attr
128
128
  end
129
129
 
130
130
  def loading_indicator_tag(options)
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: ajax_scaffold_generator
5
5
  version: !ruby/object:Gem::Version
6
- version: 3.1.9
7
- date: 2006-09-18 00:00:00 -06:00
6
+ version: 3.1.10
7
+ date: 2006-09-19 00:00:00 -06:00
8
8
  summary: Ajax scaffold generator is a rails generator for ajaxified scaffolds
9
9
  require_paths:
10
10
  - lib