scaffolding_extensions 1.0.0
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/LICENSE +19 -0
- data/README +144 -0
- data/contrib/scaffold_associations_tree/README +9 -0
- data/contrib/scaffold_associations_tree/bullet.gif +0 -0
- data/contrib/scaffold_associations_tree/minus.gif +0 -0
- data/contrib/scaffold_associations_tree/plus.gif +0 -0
- data/contrib/scaffold_associations_tree/scaffold_associations_tree.css +20 -0
- data/contrib/scaffold_associations_tree/scaffold_associations_tree.js +57 -0
- data/contrib/scaffold_auto_complete_style/README +8 -0
- data/contrib/scaffold_auto_complete_style/auto_complete.css +23 -0
- data/contrib/scaffold_form_focus/README +12 -0
- data/contrib/scaffold_form_focus/scaffold_form_focus.js +21 -0
- data/contrib/scaffold_jquery_autocomplete/README +8 -0
- data/contrib/scaffold_jquery_autocomplete/jquery.ui.se_autocomplete.css +22 -0
- data/contrib/scaffold_jquery_autocomplete/jquery.ui.se_autocomplete.js +121 -0
- data/doc/advanced.txt +154 -0
- data/doc/camping.txt +25 -0
- data/doc/controller_spec.txt +20 -0
- data/doc/conversion.txt +102 -0
- data/doc/model_spec.txt +54 -0
- data/doc/ramaze.txt +20 -0
- data/doc/sinatra.txt +20 -0
- data/doc/testing.txt +12 -0
- data/lib/scaffolding_extensions.rb +89 -0
- data/lib/scaffolding_extensions/controller.rb +79 -0
- data/lib/scaffolding_extensions/controller/action_controller.rb +116 -0
- data/lib/scaffolding_extensions/controller/camping.rb +150 -0
- data/lib/scaffolding_extensions/controller/ramaze.rb +116 -0
- data/lib/scaffolding_extensions/controller/sinatra.rb +183 -0
- data/lib/scaffolding_extensions/helper.rb +304 -0
- data/lib/scaffolding_extensions/jquery_helper.rb +58 -0
- data/lib/scaffolding_extensions/meta_controller.rb +337 -0
- data/lib/scaffolding_extensions/meta_model.rb +571 -0
- data/lib/scaffolding_extensions/model.rb +30 -0
- data/lib/scaffolding_extensions/model/active_record.rb +184 -0
- data/lib/scaffolding_extensions/model/ardm.rb +47 -0
- data/lib/scaffolding_extensions/model/data_mapper.rb +190 -0
- data/lib/scaffolding_extensions/overridable.rb +67 -0
- data/lib/scaffolding_extensions/prototype_helper.rb +59 -0
- data/scaffolds/edit.rhtml +12 -0
- data/scaffolds/habtm.rhtml +24 -0
- data/scaffolds/index.rhtml +6 -0
- data/scaffolds/layout.rhtml +82 -0
- data/scaffolds/list.rhtml +13 -0
- data/scaffolds/listtable.rhtml +46 -0
- data/scaffolds/manage.rhtml +15 -0
- data/scaffolds/merge.rhtml +23 -0
- data/scaffolds/new.rhtml +5 -0
- data/scaffolds/search.rhtml +11 -0
- data/scaffolds/show.rhtml +19 -0
- data/test/scaffolding_extensions_test.rb +44 -0
- metadata +106 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
module ScaffoldingExtensions
|
2
|
+
module Overridable
|
3
|
+
private
|
4
|
+
# If a method exists matches scaffold_#{action}_#{m}, return a proc that calls it.
|
5
|
+
# If not and the instance variable @scaffold_#{action}_#{m} is defined, return a
|
6
|
+
# proc that gives that value. Otherwise, return nil.
|
7
|
+
def scaffold_method_iv_override(m, action)
|
8
|
+
return nil unless action
|
9
|
+
meth = "scaffold_#{action}_#{m}"
|
10
|
+
if respond_to?(meth)
|
11
|
+
Proc.new{send(meth)}
|
12
|
+
elsif instance_variable_defined?(meth = "@#{meth}")
|
13
|
+
Proc.new{instance_variable_get(meth)}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# If a method exists matches scaffold_#{action}_#{m}, return a proc that calls it with
|
18
|
+
# the other provided arguments, otherwise return nil.
|
19
|
+
def scaffold_method_override(m, action, *args)
|
20
|
+
return nil unless action
|
21
|
+
meth = "scaffold_#{action}_#{m}"
|
22
|
+
Proc.new{send(meth, *args)} if respond_to?(meth)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module MetaOverridable
|
27
|
+
private
|
28
|
+
def scaffold_override_alias_method(meth)
|
29
|
+
pub_meth = "scaffold_#{meth}".to_sym
|
30
|
+
priv_meth = "_#{pub_meth}".to_sym
|
31
|
+
@scaffold_aliased_methods ||= Set.new
|
32
|
+
return false if @scaffold_aliased_methods.include?(pub_meth)
|
33
|
+
alias_method(priv_meth, pub_meth)
|
34
|
+
private(priv_meth)
|
35
|
+
@scaffold_aliased_methods.add(pub_meth)
|
36
|
+
[pub_meth, priv_meth]
|
37
|
+
end
|
38
|
+
|
39
|
+
def scaffold_override_iv_methods(*meths)
|
40
|
+
meths.each do |meth|
|
41
|
+
pub_meth, priv_meth = scaffold_override_alias_method(meth)
|
42
|
+
return unless pub_meth && priv_meth
|
43
|
+
define_method(pub_meth) do |arg|
|
44
|
+
if m = scaffold_method_iv_override(meth, arg)
|
45
|
+
m.call
|
46
|
+
else
|
47
|
+
send(priv_meth, arg)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def scaffold_override_methods(*meths)
|
54
|
+
meths.each do |meth|
|
55
|
+
pub_meth, priv_meth = scaffold_override_alias_method(meth)
|
56
|
+
return unless pub_meth && priv_meth
|
57
|
+
define_method(pub_meth) do |*args|
|
58
|
+
if m = scaffold_method_override(meth, *args)
|
59
|
+
m.call
|
60
|
+
else
|
61
|
+
send(priv_meth, *args)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module ScaffoldingExtensions
|
2
|
+
# Helper methods that require the Prototype Javascript library to work
|
3
|
+
module PrototypeHelper
|
4
|
+
JS_CHAR_FILTER = {'<'=>'\u003C', '>'=>'\u003E', '"'=>'\\"', "\n"=>'\n'}
|
5
|
+
|
6
|
+
private
|
7
|
+
# Javascript for adding an element to the top of the list of associated records,
|
8
|
+
# and setting the autocomplete text box value to blank (if using autocompleting),
|
9
|
+
# or removing the item from the select box and showing the blank record instead
|
10
|
+
# (if not using autocompleting).
|
11
|
+
def scaffold_add_habtm_element
|
12
|
+
content = "new Insertion.Top('#{@records_list}', \"#{scaffold_javascript_character_filter(scaffold_habtm_association_line_item(@klass, @association, @record, @associated_record))}\");\n"
|
13
|
+
if @auto_complete
|
14
|
+
content << "$('#{@element_id}').value = '';\n"
|
15
|
+
else
|
16
|
+
content << "Element.remove('#{@element_id}_#{@associated_record.scaffold_id}');\n"
|
17
|
+
content << "$('#{@element_id}').selectedIndex = 0;\n"
|
18
|
+
end
|
19
|
+
content
|
20
|
+
end
|
21
|
+
|
22
|
+
# A form tag with an onsubmit attribute that submits the form to the given url via Ajax
|
23
|
+
def scaffold_form_remote_tag(url, options)
|
24
|
+
u = scaffold_url(url, options)
|
25
|
+
"<form method='post' action='#{u}' onsubmit=\"new Ajax.Request('#{u}', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">\n#{scaffold_token_tag}\n"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Javascript that takes the given id as the text box to autocomplete for,
|
29
|
+
# submitting the autocomplete request to scaffold_auto_complete_for_#{model_name}
|
30
|
+
# (with the association if one is given), using the get method, and displaying values
|
31
|
+
# in #{id}_scaffold_auto_complete.
|
32
|
+
def scaffold_javascript_autocompleter(id, model_name, association)
|
33
|
+
"\n<div class='auto_complete' id='#{id}_scaffold_auto_complete'></div>\n" <<
|
34
|
+
scaffold_javascript_tag("var #{id}_auto_completer = new Ajax.Autocompleter('#{id}', '#{"#{id}_scaffold_auto_complete"}', '#{scaffold_url("scaffold_auto_complete_for_#{model_name}")}', {paramName:'id', method:'get'#{", parameters:'association=#{association}'" if association}})")
|
35
|
+
end
|
36
|
+
|
37
|
+
# Filters some html entities and replaces them with their javascript equivalents
|
38
|
+
# suitable for use inside a javascript quoted string.
|
39
|
+
def scaffold_javascript_character_filter(string)
|
40
|
+
string.gsub(/[<>"\n]/){|x| JS_CHAR_FILTER[x]}
|
41
|
+
end
|
42
|
+
|
43
|
+
# Div with link inside that requests the associations html for the @scaffold_object
|
44
|
+
# via Ajax and replaces the link with the html returned by the request
|
45
|
+
def scaffold_load_associations_with_ajax_link
|
46
|
+
soid = @scaffold_object.scaffold_id
|
47
|
+
divid = "scaffold_ajax_content_#{soid}"
|
48
|
+
"<div id='#{divid}'><a href='#{scaffold_url("edit#{@scaffold_suffix}", :id=>soid, :associations=>:show)}' onclick=\"new Ajax.Updater('#{divid}', '#{scaffold_url("associations#{@scaffold_suffix}", :id=>soid)}', {method:'get', asynchronous:true, evalScripts:true}); return false;\">Modify Associations</a></div>"
|
49
|
+
end
|
50
|
+
|
51
|
+
# Javascript that removes @remove_element_id from the page and inserts
|
52
|
+
# an option into the appropriate select box (unless @auto_complete).
|
53
|
+
def scaffold_remove_existing_habtm_element
|
54
|
+
content = "Element.remove('#{@remove_element_id}');\n"
|
55
|
+
content << "new Insertion.Bottom('#{@select_id}', \"\\u003Coption value='#{@select_value}' id='#{@select_id}_#{@select_value}'\\u003E#{@select_text}\\u003C/option\\u003E\");\n" unless @auto_complete
|
56
|
+
content
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<% @scaffold_title = "Editing #{@scaffold_options[:singular_lc_human_name]}" %>
|
2
|
+
|
3
|
+
<%= scaffold_model_form('update', @scaffold_class.scaffold_fields(:edit)) %>
|
4
|
+
|
5
|
+
<% if @scaffold_class.scaffold_load_associations_with_ajax && !@scaffold_show_associations %>
|
6
|
+
<%= scaffold_load_associations_with_ajax_link %>
|
7
|
+
<% else %>
|
8
|
+
<%= scaffold_habtm_ajax_associations %>
|
9
|
+
<%= scaffold_association_links %>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<%= scaffold_manage_link %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<% @scaffold_title = "Update #{sn = h(@scaffold_object.scaffold_name)}'s #{mpn = (so = @scaffold_options )[:aplch_name]}" %>
|
2
|
+
|
3
|
+
<%= scaffold_form(scaffold_url("update#{@scaffold_suffix}", :id=>(soid=@scaffold_object.scaffold_id))) %>
|
4
|
+
|
5
|
+
<% if @scaffold_class.scaffold_association_use_auto_complete(assoc = so[:association]) %>
|
6
|
+
<h4>Add this <%= so[:aslhc_name] %></h4>
|
7
|
+
<%= scaffold_text_field_tag_with_auto_complete('add', so[:singular_name], assoc) %>
|
8
|
+
<% elsif @items_to_add.length > 0 %>
|
9
|
+
<h4>Add these <%= mpn %></h4>
|
10
|
+
<%= scaffold_select_tag('add', @items_to_add, true) %>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<% if @items_to_remove.length > 0 %>
|
14
|
+
<h4>Remove these <%= mpn %></h4>
|
15
|
+
<%= scaffold_select_tag('remove', @items_to_remove, true) %>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<br /><br />
|
19
|
+
<input type='submit' value="Update <%= sn %>'s <%= mpn %>" />
|
20
|
+
</form>
|
21
|
+
|
22
|
+
<% if '' != (edit_link = scaffold_check_link("Edit #{sn}", true, "edit_#{@scaffold_options[:singular_name]}", :id=>soid)) %>
|
23
|
+
<h2><%= edit_link %></h2>
|
24
|
+
<% end %>
|
@@ -0,0 +1,82 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Scaffolding Extensions<%= " - #{@scaffold_title}" if @scaffold_title %></title>
|
4
|
+
<style type="text/css">
|
5
|
+
body { background-color: #fff; color: #333; }
|
6
|
+
|
7
|
+
body, p, ol, ul, td {
|
8
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
9
|
+
font-size: 13px;
|
10
|
+
line-height: 18px;
|
11
|
+
}
|
12
|
+
|
13
|
+
h4 { font-size: 16px; }
|
14
|
+
|
15
|
+
pre {
|
16
|
+
background-color: #eee;
|
17
|
+
padding: 10px;
|
18
|
+
font-size: 11px;
|
19
|
+
}
|
20
|
+
|
21
|
+
a { color: #000; }
|
22
|
+
a:visited { color: #666; }
|
23
|
+
a:hover { color: #fff; background-color:#000; }
|
24
|
+
|
25
|
+
div.habtm_ajax_remove_associations form { display: inline; }
|
26
|
+
|
27
|
+
div.auto_complete {
|
28
|
+
width: 350px;
|
29
|
+
background: #fff;
|
30
|
+
}
|
31
|
+
div.auto_complete ul {
|
32
|
+
border:1px solid #888;
|
33
|
+
margin:0;
|
34
|
+
padding:0;
|
35
|
+
width:100%;
|
36
|
+
list-style-type:none;
|
37
|
+
}
|
38
|
+
div.auto_complete ul li {
|
39
|
+
margin:0;
|
40
|
+
padding:3px;
|
41
|
+
}
|
42
|
+
div.auto_complete ul li.selected {
|
43
|
+
background-color: #ffb;
|
44
|
+
}
|
45
|
+
div.auto_complete ul strong.highlight {
|
46
|
+
color: #800;
|
47
|
+
margin:0;
|
48
|
+
padding:0;
|
49
|
+
}
|
50
|
+
|
51
|
+
ul.se_autocomplete {
|
52
|
+
position: absolute;
|
53
|
+
overflow: hidden;
|
54
|
+
background-color: #fff;
|
55
|
+
border: 1px solid #aaa;
|
56
|
+
margin: 0px;
|
57
|
+
padding: 0;
|
58
|
+
list-style: none;
|
59
|
+
font: normal .75em/.75em Verdana, Arial, sans-serif;
|
60
|
+
color: #333;
|
61
|
+
}
|
62
|
+
ul.se_autocomplete li {
|
63
|
+
display: block;
|
64
|
+
padding: .3em .5em .3em .3em;
|
65
|
+
overflow: hidden;
|
66
|
+
width: 100%;
|
67
|
+
}
|
68
|
+
|
69
|
+
ul.se_autocomplete li.active {
|
70
|
+
background-color: #3875d7;
|
71
|
+
color: #fff;
|
72
|
+
}
|
73
|
+
</style>
|
74
|
+
</head>
|
75
|
+
<body>
|
76
|
+
<%= "<h1>#{@scaffold_title}</h1>" if @scaffold_title %>
|
77
|
+
<%= "<h4>#{scaffold_flash[:notice]}</h4>" if scaffold_flash[:notice] %>
|
78
|
+
|
79
|
+
<%= @content %>
|
80
|
+
|
81
|
+
</body>
|
82
|
+
</html>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% @scaffold_title = "Choose #{hn = @scaffold_options[:singular_lc_human_name]} to #{(haction = (action = @scaffold_action).to_s.humanize).downcase}" %>
|
2
|
+
|
3
|
+
<%= scaffold_form(scaffold_url("#{action}#{@scaffold_suffix}"), :method=>(action == :destroy ? :post : :get)) %>
|
4
|
+
<% if @scaffold_class.scaffold_use_auto_complete %>
|
5
|
+
<%= scaffold_text_field_tag_with_auto_complete('id', @scaffold_options[:singular_name]) %>
|
6
|
+
<% else %>
|
7
|
+
<%= scaffold_select_tag('id', @scaffold_objects) %>
|
8
|
+
<% end %>
|
9
|
+
<br /><br />
|
10
|
+
<input type="submit" value="<%= haction %> <%= hn %>" />
|
11
|
+
</form>
|
12
|
+
|
13
|
+
<%= scaffold_manage_link %>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<% @scaffold_title = "Listing #{@scaffold_options[:plural_lc_human_name]}" %>
|
2
|
+
|
3
|
+
<table id="scaffolded" class="<%= @scaffold_class.scaffold_table_class(:list) %>">
|
4
|
+
<thead><tr>
|
5
|
+
<% @scaffold_class.scaffold_fields(@scaffold_listtable_type).each do |column| -%>
|
6
|
+
<th><%=h @scaffold_class.scaffold_column_name(column) %></th>
|
7
|
+
<% end %>
|
8
|
+
<%= "<th>#{s = 'Show'}</th>" if show = scaffolded_method?(ss = "show#{@scaffold_suffix}") %>
|
9
|
+
<%= "<th>#{e = 'Edit'}</th>" if edit = scaffolded_method?(es = "edit#{@scaffold_suffix}") %>
|
10
|
+
<%= "<th>#{d = 'Delete'}</th>" if delete = scaffolded_method?(ds = "destroy#{@scaffold_suffix}") %>
|
11
|
+
</tr></thead><tbody>
|
12
|
+
<% @scaffold_objects.each do |entry| eid = entry.scaffold_id %>
|
13
|
+
<tr>
|
14
|
+
<% @scaffold_class.scaffold_fields(@scaffold_listtable_type).each do |column| %>
|
15
|
+
<td><%=h entry.scaffold_value(column).to_s %></td>
|
16
|
+
<% end %>
|
17
|
+
<%= "<td>#{scaffold_button_to(s, scaffold_url(ss, :id=>eid), :method=>:get)}</td>" if show %>
|
18
|
+
<%= "<td>#{scaffold_button_to(e, scaffold_url(es, :id=>eid), :method=>:get)}</td>" if edit %>
|
19
|
+
<%= "<td>#{scaffold_button_to(d, scaffold_url(ds, :id=>eid))}</td>" if delete %>
|
20
|
+
</tr>
|
21
|
+
<% end %>
|
22
|
+
</tbody></table>
|
23
|
+
|
24
|
+
<% if @scaffold_listtable_type == :browse %>
|
25
|
+
<%= "<a href='#{scaffold_url("browse#{@scaffold_suffix}", :page=>(@page-1))}'>Previous Page</a>" if @page > 1 %>
|
26
|
+
<%= "<a href='#{scaffold_url("browse#{@scaffold_suffix}", :page=>(@page+1))}'>Next Page</a>" if @next_page %>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
<% if @scaffold_listtable_type == :search && @scaffold_search_results_form_params && (@scaffold_search_results_form_params[:page] > 1 || @scaffold_search_results_form_params[:next_page]) %>
|
30
|
+
<%= scaffold_form(scaffold_url("results#{@scaffold_suffix}")) %>
|
31
|
+
<%= scaffold_field_tag(:hidden, :value=>@scaffold_search_results_form_params[:page], :id=>'page') %>
|
32
|
+
<% @scaffold_search_results_form_params[:model].each do |key, value| -%>
|
33
|
+
<%= scaffold_field_tag(:hidden, :value=>value, :id=>"#{@scaffold_singular_name}_#{key}", :name=>"#{@scaffold_singular_name}[#{key}]") %>
|
34
|
+
<% end %>
|
35
|
+
<% @scaffold_search_results_form_params[:notnull].each do |field| -%>
|
36
|
+
<%= scaffold_field_tag(:hidden, :value=>field, :name=>"notnull#{scaffold_param_list_suffix}") %>
|
37
|
+
<% end %>
|
38
|
+
<% @scaffold_search_results_form_params[:null].each do |field| -%>
|
39
|
+
<%= scaffold_field_tag(:hidden, :value=>field, :name=>"null#{scaffold_param_list_suffix}") %>
|
40
|
+
<% end %>
|
41
|
+
<%= '<input type="submit" name="page_previous" value="Previous Page" >' if @scaffold_search_results_form_params[:page] > 1 %>
|
42
|
+
<%= '<input type="submit" name="page_next" value="Next Page" >' if @scaffold_search_results_form_params[:next_page] %>
|
43
|
+
</form>
|
44
|
+
<% end %>
|
45
|
+
|
46
|
+
<%= scaffold_manage_link %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% @scaffold_title = "Manage #{plural_name = @scaffold_options[:plural_lc_human_name]}" %>
|
2
|
+
<ul>
|
3
|
+
<% [["Browse #{plural_name}", :browse],
|
4
|
+
["Create #{singular_name = @scaffold_options[:singular_lc_human_name]}", :new],
|
5
|
+
["Delete #{singular_name}", :delete],
|
6
|
+
["Edit #{singular_name}", :edit],
|
7
|
+
["Merge #{plural_name}", :merge],
|
8
|
+
["Search #{plural_name}", :search],
|
9
|
+
["Show #{singular_name}", :show]].each do |text, action| -%>
|
10
|
+
<% link = scaffold_check_link(text, true, "#{action}#{@scaffold_suffix}") -%>
|
11
|
+
<%= "<li>#{link}</li>" unless link == '' %>
|
12
|
+
<% end %>
|
13
|
+
</ul>
|
14
|
+
|
15
|
+
<%= scaffold_check_link('Manage Models', true, 'index') %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<% @scaffold_title = "Merge two #{@scaffold_options[:plural_lc_human_name]}" %>
|
2
|
+
|
3
|
+
<%= scaffold_form(scaffold_url("merge_update#{@scaffold_suffix}")) %>
|
4
|
+
<p>Merge:
|
5
|
+
<% if @scaffold_class.scaffold_use_auto_complete %>
|
6
|
+
<%= scaffold_text_field_tag_with_auto_complete('from', @scaffold_options[:singular_name]) %>
|
7
|
+
<% else %>
|
8
|
+
<%= scaffold_select_tag('from', @scaffold_objects) %>
|
9
|
+
<% end %>
|
10
|
+
</p>
|
11
|
+
|
12
|
+
<p>into:
|
13
|
+
<% if @scaffold_class.scaffold_use_auto_complete %>
|
14
|
+
<%= scaffold_text_field_tag_with_auto_complete('to', @scaffold_options[:singular_name]) %>
|
15
|
+
<% else %>
|
16
|
+
<%= scaffold_select_tag('to', @scaffold_objects) %>
|
17
|
+
<% end %>
|
18
|
+
</p>
|
19
|
+
|
20
|
+
<input type="submit" value="Merge <%= @scaffold_options[:plural_lc_human_name] %>" />
|
21
|
+
</form>
|
22
|
+
|
23
|
+
<%= scaffold_manage_link %>
|
data/scaffolds/new.rhtml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
<% @scaffold_title = "Search #{@scaffold_options[:plural_lc_human_name]}" %>
|
2
|
+
|
3
|
+
<%= scaffold_model_form('results', @scaffold_class.scaffold_fields(:search)) do |form|
|
4
|
+
form << "<table class='#{@scaffold_class.scaffold_table_class(:form)}'><tbody>"
|
5
|
+
form << "<tr><td><label for='null'>Null Fields</label>:</td><td><select name='null#{scaffold_param_list_suffix}' id='null' multiple='multiple'>#{@scaffold_class.scaffold_search_null_options.collect{|name, i| "<option value='#{i}'>#{name}</option>"}.join("\n")}</select></td></tr>\n"
|
6
|
+
form << "<tr><td><label for='notnull'>Not Null Fields</label>:</td><td><select name='notnull#{scaffold_param_list_suffix}' id='notnull' multiple='multiple'>#{@scaffold_class.scaffold_search_null_options.collect{|name, i| "<option value='#{i}'>#{name}</option>"}.join("\n")}</select></td></tr>\n"
|
7
|
+
form << '</tbody></table>'
|
8
|
+
@scaffold_submit_value = @scaffold_title
|
9
|
+
end %>
|
10
|
+
|
11
|
+
<%= scaffold_manage_link %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<% @scaffold_title = "Showing #{@scaffold_options[:singular_lc_human_name]}" %>
|
2
|
+
<% if '' != (edit_link = scaffold_check_link('Edit', true, "edit_#{@scaffold_options[:singular_name]}", :id=>@scaffold_object.scaffold_id)) %>
|
3
|
+
<h2><%= edit_link %></h2>
|
4
|
+
<% end %>
|
5
|
+
|
6
|
+
<table id="scaffolded" class="<%= @scaffold_class.scaffold_table_class(:show) %>">
|
7
|
+
<thead><tr><th>Attribute</th><th>Value</th></tr></thead>
|
8
|
+
<tbody>
|
9
|
+
<% @scaffold_class.scaffold_fields(:show).each do |column| %>
|
10
|
+
<tr>
|
11
|
+
<td><%= @scaffold_class.scaffold_column_name(column) %></td>
|
12
|
+
<td><%=h @scaffold_object.scaffold_value(column).to_s %></td>
|
13
|
+
</tr>
|
14
|
+
<% end %>
|
15
|
+
</tbody></table>
|
16
|
+
|
17
|
+
<%= scaffold_association_links %>
|
18
|
+
|
19
|
+
<%= scaffold_manage_link %>
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
# Simple test framework to check that public facing pages without an id respond successfully
|
4
|
+
#
|
5
|
+
# This is only a basic check, it does not check that all form submittals work, as that
|
6
|
+
# requires that you choose an object to test. If you want to be sure that all parts of
|
7
|
+
# Scaffolding Extensions work with your applications, you should extend the tests here to do so.
|
8
|
+
class Test::Unit::TestCase
|
9
|
+
# Test the scaffold_all_models method using the same arguments as the method
|
10
|
+
def self.test_scaffold_all_models(options = {})
|
11
|
+
ActionController::Base.send(:scaffold_all_models_parse_options, options).each{|model, options| test_scaffold(model, options)}
|
12
|
+
end
|
13
|
+
|
14
|
+
# Test the scaffold method using the same arguments as the method
|
15
|
+
def self.test_scaffold(model, options = {})
|
16
|
+
define_method("test_scaffold_#{model.scaffold_name}"){scaffold_test(model, options)}
|
17
|
+
end
|
18
|
+
|
19
|
+
# Test that getting all display actions for the scaffold returns success
|
20
|
+
def scaffold_test(model, options = {})
|
21
|
+
klass = @controller.class
|
22
|
+
methods = options[:only] ? klass.scaffold_normalize_options(options[:only]) : ScaffoldingExtensions::DEFAULT_METHODS
|
23
|
+
methods -= klass.scaffold_normalize_options(options[:except]) if options[:except]
|
24
|
+
methods.each do |action|
|
25
|
+
assert_nothing_raised("Error requesting scaffolded action #{action} for model #{model.name}") do
|
26
|
+
get "#{action}_#{model.scaffold_name}"
|
27
|
+
end
|
28
|
+
assert_response :success, "Response for scaffolded action #{action} for model #{model.name} not :success"
|
29
|
+
# # The habtm scaffolds can't be tested without an id. If the fixture for the
|
30
|
+
# # main scaffolded class is loaded and it has id = 1, you may want to enable
|
31
|
+
# # the following code for testing those scaffolds.
|
32
|
+
# model.scaffold_habtm_associations.each do |association|
|
33
|
+
# scaffold_habtm_test(model, association, 1)
|
34
|
+
# end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Test the habtm scaffold for singular class, many class, and the specific id
|
39
|
+
def scaffold_habtm_test(model, association, id)
|
40
|
+
action = "edit_#{model.scaffold_name}_#{association}", {:id=>id}
|
41
|
+
assert_nothing_raised("Error requesting habtm scaffold #{action}"){get action}
|
42
|
+
assert_response :success, "Response for habtm scaffold #{action} not :success"
|
43
|
+
end
|
44
|
+
end
|