tybo 0.0.24 → 0.0.26

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
  SHA256:
3
- metadata.gz: 1f138be56ff33db2fcedafd153fc1cee963e47d792dbe0c4ee17bc754e66ee66
4
- data.tar.gz: 2bf0ce49099e0634292b659c228a18b3abec4045dade3126e29897b8d8c43989
3
+ metadata.gz: 5fbea06a07d892cf6275cb13c24757606e007cd02e32a46ecabbe48a285ef16e
4
+ data.tar.gz: eeac4d661b717d758bac0afdc97fca2f937906316dec84653e1aab408c096beb
5
5
  SHA512:
6
- metadata.gz: d069473a8f19c67a1247364b82ae0c2063e46204e51a64b6067107c0d9569e9434e4b142449d345845217672a233edd3b7297f5b6b9b9c8a633ca9396bbe79e8
7
- data.tar.gz: 632f6ba0d1ca819621414385afcabe9b32ee77513a419bf4bfc857b397e36edd0d4cedf9857a8f1f1bb6e17974a03ab3910d52206b51f9ffc0060ec2f695c369
6
+ metadata.gz: f892ee8c9c883acc0940845639654b64fa27087391a445ac905268793dc8c1e0c7ee355cab54762e841b7369404dec38549779463590359520f97167663210af
7
+ data.tar.gz: af85a402e65ec548dc5485532a8c1ad20e44141984f239ec40ce5e06e786eb075122b8408c65517ed6c8bb644d59eb4063e2dc1a7d2dcdd26f8d968d1c07e8c7
@@ -1,5 +1,5 @@
1
1
  <% flash.each do |key, errors| %>
2
- <div class="rounded-md <%= classes_for_flash(key) %> p-4" data-controller="flash">
2
+ <div class="rounded-md <%= classes_for_flash(key) %> p-4 m-4" data-controller="flash">
3
3
  <div class="flex">
4
4
  <div class="flex-shrink-0">
5
5
  <svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
@@ -69,19 +69,19 @@ class BoGenerator < Rails::Generators::NamedBase
69
69
 
70
70
  def permited_params
71
71
  params = {}
72
- action_text_columns = has_one_assoc&.select { |a| a.options[:class_name] == 'ActionText::RichText' }
73
72
  permitted_columns&.map do |col|
74
73
  params["#{col}".to_sym] = nil
75
74
  end
76
- action_text_columns&.map do |col|
77
- params["#{col.name.to_s.remove('rich_text_' )}".to_sym] = nil
75
+ storage_assoc&.map do |col|
76
+ params["#{col.name.to_s.remove('_attachment' )}".to_sym] = nil
77
+ end
78
+ rich_text_assoc&.map do |col|
79
+ params["#{col.name.to_s.remove('rich_text_')}".to_sym] = nil
78
80
  end
79
81
  has_many_assoc&.map do |association|
80
82
  params["#{association.name.to_s.singularize}_ids".to_sym] = []
81
83
  end
82
84
  has_one_assoc&.map do |association|
83
- next if association.options[:class_name] == 'ActionText::RichText'
84
-
85
85
  attributes = association.klass.column_names.map(&:to_sym).delete_if { |attr| excluded_columns.include?(attr) }
86
86
  params["#{association.name.to_s.singularize}_attributes".to_sym] = attributes
87
87
  end
@@ -97,7 +97,22 @@ class BoGenerator < Rails::Generators::NamedBase
97
97
  end
98
98
 
99
99
  def has_one_assoc
100
- bo_model.reflect_on_all_associations(:has_one)
100
+ excluded = ['ActiveStorage::Attachment', 'ActionText::RichText', 'ActiveStorage::Blob']
101
+ bo_model.reflect_on_all_associations(:has_one).reject do |assoc|
102
+ excluded.include?(assoc.options[:class_name])
103
+ end
104
+ end
105
+
106
+ def storage_assoc
107
+ bo_model.reflect_on_all_associations(:has_one).select do |assoc|
108
+ assoc.options[:class_name] == 'ActiveStorage::Attachment'
109
+ end
110
+ end
111
+
112
+ def rich_text_assoc
113
+ bo_model.reflect_on_all_associations(:has_one).select do |assoc|
114
+ assoc.options[:class_name] == 'ActionText::RichText'
115
+ end
101
116
  end
