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 +4 -4
- data/app/helpers/tybo/flash_helper.rb +1 -1
- data/app/views/layouts/_flash.html.erb +1 -1
- data/lib/generators/bo/bo_generator.rb +21 -6
- data/lib/generators/bo/templates/_form.html.erb +9 -6
- data/lib/generators/bo/templates/controller.rb +0 -2
- data/lib/generators/bo_namespace/templates/admin_controller.rb +1 -1
- data/lib/tybo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbff25691614a09bb930d8f9695c521494e2ae745b22611c9a82a3839f95b741
|
4
|
+
data.tar.gz: 67ac3cef194b2275d890f061f153509de257016d098835a38df4d727adb53a81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efa16a7f897fa95148bf795b6931549fb16288607daf33e6979853276ccf0588b303fa090bedb78b8560515791068035b1b3383e8dd86e61b8b980f13cdf7af7
|
7
|
+
data.tar.gz: c9517c9abd01abe57476776994f8e6b68cc0f8f3db8e813fe3426d5781d1c7ffac11439057b33f7745025b3f899222f139065e2cc180ac233a55e3158351a280
|
@@ -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
|
-
|
77
|
-
params["#{col.name.to_s.remove('
|
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
|
-
|
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
|
-
<!--
|
12
|
-
<%-
|
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
|
-
|
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
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.
|
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-
|
12
|
+
date: 2023-03-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|