wallaby 6.1.5 → 7.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/fonts/FontAwesome.otf +0 -0
  3. data/app/assets/fonts/fontawesome-webfont.eot +0 -0
  4. data/app/assets/fonts/fontawesome-webfont.svg +2671 -0
  5. data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
  6. data/app/assets/fonts/fontawesome-webfont.woff +0 -0
  7. data/app/assets/fonts/fontawesome-webfont.woff2 +0 -0
  8. data/app/assets/fonts/summernote.eot +0 -0
  9. data/app/assets/fonts/summernote.hash +1 -0
  10. data/app/assets/fonts/summernote.ttf +0 -0
  11. data/app/assets/fonts/summernote.woff +0 -0
  12. data/app/assets/fonts/summernote.woff2 +0 -0
  13. data/app/assets/javascripts/wallaby/base.js +1 -17
  14. data/app/assets/javascripts/wallaby/core.js +46172 -0
  15. data/app/assets/javascripts/wallaby/core.js.map +7 -0
  16. data/app/assets/javascripts/wallaby/{setup.js.erb → setup.js} +17 -5
  17. data/app/assets/stylesheets/wallaby/base/_fonts.scss +22 -0
  18. data/app/assets/stylesheets/wallaby/base/_functions.scss +15 -29
  19. data/app/assets/stylesheets/wallaby/base/_mixins.scss +7 -7
  20. data/app/assets/stylesheets/wallaby/base.scss +2 -8
  21. data/app/assets/stylesheets/wallaby/core.scss +12139 -0
  22. data/app/assets/stylesheets/wallaby/pages/_index.scss +1 -1
  23. data/app/javascript/wallaby/core.js +23 -0
  24. data/app/javascript/wallaby/globals.js +9 -0
  25. data/app/stylesheets/wallaby/core.scss +15 -0
  26. data/app/views/layouts/wallaby/resources.html.erb +1 -3
  27. data/app/views/wallaby/resources/_edit_page.html.erb +20 -0
  28. data/app/views/wallaby/resources/_form.html.erb +7 -1
  29. data/app/views/wallaby/resources/_frontend.html.erb +2 -3
  30. data/app/views/wallaby/resources/_home_page.html.erb +5 -0
  31. data/app/views/wallaby/resources/_index_page.html.erb +59 -0
  32. data/app/views/wallaby/resources/_index_query.html.erb +2 -2
  33. data/app/views/wallaby/resources/_new_page.html.erb +19 -0
  34. data/app/views/wallaby/resources/_show_page.html.erb +42 -0
  35. data/app/views/wallaby/resources/edit.html.erb +1 -18
  36. data/app/views/wallaby/resources/error.json.jbuilder +1 -0
  37. data/app/views/wallaby/resources/form/_belongs_to.html.erb +1 -1
  38. data/app/views/wallaby/resources/form/_citext.html.erb +1 -1
  39. data/app/views/wallaby/resources/form/_color.html.erb +1 -1
  40. data/app/views/wallaby/resources/form/_date.html.erb +1 -1
  41. data/app/views/wallaby/resources/form/_daterange.html.erb +1 -1
  42. data/app/views/wallaby/resources/form/_datetime.html.erb +1 -1
  43. data/app/views/wallaby/resources/form/_has_and_belongs_to_many.html.erb +1 -1
  44. data/app/views/wallaby/resources/form/_has_many.html.erb +1 -1
  45. data/app/views/wallaby/resources/form/_hstore.html.erb +1 -1
  46. data/app/views/wallaby/resources/form/_json.html.erb +1 -1
  47. data/app/views/wallaby/resources/form/_jsonb.html.erb +1 -1
  48. data/app/views/wallaby/resources/form/_longtext.html.erb +1 -1
  49. data/app/views/wallaby/resources/form/_markdown.html.erb +1 -1
  50. data/app/views/wallaby/resources/form/_mediumtext.html.erb +1 -1
  51. data/app/views/wallaby/resources/form/_text.html.erb +1 -1
  52. data/app/views/wallaby/resources/form/_time.html.erb +1 -1
  53. data/app/views/wallaby/resources/form/_tinytext.html.erb +1 -1
  54. data/app/views/wallaby/resources/form/_tsrange.html.erb +1 -1
  55. data/app/views/wallaby/resources/form/_tstzrange.html.erb +1 -1
  56. data/app/views/wallaby/resources/form/_xml.html.erb +1 -1
  57. data/app/views/wallaby/resources/home.html.erb +1 -5
  58. data/app/views/wallaby/resources/index/_box.html.erb +1 -1
  59. data/app/views/wallaby/resources/index/_circle.html.erb +1 -1
  60. data/app/views/wallaby/resources/index/_citext.html.erb +1 -1
  61. data/app/views/wallaby/resources/index/_dollar.html.erb +5 -0
  62. data/app/views/wallaby/resources/index/_hstore.html.erb +1 -1
  63. data/app/views/wallaby/resources/index/_json.html.erb +1 -1
  64. data/app/views/wallaby/resources/index/_jsonb.html.erb +1 -1
  65. data/app/views/wallaby/resources/index/_line.html.erb +1 -1
  66. data/app/views/wallaby/resources/index/_longtext.html.erb +1 -1
  67. data/app/views/wallaby/resources/index/_lseg.html.erb +1 -1
  68. data/app/views/wallaby/resources/index/_ltree.html.erb +1 -1
  69. data/app/views/wallaby/resources/index/_mediumtext.html.erb +1 -1
  70. data/app/views/wallaby/resources/index/_path.html.erb +1 -1
  71. data/app/views/wallaby/resources/index/_percent.html.erb +10 -0
  72. data/app/views/wallaby/resources/index/_polygon.html.erb +1 -1
  73. data/app/views/wallaby/resources/index/_sti.html.erb +1 -1
  74. data/app/views/wallaby/resources/index/_string.html.erb +1 -1
  75. data/app/views/wallaby/resources/index/_text.html.erb +1 -1
  76. data/app/views/wallaby/resources/index/_tinytext.html.erb +1 -1
  77. data/app/views/wallaby/resources/index/_tsvector.html.erb +1 -1
  78. data/app/views/wallaby/resources/index/_uuid.html.erb +1 -1
  79. data/app/views/wallaby/resources/index/_xml.html.erb +1 -1
  80. data/app/views/wallaby/resources/index.csv.erb +7 -1
  81. data/app/views/wallaby/resources/index.html.erb +1 -54
  82. data/app/views/wallaby/resources/new.html.erb +1 -18
  83. data/app/views/wallaby/resources/show/_active_storage.html.erb +5 -0
  84. data/app/views/wallaby/resources/show.html.erb +1 -35
  85. data/lib/generators/wallaby/engine/partials/USAGE +23 -0
  86. data/lib/generators/wallaby/engine/partials/partials_generator.rb +25 -0
  87. data/lib/generators/wallaby/install/install_generator.rb +1 -54
  88. data/lib/wallaby/ui_engine.rb +3 -2
  89. data/lib/wallaby/version.rb +1 -1
  90. data/lib/wallaby/views.rb +2 -11
  91. metadata +45 -122
  92. data/app/assets/stylesheets/wallaby/summernote.scss.erb +0 -7
  93. data/lib/generators/wallaby/install/templates/application_authorizer.rb.erb +0 -40
  94. data/lib/generators/wallaby/install/templates/application_controller.rb.erb +0 -148
  95. data/lib/generators/wallaby/install/templates/application_decorator.rb.erb +0 -10
  96. data/lib/generators/wallaby/install/templates/application_paginator.rb.erb +0 -30
  97. data/lib/generators/wallaby/install/templates/application_servicer.rb.erb +0 -50
  98. data/lib/generators/wallaby/install/templates/initializer.rb.erb +0 -58
  99. /data/app/views/wallaby/resources/{_active_storage.html.erb → index/_active_storage.html.erb} +0 -0
