tybo 0.0.24 → 0.0.27

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: cbff25691614a09bb930d8f9695c521494e2ae745b22611c9a82a3839f95b741
4
+ data.tar.gz: 67ac3cef194b2275d890f061f153509de257016d098835a38df4d727adb53a81
5
5
  SHA512:
6
- metadata.gz: d069473a8f19c67a1247364b82ae0c2063e46204e51a64b6067107c0d9569e9434e4b142449d345845217672a233edd3b7297f5b6b9b9c8a633ca9396bbe79e8
7
- data.tar.gz: 632f6ba0d1ca819621414385afcabe9b32ee77513a419bf4bfc857b397e36edd0d4cedf9857a8f1f1bb6e17974a03ab3910d52206b51f9ffc0060ec2f695c369
6
+ metadata.gz: efa16a7f897fa95148bf795b6931549fb16288607daf33e6979853276ccf0588b303fa090bedb78b8560515791068035b1b3383e8dd86e61b8b980f13cdf7af7
7
+ data.tar.gz: c9517c9abd01abe57476776994f8e6b68cc0f8f3db8e813fe3426d5781d1c7ffac11439057b33f7745025b3f899222f139065e2cc180ac233a55e3158351a280
@@ -5,7 +5,7 @@ module Tybo
5
5
  if %w[error alert].include?(key)
6
6
  'bg-red-100 text-red-700'
7
7
  else
8
- 'bg-green-50 text-green-700'
8
+ 'bg-tybo text-white'
9
9
  end
10
10
  end
11
11
  end
@@ -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
@@ -9,6 +9,6 @@ class <%= class_name %>Controller < ApplicationController
9
9
  private
10
10
 
11
11
  def namespace
12
- @namespace ||= Bo::<%= class_name %>
12
+ @namespace ||= Bo::<%= class_name %>.pluralize
13
13
  end
14
14
  end
data/lib/tybo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tybo
2
- VERSION = '0.0.24'
2
+ VERSION = '0.0.27'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Delpierre
@@ -9,7 +9,7 @@ authors:
9
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