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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2510a27d312d495c3d4a1163f6aace27f801370e
4
- data.tar.gz: ae0a3e6d44d4c30ea885097bf4219e0717564bd5
3
+ metadata.gz: 119d2b18447e11794e3242645aacd697afa47258
4
+ data.tar.gz: 90fa0a23e723b28b1a597bed200157783252ed43
5
5
  SHA512:
6
- metadata.gz: b3a0574fd5d942b756698fb48f5772247335f8d89f2233c943d66089915b8f43520fffcbdcda3919804b316256d3270f1f79e50108da386e4f9e3a526d24f758
7
- data.tar.gz: 453bada55663e0c324cb2c3f417933d3bf7635f5f075ec5b8a87c435820ddb712973d8f1e09286db956c955f9290a428483aa171aacedebe393662d60bd42287
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
- template 'views/admin/index.html.erb', "app/views/admin/#{module_name_formatted}/index.html.erb"
27
- template 'views/admin/show.html.erb', "app/views/admin/#{module_name_formatted}/show.html.erb"
28
- template 'views/admin/new.html.erb', "app/views/admin/#{module_name_formatted}/new.html.erb"
29
- template 'views/admin/edit.html.erb', "app/views/admin/#{module_name_formatted}/edit.html.erb"
30
- template 'views/admin/_form.html.erb', "app/views/admin/#{module_name_formatted}/_form.html.erb"
31
- template 'views/frontend/index.html.erb', "app/views/#{module_name_formatted}/index.html.erb"
32
- template 'views/frontend/show.html.erb', "app/views/#{module_name_formatted}/show.html.erb"
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 &nbsp;
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 &nbsp;
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);
@@ -1,23 +1,33 @@
1
- module Spud
2
- module Core
3
- module ClassMethods
4
-
5
- def method_missing(method_signature, *args, &block)
6
- if TbCore.respond_to?(method_signature)
7
- ActiveSupport::Deprecation.warn(
8
- 'The Spud::Core namespace is being replaced by TbCore. Please update your app code accordingly.',
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
- def respond_to_missing?(method_signature)
18
- TbCore.respond_to?(method_signature) || super
19
- end
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
@@ -1,3 +1,3 @@
1
1
  module TbCore
2
- VERSION = '1.4.4'.freeze
2
+ VERSION = '1.4.5'.freeze
3
3
  end
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
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-02-23 00:00:00.000000000 Z
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