@@ -0,0 +1,10 @@
1
+ <%# @param object [model] model instance %>
2
+ <%# @param field_name [String] name of the field %>
3
+ <%# @param value [Object] value of the field %>
4
+ <%# @param metadata [Hash] metadata of the field %>
5
+ <%= if value.nil?
6
+ null
7
+ else
8
+ "%.#{ metadata[:precision] || 2 }f%%" %
9
+ (value.to_f * (metadata[:is_percent] ? 1 : 100))
10
+ end %>
@@ -5,7 +5,7 @@
5
5
  <%= if value.nil?
6
6
  null
7
7
  else
8
- max = metadata[:max] || default_metadata.max
8
+ max = metadata[:max] || max_text_length
9
9
  value = value.to_s
10
10
  if value.length > max
11
11
  concat content_tag(:code, value.truncate(max))
@@ -5,7 +5,7 @@
5
5
  <%= if value.nil?
6
6
  null
7
7
  else
8
- max = metadata[:max] || default_metadata.max
8
+ max = metadata[:max] || max_text_length
9
9
  value = value.to_s
10
10
  if value.length > max
11
11
  concat content_tag(:span, value.truncate(max))
@@ -5,7 +5,7 @@
5
5
  <%= if value.nil?
6
6
  null
7
7
  else
