Module: Recourse::Helpers
- Includes:
- Cells, Comboboxes, Constraints, Examples, Fields, Navigation, References
- Defined in:
- lib/recourse/helpers.rb,
lib/recourse/helpers/cells.rb,
lib/recourse/helpers/fields.rb,
lib/recourse/helpers/examples.rb,
lib/recourse/helpers/comboboxes.rb,
lib/recourse/helpers/navigation.rb,
lib/recourse/helpers/references.rb,
lib/recourse/helpers/constraints.rb
Overview
View helpers for the pages the gem renders, and what the parts share.
Defined Under Namespace
Modules: Cells, Comboboxes, Constraints, Examples, Fields, Navigation, References
Constant Summary collapse
- FLASH_THEMES =
Bootstrap theme for each flash key, so a notice and an alert read apart.
{ 'notice' => 'theme-success', 'alert' => 'theme-danger' }
Constants included from Cells
Constants included from Constraints
Constraints::DISPLAY_PATTERNS, Constraints::PHONE_CONTROLLER, Constraints::SAMPLE_PLACEHOLDERS
Constants included from Examples
Examples::CLASS_SAMPLE, Examples::CLASS_TOKEN, Examples::PATTERN_TOKENS
Instance Method Summary collapse
-
#flash_theme(key) ⇒ Object
Theme for one flash entry, falling back to a neutral one for a host's key.
-
#resource_key ⇒ Object
Local name a row partial receives its record under, e.g.
-
#resource_name ⇒ Object
Singular, lowercase name of the resource, e.g.
-
#resource_record ⇒ Object
The record the action built, read from the assigns rather than by ivar name.
-
#resource_record_label ⇒ Object
What the record on the page is called, by whatever its model labels it with.
-
#resources_name ⇒ Object
Human, plural name of the resource on the page, e.g.
Methods included from Cells
#column, #editable_columns, #resource_cell, #resource_column_title, #resource_columns
Methods included from Comboboxes
Methods included from Constraints
Methods included from Examples
Methods included from Fields
Methods included from Navigation
#current_resource?, #edit_resource_link, #new_resource_path, #resource_breadcrumbs, #resource_label, #sidebar_resources
Methods included from References
#belongs_to_association, #reference_cell, #reference_field, #reference_title
Instance Method Details
#flash_theme(key) ⇒ Object
Theme for one flash entry, falling back to a neutral one for a host's key.
18 19 20 |
# File 'lib/recourse/helpers.rb', line 18 def flash_theme(key) FLASH_THEMES.fetch key.to_s, 'theme-primary' end |
#resource_key ⇒ Object
Local name a row partial receives its record under, e.g. :contact.
33 34 35 |
# File 'lib/recourse/helpers.rb', line 33 def resource_key controller.controller_name.singularize.to_sym end |
#resource_name ⇒ Object
Singular, lowercase name of the resource, e.g. 'contact'.
28 29 30 |
# File 'lib/recourse/helpers.rb', line 28 def resource_name controller.controller_name.singularize.humanize.downcase end |
#resource_record ⇒ Object
The record the action built, read from the assigns rather than by ivar name.
38 39 40 |
# File 'lib/recourse/helpers.rb', line 38 def resource_record controller.view_assigns[resource_key.to_s] end |
#resource_record_label ⇒ Object
What the record on the page is called, by whatever its model labels it with.
43 44 45 |
# File 'lib/recourse/helpers.rb', line 43 def resource_record_label resource_record.attributes[resource_model.recourse_label.to_s] end |
#resources_name ⇒ Object
Human, plural name of the resource on the page, e.g. 'Contacts'.
23 24 25 |
# File 'lib/recourse/helpers.rb', line 23 def resources_name controller.controller_name.humanize end |