Module: DbdocEngine::HomeHelper
- Defined in:
- app/helpers/dbdoc_engine/home_helper.rb
Instance Method Summary collapse
-
#changelog_count ⇒ Object
Returns the total count of changelog entries.
-
#column_count(table) ⇒ Object
Uses .size to leverage eager-loaded associations when available.
-
#dynamic_column_count ⇒ Object
Returns the total count of dynamic columns.
-
#dynamic_table_count ⇒ Object
Returns the total count of dynamic tables.
-
#fetch_table_groups ⇒ Object
Fetches all table groups with their associated dynamic tables.
-
#format_action_badge(action_type) ⇒ Object
Returns a badge element with appropriate styling based on the action type.
-
#format_entity_type(entity_type) ⇒ Object
Formats the entity type into a human-readable format.
- #group_badge_style(group) ⇒ Object
-
#hex_to_rgba(hex_color, alpha = 0.3) ⇒ Object
Converts a hex color (e.g., "#829ED4") to an RGBA string with transparency.
- #table_column_count(table) ⇒ Object
Instance Method Details
#changelog_count ⇒ Object
Returns the total count of changelog entries
57 58 59 |
# File 'app/helpers/dbdoc_engine/home_helper.rb', line 57 def changelog_count DbdocEngine::DbDesignChangelogQueries.filtered_changelogs.count end |
#column_count(table) ⇒ Object
Uses .size to leverage eager-loaded associations when available
36 37 38 |
# File 'app/helpers/dbdoc_engine/home_helper.rb', line 36 def column_count(table) table.db_design_dynamic_columns.size end |
#dynamic_column_count ⇒ Object
Returns the total count of dynamic columns
47 48 49 |
# File 'app/helpers/dbdoc_engine/home_helper.rb', line 47 def dynamic_column_count AdminDashboardQueries.columns_count end |
#dynamic_table_count ⇒ Object
Returns the total count of dynamic tables
52 53 54 |
# File 'app/helpers/dbdoc_engine/home_helper.rb', line 52 def dynamic_table_count AdminDashboardQueries.tables_count end |
#fetch_table_groups ⇒ Object
Fetches all table groups with their associated dynamic tables
62 63 64 |
# File 'app/helpers/dbdoc_engine/home_helper.rb', line 62 def fetch_table_groups DbdocEngine::DbDesignTableGroupQueries.all_groups_with_tables_and_columns end |
#format_action_badge(action_type) ⇒ Object
Returns a badge element with appropriate styling based on the action type.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/helpers/dbdoc_engine/home_helper.rb', line 6 def format_action_badge(action_type) badge_classes = 'inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium' case action_type when 'create' content_tag(:span, 'Create', class: "#{badge_classes} bg-green-100 text-green-800") when 'update' content_tag(:span, 'Update', class: "#{badge_classes} bg-blue-100 text-blue-800") when 'delete' content_tag(:span, 'Delete', class: "#{badge_classes} bg-red-100 text-red-800") else content_tag(:span, action_type.capitalize, class: "#{badge_classes} bg-gray-100 text-gray-800") end end |
#format_entity_type(entity_type) ⇒ Object
Formats the entity type into a human-readable format.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/helpers/dbdoc_engine/home_helper.rb', line 22 def format_entity_type(entity_type) case entity_type when 'table_group' 'Table Group' when 'table' 'Table' when 'column' 'Column' else entity_type.capitalize end end |
#group_badge_style(group) ⇒ Object
66 67 68 69 |
# File 'app/helpers/dbdoc_engine/home_helper.rb', line 66 def group_badge_style(group) rgba_color = hex_to_rgba(group.group_color) "background-color: #{rgba_color}; color: #{group.group_color};" end |
#hex_to_rgba(hex_color, alpha = 0.3) ⇒ Object
Converts a hex color (e.g., "#829ED4") to an RGBA string with transparency
41 42 43 44 |
# File 'app/helpers/dbdoc_engine/home_helper.rb', line 41 def hex_to_rgba(hex_color, alpha = 0.3) rgb_values = hex_color.delete('#').scan(/../).map { |component| component.to_i(16) } "rgba(#{rgb_values.join(', ')}, #{alpha})" end |
#table_column_count(table) ⇒ Object
71 72 73 |
# File 'app/helpers/dbdoc_engine/home_helper.rb', line 71 def table_column_count(table) table.db_design_dynamic_columns.size end |