8
- max = metadata[:max] || default_metadata.max
8
+ max = metadata[:max] || max_text_length
9
9
  value = value.to_s
10
10
  if value.length > max
11
11
  concat content_tag(:span, value.truncate(max))
@@ -5,7 +5,7 @@
5
5
  <%= if value.nil?
6
6
  null
7
7
  else
8
- max = metadata[:max] || default_metadata.max
8
+ max = metadata[:max] || max_text_length
9
9
  value = value.to_s
10
10
  if value.length > max
11
11
  concat content_tag(:span, value.truncate(max))
@@ -5,7 +5,7 @@
5
5
  <%= if value.nil?
6
6
  null
7
7
  else
8
- max = metadata[:max] || default_metadata.max
8
+ max = metadata[:max] || max_text_length
9
9
  value = value.to_s
10
10
  if value.length > max
11
11
  concat content_tag(:span, value.truncate(max))
@@ -5,7 +5,7 @@
5
5
  <%= if value.nil?
6
6
  null
7
7
  else
8
- max = metadata[:max] || default_metadata.max
8
+ max = metadata[:max] || max_text_length
9
9
  value = value.to_s
10
10
  if value.length > max
11
11
  concat content_tag(:span, value.truncate(max))
@@ -5,7 +5,7 @@
5
5
  <%= if value.nil?
6
6
  null
7
7
  else
8
- max = metadata[:max] || default_metadata.max
8
+ max = metadata[:max] || max_text_length
9
9
  value = value.to_s
10
10
  if value.length > max
11
11
  concat content_tag(:span, value.truncate(max))
@@ -5,7 +5,7 @@
5
5
  <%= if value.nil?
6
6
  null
7
7
  else
8
- max = metadata[:max] || default_metadata.max
8
+ max = metadata[:max] || max_text_length
9
9
  value = value.to_s
10
10
  if value.length > max
11
11
  concat content_tag(:code, value.truncate(max))
@@ -8,7 +8,13 @@
8
8
  <%
9
9
  decorated_collection.each do |decorated|
10
10
  data = current_model_decorator.index_field_names.map do |field_name|
11
- type_render decorated.index_type_of(field_name), object: decorated, field_name: field_name
11
+ render(
12
+ decorated.index_type_of(field_name),
13
+ object: decorated,
14
+ field_name: field_name,
15
+ value: decorated.try(field_name),
16
+ metadata: decorated.index_metadata_of(field_name)
17
+ )
12
18
  end
13
19
  %>
14
20
  <%= ::CSV.generate_line(data).strip.html_safe %>
