Module: Dbviewer::DatatableUiHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/dbviewer/datatable_ui_helper.rb
Instance Method Summary collapse
-
#column_type_icon(column_type) ⇒ Object
Get appropriate icon for column data type.
-
#current_table?(table_name) ⇒ Boolean
Determine if the current table should be active in the sidebar.
-
#format_table_name(table_name) ⇒ Object
Format table name for display - truncate if too long.
Instance Method Details
#column_type_icon(column_type) ⇒ Object
Get appropriate icon for column data type
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/dbviewer/datatable_ui_helper.rb', line 4 def column_type_icon(column_type) case column_type.to_s.downcase when /int/, /serial/, /number/, /decimal/, /float/, /double/ "bi-123" when /char/, /text/, /string/, /uuid/ "bi-fonts" when /date/, /time/ "bi-calendar" when /bool/ "bi-toggle-on" when /json/, /jsonb/ "bi-braces" when /array/ "bi-list-ol" else "bi-file-earmark" end end |
#current_table?(table_name) ⇒ Boolean
Determine if the current table should be active in the sidebar
33 34 35 |
# File 'app/helpers/dbviewer/datatable_ui_helper.rb', line 33 def current_table?(table_name) @table_name.present? && @table_name == table_name end |
#format_table_name(table_name) ⇒ Object
Format table name for display - truncate if too long
24 25 26 27 28 29 30 |
# File 'app/helpers/dbviewer/datatable_ui_helper.rb', line 24 def format_table_name(table_name) if table_name.length > 20 "#{table_name.first(17)}..." else table_name end end |