ajax_scaffold_generator 2.1.0 → 2.2.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/README +4 -0
- data/templates/controller.rb +32 -15
- data/templates/partial_item.rhtml +17 -15
- data/templates/script.js +8 -10
- data/templates/style.css +90 -71
- data/templates/view_edit.rhtml +36 -22
- data/templates/view_list.rhtml +13 -12
- data/templates/view_new.rhtml +33 -23
- metadata +2 -2
data/README
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
*******************************************************************************************
|
2
|
+
** For all documentation see the project website: http://ajaxscaffold.height1percent.com **
|
3
|
+
*******************************************************************************************
|
4
|
+
|
1
5
|
Description:
|
2
6
|
The ajax scaffold generator creates a controller to interact with a model.
|
3
7
|
If the model does not exist, it creates the model as well. Unlike the
|
data/templates/controller.rb
CHANGED
@@ -11,6 +11,13 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
11
11
|
end
|
12
12
|
<% end -%>
|
13
13
|
|
14
|
+
def return_to_main
|
15
|
+
# If you have multiple scaffolds on the same view then you will want to change this to
|
16
|
+
# to whatever controller/action shows all the views
|
17
|
+
# (ex: redirect_to :controller => 'AdminConsole', :action => 'index')
|
18
|
+
redirect_to :action => 'index'
|
19
|
+
end
|
20
|
+
|
14
21
|
def list<%= suffix %>
|
15
22
|
@<%= plural_name %> = <%= model_name %>.find :all
|
16
23
|
render :layout => false
|
@@ -18,44 +25,54 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
18
25
|
|
19
26
|
def new<%= suffix %>
|
20
27
|
@<%= singular_name %> = <%= model_name %>.new
|
28
|
+
|
29
|
+
if request.xhr?
|
30
|
+
@temp_id = Time.new.to_i
|
31
|
+
@headers['<%= singular_name %>-id'] = @temp_id
|
32
|
+
@headers['Content-Type'] = 'text/html; charset=utf-8'
|
21
33
|
|
22
|
-
|
23
|
-
@headers['<%= singular_name %>-id'] = @temp_id
|
24
|
-
@headers['Content-Type'] = 'text/html; charset=utf-8'
|
34
|
+
render :layout => false
|
25
35
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
# render :inline => "Error text goes here", :layout => false, :status => 500
|
36
|
+
# If you want to send an error message:
|
37
|
+
# render :inline => "Error text goes here", :layout => false, :status => 500
|
38
|
+
end
|
30
39
|
end
|
31
40
|
|
32
41
|
def create<%= suffix %>
|
33
42
|
@<%= singular_name %> = <%= model_name %>.new(params[:<%= singular_name %>])
|
34
43
|
if @<%= singular_name %>.save
|
35
|
-
|
36
|
-
|
37
|
-
|
44
|
+
if request.xhr?
|
45
|
+
@headers['<%= singular_name %>-id'] = @<%= singular_name %>.id
|
46
|
+
@headers['Content-Type'] = 'text/html; charset=utf-8'
|
47
|
+
render :partial => '<%= singular_name %><%= suffix %>', :layout => false, :locals => { :hidden => true }
|
48
|
+
else
|
49
|
+
return_to_main
|
50
|
+
end
|
38
51
|
else
|
39
|
-
render :partial => 'form_errors', :layout => false, :status => 500
|
52
|
+
render :partial => 'form_errors', :layout => false, :status => 500 if request.xhr?
|
53
|
+
render :action => 'new' if not request.xhr?
|
40
54
|
end
|
41
55
|
end
|
42
56
|
|
43
57
|
def edit<%= suffix %>
|
44
58
|
@<%= singular_name %> = <%= model_name %>.find(params[:id])
|
45
|
-
render :layout => false
|
59
|
+
render :layout => false if request.xhr?
|
46
60
|
end
|
47
61
|
|
48
62
|
def update
|
49
63
|
@<%= singular_name %> = <%= model_name %>.find(params[:id])
|
50
64
|
if @<%= singular_name %>.update_attributes(params[:<%= singular_name %>])
|
51
|
-
render :partial => '<%= singular_name %><%= suffix %>', :layout => false, :locals => { :hidden => true }
|
65
|
+
render :partial => '<%= singular_name %><%= suffix %>', :layout => false, :locals => { :hidden => true } if request.xhr?
|
66
|
+
return_to_main if not request.xhr?
|
52
67
|
else
|
53
|
-
render :partial => 'form_errors', :layout => false, :status => 500
|
68
|
+
render :partial => 'form_errors', :layout => false, :status => 500 if request.xhr?
|
69
|
+
render :action => 'edit' if not request.xhr?
|
54
70
|
end
|
55
71
|
end
|
56
72
|
|
57
73
|
def destroy<%= suffix %>
|
58
74
|
<%= model_name %>.find(params[:id]).destroy
|
59
|
-
render :nothing => true
|
75
|
+
render :nothing => true if request.xhr?
|
76
|
+
return_to_main if not request.xhr?
|
60
77
|
end
|
61
78
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
<%% # The following is used when the browser doesn't have javascript enabled %>
|
2
|
+
<%% classAttr = cycle("", "class=\"even\"") %>
|
3
|
+
<tr <%%= classAttr %> id="view-<%= singular_name %>-<%%= <%= singular_name %>.id %>" <%%= "style=\"display: none;\"" if hidden %>>
|
2
4
|
<%% for column in <%= model_name %>.content_columns %>
|
3
5
|
<td><%%=h <%= singular_name %>.send(column.name) %> </td>
|
4
6
|
<%% end %>
|
@@ -6,20 +8,20 @@
|
|
6
8
|
<div>
|
7
9
|
<%%= loading_indicator_tag '<%= singular_name %>', "edit-#{<%= singular_name %>.id}" %>
|
8
10
|
<%%= link_to_remote "Edit",
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
{ :url => { :controller => '<%= controller_name %>', :action => 'edit', :id => <%= singular_name %> },
|
12
|
+
:loading => "AjaxScaffold.editOnLoading(request,'<%= singular_name %>', #{<%= singular_name %>.id});",
|
13
|
+
:success => "AjaxScaffold.editOnSuccess(request,'<%= singular_name %>', #{<%= singular_name %>.id});",
|
14
|
+
:failure => "AjaxScaffold.editOnFailure(request,'<%= singular_name %>', #{<%= singular_name %>.id});",
|
15
|
+
:post => true },
|
16
|
+
{ :href => url_for( :controller => '<%= controller_name %>', :action => 'edit', :id => <%= singular_name %> ) } %>
|
15
17
|
<%%= link_to_remote "Delete",
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
{ :url => { :controller => '<%= controller_name %>',:action => 'destroy', :id => <%= singular_name %> },
|
19
|
+
:confirm => 'Are you sure?',
|
20
|
+
:loading => "AjaxScaffold.deleteOnLoading('<%= singular_name %>', #{<%= singular_name %>.id});",
|
21
|
+
:success => "AjaxScaffold.deleteOnSuccess('<%= singular_name %>', #{<%= singular_name %>.id});",
|
22
|
+
:failure => "AjaxScaffold.deleteOnFailure('<%= singular_name %>', #{<%= singular_name %>.id});",
|
23
|
+
:post => true },
|
24
|
+
{ :href => url_for(:controller => '<%= controller_name %>', :action => 'destroy', :id => <%= singular_name %>) } %>
|
23
25
|
</div>
|
24
26
|
</td>
|
25
|
-
</tr>
|
27
|
+
</tr>
|
data/templates/script.js
CHANGED
@@ -228,6 +228,7 @@ var AjaxScaffold = {
|
|
228
228
|
},
|
229
229
|
newOnSuccess: function(request, type) {
|
230
230
|
var createForm = request.responseText;
|
231
|
+
|
231
232
|
var id = this.getId(request,type);
|
232
233
|
|
233
234
|
new Insertion.Top(this.getTableBodyElement(type), createForm);
|
@@ -240,14 +241,8 @@ var AjaxScaffold = {
|
|
240
241
|
TableBodyUtil.highlight(createElement,this.getTableBodyElement(type));
|
241
242
|
Form.focusFirstElement(this.getFormElement('create',type,id));
|
242
243
|
},
|
243
|
-
newOnComplete: function(request, type) {
|
244
|
-
|
245
|
-
},
|
246
|
-
getNewIndicator: function(type) {
|
247
|
-
return $(type + "-new-loading-indicator");
|
248
|
-
},
|
249
244
|
|
250
|
-
|
245
|
+
|
251
246
|
createOnLoading: function(request,type,id) {
|
252
247
|
Element.show(this.getIndicator('create',type,id));
|
253
248
|
},
|
@@ -330,7 +325,8 @@ var AjaxScaffold = {
|
|
330
325
|
Element.hide(viewElement);
|
331
326
|
Element.hide(this.getIndicator('edit',type,id));
|
332
327
|
Element.show(editElement);
|
333
|
-
|
328
|
+
|
329
|
+
new TableEffect.Highlight(editElement);
|
334
330
|
Form.focusFirstElement(formElement);
|
335
331
|
},
|
336
332
|
|
@@ -358,7 +354,7 @@ var AjaxScaffold = {
|
|
358
354
|
new Insertion.Bottom(this.getTableBodyElement(type), view);
|
359
355
|
var viewElement = this.getViewElement(type,id);
|
360
356
|
new TableRow.MoveBefore(editElement, viewElement);
|
361
|
-
|
357
|
+
|
362
358
|
Element.remove(editElement);
|
363
359
|
Element.show(viewElement);
|
364
360
|
|
@@ -388,7 +384,9 @@ var AjaxScaffold = {
|
|
388
384
|
|
389
385
|
|
390
386
|
|
391
|
-
|
387
|
+
getNewIndicator: function(type) {
|
388
|
+
return $(type + "-new-loading-indicator");
|
389
|
+
},
|
392
390
|
getIndicator: function(scope, type,id) {
|
393
391
|
return $(type + '-' + scope + '-' + id + "-loading-indicator");
|
394
392
|
},
|
data/templates/style.css
CHANGED
@@ -1,33 +1,39 @@
|
|
1
|
-
.
|
2
|
-
.
|
3
|
-
.
|
4
|
-
.
|
5
|
-
.
|
1
|
+
.ajax-scaffold-wrapper form,
|
2
|
+
.ajax-scaffold-wrapper table,
|
3
|
+
.ajax-scaffold-wrapper p,
|
4
|
+
.ajax-scaffold-wrapper div,
|
5
|
+
.ajax-scaffold-wrapper fieldset,
|
6
|
+
.ajax-scaffold form,
|
7
|
+
.ajax-scaffold table,
|
8
|
+
.ajax-scaffold p,
|
9
|
+
.ajax-scaffold div,
|
10
|
+
.ajax-scaffold fieldset {
|
6
11
|
margin: 0;
|
7
12
|
padding: 0;
|
8
13
|
}
|
9
14
|
|
10
|
-
|
15
|
+
.ajax-scaffold a {
|
11
16
|
color: #0066CC;
|
17
|
+
text-decoration: none;
|
12
18
|
}
|
13
19
|
|
14
|
-
.
|
20
|
+
.ajax-scaffold-wrapper {
|
15
21
|
margin: 5px 0;
|
16
22
|
}
|
17
23
|
|
18
|
-
|
24
|
+
.ajax-scaffold {
|
19
25
|
width: 100%;
|
20
26
|
}
|
21
27
|
|
22
28
|
/* Header Styling
|
23
29
|
======================== */
|
24
30
|
|
25
|
-
.
|
31
|
+
.ajax-scaffold-header {
|
26
32
|
position: relative;
|
27
33
|
background: #005CB8;
|
28
34
|
}
|
29
35
|
|
30
|
-
.
|
36
|
+
.ajax-scaffold-header div.actions a {
|
31
37
|
color: #fff;
|
32
38
|
background: url(/images/add.gif) 1px 50% no-repeat;
|
33
39
|
font-size: 13px;
|
@@ -37,11 +43,11 @@ text-decoration: none;
|
|
37
43
|
padding: 1px 2px 1px 19px;
|
38
44
|
}
|
39
45
|
|
40
|
-
.
|
46
|
+
.ajax-scaffold-header div.actions a:hover {
|
41
47
|
background: #378CDF url(/images/add.gif) 1px 50% no-repeat;
|
42
48
|
}
|
43
49
|
|
44
|
-
.
|
50
|
+
.ajax-scaffold-header h2 {
|
45
51
|
color: #fff;
|
46
52
|
padding: 3px 5px;
|
47
53
|
margin: 0;
|
@@ -50,7 +56,7 @@ font-weight: normal;
|
|
50
56
|
font-family: Verdana, sans-serif;
|
51
57
|
}
|
52
58
|
|
53
|
-
.
|
59
|
+
.ajax-scaffold-header .actions {
|
54
60
|
position: absolute;
|
55
61
|
right: 5px;
|
56
62
|
bottom: 2px;
|
@@ -59,12 +65,11 @@ bottom: 2px;
|
|
59
65
|
/* Table Column Headers
|
60
66
|
============================= */
|
61
67
|
|
62
|
-
|
63
|
-
table.list tr.header {
|
68
|
+
.ajax-scaffold tr.header {
|
64
69
|
background: #C5DBF7;
|
65
70
|
}
|
66
71
|
|
67
|
-
|
72
|
+
.ajax-scaffold th {
|
68
73
|
font-size: 11px;
|
69
74
|
padding: 2px;
|
70
75
|
color: #fff;
|
@@ -78,7 +83,7 @@ padding-left: 5px;
|
|
78
83
|
/* Table Body Styling
|
79
84
|
============================= */
|
80
85
|
|
81
|
-
|
86
|
+
.ajax-scaffold td {
|
82
87
|
padding: 5px 4px;
|
83
88
|
border-bottom: solid 1px #C5DBF7;
|
84
89
|
color: #333;
|
@@ -87,23 +92,20 @@ font-size: 11px;
|
|
87
92
|
background-color: #E6F2FF;
|
88
93
|
}
|
89
94
|
|
90
|
-
|
95
|
+
.ajax-scaffold tr.even td {
|
91
96
|
background-color: #fff;
|
92
97
|
}
|
93
98
|
|
94
|
-
|
95
|
-
|
96
|
-
table.list .create td {
|
99
|
+
.ajax-scaffold .edit td,
|
100
|
+
.ajax-scaffold .create td {
|
97
101
|
padding: 0;
|
98
102
|
padding: 4px;
|
99
103
|
}
|
100
104
|
|
101
|
-
|
102
|
-
|
103
|
-
padding-right: 2px;
|
104
|
-
}
|
105
|
+
/* Table Actions (Edit, Delete) Styling
|
106
|
+
============================= */
|
105
107
|
|
106
|
-
|
108
|
+
.ajax-scaffold td a {
|
107
109
|
font-family: Verdana, sans-serif;
|
108
110
|
font-size: 11px;
|
109
111
|
font-weight: bold;
|
@@ -112,40 +114,51 @@ padding: 2px;
|
|
112
114
|
line-height: 18px;
|
113
115
|
}
|
114
116
|
|
115
|
-
|
117
|
+
/* The following fixes some very weird
|
118
|
+
layout issue in IE where the edit link
|
119
|
+
is too close to the delete link after
|
120
|
+
the introduction of the taconite JS library
|
121
|
+
.ajax-scaffold .actions a {
|
122
|
+
display: block;
|
123
|
+
float: right;
|
124
|
+
padding: 0 2px;
|
125
|
+
margin-left: 3px;
|
126
|
+
}
|
127
|
+
*/
|
128
|
+
|
129
|
+
.ajax-scaffold td a:hover {
|
116
130
|
background: #ff8;
|
117
131
|
}
|
118
132
|
|
119
|
-
|
120
|
-
|
133
|
+
.ajax-scaffold .edit td,
|
134
|
+
.ajax-scaffold .create td {
|
121
135
|
background: #DAFFCD;
|
122
136
|
}
|
123
137
|
|
124
|
-
|
125
|
-
|
138
|
+
.ajax-scaffold .edit td,
|
139
|
+
.ajax-scaffold .create td {
|
126
140
|
border-top: solid 2px #fff;
|
127
141
|
border-bottom: solid 2px #fff;
|
128
142
|
}
|
129
143
|
|
130
|
-
|
144
|
+
.ajax-scaffold .actions div {
|
131
145
|
width: 95px;
|
132
|
-
right: 0;
|
133
146
|
text-align: right;
|
134
147
|
float: right;
|
135
148
|
padding-right: 2px;
|
136
149
|
}
|
137
150
|
|
138
|
-
/*
|
151
|
+
/* ajax-scaffold Footer Styling
|
139
152
|
========================== */
|
140
153
|
|
141
|
-
.
|
154
|
+
.ajax-scaffold-wrapper .ajax-scaffold-footer {
|
142
155
|
text-align: right;
|
143
156
|
background: #005CB8;
|
144
157
|
padding: 2px 0;
|
145
158
|
border-bottom: none;
|
146
159
|
}
|
147
160
|
|
148
|
-
|
161
|
+
.ajax-scaffold tfoot a {
|
149
162
|
color: #fff;
|
150
163
|
font-size: 12px;
|
151
164
|
font-weight: bold;
|
@@ -153,20 +166,20 @@ letter-spacing: 0;
|
|
153
166
|
font-family: Arial, sans-serif;
|
154
167
|
}
|
155
168
|
|
156
|
-
|
169
|
+
.ajax-scaffold tfoot a:hover {
|
157
170
|
color: #0066CC;
|
158
171
|
}
|
159
172
|
|
160
173
|
/* Messages
|
161
174
|
========================= */
|
162
175
|
|
163
|
-
|
176
|
+
.ajax-scaffold .empty-message td {
|
164
177
|
background: #e8e8e8;
|
165
178
|
text-align: center;
|
166
179
|
color: #666;
|
167
180
|
}
|
168
181
|
|
169
|
-
|
182
|
+
.ajax-scaffold .error-message td {
|
170
183
|
border-bottom: solid 1px #fff;
|
171
184
|
background: #f66;
|
172
185
|
color: #333;
|
@@ -174,30 +187,35 @@ font-size: 11px;
|
|
174
187
|
font-weight: bold;
|
175
188
|
}
|
176
189
|
|
177
|
-
|
190
|
+
.ajax-scaffold .error-message p {
|
178
191
|
padding-left: 19px;
|
179
192
|
background: url(/images/error.gif) 0 0 no-repeat;
|
180
193
|
}
|
181
194
|
|
182
|
-
|
195
|
+
.ajax-scaffold .error-message td.actions {
|
183
196
|
background: #f66;
|
184
197
|
text-align: right;
|
185
198
|
}
|
186
199
|
|
187
|
-
|
200
|
+
.ajax-scaffold .error-message td.actions a {
|
188
201
|
color: #333;
|
189
202
|
}
|
190
203
|
|
191
204
|
/* Error Styling
|
192
205
|
========================== */
|
193
206
|
|
194
|
-
|
207
|
+
.ajax-scaffold #errorExplanation {
|
195
208
|
background: #fcc;
|
196
209
|
margin: 2px 7px;
|
197
210
|
border: solid 1px #f66;
|
211
|
+
float: left;
|
212
|
+
}
|
213
|
+
|
214
|
+
.ajax-scaffold fieldset {
|
215
|
+
clear: both;
|
198
216
|
}
|
199
217
|
|
200
|
-
|
218
|
+
.ajax-scaffold #errorExplanation h2 {
|
201
219
|
padding: 2px 5px 3px 20px;
|
202
220
|
color: #333;
|
203
221
|
font-size: 11px;
|
@@ -207,51 +225,49 @@ font-family: Verdana;
|
|
207
225
|
background: #f66 url(/images/error.gif) 2px 1px no-repeat;
|
208
226
|
}
|
209
227
|
|
210
|
-
|
228
|
+
.ajax-scaffold #errorExplanation ul {
|
211
229
|
margin: 0;
|
212
230
|
padding: 2px 2px 4px 25px;
|
213
231
|
}
|
214
232
|
|
215
|
-
|
233
|
+
.ajax-scaffold #errorExplanation p {
|
216
234
|
font-size: 11px;
|
217
235
|
padding: 2px 5px;
|
218
236
|
font-family: Verdana;
|
219
237
|
margin: 0;
|
220
238
|
}
|
221
239
|
|
222
|
-
|
240
|
+
.ajax-scaffold #errorExplanation ul li {
|
223
241
|
font-size: 11px;
|
224
242
|
margin: 0;
|
225
243
|
font-family: Verdana;
|
226
244
|
padding: 0;
|
227
245
|
}
|
228
246
|
|
229
|
-
|
247
|
+
.ajax-scaffold .fieldWithErrors input {
|
230
248
|
border: solid 1px #f00;
|
231
249
|
}
|
232
250
|
|
233
251
|
/* Loading Indicators
|
234
252
|
============================== */
|
235
253
|
|
236
|
-
.
|
254
|
+
.ajax-scaffold-wrapper .loading-indicator {
|
237
255
|
vertical-align: bottom;
|
238
256
|
margin: 0;
|
239
257
|
}
|
240
258
|
|
241
|
-
.
|
242
|
-
.
|
243
|
-
.
|
259
|
+
.ajax-scaffold-wrapper .ajax-scaffold-header .loading-indicator,
|
260
|
+
.ajax-scaffold-wrapper .edit .loading-indicator,
|
261
|
+
.ajax-scaffold-wrapper .create .loading-indicator {
|
244
262
|
vertical-align: bottom;
|
245
263
|
margin-bottom: 3px;
|
246
264
|
}
|
247
265
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
266
|
/* Form Styling
|
252
267
|
============================== */
|
253
268
|
|
254
|
-
.
|
269
|
+
.ajax-scaffold-wrapper .submit,
|
270
|
+
.ajax-scaffold .submit {
|
255
271
|
font-weight: bold;
|
256
272
|
font-size: 14px;
|
257
273
|
font-family: Arial, sans-serif;
|
@@ -260,55 +276,58 @@ margin: 0;
|
|
260
276
|
margin-top: 5px;
|
261
277
|
}
|
262
278
|
|
263
|
-
.
|
279
|
+
.ajax-scaffold-wrapper fieldset,
|
280
|
+
.ajax-scaffold fieldset {
|
264
281
|
border: none;
|
265
282
|
}
|
266
283
|
|
267
|
-
|
284
|
+
.ajax-scaffold label.required{
|
268
285
|
font-weight: bold;
|
269
286
|
}
|
270
287
|
|
271
|
-
|
288
|
+
.ajax-scaffold label.example {
|
272
289
|
font-size: 11px;
|
273
290
|
font-family: arial;
|
274
291
|
color: #888;
|
275
292
|
}
|
276
293
|
|
277
|
-
|
294
|
+
.ajax-scaffold h4 {
|
278
295
|
padding: 2px;
|
279
296
|
margin: 0;
|
297
|
+
font-weight: bold;
|
298
|
+
text-transform: none;
|
280
299
|
color: #1F7F00;
|
281
300
|
font-size: 16px;
|
282
301
|
letter-spacing: -1px;
|
283
302
|
font-family: Georgia, Arial, sans-serif;
|
284
303
|
}
|
285
304
|
|
286
|
-
|
287
|
-
|
305
|
+
.ajax-scaffold .edit a,
|
306
|
+
.ajax-scaffold .create a {
|
288
307
|
font-size: 14px;
|
289
308
|
font-weight: bold;
|
290
309
|
font-family: Arial, sans-serif;
|
291
310
|
letter-spacing: 0;
|
292
311
|
}
|
293
312
|
|
294
|
-
|
313
|
+
.ajax-scaffold p {
|
295
314
|
clear: both;
|
296
315
|
}
|
297
316
|
|
298
|
-
|
317
|
+
.ajax-scaffold div.row {
|
299
318
|
clear: both;
|
300
319
|
float: none;
|
301
320
|
padding: 2px;
|
302
321
|
margin-left: 5px;
|
303
322
|
}
|
304
323
|
|
305
|
-
|
324
|
+
.ajax-scaffold div.form-element {
|
306
325
|
float: left;
|
307
326
|
margin-right: 10px;
|
308
327
|
margin-bottom: 2px;
|
309
328
|
}
|
310
329
|
|
311
|
-
|
330
|
+
.ajax-scaffold label {
|
312
331
|
display: block;
|
313
332
|
font-family: Verdana, sans-serif;
|
314
333
|
color: #555;
|
@@ -316,20 +335,20 @@ font-size: 11px;
|
|
316
335
|
padding-bottom: 1px;
|
317
336
|
}
|
318
337
|
|
319
|
-
|
320
|
-
|
338
|
+
.ajax-scaffold input,
|
339
|
+
.ajax-scaffold select {
|
321
340
|
font-size: 16px;
|
322
341
|
font-weight: bold;
|
323
342
|
font-family: Arial, sans-serif;
|
324
343
|
letter-spacing: -1px;
|
325
344
|
}
|
326
345
|
|
327
|
-
|
346
|
+
.ajax-scaffold .form-element input {
|
328
347
|
padding: 1px;
|
329
348
|
border: solid 1px #1F7F00;
|
330
349
|
}
|
331
350
|
|
332
|
-
|
351
|
+
.ajax-scaffold textarea {
|
333
352
|
height: 65px;
|
334
353
|
font-family: Arial, sans-serif;
|
335
354
|
font-size: 12px;
|
@@ -340,6 +359,6 @@ border: solid 1px #1F7F00;
|
|
340
359
|
/* IE hacks
|
341
360
|
==================================== */
|
342
361
|
|
343
|
-
* html .
|
362
|
+
* html .ajax-scaffold-header {
|
344
363
|
height: 1%;
|
345
364
|
}
|
data/templates/view_edit.rhtml
CHANGED
@@ -1,22 +1,36 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
1
|
+
<%% if not request.xhr? %>
|
2
|
+
<table class="ajax-scaffold" cellpadding="0" cellspacing="0">
|
3
|
+
<tbody>
|
4
|
+
<%% end %>
|
5
|
+
<tr id="<%%= "edit-<%= singular_name %>-#{@<%= singular_name %>.id}" %>" class="edit" <%%= "style=\"display: none;\"" if request.xhr? %> >
|
6
|
+
<td colspan="<%%= num_columns %>">
|
7
|
+
<%%= form_remote_tag :url => { :controller => '<%= controller_name %>', :action => 'update', :id => @<%= singular_name %> },
|
8
|
+
:loading => "AjaxScaffold.updateOnLoading(request,'<%= singular_name %>',#{@<%= singular_name %>.id});",
|
9
|
+
:success => "AjaxScaffold.updateOnSuccess(request,'<%= singular_name %>',#{@<%= singular_name %>.id});",
|
10
|
+
:failure => "AjaxScaffold.updateOnFailure(request,'<%= singular_name %>',#{@<%= singular_name %>.id});",
|
11
|
+
:html => { :action => url_for(:controller => '<%= controller_name %>', :action => 'update', :id => @<%= singular_name %>),
|
12
|
+
:id => "edit-<%= singular_name %>-#{@<%= singular_name %>.id}-form" } %>
|
13
|
+
<h4>Edit <%= Inflector.titleize(singular_name) %></h4>
|
14
|
+
|
15
|
+
<%% # Its actually okay to leave both of these elements (ex: form_errors will only generate HTML when in fallback mode) %>
|
16
|
+
<%% if request.xhr? %>
|
17
|
+
<div id="<%%= "update-<%= singular_name %>-#{@<%= singular_name %>.id}-errors" %>" style="display: none;" ></div>
|
18
|
+
<%% else %>
|
19
|
+
<%%= render :partial => 'form_errors' %>
|
20
|
+
<%% end %>
|
21
|
+
|
22
|
+
<%%= render :partial => 'form' %>
|
23
|
+
|
24
|
+
<p>
|
25
|
+
<%%= submit_tag "Update", :class => "submit" %>
|
26
|
+
<%%= link_to_function "Cancel", "AjaxScaffold.updateOnCancel('<%= singular_name %>',#{@<%= singular_name %>.id});",
|
27
|
+
:href => url_for(:controller => '<%= controller_name %>', :action => 'return_to_main') %>
|
28
|
+
<%%= loading_indicator_tag '<%= singular_name %>', "update-#{@<%= singular_name %>.id}" %>
|
29
|
+
</p>
|
30
|
+
<%%= end_form_tag %>
|
31
|
+
</td>
|
32
|
+
</tr>
|
33
|
+
<%% if not request.xhr? %>
|
34
|
+
</tbody>
|
35
|
+
</table>
|
36
|
+
<%% end %>
|
data/templates/view_list.rhtml
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
<div id="<%= singular_name %>-list-wrapper" class="
|
2
|
-
<div id="<%= singular_name %>-list-header" class="
|
1
|
+
<div id="<%= singular_name %>-list-wrapper" class="ajax-scaffold-wrapper">
|
2
|
+
<div id="<%= singular_name %>-list-header" class="ajax-scaffold-header">
|
3
3
|
<h2><%= Inflector.titleize(plural_name) %></h2>
|
4
4
|
|
5
5
|
<div class="actions">
|
6
6
|
<%%= loading_indicator_tag '<%= singular_name %>', "new" %>
|
7
7
|
<%%= link_to_remote "Create New",
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
{ :url => { :controller => '<%= controller_name %>', :action => 'new' },
|
9
|
+
:loading => "AjaxScaffold.newOnLoading(request,'<%= singular_name %>');",
|
10
|
+
:success => "AjaxScaffold.newOnSuccess(request,'<%= singular_name %>');",
|
11
|
+
:failure => "AjaxScaffold.newOnFailure(request,'<%= singular_name %>');" },
|
12
|
+
{ :href => url_for(:controller => '<%= controller_name %>', :action => 'new'),
|
13
|
+
:class => "create" } %>
|
14
14
|
|
15
15
|
</div>
|
16
16
|
|
17
17
|
</div>
|
18
|
-
<table id="<%= singular_name %>-list" class="
|
18
|
+
<table id="<%= singular_name %>-list" class="ajax-scaffold" cellpadding="0" cellspacing="0">
|
19
19
|
<thead>
|
20
20
|
<tr class="header">
|
21
21
|
<%% for column in <%= model_name %>.content_columns %>
|
@@ -40,11 +40,12 @@
|
|
40
40
|
<tbody id="<%= singular_name %>-list-body">
|
41
41
|
<%% if !@<%= plural_name %>.empty? %>
|
42
42
|
<%%= render :partial => '<%= singular_name %>', :collection => @<%= plural_name %>, :locals => { :hidden => false } %>
|
43
|
-
<%%
|
44
|
-
|
43
|
+
<%% else %>
|
44
|
+
<%% # Do not remove the following TR, it is needed to load up the even row color when enableHighlighting is turned on and the list is empty %>
|
45
45
|
<tr class="even ignore" style="display: none;">
|
46
46
|
<td colspan="<%%= num_columns %>"></td>
|
47
47
|
</tr>
|
48
|
+
<%% end %>
|
48
49
|
</tbody>
|
49
50
|
</table>
|
50
51
|
</div>
|
@@ -55,4 +56,4 @@ TableBodyUtil.enableHighlighting(AjaxScaffold.getTableBodyElement('<%= singular_
|
|
55
56
|
TableBodyUtil.paintStripes(AjaxScaffold.getTableBodyElement('<%= singular_name %>'));
|
56
57
|
<%% end %>
|
57
58
|
Rico.Corner.round('<%= singular_name %>-list-wrapper', {color: '#005CB8', bgColor: '#fff', compact: true});
|
58
|
-
</script>
|
59
|
+
</script>
|
data/templates/view_new.rhtml
CHANGED
@@ -1,23 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
1
|
+
<%% if not request.xhr? %>
|
2
|
+
<table class="ajax-scaffold" cellpadding="0" cellspacing="0">
|
3
|
+
<tbody>
|
4
|
+
<%% end %>
|
5
|
+
<tr id="create-<%= singular_name %>-<%%= @temp_id %>" class="create" <%%= "style=\"display: none;\"" if request.xhr? %>>
|
6
|
+
<td colspan="<%%= num_columns %>">
|
7
|
+
<%%= form_remote_tag :url => { :controller => '<%= controller_name %>', :action => 'create' },
|
8
|
+
:loading => "AjaxScaffold.createOnLoading(request,'<%= singular_name %>',#{@temp_id});",
|
9
|
+
:success => "AjaxScaffold.createOnSuccess(request,'<%= singular_name %>',#{@temp_id});",
|
10
|
+
:failure => "AjaxScaffold.createOnFailure(request,'<%= singular_name %>',#{@temp_id});",
|
11
|
+
:html => { :action => url_for(:controller => '<%= controller_name %>', :action => 'create'),
|
12
|
+
:id => "create-<%= singular_name %>-#{@temp_id}-form" } %>
|
13
|
+
|
14
|
+
<h4>New <%= Inflector.titleize(singular_name) %></h4>
|
15
|
+
|
16
|
+
<%% # Its actually okay to leave both of these elements (ex: form_errors will only generate HTML when in fallback mode) %>
|
17
|
+
<%% if request.xhr? %>
|
18
|
+
<div id="<%%= "create-<%= singular_name %>-#{@temp_id}-errors" %>" style="display: none;" ></div>
|
19
|
+
<%% else %>
|
20
|
+
<%%= render :partial => 'form_errors' %>
|
21
|
+
<%% end %>
|
22
|
+
|
23
|
+
<%%= render :partial => 'form' %>
|
24
|
+
|
25
|
+
<p>
|
26
|
+
<%%= submit_tag "Create", :class => "submit" %>
|
27
|
+
<%%= link_to_function "Cancel", "AjaxScaffold.createOnCancel('<%= singular_name %>',#{@temp_id});",
|
28
|
+
:href => url_for(:controller => '<%= controller_name %>', :action => 'return_to_main') %>
|
29
|
+
<%%= loading_indicator_tag '<%= singular_name %>', "create-#{@temp_id}" %>
|
30
|
+
</p>
|
31
|
+
<%%= end_form_tag %>
|
32
|
+
</td>
|
33
|
+
</tr>
|
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: 2.
|
7
|
-
date: 2006-
|
6
|
+
version: 2.2.0
|
7
|
+
date: 2006-03-03 00:00:00 -05:00
|
8
8
|
summary: Ajax scaffold generator is a rails generator for ajaxified scaffolds
|
9
9
|
require_paths:
|
10
10
|
- lib
|