Module: Crm::FloorPlanDisplaysHelper
- Defined in:
- app/helpers/crm/floor_plan_displays_helper.rb
Overview
View helpers for the CRM floor plan display screens: state badges, action
button groups, and image / room / operating-cost summary chips.
Instance Method Summary collapse
-
#floor_plan_display_actions(floor_plan_display) ⇒ ActiveSupport::SafeBuffer
Renders the View / Edit / Images / Preview button group for a display.
-
#floor_plan_display_image_count(floor_plan_display) ⇒ ActiveSupport::SafeBuffer
Renders a badge with the number of images attached to a display.
-
#floor_plan_display_operating_cost(floor_plan_display) ⇒ ActiveSupport::SafeBuffer, String
Renders the display's total operating cost as a dollar amount.
-
#floor_plan_display_room_count(floor_plan_display) ⇒ ActiveSupport::SafeBuffer
Renders a badge with the number of room configurations on a display.
-
#floor_plan_display_state_badge(state) ⇒ ActiveSupport::SafeBuffer
Renders a Bootstrap badge colored by the display's lifecycle state.
Instance Method Details
#floor_plan_display_actions(floor_plan_display) ⇒ ActiveSupport::SafeBuffer
Renders the View / Edit / Images / Preview button group for a display.
31 32 33 34 35 36 37 38 |
# File 'app/helpers/crm/floor_plan_displays_helper.rb', line 31 def floor_plan_display_actions(floor_plan_display) content_tag :div, class: 'btn-group', role: 'group' do concat link_to('View', floor_plan_display_path(floor_plan_display), class: 'btn btn-sm btn-outline-primary') concat link_to('Edit', edit_floor_plan_display_path(floor_plan_display), class: 'btn btn-sm btn-outline-secondary') concat link_to('Images', edit_images_floor_plan_display_path(floor_plan_display), class: 'btn btn-sm btn-outline-info') concat link_to('Preview', preview_floor_plan_display_path(floor_plan_display), class: 'btn btn-sm btn-outline-success', target: '_blank', rel: 'noopener') end end |
#floor_plan_display_image_count(floor_plan_display) ⇒ ActiveSupport::SafeBuffer
Renders a badge with the number of images attached to a display.
44 45 46 47 |
# File 'app/helpers/crm/floor_plan_displays_helper.rb', line 44 def floor_plan_display_image_count(floor_plan_display) count = floor_plan_display.images.count content_tag :span, count, class: 'badge bg-info' end |
#floor_plan_display_operating_cost(floor_plan_display) ⇒ ActiveSupport::SafeBuffer, String
Renders the display's total operating cost as a dollar amount.
63 64 65 66 67 68 |
# File 'app/helpers/crm/floor_plan_displays_helper.rb', line 63 def (floor_plan_display) return 'N/A' if floor_plan_display.total_cost_to_operate.zero? content_tag :span, "$#{number_with_precision(floor_plan_display.total_cost_to_operate, precision: 2)}", class: 'text-success fw-bold' end |
#floor_plan_display_room_count(floor_plan_display) ⇒ ActiveSupport::SafeBuffer
Renders a badge with the number of room configurations on a display.
53 54 55 56 |
# File 'app/helpers/crm/floor_plan_displays_helper.rb', line 53 def floor_plan_display_room_count(floor_plan_display) count = floor_plan_display.room_configurations.count content_tag :span, count, class: 'badge bg-primary' end |
#floor_plan_display_state_badge(state) ⇒ ActiveSupport::SafeBuffer
Renders a Bootstrap badge colored by the display's lifecycle state.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/helpers/crm/floor_plan_displays_helper.rb', line 14 def floor_plan_display_state_badge(state) case state when 'published' content_tag :span, state.humanize, class: 'badge bg-success' when 'draft' content_tag :span, state.humanize, class: 'badge bg-warning' when 'archived' content_tag :span, state.humanize, class: 'badge bg-secondary' else content_tag :span, state.humanize, class: 'badge bg-secondary' end end |