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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6da1376c6052a70bacdbb878ee703543e04e0dc044f57cb5b04c35aa08ea536c
4
- data.tar.gz: 9fe6747b3ee47446e501a37c82978a1e1d00fc33b517ad8c8a34ec13b9620889
3
+ metadata.gz: bddc5aafa6fba7a2d87bb86fd4e29d5ddfeb476c2440594603c669782eb8815b
4
+ data.tar.gz: 06f9d7c58f0241269f060debbc67ef2f94049cfc5f46d3e2165989c67387eabc
5
5
  SHA512:
6
- metadata.gz: 316fb61ca947bd8a4d581bcd46a6b1c74a4b0b6a2b6c8113e27ceed6df52f124721a2c8b12d09fb7fbe9f09eb69e8a4ead22d79175946d9d1f74a33da23612a9
7
- data.tar.gz: d15cdb461bfc96aa705c463f0f174ce8490a836afaf8755225d6268edd90462e94019687f3f717a4559e32de3a4dc6711d3b580546477b8f7e674e164f866710
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 %>: Terrazzo::<%= type %>.with_options(collection: <%= enum_collection(attr.to_s).inspect %>),
7
+ <%= attr %>: <%= type %>.with_options(collection: <%= enum_collection(attr.to_s).inspect %>),
8
8
  <% else -%>
9
- <%= attr %>: Terrazzo::<%= type %>,
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 line for this field type
140
- # by inserting local exports before the terrazzo re-exports
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
- append_to_file barrel_path, "\n#{local_exports}\n"
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
 
@@ -1,3 +1,3 @@
1
1
  module Terrazzo
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terrazzo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Terrazzo Contributors