tb_core 1.4.4 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/admin/core/application.scss +8 -2
- data/lib/generators/spud/module_generator.rb +42 -7
- data/lib/generators/spud/templates/views/admin/_form.html.slim +12 -0
- data/lib/generators/spud/templates/views/admin/edit.html.slim +1 -0
- data/lib/generators/spud/templates/views/admin/index.html.slim +39 -0
- data/lib/generators/spud/templates/views/admin/new.html.slim +1 -0
- data/lib/generators/spud/templates/views/admin/show.html.slim +16 -0
- data/lib/generators/spud/templates/views/frontend/index.html.slim +22 -0
- data/lib/generators/spud/templates/views/frontend/show.html.slim +12 -0
- data/lib/tb_core/spud_core.rb +29 -19
- data/lib/tb_core/version.rb +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 119d2b18447e11794e3242645aacd697afa47258
|
4
|
+
data.tar.gz: 90fa0a23e723b28b1a597bed200157783252ed43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66144e84faacb6b62cb9ee33ea90342b6cb426238a7d41ab75aa09c2b644be8a5e3fe48a0a767d2add4c82fb0b4222127bcce70ed60d7b9cb4e5b671f90def8f
|
7
|
+
data.tar.gz: 3fb79b93110d12782939307eee24776d1bc0f1cd7c424e7a90f2252aeb5bc9bdb345d6760a552afc1d5e086ff19f29af7ec4859d31a5349e6b4e5e4dfe16c5ae
|
@@ -45,7 +45,7 @@ body {
|
|
45
45
|
display:block;
|
46
46
|
color:#000;
|
47
47
|
padding:10px 10px;
|
48
|
-
text-decoration:none;
|
48
|
+
text-decoration:none;
|
49
49
|
}
|
50
50
|
img {
|
51
51
|
width: 125px;
|
@@ -94,6 +94,9 @@ body {
|
|
94
94
|
}
|
95
95
|
.data-controls{
|
96
96
|
float: right;
|
97
|
+
.btn:not(:first-child) {
|
98
|
+
margin-left: 0.5rem;
|
99
|
+
}
|
97
100
|
}
|
98
101
|
.pagination{
|
99
102
|
margin-bottom: 0;
|
@@ -142,7 +145,7 @@ p.form-error-base{
|
|
142
145
|
}
|
143
146
|
.date-select{
|
144
147
|
&.form-control{
|
145
|
-
display: inline-block;
|
148
|
+
display: inline-block;
|
146
149
|
}
|
147
150
|
&.year{
|
148
151
|
width: 20%
|
@@ -176,6 +179,9 @@ td.no-wrap{
|
|
176
179
|
td.table-actions{
|
177
180
|
white-space: nowrap;
|
178
181
|
text-align: right;
|
182
|
+
.btn:not(:first-child) {
|
183
|
+
margin-left: 0.5rem;
|
184
|
+
}
|
179
185
|
}
|
180
186
|
.table .nesting-spacer{
|
181
187
|
display: inline-block;
|
@@ -23,13 +23,33 @@ class Spud::ModuleGenerator < ::Rails::Generators::Base
|
|
23
23
|
template 'controller.rb.erb', "app/controllers/#{module_name_formatted}_controller.rb"
|
24
24
|
template 'assets/module.js.erb', "app/assets/javascripts/#{module_name_formatted}.js"
|
25
25
|
template 'assets/admin/module.js.erb', "app/assets/javascripts/admin/#{module_name_formatted}.js"
|
26
|
-
|
27
|
-
|
28
|
-
template
|
29
|
-
template
|
30
|
-
template
|
31
|
-
template
|
32
|
-
template
|
26
|
+
|
27
|
+
# Admin views
|
28
|
+
template(*view_template_args('index', true))
|
29
|
+
template(*view_template_args('show', true))
|
30
|
+
template(*view_template_args('new', true))
|
31
|
+
template(*view_template_args('edit', true))
|
32
|
+
template(*view_template_args('_form', true))
|
33
|
+
|
34
|
+
# Front-end views
|
35
|
+
template(*view_template_args('index'))
|
36
|
+
template(*view_template_args('show'))
|
37
|
+
end
|
38
|
+
|
39
|
+
def view_template_args(name, admin=false)
|
40
|
+
template_name = "#{name}.html.#{view_template_ext}"
|
41
|
+
[
|
42
|
+
[
|
43
|
+
'views', (admin ? 'admin' : 'frontend'), template_name
|
44
|
+
].join('/'),
|
45
|
+
[
|
46
|
+
'app', (admin ? 'views/admin' : 'views'), module_name_formatted, template_name
|
47
|
+
].join('/')
|
48
|
+
]
|
49
|
+
end
|
50
|
+
|
51
|
+
def view_template_ext
|
52
|
+
defined?(Slim) ? 'slim' : 'erb'
|
33
53
|
end
|
34
54
|
|
35
55
|
def install_assets
|
@@ -87,6 +107,21 @@ RUBY
|
|
87
107
|
end
|
88
108
|
end
|
89
109
|
|
110
|
+
def slim_field_for_attribute(type, name)
|
111
|
+
case type
|
112
|
+
when 'integer'
|
113
|
+
"= f.tb_number_field :#{name}"
|
114
|
+
when 'text'
|
115
|
+
"= f.tb_text_area :#{name}, rows: 4"
|
116
|
+
when 'boolean'
|
117
|
+
"= f.tb_check_box :#{name}"
|
118
|
+
when 'date'
|
119
|
+
"= f.tb_date_select :#{name}"
|
120
|
+
else
|
121
|
+
"= f.tb_text_field :#{name}"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
90
125
|
def application_name
|
91
126
|
Rails.application.class.name.split('::').first.underscore
|
92
127
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
= tb_form_for [:admin, @<%=module_name_formatted.singularize%>],
|
2
|
+
remote: true,
|
3
|
+
data: { errors: :inline, success: admin_<%= module_name_formatted %>_path } do |f|
|
4
|
+
|
5
|
+
= tb_form_errors(f.object, :base)
|
6
|
+
<%- attributes.collect{ |att| att.split(':') }.each do |arg_0, arg_1| %>
|
7
|
+
<%= slim_field_for_attribute(arg_1, arg_0) %>
|
8
|
+
<%- end %>
|
9
|
+
= f.tb_save_buttons('<%= module_name_formatted.singularize.humanize.titlecase %>', admin_<%= module_name_formatted %>_path)
|
10
|
+
|
11
|
+
javascript:
|
12
|
+
document.addEventListener('DOMContentLoaded', app.admin.<%= module_name_formatted %>.edit);
|
@@ -0,0 +1 @@
|
|
1
|
+
= render 'form'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
= content_for :data_controls do
|
2
|
+
= render partial: '/layouts/admin/search',
|
3
|
+
locals: { search_path: admin_<%= module_name_formatted %>_path }
|
4
|
+
= link_to 'New <%=module_name_formatted.singularize.humanize.titlecase%>',
|
5
|
+
new_admin_<%=module_name_formatted.singularize%>_path,
|
6
|
+
class: 'btn btn-primary'
|
7
|
+
|
8
|
+
= content_for :detail do
|
9
|
+
.table-responsive
|
10
|
+
table.table.table-striped.table-hover
|
11
|
+
thead
|
12
|
+
tr
|
13
|
+
<%- attribute_names.each do |attribute| -%>
|
14
|
+
th <%= attribute.humanize.titlecase %>
|
15
|
+
<%- end -%>
|
16
|
+
th
|
17
|
+
tbody
|
18
|
+
- @<%=module_name_formatted%>.each do |<%=module_name_formatted.singularize%>|
|
19
|
+
tr
|
20
|
+
<%-attribute_names.each do |attribute|-%>
|
21
|
+
td = <%=module_name_formatted.singularize%>.<%=attribute%>
|
22
|
+
<%-end-%>
|
23
|
+
td.table-actions
|
24
|
+
= link_to 'Details',
|
25
|
+
admin_<%=module_name_formatted.singularize%>_path(<%=module_name_formatted.singularize%>),
|
26
|
+
class: 'btn btn-default btn-sm'
|
27
|
+
= link_to 'Edit',
|
28
|
+
edit_admin_<%=module_name_formatted.singularize%>_path(<%=module_name_formatted.singularize%>),
|
29
|
+
class: 'btn btn-default btn-sm'
|
30
|
+
= link_to 'Delete',
|
31
|
+
admin_<%=module_name_formatted.singularize%>_path(<%=module_name_formatted.singularize%>),
|
32
|
+
class: 'btn btn-danger btn-sm',
|
33
|
+
method: :delete,
|
34
|
+
data: { confirm: 'Are you sure?' }
|
35
|
+
|
36
|
+
= will_paginate @<%=module_name_formatted%>, renderer: BootstrapPagination::Rails
|
37
|
+
|
38
|
+
javascript:
|
39
|
+
document.addEventListener('DOMContentLoaded', app.admin.<%= module_name_formatted %>.index);
|
@@ -0,0 +1 @@
|
|
1
|
+
= render 'form'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
= content_for :data_controls do
|
2
|
+
= link_to 'Edit',
|
3
|
+
edit_admin_<%=module_name_formatted.singularize%>_path(@<%=module_name_formatted.singularize%>),
|
4
|
+
class: 'btn btn-default'
|
5
|
+
= link_to 'Back',
|
6
|
+
admin_<%= module_name_formatted %>_path,
|
7
|
+
class: 'btn btn-default'
|
8
|
+
|
9
|
+
dl.dl-horizontal
|
10
|
+
<%- attribute_names.each do |attribute| -%>
|
11
|
+
dt <%= attribute.humanize.titlecase %>:
|
12
|
+
dd = @<%= module_name_formatted.singularize %>.<%= attribute %>
|
13
|
+
<%- end -%>
|
14
|
+
|
15
|
+
javascript:
|
16
|
+
document.addEventListener('DOMContentLoaded', app.admin.<%= module_name_formatted %>.show);
|
@@ -0,0 +1,22 @@
|
|
1
|
+
h1 <%= module_name_formatted.pluralize.camelize %>
|
2
|
+
|
3
|
+
table.table
|
4
|
+
thead
|
5
|
+
tr
|
6
|
+
<%- attributes.each do |attribute| -%>
|
7
|
+
<%- attribute_args = attribute.split(":") -%>
|
8
|
+
th <%= attribute_args.first.humanize.titlecase %>
|
9
|
+
<%- end %>
|
10
|
+
th
|
11
|
+
tbody
|
12
|
+
- @<%= module_name_formatted %>.each do |<%= module_name_formatted.singularize %>|
|
13
|
+
tr
|
14
|
+
<%- attributes.each do |attribute| -%>
|
15
|
+
<%- attribute_args = attribute.split(":") -%>
|
16
|
+
td = <%= module_name_formatted.singularize %>.<%= attribute_args.first %>
|
17
|
+
<%- end %>
|
18
|
+
td = link_to 'Details', <%= module_name_formatted.singularize %>_path(<%= module_name_formatted.singularize %>)
|
19
|
+
= will_paginate @<%= module_name_formatted %>
|
20
|
+
|
21
|
+
javascript:
|
22
|
+
document.addEventListener('DOMContentLoaded', app.<%= module_name_formatted %>.index);
|
@@ -0,0 +1,12 @@
|
|
1
|
+
h1 <%= module_name_formatted.singularize.camelize %>
|
2
|
+
|
3
|
+
dl.dl-horizontal
|
4
|
+
<%- attribute_names.each do |attribute| -%>
|
5
|
+
dt <%= attribute.humanize.titlecase %>:
|
6
|
+
dd = @<%= module_name_formatted.singularize %>.<%= attribute %>
|
7
|
+
<%- end -%>
|
8
|
+
|
9
|
+
p = link_to 'Back', <%=module_name_formatted.pluralize%>_path
|
10
|
+
|
11
|
+
javascript:
|
12
|
+
document.addEventListener('DOMContentLoaded', app.<%= module_name_formatted %>.show);
|
data/lib/tb_core/spud_core.rb
CHANGED
@@ -1,23 +1,33 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
caller
|
10
|
-
)
|
11
|
-
TbCore.__send__(method_signature, *args, &block)
|
12
|
-
else
|
13
|
-
super
|
14
|
-
end
|
15
|
-
end
|
1
|
+
module SpudDeprecatedNamespace
|
2
|
+
def const_missing(const)
|
3
|
+
ActiveSupport::Deprecation.warn(
|
4
|
+
'The Spud namespace is being replaced by TbCore. Please update your app code accordingly.',
|
5
|
+
caller
|
6
|
+
)
|
7
|
+
TbCore.const_get(const)
|
8
|
+
end
|
16
9
|
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
def method_missing(method_signature, *args, &block)
|
11
|
+
if TbCore.respond_to?(method_signature)
|
12
|
+
ActiveSupport::Deprecation.warn(
|
13
|
+
'The Spud::Core namespace is being replaced by TbCore. Please update your app code accordingly.',
|
14
|
+
caller
|
15
|
+
)
|
16
|
+
TbCore.__send__(method_signature, *args, &block)
|
17
|
+
else
|
18
|
+
super
|
20
19
|
end
|
21
|
-
extend ClassMethods
|
22
20
|
end
|
21
|
+
|
22
|
+
def respond_to_missing?(method_signature)
|
23
|
+
TbCore.respond_to?(method_signature) || super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module Spud
|
28
|
+
extend SpudDeprecatedNamespace
|
29
|
+
end
|
30
|
+
|
31
|
+
module Spud::Core
|
32
|
+
extend SpudDeprecatedNamespace
|
23
33
|
end
|
data/lib/tb_core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tb_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Woods
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: authlogic
|
@@ -396,12 +396,19 @@ files:
|
|
396
396
|
- lib/generators/spud/templates/controller.rb.erb
|
397
397
|
- lib/generators/spud/templates/controller_spec.rb.erb
|
398
398
|
- lib/generators/spud/templates/views/admin/_form.html.erb
|
399
|
+
- lib/generators/spud/templates/views/admin/_form.html.slim
|
399
400
|
- lib/generators/spud/templates/views/admin/edit.html.erb
|
401
|
+
- lib/generators/spud/templates/views/admin/edit.html.slim
|
400
402
|
- lib/generators/spud/templates/views/admin/index.html.erb
|
403
|
+
- lib/generators/spud/templates/views/admin/index.html.slim
|
401
404
|
- lib/generators/spud/templates/views/admin/new.html.erb
|
405
|
+
- lib/generators/spud/templates/views/admin/new.html.slim
|
402
406
|
- lib/generators/spud/templates/views/admin/show.html.erb
|
407
|
+
- lib/generators/spud/templates/views/admin/show.html.slim
|
403
408
|
- lib/generators/spud/templates/views/frontend/index.html.erb
|
409
|
+
- lib/generators/spud/templates/views/frontend/index.html.slim
|
404
410
|
- lib/generators/spud/templates/views/frontend/show.html.erb
|
411
|
+
- lib/generators/spud/templates/views/frontend/show.html.slim
|
405
412
|
- lib/generators/spud/templates/views/layouts/application.html.erb
|
406
413
|
- lib/generators/spud/templates/views/layouts/error_page.html.erb
|
407
414
|
- lib/tasks/spud_core_tasks.rake
|