beautiful_scaffold 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/beautiful_scaffold.gemspec +1 -1
- data/lib/generators/beautiful_scaffold_generator.rb +13 -3
- data/lib/generators/templates/app/assets/javascripts/bootstrap-datepicker.js +834 -0
- data/lib/generators/templates/app/assets/javascripts/bootstrap-datetimepicker-for-beautiful-scaffold.js +28 -0
- data/lib/generators/templates/app/assets/javascripts/bootstrap-timepicker.js +793 -0
- data/lib/generators/templates/app/assets/javascripts/jquery.livequery.js +226 -0
- data/lib/generators/templates/app/assets/stylesheets/datepicker.css +224 -0
- data/lib/generators/templates/app/assets/stylesheets/timepicker.css +92 -0
- data/lib/generators/templates/app/controllers/base.rb +14 -2
- data/lib/generators/templates/app/helpers/beautiful_helper.rb +38 -7
- data/lib/generators/templates/app/views/_form.html.erb +1 -1
- data/lib/generators/templates/app/views/_mass_inserting.html.erb +41 -0
- data/lib/generators/templates/app/views/_modal_columns.html.erb +4 -0
- data/lib/generators/templates/app/views/index.html.erb +16 -2
- data/lib/generators/templates/app/views/layout.html.erb +13 -5
- data/lib/generators/templates/app/views/partials/_form_field.html.erb +29 -0
- data/lib/generators/templates/app/views/partials/_index_column.html.erb +6 -6
- metadata +9 -2
@@ -0,0 +1,226 @@
|
|
1
|
+
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
|
2
|
+
* Dual licensed under the MIT (MIT_LICENSE.txt)
|
3
|
+
* and GPL Version 2 (GPL_LICENSE.txt) licenses.
|
4
|
+
*
|
5
|
+
* Version: 1.1.1
|
6
|
+
* Requires jQuery 1.3+
|
7
|
+
* Docs: http://docs.jquery.com/Plugins/livequery
|
8
|
+
*/
|
9
|
+
|
10
|
+
(function($) {
|
11
|
+
|
12
|
+
$.extend($.fn, {
|
13
|
+
livequery: function(type, fn, fn2) {
|
14
|
+
var self = this, q;
|
15
|
+
|
16
|
+
// Handle different call patterns
|
17
|
+
if ($.isFunction(type))
|
18
|
+
fn2 = fn, fn = type, type = undefined;
|
19
|
+
|
20
|
+
// See if Live Query already exists
|
21
|
+
$.each( $.livequery.queries, function(i, query) {
|
22
|
+
if ( self.selector == query.selector && self.context == query.context &&
|
23
|
+
type == query.type && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) )
|
24
|
+
// Found the query, exit the each loop
|
25
|
+
return (q = query) && false;
|
26
|
+
});
|
27
|
+
|
28
|
+
// Create new Live Query if it wasn't found
|
29
|
+
q = q || new $.livequery(this.selector, this.context, type, fn, fn2);
|
30
|
+
|
31
|
+
// Make sure it is running
|
32
|
+
q.stopped = false;
|
33
|
+
|
34
|
+
// Run it immediately for the first time
|
35
|
+
q.run();
|
36
|
+
|
37
|
+
// Contnue the chain
|
38
|
+
return this;
|
39
|
+
},
|
40
|
+
|
41
|
+
expire: function(type, fn, fn2) {
|
42
|
+
var self = this;
|
43
|
+
|
44
|
+
// Handle different call patterns
|
45
|
+
if ($.isFunction(type))
|
46
|
+
fn2 = fn, fn = type, type = undefined;
|
47
|
+
|
48
|
+
// Find the Live Query based on arguments and stop it
|
49
|
+
$.each( $.livequery.queries, function(i, query) {
|
50
|
+
if ( self.selector == query.selector && self.context == query.context &&
|
51
|
+
(!type || type == query.type) && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) && !this.stopped )
|
52
|
+
$.livequery.stop(query.id);
|
53
|
+
});
|
54
|
+
|
55
|
+
// Continue the chain
|
56
|
+
return this;
|
57
|
+
}
|
58
|
+
});
|
59
|
+
|
60
|
+
$.livequery = function(selector, context, type, fn, fn2) {
|
61
|
+
this.selector = selector;
|
62
|
+
this.context = context;
|
63
|
+
this.type = type;
|
64
|
+
this.fn = fn;
|
65
|
+
this.fn2 = fn2;
|
66
|
+
this.elements = [];
|
67
|
+
this.stopped = false;
|
68
|
+
|
69
|
+
// The id is the index of the Live Query in $.livequery.queries
|
70
|
+
this.id = $.livequery.queries.push(this)-1;
|
71
|
+
|
72
|
+
// Mark the functions for matching later on
|
73
|
+
fn.$lqguid = fn.$lqguid || $.livequery.guid++;
|
74
|
+
if (fn2) fn2.$lqguid = fn2.$lqguid || $.livequery.guid++;
|
75
|
+
|
76
|
+
// Return the Live Query
|
77
|
+
return this;
|
78
|
+
};
|
79
|
+
|
80
|
+
$.livequery.prototype = {
|
81
|
+
stop: function() {
|
82
|
+
var query = this;
|
83
|
+
|
84
|
+
if ( this.type )
|
85
|
+
// Unbind all bound events
|
86
|
+
this.elements.unbind(this.type, this.fn);
|
87
|
+
else if (this.fn2)
|
88
|
+
// Call the second function for all matched elements
|
89
|
+
this.elements.each(function(i, el) {
|
90
|
+
query.fn2.apply(el);
|
91
|
+
});
|
92
|
+
|
93
|
+
// Clear out matched elements
|
94
|
+
this.elements = [];
|
95
|
+
|
96
|
+
// Stop the Live Query from running until restarted
|
97
|
+
this.stopped = true;
|
98
|
+
},
|
99
|
+
|
100
|
+
run: function() {
|
101
|
+
// Short-circuit if stopped
|
102
|
+
if ( this.stopped ) return;
|
103
|
+
var query = this;
|
104
|
+
|
105
|
+
var oEls = this.elements,
|
106
|
+
els = $(this.selector, this.context),
|
107
|
+
nEls = els.not(oEls);
|
108
|
+
|
109
|
+
// Set elements to the latest set of matched elements
|
110
|
+
this.elements = els;
|
111
|
+
|
112
|
+
if (this.type) {
|
113
|
+
// Bind events to newly matched elements
|
114
|
+
nEls.bind(this.type, this.fn);
|
115
|
+
|
116
|
+
// Unbind events to elements no longer matched
|
117
|
+
if (oEls.length > 0)
|
118
|
+
$.each(oEls, function(i, el) {
|
119
|
+
if ( $.inArray(el, els) < 0 )
|
120
|
+
$.event.remove(el, query.type, query.fn);
|
121
|
+
});
|
122
|
+
}
|
123
|
+
else {
|
124
|
+
// Call the first function for newly matched elements
|
125
|
+
nEls.each(function() {
|
126
|
+
query.fn.apply(this);
|
127
|
+
});
|
128
|
+
|
129
|
+
// Call the second function for elements no longer matched
|
130
|
+
if ( this.fn2 && oEls.length > 0 )
|
131
|
+
$.each(oEls, function(i, el) {
|
132
|
+
if ( $.inArray(el, els) < 0 )
|
133
|
+
query.fn2.apply(el);
|
134
|
+
});
|
135
|
+
}
|
136
|
+
}
|
137
|
+
};
|
138
|
+
|
139
|
+
$.extend($.livequery, {
|
140
|
+
guid: 0,
|
141
|
+
queries: [],
|
142
|
+
queue: [],
|
143
|
+
running: false,
|
144
|
+
timeout: null,
|
145
|
+
|
146
|
+
checkQueue: function() {
|
147
|
+
if ( $.livequery.running && $.livequery.queue.length ) {
|
148
|
+
var length = $.livequery.queue.length;
|
149
|
+
// Run each Live Query currently in the queue
|
150
|
+
while ( length-- )
|
151
|
+
$.livequery.queries[ $.livequery.queue.shift() ].run();
|
152
|
+
}
|
153
|
+
},
|
154
|
+
|
155
|
+
pause: function() {
|
156
|
+
// Don't run anymore Live Queries until restarted
|
157
|
+
$.livequery.running = false;
|
158
|
+
},
|
159
|
+
|
160
|
+
play: function() {
|
161
|
+
// Restart Live Queries
|
162
|
+
$.livequery.running = true;
|
163
|
+
// Request a run of the Live Queries
|
164
|
+
$.livequery.run();
|
165
|
+
},
|
166
|
+
|
167
|
+
registerPlugin: function() {
|
168
|
+
$.each( arguments, function(i,n) {
|
169
|
+
// Short-circuit if the method doesn't exist
|
170
|
+
if (!$.fn[n]) return;
|
171
|
+
|
172
|
+
// Save a reference to the original method
|
173
|
+
var old = $.fn[n];
|
174
|
+
|
175
|
+
// Create a new method
|
176
|
+
$.fn[n] = function() {
|
177
|
+
// Call the original method
|
178
|
+
var r = old.apply(this, arguments);
|
179
|
+
|
180
|
+
// Request a run of the Live Queries
|
181
|
+
$.livequery.run();
|
182
|
+
|
183
|
+
// Return the original methods result
|
184
|
+
return r;
|
185
|
+
}
|
186
|
+
});
|
187
|
+
},
|
188
|
+
|
189
|
+
run: function(id) {
|
190
|
+
if (id != undefined) {
|
191
|
+
// Put the particular Live Query in the queue if it doesn't already exist
|
192
|
+
if ( $.inArray(id, $.livequery.queue) < 0 )
|
193
|
+
$.livequery.queue.push( id );
|
194
|
+
}
|
195
|
+
else
|
196
|
+
// Put each Live Query in the queue if it doesn't already exist
|
197
|
+
$.each( $.livequery.queries, function(id) {
|
198
|
+
if ( $.inArray(id, $.livequery.queue) < 0 )
|
199
|
+
$.livequery.queue.push( id );
|
200
|
+
});
|
201
|
+
|
202
|
+
// Clear timeout if it already exists
|
203
|
+
if ($.livequery.timeout) clearTimeout($.livequery.timeout);
|
204
|
+
// Create a timeout to check the queue and actually run the Live Queries
|
205
|
+
$.livequery.timeout = setTimeout($.livequery.checkQueue, 20);
|
206
|
+
},
|
207
|
+
|
208
|
+
stop: function(id) {
|
209
|
+
if (id != undefined)
|
210
|
+
// Stop are particular Live Query
|
211
|
+
$.livequery.queries[ id ].stop();
|
212
|
+
else
|
213
|
+
// Stop all Live Queries
|
214
|
+
$.each( $.livequery.queries, function(id) {
|
215
|
+
$.livequery.queries[ id ].stop();
|
216
|
+
});
|
217
|
+
}
|
218
|
+
});
|
219
|
+
|
220
|
+
// Register core DOM manipulation methods
|
221
|
+
$.livequery.registerPlugin('append', 'prepend', 'after', 'before', 'wrap', 'attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'empty', 'remove', 'html');
|
222
|
+
|
223
|
+
// Run Live Queries when the Document is ready
|
224
|
+
$(function() { $.livequery.play(); });
|
225
|
+
|
226
|
+
})(jQuery);
|
@@ -0,0 +1,224 @@
|
|
1
|
+
/*!
|
2
|
+
* Datepicker for Bootstrap
|
3
|
+
*
|
4
|
+
* Copyright 2012 Stefan Petre
|
5
|
+
* Improvements by Andrew Rowls
|
6
|
+
* Licensed under the Apache License v2.0
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
.datepicker {
|
11
|
+
top: 0;
|
12
|
+
left: 0;
|
13
|
+
padding: 4px;
|
14
|
+
margin-top: 1px;
|
15
|
+
-webkit-border-radius: 4px;
|
16
|
+
-moz-border-radius: 4px;
|
17
|
+
border-radius: 4px;
|
18
|
+
/*.dow {
|
19
|
+
border-top: 1px solid #ddd !important;
|
20
|
+
}*/
|
21
|
+
|
22
|
+
}
|
23
|
+
.datepicker:before {
|
24
|
+
content: '';
|
25
|
+
display: inline-block;
|
26
|
+
border-left: 7px solid transparent;
|
27
|
+
border-right: 7px solid transparent;
|
28
|
+
border-bottom: 7px solid #ccc;
|
29
|
+
border-bottom-color: rgba(0, 0, 0, 0.2);
|
30
|
+
position: absolute;
|
31
|
+
top: -7px;
|
32
|
+
left: 6px;
|
33
|
+
}
|
34
|
+
.datepicker:after {
|
35
|
+
content: '';
|
36
|
+
display: inline-block;
|
37
|
+
border-left: 6px solid transparent;
|
38
|
+
border-right: 6px solid transparent;
|
39
|
+
border-bottom: 6px solid #ffffff;
|
40
|
+
position: absolute;
|
41
|
+
top: -6px;
|
42
|
+
left: 7px;
|
43
|
+
}
|
44
|
+
.datepicker > div {
|
45
|
+
display: none;
|
46
|
+
}
|
47
|
+
.datepicker.days div.datepicker-days {
|
48
|
+
display: block;
|
49
|
+
}
|
50
|
+
.datepicker.months div.datepicker-months {
|
51
|
+
display: block;
|
52
|
+
}
|
53
|
+
.datepicker.years div.datepicker-years {
|
54
|
+
display: block;
|
55
|
+
}
|
56
|
+
.datepicker table {
|
57
|
+
width: 100%;
|
58
|
+
margin: 0;
|
59
|
+
}
|
60
|
+
.datepicker td,
|
61
|
+
.datepicker th {
|
62
|
+
text-align: center;
|
63
|
+
width: 20px;
|
64
|
+
height: 20px;
|
65
|
+
-webkit-border-radius: 4px;
|
66
|
+
-moz-border-radius: 4px;
|
67
|
+
border-radius: 4px;
|
68
|
+
}
|
69
|
+
.datepicker td.day:hover {
|
70
|
+
background: #eeeeee;
|
71
|
+
cursor: pointer;
|
72
|
+
}
|
73
|
+
.datepicker td.old,
|
74
|
+
.datepicker td.new {
|
75
|
+
color: #999999;
|
76
|
+
}
|
77
|
+
.datepicker td.disabled,
|
78
|
+
.datepicker td.disabled:hover {
|
79
|
+
background: none;
|
80
|
+
color: #999999;
|
81
|
+
cursor: default;
|
82
|
+
}
|
83
|
+
.datepicker td.active,
|
84
|
+
.datepicker td.active:hover,
|
85
|
+
.datepicker td.active.disabled,
|
86
|
+
.datepicker td.active.disabled:hover {
|
87
|
+
background-color: #006dcc;
|
88
|
+
background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
|
89
|
+
background-image: -ms-linear-gradient(top, #0088cc, #0044cc);
|
90
|
+
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
|
91
|
+
background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
|
92
|
+
background-image: -o-linear-gradient(top, #0088cc, #0044cc);
|
93
|
+
background-image: linear-gradient(top, #0088cc, #0044cc);
|
94
|
+
background-repeat: repeat-x;
|
95
|
+
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0);
|
96
|
+
border-color: #0044cc #0044cc #002a80;
|
97
|
+
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
98
|
+
filter: progid:dximagetransform.microsoft.gradient(enabled=false);
|
99
|
+
color: #fff;
|
100
|
+
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
101
|
+
}
|
102
|
+
.datepicker td.active:hover,
|
103
|
+
.datepicker td.active:hover:hover,
|
104
|
+
.datepicker td.active.disabled:hover,
|
105
|
+
.datepicker td.active.disabled:hover:hover,
|
106
|
+
.datepicker td.active:active,
|
107
|
+
.datepicker td.active:hover:active,
|
108
|
+
.datepicker td.active.disabled:active,
|
109
|
+
.datepicker td.active.disabled:hover:active,
|
110
|
+
.datepicker td.active.active,
|
111
|
+
.datepicker td.active:hover.active,
|
112
|
+
.datepicker td.active.disabled.active,
|
113
|
+
.datepicker td.active.disabled:hover.active,
|
114
|
+
.datepicker td.active.disabled,
|
115
|
+
.datepicker td.active:hover.disabled,
|
116
|
+
.datepicker td.active.disabled.disabled,
|
117
|
+
.datepicker td.active.disabled:hover.disabled,
|
118
|
+
.datepicker td.active[disabled],
|
119
|
+
.datepicker td.active:hover[disabled],
|
120
|
+
.datepicker td.active.disabled[disabled],
|
121
|
+
.datepicker td.active.disabled:hover[disabled] {
|
122
|
+
background-color: #0044cc;
|
123
|
+
}
|
124
|
+
.datepicker td.active:active,
|
125
|
+
.datepicker td.active:hover:active,
|
126
|
+
.datepicker td.active.disabled:active,
|
127
|
+
.datepicker td.active.disabled:hover:active,
|
128
|
+
.datepicker td.active.active,
|
129
|
+
.datepicker td.active:hover.active,
|
130
|
+
.datepicker td.active.disabled.active,
|
131
|
+
.datepicker td.active.disabled:hover.active {
|
132
|
+
background-color: #003399 \9;
|
133
|
+
}
|
134
|
+
.datepicker td span {
|
135
|
+
display: block;
|
136
|
+
width: 47px;
|
137
|
+
height: 54px;
|
138
|
+
line-height: 54px;
|
139
|
+
float: left;
|
140
|
+
margin: 2px;
|
141
|
+
cursor: pointer;
|
142
|
+
-webkit-border-radius: 4px;
|
143
|
+
-moz-border-radius: 4px;
|
144
|
+
border-radius: 4px;
|
145
|
+
}
|
146
|
+
.datepicker td span:hover {
|
147
|
+
background: #eeeeee;
|
148
|
+
}
|
149
|
+
.datepicker td span.disabled,
|
150
|
+
.datepicker td span.disabled:hover {
|
151
|
+
background: none;
|
152
|
+
color: #999999;
|
153
|
+
cursor: default;
|
154
|
+
}
|
155
|
+
.datepicker td span.active,
|
156
|
+
.datepicker td span.active:hover,
|
157
|
+
.datepicker td span.active.disabled,
|
158
|
+
.datepicker td span.active.disabled:hover {
|
159
|
+
background-color: #006dcc;
|
160
|
+
background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
|
161
|
+
background-image: -ms-linear-gradient(top, #0088cc, #0044cc);
|
162
|
+
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
|
163
|
+
background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
|
164
|
+
background-image: -o-linear-gradient(top, #0088cc, #0044cc);
|
165
|
+
background-image: linear-gradient(top, #0088cc, #0044cc);
|
166
|
+
background-repeat: repeat-x;
|
167
|
+
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0);
|
168
|
+
border-color: #0044cc #0044cc #002a80;
|
169
|
+
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
170
|
+
filter: progid:dximagetransform.microsoft.gradient(enabled=false);
|
171
|
+
color: #fff;
|
172
|
+
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
173
|
+
}
|
174
|
+
.datepicker td span.active:hover,
|
175
|
+
.datepicker td span.active:hover:hover,
|
176
|
+
.datepicker td span.active.disabled:hover,
|
177
|
+
.datepicker td span.active.disabled:hover:hover,
|
178
|
+
.datepicker td span.active:active,
|
179
|
+
.datepicker td span.active:hover:active,
|
180
|
+
.datepicker td span.active.disabled:active,
|
181
|
+
.datepicker td span.active.disabled:hover:active,
|
182
|
+
.datepicker td span.active.active,
|
183
|
+
.datepicker td span.active:hover.active,
|
184
|
+
.datepicker td span.active.disabled.active,
|
185
|
+
.datepicker td span.active.disabled:hover.active,
|
186
|
+
.datepicker td span.active.disabled,
|
187
|
+
.datepicker td span.active:hover.disabled,
|
188
|
+
.datepicker td span.active.disabled.disabled,
|
189
|
+
.datepicker td span.active.disabled:hover.disabled,
|
190
|
+
.datepicker td span.active[disabled],
|
191
|
+
.datepicker td span.active:hover[disabled],
|
192
|
+
.datepicker td span.active.disabled[disabled],
|
193
|
+
.datepicker td span.active.disabled:hover[disabled] {
|
194
|
+
background-color: #0044cc;
|
195
|
+
}
|
196
|
+
.datepicker td span.active:active,
|
197
|
+
.datepicker td span.active:hover:active,
|
198
|
+
.datepicker td span.active.disabled:active,
|
199
|
+
.datepicker td span.active.disabled:hover:active,
|
200
|
+
.datepicker td span.active.active,
|
201
|
+
.datepicker td span.active:hover.active,
|
202
|
+
.datepicker td span.active.disabled.active,
|
203
|
+
.datepicker td span.active.disabled:hover.active {
|
204
|
+
background-color: #003399 \9;
|
205
|
+
}
|
206
|
+
.datepicker td span.old {
|
207
|
+
color: #999999;
|
208
|
+
}
|
209
|
+
.datepicker th.switch {
|
210
|
+
width: 145px;
|
211
|
+
}
|
212
|
+
.datepicker thead tr:first-child th {
|
213
|
+
cursor: pointer;
|
214
|
+
}
|
215
|
+
.datepicker thead tr:first-child th:hover {
|
216
|
+
background: #eeeeee;
|
217
|
+
}
|
218
|
+
.input-append.date .add-on i,
|
219
|
+
.input-prepend.date .add-on i {
|
220
|
+
display: block;
|
221
|
+
cursor: pointer;
|
222
|
+
width: 16px;
|
223
|
+
height: 16px;
|
224
|
+
}
|
@@ -0,0 +1,92 @@
|
|
1
|
+
|
2
|
+
.bootstrap-timepicker.dropdown-menu {
|
3
|
+
border-radius: 4px 4px 4px 4px;
|
4
|
+
display: none;
|
5
|
+
left: 0;
|
6
|
+
margin-top: 1px;
|
7
|
+
padding: 4px;
|
8
|
+
top: 0;
|
9
|
+
}
|
10
|
+
.bootstrap-timepicker.dropdown-menu.open {
|
11
|
+
display: inline-block;
|
12
|
+
}
|
13
|
+
.bootstrap-timepicker.dropdown-menu:before {
|
14
|
+
border-bottom: 7px solid rgba(0, 0, 0, 0.2);
|
15
|
+
border-left: 7px solid transparent;
|
16
|
+
border-right: 7px solid transparent;
|
17
|
+
content: "";
|
18
|
+
left: 6px;
|
19
|
+
position: absolute;
|
20
|
+
top: -7px;
|
21
|
+
}
|
22
|
+
.bootstrap-timepicker.dropdown-menu:after {
|
23
|
+
border-bottom: 6px solid #FFFFFF;
|
24
|
+
border-left: 6px solid transparent;
|
25
|
+
border-right: 6px solid transparent;
|
26
|
+
content: "";
|
27
|
+
left: 7px;
|
28
|
+
position: absolute;
|
29
|
+
top: -6px;
|
30
|
+
}
|
31
|
+
.bootstrap-timepicker.modal {
|
32
|
+
margin-left: -100px;
|
33
|
+
margin-top: 0;
|
34
|
+
top: 30%;
|
35
|
+
width: 200px;
|
36
|
+
}
|
37
|
+
.bootstrap-timepicker.modal .modal-content {
|
38
|
+
padding: 0;
|
39
|
+
}
|
40
|
+
.bootstrap-timepicker table {
|
41
|
+
margin: 0;
|
42
|
+
width: 100%;
|
43
|
+
}
|
44
|
+
.bootstrap-timepicker table td {
|
45
|
+
height: 30px;
|
46
|
+
margin: 0;
|
47
|
+
padding: 2px;
|
48
|
+
text-align: center;
|
49
|
+
width: 49%;
|
50
|
+
}
|
51
|
+
.bootstrap-timepicker table.show-meridian td, .bootstrap-timepicker table.show-seconds td {
|
52
|
+
width: 32%;
|
53
|
+
}
|
54
|
+
.bootstrap-timepicker table.show-seconds.show-meridian td {
|
55
|
+
width: 23.5%;
|
56
|
+
}
|
57
|
+
.bootstrap-timepicker table td.separator {
|
58
|
+
width: 2% !important;
|
59
|
+
}
|
60
|
+
.bootstrap-timepicker table td span {
|
61
|
+
width: 100%;
|
62
|
+
}
|
63
|
+
.bootstrap-timepicker table td a {
|
64
|
+
border: 1px solid transparent;
|
65
|
+
display: inline-block;
|
66
|
+
margin: 0;
|
67
|
+
outline: 0 none;
|
68
|
+
padding: 8px 0;
|
69
|
+
width: 90%;
|
70
|
+
}
|
71
|
+
.bootstrap-timepicker table td a:hover {
|
72
|
+
background-color: #EEEEEE;
|
73
|
+
border-color: #DDDDDD;
|
74
|
+
border-radius: 4px 4px 4px 4px;
|
75
|
+
}
|
76
|
+
.bootstrap-timepicker table td a i {
|
77
|
+
margin-top: 2px;
|
78
|
+
}
|
79
|
+
.bootstrap-timepicker table td input {
|
80
|
+
margin: 0;
|
81
|
+
text-align: center;
|
82
|
+
width: 25px;
|
83
|
+
}
|
84
|
+
.bootstrap-timepicker-component .add-on {
|
85
|
+
cursor: pointer;
|
86
|
+
}
|
87
|
+
.bootstrap-timepicker-component .add-on i {
|
88
|
+
display: block;
|
89
|
+
height: 16px;
|
90
|
+
width: 16px;
|
91
|
+
}
|
92
|
+
|
@@ -99,10 +99,22 @@ class <%= namespace_for_class %><%= model_camelize.pluralize %>Controller < Beau
|
|
99
99
|
|
100
100
|
respond_to do |format|
|
101
101
|
if @<%= model %>.save
|
102
|
-
format.html {
|
102
|
+
format.html {
|
103
|
+
if params[:mass_inserting] then
|
104
|
+
redirect_to <%= namespace_for_route %><%= model_pluralize %>_path(:mass_inserting => true)
|
105
|
+
else
|
106
|
+
redirect_to <%= namespace_for_route %><%= singular_table_name %>_path(@<%= model %>), :notice => t(:create_success, :model => "<%= model %>")
|
107
|
+
end
|
108
|
+
}
|
103
109
|
format.json { render :json => @<%= model %>, :status => :created, :location => @<%= model %> }
|
104
110
|
else
|
105
|
-
format.html {
|
111
|
+
format.html {
|
112
|
+
if params[:mass_inserting] then
|
113
|
+
redirect_to <%= namespace_for_route %><%= model_pluralize %>_path(:mass_inserting => true), :error => t(:error, "Error")
|
114
|
+
else
|
115
|
+
render :action => "new"
|
116
|
+
end
|
117
|
+
}
|
106
118
|
format.json { render :json => @<%= model %>.errors, :status => :unprocessable_entity }
|
107
119
|
end
|
108
120
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding : utf-8
|
2
2
|
module BeautifulHelper
|
3
3
|
|
4
|
-
def visible_column(model_name, field_name)
|
5
|
-
return ('style="display:' + ((session[:fields][model_name.to_sym].to_a.include?(field_name)) ?
|
4
|
+
def visible_column(model_name, field_name, display_default = 'table-cell', other_css = "")
|
5
|
+
return ('style="display:' + ((session[:fields][model_name.to_sym].to_a.include?(field_name)) ? display_default : 'none') + ';' + other_css + '"').html_safe
|
6
6
|
end
|
7
7
|
|
8
8
|
def dropdown_submenu(link_caption, &block)
|
@@ -74,16 +74,47 @@ module BeautifulHelper
|
|
74
74
|
case type_of_column
|
75
75
|
when :date, :datetime then
|
76
76
|
# DatePicker
|
77
|
-
response += '<div class="input-prepend input-append">'
|
77
|
+
response += '<div class="input-prepend input-append input-' + type_of_column.to_s + '">'
|
78
78
|
response += '<span class="add-on"><i class="icon-chevron-right"></i></span>'
|
79
|
-
response += f.
|
79
|
+
response += f.text_field((name_field + "_gteq").to_sym, :class => "span8 dpicker")
|
80
80
|
response += '<span class="add-on"><i class="icon-calendar"></i></span>'
|
81
81
|
response += '</div>'
|
82
|
-
|
82
|
+
|
83
|
+
response += f.hidden_field(name_field + '_gteq(3i)', :id => ('q_' + name_field + '_gteq_3i')) # Day
|
84
|
+
response += f.hidden_field(name_field + '_gteq(2i)', :id => ('q_' + name_field + '_gteq_2i')) # Mois
|
85
|
+
response += f.hidden_field(name_field + '_gteq(1i)', :id => ('q_' + name_field + '_gteq_1i')) # Year
|
86
|
+
|
87
|
+
if type_of_column == :datetime then
|
88
|
+
response += '<div class="input-prepend input-append input-' + type_of_column.to_s + '">'
|
89
|
+
response += '<span class="add-on"><i class="icon-chevron-right"></i></span>'
|
90
|
+
response += f.text_field((name_field + "_lteq").to_sym, :class => "span8 tpicker")
|
91
|
+
response += '<span class="add-on"><i class="icon-time"></i></span>'
|
92
|
+
response += '</div>'
|
93
|
+
|
94
|
+
response += f.hidden_field(name_field + '_gteq(4i)', :id => ('q_' + name_field + '_gteq_4i')) # Hour
|
95
|
+
response += f.hidden_field(name_field + '_gteq(5i)', :id => ('q_' + name_field + '_gteq_5i')) # Minute
|
96
|
+
end
|
97
|
+
|
98
|
+
response += '<div class="input-prepend input-append input-' + type_of_column.to_s + '">'
|
83
99
|
response += '<span class="add-on"><i class="icon-chevron-left"></i></span>'
|
84
|
-
response += f.
|
100
|
+
response += f.text_field((name_field + "_lteq").to_sym, :class => "span8 dpicker")
|
85
101
|
response += '<span class="add-on"><i class="icon-calendar"></i></span>'
|
86
102
|
response += '</div>'
|
103
|
+
|
104
|
+
response += f.hidden_field(name_field + '_lteq(3i)', :id => ('q_' + name_field + '_lteq_3i')) # Day
|
105
|
+
response += f.hidden_field(name_field + '_lteq(2i)', :id => ('q_' + name_field + '_lteq_2i')) # Mois
|
106
|
+
response += f.hidden_field(name_field + '_lteq(1i)', :id => ('q_' + name_field + '_lteq_1i')) # Year
|
107
|
+
|
108
|
+
if type_of_column == :datetime then
|
109
|
+
response += '<div class="input-prepend input-append input-' + type_of_column.to_s + '">'
|
110
|
+
response += '<span class="add-on"><i class="icon-chevron-left"></i></span>'
|
111
|
+
response += f.text_field((name_field + "_lteq").to_sym, :class => "span8 tpicker")
|
112
|
+
response += '<span class="add-on"><i class="icon-time"></i></span>'
|
113
|
+
response += '</div>'
|
114
|
+
|
115
|
+
response += f.hidden_field(name_field + '_lteq(4i)', :id => ('q_' + name_field + '_lteq_4i')) # Hour
|
116
|
+
response += f.hidden_field(name_field + '_lteq(5i)', :id => ('q_' + name_field + '_lteq_5i')) # Minute
|
117
|
+
end
|
87
118
|
when :boolean then
|
88
119
|
# Specify a default value (false) in rails migration
|
89
120
|
response += f.label name_field + "_eq_true", raw(f.radio_button((name_field + "_eq").to_sym, true)) + " " + h(t(:yes, :default => "Yes")), :class => "checkbox inline"
|
@@ -91,7 +122,7 @@ module BeautifulHelper
|
|
91
122
|
response += f.label name_field + "_eq", raw(f.radio_button((name_field + "_eq").to_sym, nil)) + " " + h(t(:all, :default => "All")), :class => "checkbox inline"
|
92
123
|
when :string then
|
93
124
|
response += f.text_field((name_field + "_cont").to_sym, :class => "filter span12")
|
94
|
-
when :integer, :float then
|
125
|
+
when :integer, :float, :decimal then
|
95
126
|
if is_belongs_to_column?(name_field) then
|
96
127
|
btmodel = get_belongs_to_model(name_field).classify.constantize
|
97
128
|
response += f.collection_select((name_field + "_eq").to_sym, btmodel.all, :id, :caption, { :include_blank => t(:all, :default => "All") }, { :class => "span12" })
|
@@ -5,7 +5,7 @@ if not namespace_alone.blank? then
|
|
5
5
|
end
|
6
6
|
-%>
|
7
7
|
|
8
|
-
<%%= form_for(<%= strformfor %>, :class => "form-horizontal") do |f| %>
|
8
|
+
<%%= form_for(<%= strformfor %>, :html => { :class => "form-horizontal" }) do |f| %>
|
9
9
|
<%% if @<%= singular_table_name %>.errors.any? %>
|
10
10
|
<div id="error_explanation">
|
11
11
|
<h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<%= form_for [namespace, model_name.classify.constantize.new], :method => :post, :html => { :class => "well form-horizontal mass-inserting" } do |f| %>
|
2
|
+
<%= hidden_field_tag :mass_inserting, true %>
|
3
|
+
<% for col in model_columns %>
|
4
|
+
<div <%= visible_column(model_name, col, 'inline') %> class="col-<%= col %>">
|
5
|
+
<%=
|
6
|
+
ar = model_name.classify.constantize.columns_hash[col]
|
7
|
+
if not ar.nil? then
|
8
|
+
case ar.type
|
9
|
+
when 'integer' then
|
10
|
+
if col =~ /.*_id/ then
|
11
|
+
f.collection_select((col).to_sym, col.classify.constantize.all, :id, :caption, {}, { :class => "input-small", :placeholder => col.capitalize })
|
12
|
+
else
|
13
|
+
f.text_field(col.to_sym, :class => "input-small", :placeholder => col.capitalize)
|
14
|
+
end
|
15
|
+
when 'boolean' then
|
16
|
+
(
|
17
|
+
f.radio_button_tag(col.to_sym, true)
|
18
|
+
f.label((col + "_true").to_sym, t(:yes))
|
19
|
+
f.radio_button_tag(col.to_sym, false)
|
20
|
+
f.label((col + "_false").to_sym, t(:no))
|
21
|
+
)
|
22
|
+
else
|
23
|
+
f.text_field(col.to_sym, :class => "input-small", :placeholder => col.capitalize)
|
24
|
+
end
|
25
|
+
else
|
26
|
+
f.collection_select((col + '_id').to_sym, col.classify.constantize.all, :id, :caption, {}, { :class => "input-small", :placeholder => col.capitalize })
|
27
|
+
end
|
28
|
+
%>
|
29
|
+
</div>
|
30
|
+
<% end %>
|
31
|
+
<div style="display:inline;">
|
32
|
+
<%= f.submit t(:create, :default => "Create"), :class => 'btn' %>
|
33
|
+
</div>
|
34
|
+
<% end %>
|
35
|
+
|
36
|
+
<% if params[:mass_inserting] then %>
|
37
|
+
<script type="text/javascript">
|
38
|
+
elt = $('form.mass-inserting div[style*="inline"][class*="col"] .input-small').first();
|
39
|
+
$(elt).focus();
|
40
|
+
</script>
|
41
|
+
<% end %>
|