masterview_generator 0.0.12 → 0.0.13
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/masterview_generator.rb +44 -10
- data/templates/form_scaffold.rhtml +3 -2
- data/templates/list_line_scaffold.rhtml +4 -4
- data/templates/masterview.rhtml +137 -134
- data/templates/mvpreview.js +53 -1
- data/templates/show_only_destroy.css +13 -0
- data/templates/show_only_edit.css +13 -0
- data/templates/show_only_list.css +13 -0
- data/templates/show_only_new.css +13 -0
- data/templates/show_only_show.css +13 -0
- data/templates/show_scaffold.rhtml +2 -1
- data/templates/style.css +12 -10
- metadata +7 -2
data/masterview_generator.rb
CHANGED
@@ -8,25 +8,27 @@ class ScaffoldingSandbox
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def default_input_block
|
11
|
-
Proc.new { |record, column|
|
11
|
+
Proc.new { |record, column|
|
12
|
+
" <div class=\"record\">\n <div class=\"label\"><label for=\"#{record}_#{column.name}\">#{column.human_name}:</label></div>\n <div class=\"field\">#{input(record, column.name)}</div>\n </div>\n" }
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
16
|
class ListHeadScaffoldingSandbox < ScaffoldingSandbox
|
16
17
|
def default_input_block
|
17
|
-
Proc.new { |record, column| "<th class=\"
|
18
|
+
Proc.new { |record, column| "<th class=\"th_#{column.name}\">#{column.human_name}</th>" }
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
22
|
class ListLineScaffoldingSandbox < ScaffoldingSandbox
|
22
23
|
def default_input_block
|
23
|
-
Proc.new { |record, column| "<td class=\"
|
24
|
+
Proc.new { |record, column| "<td class=\"td_#{column.name}\" mv:content=\"h #{record}.send(:#{column.name})\">#{record} #{column.human_name}</td>" }
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
28
|
class ShowScaffoldingSandbox < ScaffoldingSandbox
|
28
29
|
def default_input_block
|
29
|
-
Proc.new { |record, column|
|
30
|
+
Proc.new { |record, column|
|
31
|
+
" <div class=\"record\">\n <div class=\"label\"><label>#{column.human_name}:</label></div>\n <div class=\"field\" mv:content=\"h @#{record}.send(:#{column.name})\">#{record} #{column.human_name}</div>\n </div>\n" }
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -135,6 +137,26 @@ class MasterviewGenerator < Rails::Generator::NamedBase
|
|
135
137
|
else
|
136
138
|
@controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
|
137
139
|
end
|
140
|
+
default_options[:showSection] = :new
|
141
|
+
end
|
142
|
+
|
143
|
+
def design_time_stylesheets
|
144
|
+
dts = ''
|
145
|
+
dts << html_comment( '<link rel="stylesheet" type="text/css" href="./extra/show_only_new.css" mv:replace=""/>',
|
146
|
+
full_options[:showSection] != :new )
|
147
|
+
dts << html_comment( '<link rel="stylesheet" type="text/css" href="./extra/show_only_edit.css" mv:replace=""/>', true)
|
148
|
+
dts << html_comment( '<link rel="stylesheet" type="text/css" href="./extra/show_only_show.css" mv:replace=""/>', true)
|
149
|
+
dts << html_comment( '<link rel="stylesheet" type="text/css" href="./extra/show_only_list.css" mv:replace=""/>',
|
150
|
+
full_options[:showSection] != :list )
|
151
|
+
dts << html_comment( '<link rel="stylesheet" type="text/css" href="./extra/show_only_destroy.css" mv:replace=""/>', true)
|
152
|
+
end
|
153
|
+
|
154
|
+
def html_comment(orig, comment_out)
|
155
|
+
t = ' '
|
156
|
+
t << '<!-- ' if comment_out
|
157
|
+
t << orig
|
158
|
+
t << ' -->' if comment_out
|
159
|
+
t << "\n"
|
138
160
|
end
|
139
161
|
|
140
162
|
def manifest
|
@@ -150,6 +172,7 @@ class MasterviewGenerator < Rails::Generator::NamedBase
|
|
150
172
|
m.directory File.join('app/helpers', controller_class_path)
|
151
173
|
m.directory File.join('app/views', controller_class_path, controller_view_dir_name)
|
152
174
|
m.directory 'app/views/masterview'
|
175
|
+
m.directory 'app/views/masterview/extra'
|
153
176
|
m.directory File.join('test/functional', controller_class_path)
|
154
177
|
|
155
178
|
# Controller class, functional test, helper, and views.
|
@@ -169,10 +192,6 @@ class MasterviewGenerator < Rails::Generator::NamedBase
|
|
169
192
|
"#{controller_file_name}_helper.rb")
|
170
193
|
|
171
194
|
# MasterView
|
172
|
-
m.template 'mvpreview.js',
|
173
|
-
File.join('public/javascripts',
|
174
|
-
"mvpreview.js")
|
175
|
-
|
176
195
|
m.multi_include_template "masterview.rhtml","app/views/masterview/#{controller_masterview_name}.html", {},
|
177
196
|
{
|
178
197
|
'form_inclusion' =>
|
@@ -205,7 +224,16 @@ class MasterviewGenerator < Rails::Generator::NamedBase
|
|
205
224
|
}
|
206
225
|
}
|
207
226
|
|
208
|
-
m.template 'style.css',
|
227
|
+
m.template 'style.css', 'public/stylesheets/scaffold.css'
|
228
|
+
|
229
|
+
# design time files
|
230
|
+
m.template 'mvpreview.js', 'app/views/masterview/extra/mvpreview.js'
|
231
|
+
m.template 'show_only_new.css', 'app/views/masterview/extra/show_only_new.css'
|
232
|
+
m.template 'show_only_edit.css', 'app/views/masterview/extra/show_only_edit.css'
|
233
|
+
m.template 'show_only_show.css', 'app/views/masterview/extra/show_only_show.css'
|
234
|
+
m.template 'show_only_list.css', 'app/views/masterview/extra/show_only_list.css'
|
235
|
+
m.template 'show_only_destroy.css', 'app/views/masterview/extra/show_only_destroy.css'
|
236
|
+
|
209
237
|
|
210
238
|
end
|
211
239
|
end
|
@@ -213,7 +241,13 @@ class MasterviewGenerator < Rails::Generator::NamedBase
|
|
213
241
|
protected
|
214
242
|
# Override with your own usage banner.
|
215
243
|
def banner
|
216
|
-
"Usage: #{$0} masterview ModelName [ControllerName] [action, ...]"
|
244
|
+
"Usage: #{$0} masterview ModelName [ControllerName] [action, ...] [--showAll | --showOnlyNew | --showOnlyList]"
|
245
|
+
end
|
246
|
+
|
247
|
+
def add_options!(opt)
|
248
|
+
opt.on('-A', '--showAll', 'Generate with ALL sections visible at design time (no css hiding)') { options[:showSection] = :all }
|
249
|
+
opt.on('-N', '--showOnlyNew', 'Geneate with only NEW section visible at design time (rest hidden with css)') { options[:showSection] = :new }
|
250
|
+
opt.on('-L', '--showOnlyList', 'Geneate with only LIST section visible at design time (rest hidden with css)') { options[:showSection] = :list }
|
217
251
|
end
|
218
252
|
|
219
253
|
def scaffold_views
|
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
<%= all_input_tags(@model_instance, @singular_name, {}) %>
|
3
|
+
<td><a class="show_link" href="#" mv:link_to=":action => 'show<%= suffix %>', :id => <%= singular_name %>">Show</a></td>
|
4
|
+
<td><a class="edit_link" href="#" mv:link_to=":action => 'edit<%= suffix %>', :id => <%= singular_name %>">Edit</a></td>
|
5
|
+
<td><a class="destroy_link" href="#" mv:link_to=":action => 'destroy', :id => <%= singular_name %>">Destroy</a></td>
|
6
6
|
|
data/templates/masterview.rhtml
CHANGED
@@ -1,178 +1,181 @@
|
|
1
1
|
<html mv:generate="layouts/<%= controller_file_name %>.rhtml">
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
<head>
|
3
|
+
<title><%= controller_class_name %>: {{{= controller.action_name }}}</title>
|
4
|
+
<link rel="stylesheet" type="text/css" href="../../../public/stylesheets/scaffold.css" mv:stylesheet_link="scaffold"/>
|
5
|
+
|
6
|
+
<!--
|
7
|
+
These stylesheets below are for design time use to allow working with only one visible section at a time, especially
|
8
|
+
when trying to use absolute positioning. You may comment/uncomment which ever section you wish to work with.
|
9
|
+
You may comment all of them out to work with all at design time. These stylesheets will not be used at runtime
|
10
|
+
-->
|
11
|
+
<%= design_time_stylesheets -%>
|
12
|
+
|
5
13
|
<script type="text/javascript" src="../../../public/javascripts/prototype.js" mv:javascript_include=":defaults"></script>
|
6
14
|
<script type="text/javascript" src="../../../public/javascripts/effects.js" mv:replace=""></script>
|
7
15
|
<script type="text/javascript" src="../../../public/javascripts/dragdrop.js" mv:replace=""></script>
|
8
16
|
<script type="text/javascript" src="../../../public/javascripts/controls.js" mv:replace=""></script>
|
9
17
|
<script type="text/javascript" src="../../../public/javascripts/application.js" mv:replace=""></script>
|
10
|
-
|
11
|
-
|
18
|
+
</head>
|
19
|
+
<body>
|
12
20
|
|
13
21
|
<div class="messages" mv:if="@flash[:notice]" mv:content="@flash[:notice]">
|
14
|
-
messages
|
22
|
+
messages here - Note: Other divs are hidden at design time, disable extra/show_only_new.css or import different extra/*.css to work with other sections (extra stylesheets are show_only_edit.css, show_only_show.css, show_only_list.css, show_only_destroy.css)
|
15
23
|
</div>
|
16
24
|
|
17
|
-
<div class="main">
|
18
|
-
<div id="<%= controller_file_name %>_content" mv:replace="@content_for_layout">
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
<div class="main">
|
26
|
+
<div id="<%= controller_file_name %>_content" mv:replace="@content_for_layout">
|
27
|
+
<div id="<%= controller_file_name %>_new" mv:generate="<%= controller_view_dir_name %>/new.rhtml" mv:preview="showOne" class="new_div">
|
28
|
+
<div class="<%= controller_file_name %>_new sidebar">
|
29
|
+
<h1>Tasks:</h1>
|
30
|
+
<ul>
|
31
|
+
<li><a class="list_link" href="#" mv:link_to=":action => 'list<%= suffix %>'">Back to overview</a></li>
|
32
|
+
</ul>
|
33
|
+
</div>
|
26
34
|
|
27
|
-
|
28
|
-
|
35
|
+
<div class="<%= controller_file_name %>_new content">
|
36
|
+
<h1><%= plural_name.capitalize %></h1>
|
29
37
|
|
30
|
-
|
38
|
+
<form mv:form=":action => 'new'">
|
31
39
|
|
32
|
-
|
33
|
-
|
40
|
+
<div class="form">
|
41
|
+
<h2>Creating <%= singular_name %></h2>
|
34
42
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
</div>
|
44
|
-
|
45
|
-
<br/>
|
46
|
-
<div class="<%= controller_file_name %>_new operations">
|
47
|
-
<input type="submit" value="OK" class="primary" mv:submit="" onclick="javascript:mvpreview.showOneSection('<%= controller_file_name %>_list');return false;"/>
|
48
|
-
<input type="button" value="Cancel" style="width: auto;" onclick="window.location.href = '{{{= url_for :action => %q{list} }}}';" />
|
49
|
-
</div>
|
43
|
+
<div id="<%= controller_file_name %>_form" mv:gen_render=":partial => '<%= controller_view_dir_name %>/form'">
|
44
|
+
<div class="error_messages" mv:replace="error_messages_for :<%= singular_name %>">
|
45
|
+
error messages
|
46
|
+
</div>
|
47
|
+
<br/>
|
48
|
+
<%= form_inclusion %>
|
49
|
+
</div>
|
50
50
|
|
51
|
-
|
52
|
-
</div>
|
53
|
-
</div>
|
51
|
+
</div>
|
54
52
|
|
53
|
+
<br/>
|
54
|
+
<div class="<%= controller_file_name %>_new operations">
|
55
|
+
<input type="submit" value="OK" class="primary save_button" mv:submit=""/>
|
56
|
+
<input type="button" value="Cancel" class="cancel_button" style="width: auto;" onclick="window.location.href = '{{{= url_for :action => %q{list} }}}';" />
|
57
|
+
</div>
|
55
58
|
|
59
|
+
</form>
|
60
|
+
</div>
|
61
|
+
</div>
|
56
62
|
|
57
63
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
64
|
+
<div id="<%= controller_file_name %>_edit" mv:generate="<%= controller_view_dir_name %>/edit.rhtml" mv:preview="showOne" class="edit_div">
|
65
|
+
<div class="<%= controller_file_name %>_edit sidebar">
|
66
|
+
<h1>Tasks:</h1>
|
67
|
+
<ul>
|
68
|
+
<li><a class="list_link" href="#" mv:link_to=":action => 'list<%= suffix %>'">Back to overview</a></li>
|
69
|
+
</ul>
|
70
|
+
</div>
|
65
71
|
|
66
|
-
|
67
|
-
|
72
|
+
<div class="<%= controller_file_name %>_edit content">
|
73
|
+
<h1><%= plural_name.capitalize %></h1>
|
68
74
|
|
69
|
-
|
75
|
+
<form mv:form=":action => 'edit', :id => @<%=singular_name%>.id">
|
70
76
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
+
<div class="form">
|
78
|
+
<h2>Editing <%= singular_name %></h2>
|
79
|
+
<div mv:replace="render :partial => 'form'" mv:preview="copyOf:<%= controller_file_name %>_form">
|
80
|
+
copyOf:<%= controller_file_name %>_form
|
81
|
+
</div>
|
82
|
+
</div>
|
77
83
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
84
|
+
<br/>
|
85
|
+
<div class="<%= controller_file_name %>_edit operations">
|
86
|
+
<input type="submit" value="OK" class="primary save_button" mv:submit=""/>
|
87
|
+
<input type="button" value="Cancel" class="cancel_button" style="width: auto;" onclick="window.location.href = '{{{= url_for :action => %q{list} }}}';" /> </div>
|
82
88
|
|
83
|
-
|
84
|
-
|
85
|
-
|
89
|
+
</form>
|
90
|
+
</div>
|
91
|
+
</div>
|
86
92
|
|
87
93
|
|
94
|
+
<div id="<%= controller_file_name %>_list" mv:generate="<%= controller_view_dir_name %>/list.rhtml" mv:preview="showOne" class="list_div">
|
95
|
+
<div class="<%= controller_file_name %>_list sidebar">
|
96
|
+
<h1>Tasks:</h1>
|
97
|
+
<ul>
|
98
|
+
<li><a class="new_link" href="#" mv:link_to=":action => 'new<%= suffix %>'">Create new <%= singular_name %></a></li>
|
99
|
+
</ul>
|
100
|
+
</div>
|
88
101
|
|
89
|
-
|
90
|
-
|
91
|
-
<h1>Tasks:</h1>
|
92
|
-
<ul>
|
93
|
-
<li><a href="javascript:mvpreview.showOneSection('<%= controller_file_name %>_new');" mv:link_to=":action => 'new<%= suffix %>'">Create new <%= singular_name %></a></li>
|
94
|
-
</ul>
|
95
|
-
</div>
|
102
|
+
<div class="<%= controller_file_name %>_list content">
|
103
|
+
<h1><%= plural_name.capitalize %></h1>
|
96
104
|
|
97
|
-
|
98
|
-
|
105
|
+
<div class="list">
|
106
|
+
<table border="1" class="<%= controller_file_name %>_list_table" cellpadding="5">
|
107
|
+
<tr>
|
108
|
+
<%= list_head_inclusion %>
|
109
|
+
</tr>
|
110
|
+
<tr mv:gen_render=":partial => '<%= controller_view_dir_name %>/<%= singular_name %>', :collection => @<%= plural_name %>">
|
111
|
+
<%= list_line_inclusion %>
|
112
|
+
</tr>
|
113
|
+
</table>
|
99
114
|
|
100
|
-
|
101
|
-
|
102
|
-
<tr>
|
103
|
-
<%= list_head_inclusion %>
|
104
|
-
</tr>
|
105
|
-
<tr mv:gen_render=":partial => '<%= controller_view_dir_name %>/<%= singular_name %>', :collection => @<%= plural_name %>">
|
106
|
-
<%= list_line_inclusion %>
|
107
|
-
</tr>
|
108
|
-
</table>
|
115
|
+
<a class="previous_link" href="#" mv:if="@<%= singular_name %>_pages.current.previous" mv:link_to=":page => @<%= singular_name %>_pages.current.previous">Previous page</a>
|
116
|
+
<a class="next_link" href="#" mv:if="@<%= singular_name %>_pages.current.next" mv:link_to=":page => @<%= singular_name %>_pages.current.next">Next page</a>
|
109
117
|
|
110
|
-
|
111
|
-
|
118
|
+
</div>
|
119
|
+
</div>
|
120
|
+
</div>
|
112
121
|
|
113
|
-
</div>
|
114
|
-
</div>
|
115
|
-
</div>
|
116
122
|
|
123
|
+
<div id="<%= controller_file_name %>_show" mv:generate="<%= controller_view_dir_name %>/show.rhtml" mv:preview="showOne" class="show_div">
|
124
|
+
<div class="<%= controller_file_name %>_show sidebar">
|
125
|
+
<h1>Tasks:</h1>
|
126
|
+
<ul>
|
127
|
+
<li><a class="list_link" href="#" mv:link_to=":action => 'list<%= suffix %>'">Back to overview</a></li>
|
128
|
+
<li><a class="edit_link" href="#" mv:link_to=":action => 'edit<%= suffix %>', :id => @<%= singular_name %>.id">Edit this <%= singular_name %></a></li>
|
129
|
+
</ul>
|
130
|
+
</div>
|
117
131
|
|
132
|
+
<div class="<%= controller_file_name %>_show content">
|
133
|
+
<h1><%= plural_name.capitalize %></h1>
|
118
134
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
<ul>
|
123
|
-
<li><a href="javascript:mvpreview.showOneSection('<%= controller_file_name %>_list');" mv:link_to=":action => 'list<%= suffix %>'">Back to overview</a></li>
|
124
|
-
<li><a href="javascript:mvpreview.showOneSection('<%= controller_file_name %>_edit');" mv:link_to=":action => 'edit<%= suffix %>', :id => @<%= singular_name %>.id">Edit this <%= singular_name %></a></li>
|
125
|
-
</ul>
|
126
|
-
</div>
|
135
|
+
<div id="<%= controller_file_name %>_show_partial" class="form" mv:gen_render=":partial => '<%= controller_view_dir_name %>/show'">
|
136
|
+
<%= show_inclusion %>
|
137
|
+
</div>
|
127
138
|
|
128
|
-
|
129
|
-
|
139
|
+
</div>
|
140
|
+
</div>
|
130
141
|
|
131
|
-
<div id="<%= controller_file_name %>
|
132
|
-
|
133
|
-
|
142
|
+
<div id="<%= controller_file_name %>_destroy" mv:generate="<%= controller_view_dir_name %>/destroy.rhtml" mv:preview="showOne" class="destroy_div">
|
143
|
+
<div class="<%= controller_file_name %>_destroy sidebar">
|
144
|
+
<h1>Tasks:</h1>
|
145
|
+
<ul>
|
146
|
+
<li><a class="list_link" href="#" mv:link_to=":action => 'list<%= suffix %>'">Back to overview</a></li>
|
147
|
+
<li><a class="show_link" href="#" mv:link_to=":action => 'show<%= suffix %>', :id => @<%= singular_name %>.id">Show this <%= singular_name %></a></li>
|
148
|
+
</ul>
|
149
|
+
</div>
|
134
150
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
<div id="<%= controller_file_name %>_destroy" mv:generate="<%= controller_view_dir_name %>/destroy.rhtml" mv:preview="showOne">
|
139
|
-
<div class="<%= controller_file_name %>_destroy sidebar">
|
140
|
-
<h1>Tasks:</h1>
|
141
|
-
<ul>
|
142
|
-
<li><a href="javascript:mvpreview.showOneSection('<%= controller_file_name %>_list');" mv:link_to=":action => 'list<%= suffix %>'">Back to overview</a></li>
|
143
|
-
<li><a href="javascript:mvpreview.showOneSection('<%= controller_file_name %>_show');" mv:link_to=":action => 'show<%= suffix %>', :id => @<%= singular_name %>.id">Show this <%= singular_name %></a></li>
|
144
|
-
</ul>
|
145
|
-
</div>
|
146
|
-
|
147
|
-
<div class="<%= controller_file_name %>_destroy content">
|
148
|
-
<h1><%= plural_name.capitalize %></h1>
|
149
|
-
|
150
|
-
<div class="error_messages" mv:replace="error_messages_for :<%= singular_name %>">
|
151
|
-
error messages
|
152
|
-
</div>
|
151
|
+
<div class="<%= controller_file_name %>_destroy content">
|
152
|
+
<h1><%= plural_name.capitalize %></h1>
|
153
153
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
<div mv:replace="render :partial => 'show'" mv:preview="copyOf:<%= controller_file_name %>_show_partial">
|
158
|
-
copyOf:<%= controller_file_name %>_show_partial
|
159
|
-
</div>
|
154
|
+
<div class="error_messages" mv:replace="error_messages_for :<%= singular_name %>">
|
155
|
+
error messages
|
156
|
+
</div>
|
160
157
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
158
|
+
<div class="messages">Are you sure you want to delete this item?</div>
|
159
|
+
<br/>
|
160
|
+
<form mv:form=":action => 'destroy', :id => @<%= singular_name %>.id">
|
161
|
+
<div mv:replace="render :partial => 'show'" mv:preview="copyOf:<%= controller_file_name %>_show_partial">
|
162
|
+
copyOf:<%= controller_file_name %>_show_partial
|
163
|
+
</div>
|
164
|
+
|
165
|
+
<br/>
|
166
|
+
<div class="<%= controller_file_name %>_edit operations">
|
167
|
+
<input type="submit" value="Delete" mv:submit="" class="save_button"/>
|
168
|
+
<input type="button" value="Cancel" class="cancel_button" style="width: auto;" onclick="window.location.href = '{{{= url_for :action => %q{list} }}}';" />
|
169
|
+
</div>
|
170
|
+
</form>
|
171
|
+
</div>
|
165
172
|
</div>
|
166
|
-
</
|
173
|
+
</div>
|
167
174
|
</div>
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
<script type="text/javascript" mv:replace="" src="../../../public/javascripts/mvpreview.js"></script>
|
173
|
-
<script type="text/javascript" mv:replace="">
|
174
|
-
mvpreview.copySections();
|
175
|
-
mvpreview.showOneSection('<%= controller_file_name %>_list');
|
175
|
+
|
176
|
+
<script type="text/javascript" mv:replace="" src="./extra/mvpreview.js"></script>
|
177
|
+
<script type="text/javascript" mv:replace="">
|
178
|
+
mvpreview.preparePage( '<%= controller_file_name %>', {showOneSection: '<%= controller_file_name %>_list' } );
|
176
179
|
</script>
|
177
180
|
|
178
181
|
</body>
|
data/templates/mvpreview.js
CHANGED
@@ -27,5 +27,57 @@
|
|
27
27
|
|
28
28
|
mvpreview.showOneSection = function(id){
|
29
29
|
this.hideSections();
|
30
|
-
|
30
|
+
var sectionToShow = this.findSectionToShow(id);
|
31
|
+
window.Element.show( sectionToShow );
|
32
|
+
sectionToShow.style.display = 'block'; //force this to override show_only_new.css design time style
|
33
|
+
}
|
34
|
+
|
35
|
+
mvpreview.registerShowOneSectionLink = function(elemOrId, sectionToShow){
|
36
|
+
var elem = $(elemOrId);
|
37
|
+
if(elem.getAttribute('onclick')) elem.setAttribute('onclick', ''); //clear out any existing onclick
|
38
|
+
Event.observe( elem, 'click', function(e){ mvpreview.showOneSection(sectionToShow); Event.stop(e); }, false );
|
39
|
+
}
|
40
|
+
|
41
|
+
mvpreview.registerShowOneSectionLinks = function( prefix ){
|
42
|
+
var regexNew = new RegExp( "(^|\\s)" + 'new_link' + "(\\s|$)" );
|
43
|
+
var regexEdit = new RegExp( "(^|\\s)" + 'edit_link' + "(\\s|$)" );
|
44
|
+
var regexShow = new RegExp( "(^|\\s)" + 'show_link' + "(\\s|$)" );
|
45
|
+
var regexList = new RegExp( "(^|\\s)" + 'list_link' + "(\\s|$)" );
|
46
|
+
var regexPrevious = new RegExp( "(^|\\s)" + 'previous_link' + "(\\s|$)" );
|
47
|
+
var regexNext = new RegExp( "(^|\\s)" + 'next_link' + "(\\s|$)" );
|
48
|
+
var regexDestroy = new RegExp( "(^|\\s)" + 'destroy_link' + "(\\s|$)" );
|
49
|
+
var regexSave = new RegExp( "(^|\\s)" + 'save_button' + "(\\s|$)" );
|
50
|
+
var regexCancel = new RegExp( "(^|\\s)" + 'cancel_button' + "(\\s|$)" );
|
51
|
+
var allLinks = $A( document.getElementsByTagName('a') );
|
52
|
+
allLinks.each(
|
53
|
+
function(link){
|
54
|
+
var className = link.className;
|
55
|
+
if(className){
|
56
|
+
if(className.match(regexList)) mvpreview.registerShowOneSectionLink(link, prefix+'_list');
|
57
|
+
else if(className.match(regexNew)) mvpreview.registerShowOneSectionLink(link, prefix+'_new');
|
58
|
+
else if(className.match(regexEdit)) mvpreview.registerShowOneSectionLink(link, prefix+'_edit');
|
59
|
+
else if(className.match(regexShow)) mvpreview.registerShowOneSectionLink(link, prefix+'_show');
|
60
|
+
else if(className.match(regexDestroy)) mvpreview.registerShowOneSectionLink(link, prefix+'_destroy');
|
61
|
+
else if(className.match(regexPrevious)) mvpreview.registerShowOneSectionLink(link, prefix+'_list');
|
62
|
+
else if(className.match(regexNext)) mvpreview.registerShowOneSectionLink(link, prefix+'_list');
|
63
|
+
}
|
64
|
+
}
|
65
|
+
);
|
66
|
+
var allInputsAndButtons = $A( document.getElementsByTagName('input') ).concat( $A( document.getElementsByTagName('button') ));
|
67
|
+
allInputsAndButtons.each(
|
68
|
+
function(button){
|
69
|
+
var className = button.className;
|
70
|
+
if(className){
|
71
|
+
if(className.match(regexSave)) mvpreview.registerShowOneSectionLink(button, prefix+'_list');
|
72
|
+
else if(className.match(regexCancel)) mvpreview.registerShowOneSectionLink(button, prefix+'_list');
|
73
|
+
}
|
74
|
+
}
|
75
|
+
);
|
76
|
+
}
|
77
|
+
|
78
|
+
|
79
|
+
mvpreview.preparePage = function(prefix, options){
|
80
|
+
mvpreview.copySections();
|
81
|
+
mvpreview.registerShowOneSectionLinks(prefix);
|
82
|
+
if(options && options.showOneSection) mvpreview.showOneSection(options.showOneSection);
|
31
83
|
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
This stylesheet is only used by masterview templates at design time so that other divs are hidden, this allows
|
3
|
+
the designer to use absolute positioning for sections without other sections interfering with the layout.
|
4
|
+
If you want to work on a different section simply disable the stylesheet or import one of the others instead
|
5
|
+
*/
|
6
|
+
|
7
|
+
.destroy_div {
|
8
|
+
}
|
9
|
+
|
10
|
+
.new_div, .edit_div, .show_div, .list_div {
|
11
|
+
display: none;
|
12
|
+
}
|
13
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
This stylesheet is only used by masterview templates at design time so that other divs are hidden, this allows
|
3
|
+
the designer to use absolute positioning for sections without other sections interfering with the layout.
|
4
|
+
If you want to work on a different section simply disable the stylesheet or import one of the others instead
|
5
|
+
*/
|
6
|
+
|
7
|
+
.edit_div {
|
8
|
+
}
|
9
|
+
|
10
|
+
.new_div, .show_div, .list_div, .destroy_div {
|
11
|
+
display: none;
|
12
|
+
}
|
13
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
This stylesheet is only used by masterview templates at design time so that other divs are hidden, this allows
|
3
|
+
the designer to use absolute positioning for sections without other sections interfering with the layout.
|
4
|
+
If you want to work on a different section simply disable the stylesheet or import one of the others instead
|
5
|
+
*/
|
6
|
+
|
7
|
+
.list_div {
|
8
|
+
}
|
9
|
+
|
10
|
+
.new_div, .edit_div, .show_div, .destroy_div {
|
11
|
+
display: none;
|
12
|
+
}
|
13
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
This stylesheet is only used by masterview templates at design time so that other divs are hidden, this allows
|
3
|
+
the designer to use absolute positioning for sections without other sections interfering with the layout.
|
4
|
+
If you want to work on a different section simply disable the stylesheet or import one of the others instead
|
5
|
+
*/
|
6
|
+
|
7
|
+
.new_div {
|
8
|
+
}
|
9
|
+
|
10
|
+
.edit_div, .show_div, .list_div, .destroy_div {
|
11
|
+
display: none;
|
12
|
+
}
|
13
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
This stylesheet is only used by masterview templates at design time so that other divs are hidden, this allows
|
3
|
+
the designer to use absolute positioning for sections without other sections interfering with the layout.
|
4
|
+
If you want to work on a different section simply disable the stylesheet or import one of the others instead
|
5
|
+
*/
|
6
|
+
|
7
|
+
.show_div {
|
8
|
+
}
|
9
|
+
|
10
|
+
.new_div, .edit_div, .list_div, .destroy_div {
|
11
|
+
display: none;
|
12
|
+
}
|
13
|
+
|
data/templates/style.css
CHANGED
@@ -32,15 +32,15 @@ a:hover { color: #fff; background-color:#000; }
|
|
32
32
|
}
|
33
33
|
|
34
34
|
/* data fields in form */
|
35
|
-
.
|
35
|
+
.form_div .field {
|
36
36
|
}
|
37
37
|
|
38
38
|
/* label in form */
|
39
|
-
.
|
39
|
+
.form_div .label {
|
40
40
|
}
|
41
41
|
|
42
42
|
/* each record in form */
|
43
|
-
.
|
43
|
+
.form_div .record {
|
44
44
|
}
|
45
45
|
|
46
46
|
/* all labels whether in show or form */
|
@@ -58,15 +58,15 @@ a:hover { color: #fff; background-color:#000; }
|
|
58
58
|
}
|
59
59
|
|
60
60
|
/* list data field */
|
61
|
-
.
|
61
|
+
.list td {
|
62
62
|
}
|
63
63
|
|
64
64
|
/* list heading */
|
65
|
-
.
|
65
|
+
.list th {
|
66
66
|
}
|
67
67
|
|
68
68
|
/* list operation - action links */
|
69
|
-
.
|
69
|
+
.list td a {
|
70
70
|
}
|
71
71
|
|
72
72
|
/* main div top level div next to messages */
|
@@ -84,6 +84,8 @@ a:hover { color: #fff; background-color:#000; }
|
|
84
84
|
|
85
85
|
/* operations - div containing buttons for form */
|
86
86
|
.operations {
|
87
|
+
position: relative;
|
88
|
+
left: 130px;
|
87
89
|
}
|
88
90
|
|
89
91
|
/* each record whether on show or form */
|
@@ -93,15 +95,15 @@ a:hover { color: #fff; background-color:#000; }
|
|
93
95
|
}
|
94
96
|
|
95
97
|
/* data field on show */
|
96
|
-
.
|
98
|
+
.show_div .field {
|
97
99
|
}
|
98
100
|
|
99
101
|
/* labels on show */
|
100
|
-
.
|
102
|
+
.show_div .label {
|
101
103
|
}
|
102
104
|
|
103
105
|
/* records on show */
|
104
|
-
.
|
106
|
+
.show_div .record {
|
105
107
|
}
|
106
108
|
|
107
109
|
/* sidebar div containing navigation options for page */
|
@@ -110,7 +112,7 @@ a:hover { color: #fff; background-color:#000; }
|
|
110
112
|
|
111
113
|
#ErrorExplanation {
|
112
114
|
width: 400px;
|
113
|
-
border: 2px solid
|
115
|
+
border: 2px solid red;
|
114
116
|
padding: 7px;
|
115
117
|
padding-bottom: 12px;
|
116
118
|
margin-bottom: 20px;
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: masterview_generator
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2006-04-
|
6
|
+
version: 0.0.13
|
7
|
+
date: 2006-04-27 00:00:00 -05:00
|
8
8
|
summary: A (x)html friendly template engine for rails with the power of layouts, and partials. MasterView Generator for GEM
|
9
9
|
require_paths:
|
10
10
|
- .
|
@@ -41,6 +41,11 @@ files:
|
|
41
41
|
- templates/form_scaffold.rhtml
|
42
42
|
- templates/masterview.rhtml
|
43
43
|
- templates/fields_scaffold.rhtml
|
44
|
+
- templates/show_only_edit.css
|
45
|
+
- templates/show_only_new.css
|
46
|
+
- templates/show_only_show.css
|
47
|
+
- templates/show_only_list.css
|
48
|
+
- templates/show_only_destroy.css
|
44
49
|
- Rakefile
|
45
50
|
- USAGE
|
46
51
|
test_files: []
|