terrazzo 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/generators/terrazzo/dashboard/dashboard_generator.rb +1 -1
- data/lib/generators/terrazzo/dashboard/templates/dashboard.rb.erb +9 -2
- data/lib/generators/terrazzo/eject/eject_generator.rb +10 -3
- data/lib/generators/terrazzo/routes/routes_generator.rb +12 -0
- data/lib/terrazzo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bddc5aafa6fba7a2d87bb86fd4e29d5ddfeb476c2440594603c669782eb8815b
|
|
4
|
+
data.tar.gz: 06f9d7c58f0241269f060debbc67ef2f94049cfc5f46d3e2165989c67387eabc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 57972ea8d44edfc9d96542f0d008ffa4da02a562846a861df6e89609b128d1c652619882736715d57aa5502cf67fe80f6cf2af62e70ba51529b38c6ddd9ec0ad
|
|
7
|
+
data.tar.gz: 882f78a2c3b7faa03907e73f5638a01414c74b6950c50716d3db8419c7f4eba8067b6ab22b7ff8188c0b7e740dfee441b63332b016eaf2955cdf0942982f3149
|
|
@@ -68,7 +68,7 @@ module Terrazzo
|
|
|
68
68
|
next if col.name.end_with?("_type") && columns.any? { |c| c.name == col.name.sub(/_type$/, "_id") }
|
|
69
69
|
next if association_foreign_key?(col.name, associations)
|
|
70
70
|
|
|
71
|
-
types[col.name.to_sym] = column_to_field_type(col)
|
|
71
|
+
types[col.name.to_sym] = has_enum?(col.name) ? "Field::Select" : column_to_field_type(col)
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
# Active Storage attachment names (used to filter internal associations)
|
|
@@ -4,9 +4,9 @@ class <%= class_name %>Dashboard < Terrazzo::BaseDashboard
|
|
|
4
4
|
ATTRIBUTE_TYPES = {
|
|
5
5
|
<% attribute_types.each do |attr, type| -%>
|
|
6
6
|
<% if has_enum?(attr.to_s) -%>
|
|
7
|
-
<%= attr %>:
|
|
7
|
+
<%= attr %>: <%= type %>.with_options(collection: <%= enum_collection(attr.to_s).inspect %>),
|
|
8
8
|
<% else -%>
|
|
9
|
-
<%= attr %>:
|
|
9
|
+
<%= attr %>: <%= type %>,
|
|
10
10
|
<% end -%>
|
|
11
11
|
<% end -%>
|
|
12
12
|
}.freeze
|
|
@@ -33,4 +33,11 @@ class <%= class_name %>Dashboard < Terrazzo::BaseDashboard
|
|
|
33
33
|
# active: ->(resources) { resources.where(active: true) },
|
|
34
34
|
# recent: ->(resources) { resources.where("created_at > ?", 30.days.ago) },
|
|
35
35
|
# }.freeze
|
|
36
|
+
|
|
37
|
+
# Overwrite this method to customize how <%= file_name.pluralize.humanize.downcase %> are displayed
|
|
38
|
+
# across all pages of the admin dashboard.
|
|
39
|
+
#
|
|
40
|
+
# def display_resource(resource)
|
|
41
|
+
# "<%= class_name %> ##{resource.id}"
|
|
42
|
+
# end
|
|
36
43
|
end
|
|
@@ -136,10 +136,17 @@ module Terrazzo
|
|
|
136
136
|
new_content = build_fields_barrel_with_ejection(field_type)
|
|
137
137
|
create_file barrel_path, new_content, force: true
|
|
138
138
|
else
|
|
139
|
-
# Barrel already has explicit exports; replace the
|
|
140
|
-
#
|
|
139
|
+
# Barrel already has explicit exports; replace the terrazzo re-export
|
|
140
|
+
# for this field type with local imports
|
|
141
141
|
unless content.include?("./#{field_type}/")
|
|
142
|
-
|
|
142
|
+
# Remove the existing terrazzo re-export line for this field type
|
|
143
|
+
terrazzo_export = "export { #{type_label}IndexField, #{type_label}ShowField, #{type_label}FormField } from \"terrazzo/fields\";"
|
|
144
|
+
if content.include?(terrazzo_export)
|
|
145
|
+
new_content = content.sub(terrazzo_export, local_exports)
|
|
146
|
+
create_file barrel_path, new_content, force: true
|
|
147
|
+
else
|
|
148
|
+
append_to_file barrel_path, "\n#{local_exports}\n"
|
|
149
|
+
end
|
|
143
150
|
end
|
|
144
151
|
end
|
|
145
152
|
end
|
|
@@ -48,6 +48,18 @@ module Terrazzo
|
|
|
48
48
|
end
|
|
49
49
|
RUBY
|
|
50
50
|
|
|
51
|
+
if File.read(Rails.root.join("config/routes.rb")).include?("namespace :#{namespace_name}")
|
|
52
|
+
say_status :skip, "namespace :#{namespace_name} already exists in config/routes.rb", :yellow
|
|
53
|
+
say ""
|
|
54
|
+
say "Add these resource routes to your existing namespace :#{namespace_name} block:", :green
|
|
55
|
+
say ""
|
|
56
|
+
lines.each { |line| say line }
|
|
57
|
+
say ""
|
|
58
|
+
say " root to: \"#{first_resource}#index\"", :green if first_resource
|
|
59
|
+
say ""
|
|
60
|
+
return
|
|
61
|
+
end
|
|
62
|
+
|
|
51
63
|
route route_block.strip
|
|
52
64
|
end
|
|
53
65
|
|
data/lib/terrazzo/version.rb
CHANGED