solid_litequeen 0.16.3 → 0.17.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e27a7e16eaedb1e23e7471f98443689b868717291899e0684f40f4c66b83acb
|
4
|
+
data.tar.gz: 3d1d1dce1649fb1beef8824c7e90e28af6eab6225ad7954fa77f16cbf829e810
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 457f01d018f4fad2dc9b5ad0ae8a66a87da4036a95e5d1467c2c442a086433ecd8086270bbe45d8bde85dfaf66bdeed877f9deb7917ace3b46b11fd6a56b791f
|
7
|
+
data.tar.gz: 759ee150f0fe87479d30bcbf651cc240ea41d19cc176f9affd9931fe550763a765ebad7d13020b219c565671b40819cc8ddb037e31abf0bff4d4d7f6e498fa8d
|
@@ -120,6 +120,8 @@ module SolidLitequeen
|
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
|
+
enum_info = enum_mappings[@table_name] || {}
|
124
|
+
|
123
125
|
@columns_info = table_columns.each_with_object({}) do |column, hash|
|
124
126
|
info = {
|
125
127
|
sql_type: column.sql_type_metadata.sql_type,
|
@@ -137,6 +139,9 @@ module SolidLitequeen
|
|
137
139
|
info[:foreign_key] = fk_info[column.name]
|
138
140
|
end
|
139
141
|
|
142
|
+
# Append enum options if present
|
143
|
+
info[:enum_options] = enum_info[column.name] if enum_info[column.name]
|
144
|
+
|
140
145
|
# Append index info if available for this column
|
141
146
|
info[:indexes] = index_data[column.name] if index_data[column.name]
|
142
147
|
|
@@ -231,5 +236,17 @@ module SolidLitequeen
|
|
231
236
|
|
232
237
|
render partial: "foreign-key-data"
|
233
238
|
end
|
239
|
+
|
240
|
+
private
|
241
|
+
|
242
|
+
def enum_mappings
|
243
|
+
Rails.application.eager_load! unless Rails.application.config.eager_load
|
244
|
+
ActiveRecord::Base.descendants.each_with_object({}) do |model, map|
|
245
|
+
next if model.abstract_class?
|
246
|
+
model.defined_enums.each do |attr, mapping|
|
247
|
+
(map[model.table_name] ||= {})[attr] = mapping
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
234
251
|
end
|
235
252
|
end
|
@@ -66,6 +66,15 @@
|
|
66
66
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-[var(--color-text)]/80 "><%= column_info&.dig(:default) %></td>
|
67
67
|
</tr>
|
68
68
|
|
69
|
+
<% if column_info[:enum_options] %>
|
70
|
+
<tr>
|
71
|
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-[var(--color-text)] font-semibold">Enum values</td>
|
72
|
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-[var(--color-text)]/80">
|
73
|
+
<%= column_info[:enum_options].map { |k, v| "#{k}: #{v}" }.join(', ') %>
|
74
|
+
</td>
|
75
|
+
</tr>
|
76
|
+
<% end %>
|
77
|
+
|
69
78
|
<% if column_info&.dig(:foreign_key).present? %>
|
70
79
|
|
71
80
|
<tr>
|
@@ -155,7 +164,9 @@
|
|
155
164
|
|
156
165
|
<div class="flex justify-between gap-1">
|
157
166
|
|
158
|
-
|
167
|
+
<% enum_opts = @columns_info[column_name][:enum_options] %>
|
168
|
+
<% enum_label = enum_opts&.invert&.dig(item.to_i) if enum_opts.present? && item.present? %>
|
169
|
+
<span data-column_item title="<%= enum_label if enum_label %>"><%= truncated_item %></span>
|
159
170
|
|
160
171
|
<% if item.present? and foreign_key.present? %>
|
161
172
|
<button
|