humdrum-rails 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/humdrum-rails.gemspec +1 -1
- data/lib/humdrum/version.rb +1 -1
- data/lib/rails/generators/humdrum/layout/layout_generator.rb +11 -3
- data/lib/rails/generators/humdrum/layout/templates/images/fonts/icons/entypo.eot +0 -0
- data/lib/rails/generators/humdrum/layout/templates/images/fonts/icons/entypo.ttf +0 -0
- data/lib/rails/generators/humdrum/layout/templates/images/fonts/icons/entypo.woff +0 -0
- data/lib/rails/generators/humdrum/layout/templates/javascripts/application.js +21 -0
- data/lib/rails/generators/humdrum/layout/templates/javascripts/gumby.min.js +1 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/application.css +5 -4
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/gumby.css +383 -375
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/overrides-bootstrap.css +8 -1
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/overrides-gumby.css +10 -3
- data/lib/rails/generators/humdrum/layout/templates/views/gumby/layouts/admin/_footer.html.erb +1 -0
- data/lib/rails/generators/humdrum/layout/templates/views/gumby/layouts/admin.html.erb +1 -1
- data/lib/rails/generators/humdrum/layout/templates/views/gumby/layouts/common/_flash_message.html.erb +5 -6
- data/lib/rails/generators/humdrum/layout/templates/views/gumby/layouts/public/_footer.html.erb +1 -0
- data/lib/rails/generators/humdrum/layout/templates/views/gumby/layouts/public.html.erb +1 -1
- data/lib/rails/generators/humdrum/layout/templates/views/gumby/layouts/user/_footer.html.erb +1 -0
- data/lib/rails/generators/humdrum/layout/templates/views/gumby/layouts/user.html.erb +1 -1
- data/lib/rails/generators/humdrum/resource/resource_generator.rb +99 -19
- data/lib/rails/generators/humdrum/resource/templates/controllers/resource_controller.rb +8 -1
- data/lib/rails/generators/humdrum/resource/templates/javascripts/validations/validator.js +32 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/_edit.html.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/_filters.html.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/_form.html.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/_index.html.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/_item.html.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/_nav_filters.html.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/_new.html.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/_show.html.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/_summary.html.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/create.js.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/destroy.js.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/edit.js.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/index.html.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/index.js.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/new.js.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/show.js.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/{resource → bootstrap/resource}/update.js.erb +0 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/_edit.html.erb +7 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/_filters.html.erb +18 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/_form.html.erb +71 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/_index.html.erb +22 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/_item.html.erb +21 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/_nav_filters.html.erb +9 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/_new.html.erb +9 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/_show.html.erb +45 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/_summary.html.erb +10 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/create.js.erb +15 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/destroy.js.erb +14 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/edit.js.erb +3 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/index.html.erb +37 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/index.js.erb +15 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/new.js.erb +3 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/show.js.erb +2 -0
- data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/update.js.erb +14 -0
- data/lib/rails/generators/humdrum/setup/setup_generator.rb +45 -0
- data/lib/rails/generators/humdrum/setup/templates/config/database.example.sql +59 -0
- data/lib/rails/generators/humdrum/setup/templates/config/database.sql +59 -0
- data/lib/rails/generators/humdrum/setup/templates/gitignore +28 -0
- data/lib/rails/generators/humdrum/setup/templates/ruby-gemset +1 -0
- data/lib/rails/generators/humdrum/setup/templates/ruby-version +1 -0
- metadata +50 -21
@@ -2,7 +2,7 @@
|
|
2
2
|
Ensure that you load this file in application.css after bootstrap (backword slash to escape)
|
3
3
|
*/
|
4
4
|
|
5
|
-
body {padding-top:50px;font-size:
|
5
|
+
body {padding-top:50px;font-size:14px;}
|
6
6
|
|
7
7
|
/* Gliphicons Icon Path */
|
8
8
|
|
@@ -26,3 +26,10 @@ body {padding-top:50px;font-size:12px;}
|
|
26
26
|
/* This will compact the alert boxes */
|
27
27
|
.alert .close {top: -5px;}
|
28
28
|
.alert p {margin: 0px;}
|
29
|
+
|
30
|
+
h1 { font-size: 32px; font-size: 2.00rem}
|
31
|
+
h2 { font-size: 28px; font-size: 1.80rem}
|
32
|
+
h3 { font-size: 24px; font-size: 1.60rem}
|
33
|
+
h4 { font-size: 20px; font-size: 1.50rem}
|
34
|
+
h5 { font-size: 16px; font-size: 1.40rem}
|
35
|
+
h6 { font-size: 14px; font-size: 1.30rem}
|
@@ -2,10 +2,17 @@
|
|
2
2
|
Ensure that you load this file in application.css after gumby (backword slash to escape)
|
3
3
|
*/
|
4
4
|
|
5
|
-
body {font-size:12px;}
|
6
|
-
|
7
5
|
/* handy CSS will insist a margin and padding for all ul and li. Overriding handy css behaviour for ul and li in .navbar class*/
|
8
6
|
.navbar ul, .navbar ul > li, .navbar ul > li > div.dropdown > ul {margin:0px !important; padding:0px !important;}
|
9
7
|
|
10
8
|
/* logo left padding is not required */
|
11
|
-
.navbar .logo a {padding:0px; color:#fff;}
|
9
|
+
.navbar .logo a {padding:0px; color:#fff;}
|
10
|
+
.navbar {margin-bottom:0px;}
|
11
|
+
|
12
|
+
h1 { font-size: 32px; font-size: 2.00rem}
|
13
|
+
h2 { font-size: 28px; font-size: 1.80rem}
|
14
|
+
h3 { font-size: 24px; font-size: 1.60rem}
|
15
|
+
h4 { font-size: 20px; font-size: 1.50rem}
|
16
|
+
h5 { font-size: 16px; font-size: 1.40rem}
|
17
|
+
h6 { font-size: 14px; font-size: 1.30rem}
|
18
|
+
|
data/lib/rails/generators/humdrum/layout/templates/views/gumby/layouts/admin/_footer.html.erb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
<div class="cl-50"></div>
|
@@ -9,16 +9,15 @@
|
|
9
9
|
flash_message = flash[:success] || flash[:notice] || flash[:alert]
|
10
10
|
end
|
11
11
|
cls_name = "alert"
|
12
|
-
cls_name = 'alert
|
13
|
-
cls_name = 'alert
|
14
|
-
cls_name = 'alert
|
12
|
+
cls_name = 'alert success' if flash.now[:success] || flash[:success]
|
13
|
+
cls_name = 'alert warning' if flash.now[:notice] || flash[:notice]
|
14
|
+
cls_name = 'alert danger' if flash.now[:alert] || flash[:alert]
|
15
15
|
|
16
16
|
flash_message = flash_message.strip if flash_message
|
17
17
|
|
18
18
|
%>
|
19
19
|
<%% unless flash_message.blank? %>
|
20
|
-
<div class="<%%= style_classes %>
|
21
|
-
|
22
|
-
<p><%%= flash_message %></p>
|
20
|
+
<div class="<%%= style_classes %> <%%= cls_name %> fade in" data-alert="alert" style="margin-bottom:5px;">
|
21
|
+
<%%= flash_message %>
|
23
22
|
</div>
|
24
23
|
<%% end %>
|
data/lib/rails/generators/humdrum/layout/templates/views/gumby/layouts/public/_footer.html.erb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
<div class="cl-50"></div>
|
data/lib/rails/generators/humdrum/layout/templates/views/gumby/layouts/user/_footer.html.erb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
<div class="cl-50"></div>
|
@@ -21,6 +21,8 @@ module Humdrum
|
|
21
21
|
class_option :fluid, :type => :boolean, :default => true, :desc => "Pass true to create fluid layouts"
|
22
22
|
class_option :debug, :type => :boolean, :default => false, :desc => "This will print the arguments for debugging"
|
23
23
|
|
24
|
+
class_option :front_end_framework, :type => :string, :default => 'gumby', :desc => "Support Twitter Bootstrap (twitter.github.io/bootstrap/) and Gumpy (http://gumbyframework.com/). Default is bootstrap. Pass gumby for Gumby Framework"
|
25
|
+
|
24
26
|
def debug_args
|
25
27
|
print_args if options.debug?
|
26
28
|
end
|
@@ -30,29 +32,33 @@ module Humdrum
|
|
30
32
|
end
|
31
33
|
|
32
34
|
def generate_views
|
33
|
-
template "views/resource/_edit.html.erb", "app/views/#{controller_path}/_edit.html.erb"
|
34
|
-
template "views/resource/_filters.html.erb", "app/views/#{controller_path}/_filters.html.erb"
|
35
|
-
template "views/resource/_form.html.erb", "app/views/#{controller_path}/_form.html.erb"
|
36
|
-
template "views/resource/_index.html.erb", "app/views/#{controller_path}/_index.html.erb"
|
37
|
-
template "views/resource/_item.html.erb", "app/views/#{controller_path}/_item.html.erb"
|
38
|
-
template "views/resource/_nav_filters.html.erb", "app/views/#{controller_path}/_nav_filters.html.erb"
|
39
|
-
template "views/resource/_new.html.erb", "app/views/#{controller_path}/_new.html.erb"
|
40
|
-
template "views/resource/_show.html.erb", "app/views/#{controller_path}/_show.html.erb"
|
41
|
-
template "views/resource/_summary.html.erb", "app/views/#{controller_path}/_summary.html.erb"
|
42
|
-
template "views/resource/create.js.erb", "app/views/#{controller_path}/create.js.erb"
|
43
|
-
template "views/resource/destroy.js.erb", "app/views/#{controller_path}/destroy.js.erb"
|
44
|
-
template "views/resource/edit.js.erb", "app/views/#{controller_path}/edit.js.erb"
|
45
|
-
template "views/resource/index.js.erb", "app/views/#{controller_path}/index.js.erb"
|
46
|
-
template "views/resource/new.js.erb", "app/views/#{controller_path}/new.js.erb"
|
47
|
-
template "views/resource/show.js.erb", "app/views/#{controller_path}/show.js.erb"
|
48
|
-
template "views/resource/update.js.erb", "app/views/#{controller_path}/update.js.erb"
|
49
|
-
template "views/resource/index.html.erb", "app/views/#{controller_path}/index.html.erb"
|
35
|
+
template "views/#{options.front_end_framework}/resource/_edit.html.erb", "app/views/#{controller_path}/_edit.html.erb"
|
36
|
+
template "views/#{options.front_end_framework}/resource/_filters.html.erb", "app/views/#{controller_path}/_filters.html.erb"
|
37
|
+
template "views/#{options.front_end_framework}/resource/_form.html.erb", "app/views/#{controller_path}/_form.html.erb"
|
38
|
+
template "views/#{options.front_end_framework}/resource/_index.html.erb", "app/views/#{controller_path}/_index.html.erb"
|
39
|
+
template "views/#{options.front_end_framework}/resource/_item.html.erb", "app/views/#{controller_path}/_item.html.erb"
|
40
|
+
template "views/#{options.front_end_framework}/resource/_nav_filters.html.erb", "app/views/#{controller_path}/_nav_filters.html.erb"
|
41
|
+
template "views/#{options.front_end_framework}/resource/_new.html.erb", "app/views/#{controller_path}/_new.html.erb"
|
42
|
+
template "views/#{options.front_end_framework}/resource/_show.html.erb", "app/views/#{controller_path}/_show.html.erb"
|
43
|
+
template "views/#{options.front_end_framework}/resource/_summary.html.erb", "app/views/#{controller_path}/_summary.html.erb"
|
44
|
+
template "views/#{options.front_end_framework}/resource/create.js.erb", "app/views/#{controller_path}/create.js.erb"
|
45
|
+
template "views/#{options.front_end_framework}/resource/destroy.js.erb", "app/views/#{controller_path}/destroy.js.erb"
|
46
|
+
template "views/#{options.front_end_framework}/resource/edit.js.erb", "app/views/#{controller_path}/edit.js.erb"
|
47
|
+
template "views/#{options.front_end_framework}/resource/index.js.erb", "app/views/#{controller_path}/index.js.erb"
|
48
|
+
template "views/#{options.front_end_framework}/resource/new.js.erb", "app/views/#{controller_path}/new.js.erb"
|
49
|
+
template "views/#{options.front_end_framework}/resource/show.js.erb", "app/views/#{controller_path}/show.js.erb"
|
50
|
+
template "views/#{options.front_end_framework}/resource/update.js.erb", "app/views/#{controller_path}/update.js.erb"
|
51
|
+
template "views/#{options.front_end_framework}/resource/index.html.erb", "app/views/#{controller_path}/index.html.erb"
|
50
52
|
end
|
51
53
|
|
52
54
|
def generate_models
|
53
55
|
template "models/resource.rb", "app/models/#{model_path}.rb"
|
54
56
|
end
|
55
57
|
|
58
|
+
def generate_javascript_validations
|
59
|
+
template "javascripts/validations/validator.js", "app/assets/javascripts/validations/#{model_path}.js"
|
60
|
+
end
|
61
|
+
|
56
62
|
def generate_migrations
|
57
63
|
migration_template "migrations/create_resources.rb", "db/migrate/create_#{instances_name}"
|
58
64
|
end
|
@@ -214,6 +220,12 @@ module Humdrum
|
|
214
220
|
fields.map{|name, type| name if name != main_field && type == "string" }.uniq.compact
|
215
221
|
end
|
216
222
|
|
223
|
+
## List of all the string fields including main field
|
224
|
+
def string_fields_including_main_field
|
225
|
+
main_field = main_string_field
|
226
|
+
fields.map{|name, type| name if type == "string" }.uniq.compact
|
227
|
+
end
|
228
|
+
|
217
229
|
## The main string field like 'name'
|
218
230
|
def main_string_field
|
219
231
|
fields.map{|name, type| name if name.include?("name") && type == "string"}.uniq.compact || fields.keys.any? ? fields.keys.first : "id"
|
@@ -225,11 +237,79 @@ module Humdrum
|
|
225
237
|
end
|
226
238
|
|
227
239
|
def container_class
|
228
|
-
options.
|
240
|
+
if options.front_end_framework == "bootstrap"
|
241
|
+
options.fluid? ? "container-fluid" : "container"
|
242
|
+
elsif options.front_end_framework == "gumby"
|
243
|
+
"container"
|
244
|
+
else
|
245
|
+
"container"
|
246
|
+
end
|
229
247
|
end
|
230
248
|
|
231
249
|
def row_class
|
232
|
-
options.
|
250
|
+
if options.front_end_framework == "bootstrap"
|
251
|
+
options.fluid? ? "row-fluid" : "row"
|
252
|
+
elsif options.front_end_framework == "gumby"
|
253
|
+
"row"
|
254
|
+
else
|
255
|
+
"row"
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
def column_class(grid_width_value)
|
260
|
+
grid_width_value_hash = {"1" => "one",
|
261
|
+
"2" => "two",
|
262
|
+
"3" => "three",
|
263
|
+
"4" => "four",
|
264
|
+
"5" => "five",
|
265
|
+
"6" => "six",
|
266
|
+
"7" => "seven",
|
267
|
+
"8" => "eight",
|
268
|
+
"9" => "nine",
|
269
|
+
"10" => "ten",
|
270
|
+
"11" => "eleven",
|
271
|
+
"12" => "twelve",
|
272
|
+
"13" => "thirteen",
|
273
|
+
"14" => "fourteen",
|
274
|
+
"15" => "fifteen",
|
275
|
+
"16" => "sixteen"}
|
276
|
+
if options.front_end_framework == "bootstrap"
|
277
|
+
"span#{grid_width_value}"
|
278
|
+
elsif options.front_end_framework == "gumby"
|
279
|
+
"#{grid_width_value_hash[grid_width_value.to_s]} columns"
|
280
|
+
else
|
281
|
+
"col#{grid_width_value}"
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
# This function is not used now.
|
286
|
+
def button_class(color, size, rounded="", pretty="")
|
287
|
+
if options.front_end_framework == "bootstrap"
|
288
|
+
color_hash = {"blue" => "btn-primary",
|
289
|
+
"light-blue" => "btn-info",
|
290
|
+
"grey" => "",
|
291
|
+
"black" => "btn-inverse",
|
292
|
+
"red" => "btn-danger",
|
293
|
+
"green" => "btn-success",
|
294
|
+
"orange" => "btn-warning"}
|
295
|
+
size_hash = {"large" => "btn-large",
|
296
|
+
"medium" => "",
|
297
|
+
"small" => "btn-tiny"}
|
298
|
+
elsif options.front_end_framework == "gumby"
|
299
|
+
color_hash = {"blue" => "primary",
|
300
|
+
"dark-green" => "secondary",
|
301
|
+
"grey" => "default",
|
302
|
+
"black" => "info",
|
303
|
+
"red" => "danger",
|
304
|
+
"green" => "success",
|
305
|
+
"orange" => "warning"}
|
306
|
+
size_hash = {"xlarge" => "xlarge",
|
307
|
+
"large" => "large",
|
308
|
+
"medium" => "medium",
|
309
|
+
"small" => "small",
|
310
|
+
"green" => "btn-success"}
|
311
|
+
end
|
312
|
+
"#{pretty.blank? ? "" : "#{pretty} "}#{rounded.blank? ? "" : "#{rounded} "}#{size_hash[size]} #{color_hash[color]} btn"
|
233
313
|
end
|
234
314
|
|
235
315
|
end
|
@@ -176,7 +176,14 @@ class <%= controller_class %> < ApplicationController
|
|
176
176
|
if params[:<%= instance_name %>] && params[:<%= instance_name %>][:query]
|
177
177
|
@query = params[:<%= instance_name %>][:query].strip
|
178
178
|
if !@query.blank?
|
179
|
-
relation = relation.where("
|
179
|
+
relation = relation.where("
|
180
|
+
<% string_fields_including_main_field.each_with_index do |sfield, i| -%>
|
181
|
+
<% if string_fields_including_main_field.size - 1 != i -%>
|
182
|
+
LOWER(<%= sfield %>) LIKE LOWER('%#{@query}%') OR\
|
183
|
+
<% else -%>
|
184
|
+
LOWER(<%= sfield %>) LIKE LOWER('%#{@query}%')")
|
185
|
+
<% end -%>
|
186
|
+
<% end -%>
|
180
187
|
end
|
181
188
|
end
|
182
189
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
function validate<%= model_class %>Form() {
|
2
|
+
|
3
|
+
$('#form_<%= instance_name %>').validation({
|
4
|
+
required: [
|
5
|
+
{name: 'first_name'},
|
6
|
+
{name: 'last_name'},
|
7
|
+
{name: 'designation'},
|
8
|
+
{
|
9
|
+
name : 'email',
|
10
|
+
// email must contain an @
|
11
|
+
validate : function($el) {
|
12
|
+
return $el.val().match('@') !== null;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
],
|
16
|
+
fail: function(failed) {
|
17
|
+
errorText = "Please fill out all the required fields and ensure the data entered is valid.";
|
18
|
+
$("#div_<%= instance_name %>_form_error").remove();
|
19
|
+
txtDiv = "<div id='div_<%= instance_name %>_form_error' class=\"alert danger\" data-alert=\"alert\" style=\"margin-bottom:5px;\">"+ errorText +"</div>"
|
20
|
+
$("#div_<%= instance_name %>_details").prepend(txtDiv);
|
21
|
+
},
|
22
|
+
submit: function(data) {
|
23
|
+
$.ajax({
|
24
|
+
url: $("#form_<%= instance_name %> input[name=faction]").val(),
|
25
|
+
type: $("#form_<%= instance_name %> input[name=fmethod]").val(),
|
26
|
+
dataType: 'script',
|
27
|
+
data: data
|
28
|
+
});
|
29
|
+
}
|
30
|
+
});
|
31
|
+
|
32
|
+
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<div class="row">
|
2
|
+
<div class="eight columns">
|
3
|
+
<%%= form_for <%= model_class %>.new, :url => <%= resource_link('index', 'path') %>, :method => :get, :remote=>true, :html=>{:style=>"margin-bottom:0px;"} do |f| %>
|
4
|
+
<div class="append field">
|
5
|
+
<input class="wide input" type="text" placeholder="Search ..." style="width:240px;" name="<%= instance_name %>[query]">
|
6
|
+
<div class="pretty medium default btn icon-search">
|
7
|
+
<a href="#" onclick="alert('submitting...')">Search</a>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<%%- end %>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="four columns">
|
14
|
+
<%%= content_tag :div, :class=>"pretty medium primary btn icon-left icon-plus pull-right" do %>
|
15
|
+
<%%= link_to "New Item", <%= resource_link('new', 'path') %>, :remote=>true %>
|
16
|
+
<%% end %>
|
17
|
+
</div>
|
18
|
+
</div>
|
@@ -0,0 +1,71 @@
|
|
1
|
+
|
2
|
+
<%%# Renders a partial which is used to create a new <%= instance_name %> %>
|
3
|
+
<form id="form_<%= instance_name %>" class="margin-bottom-0" >
|
4
|
+
|
5
|
+
<%%= @<%= instance_name %>.errors[:base].to_sentence %>
|
6
|
+
|
7
|
+
<%%= hidden_field_tag :faction, @<%= instance_name %>.new_record? ? <%= instances_name %>_path : <%= instance_name %>_path(@<%= instance_name %>) %>
|
8
|
+
<%%= hidden_field_tag :fmethod, @<%= instance_name %>.new_record? ? "POST" : "PUT" %>
|
9
|
+
|
10
|
+
<div class="form-inputs">
|
11
|
+
|
12
|
+
<%- fields.each do |name, type| -%>
|
13
|
+
<!-- Type: <%= type -%> -->
|
14
|
+
<% if type == "text" %>
|
15
|
+
<div class="row">
|
16
|
+
<div class="five columns">
|
17
|
+
<label class="pull-right margin-right-10"><%= name.titleize %></label>
|
18
|
+
</div>
|
19
|
+
<div class="seven columns">
|
20
|
+
<div class="field">
|
21
|
+
<input name="<%= name %>" class="text input" type="text" placeholder="Text input" value="<%%= @<%= instance_name %>.<%= name %> %>" />
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
<% elsif type == "boolean" %>
|
26
|
+
<div class="row margin-bottom-15">
|
27
|
+
<div class="five columns"></div>
|
28
|
+
<div class="seven columns">
|
29
|
+
<input name="<%= name %>" type="checkbox" id="chk_<%= name %>" <%%= @<%= instance_name %>.<%= name %> %> ? "checked='checked'" : "" >
|
30
|
+
<span></span> <%= name.titleize %>?
|
31
|
+
</div>
|
32
|
+
</div>
|
33
|
+
<% else %>
|
34
|
+
<div class="row">
|
35
|
+
<div class="five columns">
|
36
|
+
<label class="pull-right margin-right-10"><%= name.titleize %></label>
|
37
|
+
</div>
|
38
|
+
<div class="seven columns">
|
39
|
+
<div class="field">
|
40
|
+
<input name="<%= name %>" class="text input" type="text" placeholder="Text input" value="<%%= @<%= instance_name %>.<%= name %> %>" />
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
<% end -%>
|
45
|
+
<%- end -%>
|
46
|
+
|
47
|
+
</div>
|
48
|
+
<div class="cl-10"></div>
|
49
|
+
|
50
|
+
<%% button_text = "#{@<%= instance_name %>.new_record? ? "Create" : "Update"} Item" %>
|
51
|
+
<div class="pull-right">
|
52
|
+
|
53
|
+
<%% if @<%= instance_name %>.new_record? %>
|
54
|
+
<%%= content_tag :div, :class=>"pretty medium default btn icon-left icon-cancel" do %>
|
55
|
+
<%%= link_to "Cancel", "#", :remote=>true %>
|
56
|
+
<%% end %>
|
57
|
+
<%% else %>
|
58
|
+
<%%= content_tag :div, :class=>"pretty medium default btn icon-left icon-back" do %>
|
59
|
+
<%%= link_to 'Back', <%= resource_link('index', 'path') %>, :remote => true unless @<%= instance_name %>.new_record? %>
|
60
|
+
<%% end %>
|
61
|
+
<%% end %>
|
62
|
+
|
63
|
+
<%%= content_tag :div, :class=>"pretty medium primary btn icon-left icon-plus-squared margin-left-10" do %>
|
64
|
+
<%%= submit_tag button_text, "data-reset-text"=>button_text, "data-loading-text"=>"Saving ..." %>
|
65
|
+
<%% end %>
|
66
|
+
|
67
|
+
</div>
|
68
|
+
<div class="cl-10"></div>
|
69
|
+
|
70
|
+
</form>
|
71
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
<%%# Displays list of @<%= instances_name %> %>
|
3
|
+
<div id="div_<%= instance_name %>_collections">
|
4
|
+
<%% @<%= instances_name %>.each do |<%= instance_name %>| %>
|
5
|
+
<div id="div_<%= instance_name %>_<%%= <%= instance_name %>.id %>">
|
6
|
+
<%%= render :partial=>"item", :locals=>{:<%= instance_name %>=><%= instance_name %>} %>
|
7
|
+
</div>
|
8
|
+
<%% end %>
|
9
|
+
<%% if @<%= instances_name %>.blank? %>
|
10
|
+
<div id="div_<%= instance_name %>_empty" class="box text-color-grey padding-80 text-align-center" style="height:200px;">
|
11
|
+
<%%= translate("forms.no_results_found") %>
|
12
|
+
</div>
|
13
|
+
<%% end %>
|
14
|
+
</div>
|
15
|
+
<div class="cl"></div>
|
16
|
+
|
17
|
+
<%% if @<%= instances_name %>.any? %>
|
18
|
+
<%%= content_tag :div, :class=>"pull-right" do %>
|
19
|
+
<%%= paginate @<%= instances_name %>, :remote => true %>
|
20
|
+
<%% end %>
|
21
|
+
<%% end %>
|
22
|
+
<div class="cl"></div>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%%# describes about each <%= instance_name %> %>
|
2
|
+
<div class="box hoverable padding-10 box-border-black">
|
3
|
+
|
4
|
+
<div class="pull-left width-30">
|
5
|
+
<%%= link_to <%= instance_name %>.<%= main_string_field %>, <%= resource_link('show', 'path') %>(<%= instance_name %>), :remote=>true, :class=>"font-size-16" %></br>
|
6
|
+
|
7
|
+
<div class="text-color-blue font-size-12">
|
8
|
+
<%%= display_time(<%= instance_name %>.created_at) %>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="pull-left width-60">
|
14
|
+
<%- text_fields.each do |name| -%>
|
15
|
+
<%%= scrap_word(<%= instance_name %>.<%= name %>, 200) %>
|
16
|
+
<%- end -%>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class="cl"></div>
|
20
|
+
|
21
|
+
</div>
|
data/lib/rails/generators/humdrum/resource/templates/views/gumby/resource/_nav_filters.html.erb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
<%%= link_to 'New <%= model_class %>', <%= resource_link('new', 'path') %>, :class=>"btn btn-mini btn-primary pull-right margin-left-10", :remote=>true %>
|
2
|
+
|
3
|
+
<%%# Used to add a search functionality %>
|
4
|
+
<%%= form_for <%= model_class %>.new, :url => <%= resource_link('index', 'path') %>, :method => :get, :remote=>true, :html=>{:class=>"pull-right", :style=>"margin-bottom:0px;"} do |f| %>
|
5
|
+
<div class="input-append">
|
6
|
+
<input type="text" style="height:13px;width:120px;" name="<%= instance_name %>[query]">
|
7
|
+
<button type="submit" class="btn btn-mini btn-primary"><i class="icon-search icon-white margin-right-5"></i>Search Item ...</button>
|
8
|
+
</div>
|
9
|
+
<%%- end %>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
<%%# Displays a detailed view of the <%= instance_name %> %>
|
3
|
+
<%%# Display Flash Message if any only in case of ajax request %>
|
4
|
+
<%% if request.xhr? %>
|
5
|
+
<%%= render :partial=>"layouts/common/flash_message" %>
|
6
|
+
<%% end %>
|
7
|
+
|
8
|
+
<div class="box padding-10">
|
9
|
+
|
10
|
+
<div class="margin-10 text-color-blue font-size-24">
|
11
|
+
<%%= @<%= instance_name %>.<%= main_string_field %> %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<%- string_fields.each do |name| -%>
|
15
|
+
<% next if name == main_string_field %>
|
16
|
+
<div class="margin-left-10">
|
17
|
+
<%= name.titleize %>: <%%= link_to @<%= instance_name %>.<%= name %>, "#", :class=>"text-color-red" %>
|
18
|
+
</div>
|
19
|
+
<%- end -%>
|
20
|
+
<% puts fields %>
|
21
|
+
<%- fields.map{|name, type| name unless ["text", "string"].include?(type)}.compact.uniq.each do |name| -%>
|
22
|
+
<div class="margin-left-10">
|
23
|
+
<%= name.titleize %>: <%%= @<%= instance_name %>.<%= name %> %>
|
24
|
+
</div>
|
25
|
+
<%- end -%>
|
26
|
+
|
27
|
+
<%- text_fields.each do |name| -%>
|
28
|
+
<div class='italic margin-10'><%%= simple_format @<%= instance_name %>.<%= name %> %></div>
|
29
|
+
<%- end -%>
|
30
|
+
|
31
|
+
<div class="palette-footer margin-left-10">
|
32
|
+
<%%= display_time(@<%= instance_name %>.created_at, "pull-left text-color-grey font-size-12") %>
|
33
|
+
|
34
|
+
<%%= content_tag :div, :class=>"pretty small danger btn icon-left icon-trash margin-left-10 pull-right" do %>
|
35
|
+
<%%= link_to "Delete", <%= resource_link('destroy', 'path') %>(@<%= instance_name %>), method: :delete, data: { confirm: 'Are you sure?' }, :remote=>true %>
|
36
|
+
<%% end %>
|
37
|
+
|
38
|
+
<%%= content_tag :div, :class=>"pretty small medium primary btn icon-left icon-pencil margin-left-10 pull-right" do %>
|
39
|
+
<%%= link_to "Edit", <%= resource_link('edit', 'path') %>(@<%= instance_name %>), :remote=>true %>
|
40
|
+
<%% end %>
|
41
|
+
|
42
|
+
<div class="cl-10"></div>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
</div>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
|
2
|
+
<%%# Displays Total number of items in the system %>
|
3
|
+
<%%# Display Flash Message if any only in case of ajax request %>
|
4
|
+
<%% if request.xhr? %>
|
5
|
+
<%%= render :partial=>"layouts/common/flash_message" %>
|
6
|
+
<%% end %>
|
7
|
+
|
8
|
+
<div class="box text-color-grey padding-80 text-align-center" style="height:200px;">
|
9
|
+
Total <%= instances_name %> = <%%= <%= model_class %>.count %>
|
10
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%% if @<%= instance_name %>.errors.blank? %>
|
2
|
+
|
3
|
+
// Fill the right box with first <%= instance_name %> details
|
4
|
+
$('#div_<%= instance_name %>_details').html("<%%= escape_javascript(render(:partial=>'show')) %>");
|
5
|
+
|
6
|
+
// Add the newly created item to the list
|
7
|
+
$("#div_<%= instance_name %>_collections").prepend("<div id=\"div_item_<%= instance_name %>_<%%= @<%= instance_name %>.id %>\"><%%= escape_javascript(render(:partial => 'item', :locals => { :<%= instance_name %> => @<%= instance_name %> })) %></div>")
|
8
|
+
$("#div_<%= instance_name %>_empty").hide();
|
9
|
+
|
10
|
+
<%% else %>
|
11
|
+
|
12
|
+
// Reload the form partial to display errors
|
13
|
+
$('#div_<%= instance_name %>_details').html("<%%= escape_javascript(render(:partial=>'new')) %>");
|
14
|
+
|
15
|
+
<%% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%% if @<%= instance_name %>.errors.blank? %>
|
2
|
+
|
3
|
+
// Fill the right box with first <%= instance_name %> details
|
4
|
+
$('#div_<%= instance_name %>_details').html("<%%= escape_javascript(render(:partial=>'show')) %>");
|
5
|
+
|
6
|
+
// Render health care <%= instances_name %> List
|
7
|
+
$('#div_<%= instance_name %>_collections').html("<%%= escape_javascript(render(:partial=>'index')) %>");
|
8
|
+
|
9
|
+
<%% else %>
|
10
|
+
|
11
|
+
// Render the show partial to show flash message
|
12
|
+
$('#div_<%= instance_name %>_details').html("<%%= escape_javascript(render(:partial=>'show')) %>");
|
13
|
+
|
14
|
+
<%% end %>
|