102
117
 
103
118
  def permitted_columns
@@ -8,14 +8,19 @@
8
8
  <%- belongs_to_assoc.each do |association| -%>
9
9
  <%%= f.association :<%= association.name.to_s.singularize %>, collection: <%= association.klass.name %>.all.map { |item| [item.<%=bo_model_title(association.klass.name.constantize)%>, item.id] } %>
10
10
  <%- end -%>
11
- <!-- has_one Associations -->
12
- <%- has_one_assoc.each do |association| -%>
13
- <%- if association.options[:class_name] == "ActionText::RichText" -%>
11
+ <!-- RichText Associations -->
12
+ <%- rich_text_assoc.each do |association| -%>
14
13
  <label class="block my-5 block text-sm font-medium text-gray-700 string optional text-sm font-medium text-gray-600">
15
14
  <%%= I18n.t('bo.<%= class_name.underscore %>.attributes.<%=- association.name.to_s.singularize.to_s.remove('rich_text_') -%>') %>
16
15
  </label>
17
16
  <%%= f.rich_text_area :<%= association.name.to_s.singularize.to_s.remove('rich_text_')%> %>
18
- <%- else -%>
17
+ <% end %>
18
+ <!-- File Associations -->
19
+ <%- storage_assoc.each do |association| -%>
20
+ <%%= render(Input::FileComponent.new(item: <%= class_name.underscore %>, field: '<%= association.name.to_s.singularize.to_s.remove('_attachment') %>', form: f)) %>
21
+ <%- end -%>
22
+ <!-- has_one Associations -->
23
+ <%- has_one_assoc.each do |association| -%>
19
24
  <%%= render(Forms::HasOneFormComponent.new(title: I18n.t('bo.<%= association.name %>.one') )) do %>
20
25
  <%%= f.simple_fields_for :<%= association.name.to_s %> do |<%= association.name.to_s %>_form| %>
21
26
  <%- association.klass.column_names.each do |column| -%>
@@ -25,8 +30,6 @@
25
30
  <%- end -%>
26
31
  <%% end %>
27
32
  <%% end %>
28
-
29
- <%- end -%>
30
33
  <%- end -%>
31
34
  <!-- has_many Associations -->
32
35
  <%- has_many_assoc.each do |association| -%>
@@ -15,7 +15,6 @@ module <%= options[:namespace].camelize %>
15
15
  def show
16
16
  authorize! @<%= class_name.underscore %>, to: :show?, namespace:, strict_namespace: true
17
17
  <%- has_one_assoc.each do |association| -%>
18
- <%- next if association.options[:class_name] == "ActionText::RichText" -%>
19
18
  @<%= class_name.underscore %>.build_<%= association.name %> if @<%= class_name.underscore %>.<%= association.name %>.nil?
20
19
  <%- end -%>
21
20
  end
@@ -24,7 +23,6 @@ module <%= options[:namespace].camelize %>
24
23
  @<%= class_name.underscore %> = <%= class_name %>.new
25
24
  authorize! @<%= class_name.underscore %>, to: :new?, namespace:, strict_namespace: true
26
25
  <%- has_one_assoc.each do |association| -%>
27
- <%- next if association.options[:class_name] == "ActionText::RichText" -%>
28
26
  @<%= class_name.underscore %>.build_<%= association.name %>
29
27
  <%- end -%>
30
28
  end
data/lib/tybo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tybo
2
- VERSION = '0.0.24'
2
+ VERSION = '0.0.26'
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tybo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Delpierre
8
8
  - Julien Camblan
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-03-10 00:00:00.000000000 Z
12
+ date: 2023-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -271,7 +271,7 @@ licenses:
271
271
  - MIT
272
272
  metadata:
273
273
  homepage_uri: https://rubygems.org/gems/tybo
274
- post_install_message:
274
+ post_install_message:
275
275
  rdoc_options: []
276
276
  require_paths:
277
277
  - lib
@@ -287,7 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
287
287
  version: '0'
288
288
  requirements: []
289
289
  rubygems_version: 3.0.3.1
290
- signing_key:
290
+ signing_key:
291
291
  specification_version: 4
292
292
  summary: A tailwind custom admin engine for Ruby on Rails
293
293
  test_files: []