@@ -1,54 +1 @@
1
- <%
2
- # decorate first on every page or partial
3
- decorated_collection = decorate collection
4
- %>
5
- <article class="resources">
6
- <div class="resources__header">
7
- <h1><%= to_model_label(current_model_class) %></h1>
8
- <%= render 'index_query' %>
9
- <%= render 'index_filters' %>
10
- <%= render 'index_pagination' %>
11
- </div>
12
- <%= render 'flash_messages' %>
13
-
14
- <section>
15
- <% # Data table %>
16
- <% if decorated_collection.present? %>
17
- <% field_names = current_model_decorator.index_field_names %>
18
- <div class="resources__container">
19
- <table class="resources__data">
20
- <thead>
21
- <tr>
22
- <% field_names.each do |field_name| %>
23
- <%= content_tag :th, class: sort_link_builder.current_sort[field_name] do %>
24
- <%= sort_link_builder.build field_name %>
25
- <% end %>
26
- <% end %>
27
- <th>&nbsp;</th>
28
- </tr>
29
- </thead>
30
- <tbody>
31
- <% decorated_collection.each do |decorated| %>
32
- <tr>
33
- <% field_names.each do |field_name| %>
34
- <td>
35
- <%= type_render decorated.index_type_of(field_name), object: decorated, field_name: field_name %>
36
- </td>
37
- <% end %>
38
- <td class="resource__actions">
39
- <%= render 'resource_actions', decorated: decorated %>
40
- </td>
41
- </tr>
42
- <% end %>
43
- </tbody>
44
- </table>
45
- </div>
46
- <% else %>
47
- <div class="resources__not-found">
48
- <%= image_tag 'wallaby/not_found.png' %>
49
- <%= wt 'errors.not_found.collection' %>
50
- </div>
51
- <% end %>
52
- <% # /Data table %>
53
- </section>
54
- </article>
1
+ <%= render 'index_page' %>
@@ -1,18 +1 @@
1
- <% decorated = decorate resource %>
2
- <article class="resource">
3
- <div class="resource__header">
4
- <h1><%= wt 'labels.create', model: to_model_label(current_model_class) %></h1>
5
- <%= render 'resource_navs' %>
6
- </div>
7
- <%= render 'flash_messages' %>
8
- <section>
9
- <div class="resource__container">
10
- <%= form_for(
11
- decorated, url: url_for(action: (params[:resource] ? :show : :index)),
12
- method: :post, html: { :multipart => true }, builder: Wallaby::FormBuilder
13
- ) do |form| %>
14
- <%= render 'form', form: form, decorated: decorated %>
15
- <% end %>
16
- </div>
17
- </section>
18
- </article>
1
+ <%= render 'new_page' %>
@@ -0,0 +1,5 @@
1
+ <%# @param object [model] model instance %>
2
+ <%# @param field_name [String] name of the field %>
3
+ <%# @param value [Object] value of the field %>
4
+ <%# @param metadata [Hash] metadata of the field %>
5
+ <%= value.try(:attachment) ? link_to(value.attachment.blob.filename, rails_blob_path(value)) : null %>
@@ -1,35 +1 @@
1
- <article class="resource">
2
- <%
3
- if resource
4
- # decorate first on every page or partial
5
- decorated = decorate resource
6
- %>
7
- <div class="resource__header">
8
- <h1><%= show_title decorated %></h1>
9
- <%= render 'resource_navs' %>
10
- </div>
11
- <%= render 'flash_messages' %>
12
- <section>
13
- <div class="resource__container">
14
- <% decorated.show_field_names.each do |field_name| %>
15
- <dl>
16
- <dt><%= decorated.show_label_of field_name %></dt>
17
- <dd><%= type_render decorated.show_type_of(field_name), object: decorated, field_name: field_name %></dd>
18
- </dl>
19
- <% end %>
20
- </div>
21
- </section>
22
- <% else %>
23
- <div class="resource__header">
24
- <h1><%= to_model_label(current_model_class) %></h1>
25
- <%= render 'resource_navs' %>
26
- </div>
27
- <%= render 'flash_messages' %>
28
- <section>
29
- <div class="resource__not-found">
30
- <%= image_tag 'wallaby/not_found.png' %>
31
- <%= wt 'errors.not_found.resource', resource: to_model_label(current_model_class) %>
32
- </div>
33
- </section>
34
- <% end %>
35
- </article>
1
+ <%= render 'show_page' %>
@@ -0,0 +1,23 @@
1
+ Description:
2
+ Copy the main partials and templates for the given NAME (default to 'admin').
3
+
4
+ Example:
5
+ rails generate wallaby:engine:partials admin
6
+
7
+ This will create:
8
+ - app/views/admin/application/_footer.html.erb
9
+ - app/views/admin/application/_frontend.html.erb
10
+ - app/views/admin/application/_logo.html.erb
11
+ - app/views/admin/application/_navs.html.erb
12
+ - app/views/admin/application/_title.html.erb
13
+ - app/views/admin/application/_user_menu.html.erb
14
+ - app/views/admin/application/_index_actions.html.erb
15
+ - app/views/admin/application/_index_filters.html.erb
16
+ - app/views/admin/application/_index_pagination.html.erb
17
+ - app/views/admin/application/_index_query.html.erb
18
+ - app/views/admin/application/_resource_navs.html.erb
19
+ - app/views/admin/application/index.html.erb
20
+ - app/views/admin/application/new.html.erb
21
+ - app/views/admin/application/show.html.erb
22
+ - app/views/admin/application/edit.html.erb
23
+ - app/views/admin/application/_form.html.erb
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Wallaby
4
+ class Engine
5
+ # `wallaby:engine:partials` generator
6
+ class PartialsGenerator < Rails::Generators::NamedBase
7
+ source_root File.expand_path('../../../../../', __dir__)
8
+ argument :name, type: :string, default: 'admin'
9
+
10
+ # @see https://github.com/wallaby-rails/wallaby/blob/master/lib/generators/wallaby/engine/partials/USAGE
11
+ def install
12
+ destination_prefix = "app/views/#{file_name}/application"
13
+ %w[
14
+ _footer _frontend _logo _navs _title _user_menu
15
+ _index_actions _index_filters _index_pagination _index_query _resource_navs
16
+ ].each do |name|
17
+ copy_file(
18
+ "#{source_paths.first}/app/views/wallaby/resources/#{name}.html.erb",
19
+ "#{destination_prefix}/#{name}.html.erb"
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -3,7 +3,6 @@
3
3
  module Wallaby
4
4
  # `wallaby:install` generator
5
5
  class InstallGenerator < Rails::Generators::NamedBase
6
- source_root File.expand_path('templates', __dir__)
7
6
  argument :name, type: :string, default: 'admin'
8
7
 
9
8
  class_option \
@@ -32,59 +31,7 @@ module Wallaby
32
31
 
33
32
  # @see https://github.com/wallaby-rails/wallaby/blob/master/lib/generators/wallaby/install/USAGE
34
33
  def install
35
- mount_wallaby_to_given_name
36
- return if options[:mount_only]
37
-
38
- create_wallaby_initializer_file
39
- create_application_files
40
- end
41
-
42
- private
43
-
44
- def commenting
45
- file_name == self.class.arguments.first.default && '# ' || ''
46
- end
47
-
48
- def mount_wallaby_to_given_name
49
- route %(mount Wallaby::Engine, at: '/#{file_name}')
50
- rescue StandardError => e
51
- Rails.logger.error "WARNING: #{e.message}"
52
- end
53
-
54
- def create_wallaby_initializer_file
55
- template 'initializer.rb.erb', 'config/initializers/wallaby.rb'
56
- end
57
-
58
- def create_application_files
59
- create_basic_files
60
- create_application_authorizer if options[:include_authorizer]
61
- create_application_paginator if options[:include_paginator]
62
- create_application_partials if options[:include_partials]
63
- end
64
-
65
- def create_basic_files
66
- template 'application_controller.rb.erb', "app/controllers/#{file_name}/application_controller.rb"
67
- template 'application_decorator.rb.erb', "app/decorators/#{file_name}/application_decorator.rb"
68
- template 'application_servicer.rb.erb', "app/servicers/#{file_name}/application_servicer.rb"
69
- end
70
-
71
- def create_application_authorizer
72
- template 'application_authorizer.rb.erb', "app/authorizers/#{file_name}/application_authorizer.rb"
73
- end
74
-
75
- def create_application_paginator
76
- template 'application_paginator.rb.erb', "app/paginators/#{file_name}/application_paginator.rb"
77
- end
78
-
79
- def create_application_partials
80
- source_prefix = '../../../../../app/views/wallaby/resources'
81
- destination_prefix = "app/views/#{file_name}/application"
82
- %w(
83
- footer frontend logo navs title user_menu
84
- index_actions index_filters index_pagination index_query resource_navs
85
- ).each do |name|
86
- copy_file "#{source_prefix}/_#{name}.html.erb", "#{destination_prefix}/_#{name}.html.erb"
87
- end
34
+ invoke 'wallaby:engine:install', [name], options.dup
88
35
  end
89
36
  end
90
37
  end
@@ -16,7 +16,7 @@ module Wallaby
16
16
 
17
17
  initializer 'wallaby.assets.precompile' do |_|
18
18
  config.assets.precompile +=
19
- %w(
19
+ %w[
20
20
  wallaby/application.js
21
21
  wallaby/application.css
22
22
  wallaby/bad_request.png
@@ -26,7 +26,8 @@ module Wallaby
26
26
  wallaby/not_implemented.png
27
27
  wallaby/unauthorized.png
28
28
  wallaby/unprocessable_entity.png
29
- )
29
+ ]
30
+ config.assets.paths << config.root.join("app", "assets", "fonts")
30
31
  end
31
32
  end
32
33
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wallaby
4
- VERSION = '6.1.5' # :nodoc:
4
+ VERSION = '7.0.0.beta1' # :nodoc:
5
5
  end
data/lib/wallaby/views.rb CHANGED
@@ -3,15 +3,6 @@
3
3
  # NOTE: We need to require the following rails engines
4
4
  # so that the main app could pick up the assets from these engines
5
5
  # even if they don't appear in the `Gemfile`
6
- require 'sass-rails'
7
-
8
- require 'bootstrap'
9
- require 'font-awesome-sass'
10
- require 'bootstrap4-datetime-picker-rails'
11
- require 'jquery-minicolors-rails'
12
- require 'jquery-rails'
13
- require 'momentjs-rails'
14
- require 'summernote-rails'
15
- require 'twitter-typeahead-rails'
16
- require 'jbuilder'
17
6
  require 'csv'
7
+ require 'jbuilder'
8
+ require 'sprockets/railtie'