From fe3c6c499b0f3e14711c5c27649210946b57d02a Mon Sep 17 00:00:00 2001 From: James Mason Date: Fri, 1 Jun 2018 12:01:58 -0700 Subject: [PATCH] Collapse two redundant helpers Fold one-used event_status_icon and one-used booth_status_icon into status_icon, used twice; since there is no conflict on the status- driven description. --- app/helpers/format_helper.rb | 19 +++---------------- app/views/booths/index.html.haml | 2 +- app/views/proposals/index.html.haml | 2 +- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/app/helpers/format_helper.rb b/app/helpers/format_helper.rb index ae0f2da1..376482d5 100644 --- a/app/helpers/format_helper.rb +++ b/app/helpers/format_helper.rb @@ -4,24 +4,11 @@ module FormatHelper ## # Includes functions related to formatting (like adding classes, colors) ## - def event_status_icon(event) - case event.state - when 'new' - 'fa-eye' - when 'unconfirmed' - 'fa-check text-muted' - when 'confirmed' - 'fa-check text-success' - when 'rejected', 'withdrawn', 'canceled' - 'fa-ban' - end - end - - def booth_status_icon(booth) - case booth.state + def status_icon(object) + case object.state when 'new', 'to_reject', 'to_accept' 'fa-eye' - when 'accepted' + when 'unconfirmed', 'accepted' 'fa-check text-muted' when 'confirmed' 'fa-check text-success' diff --git a/app/views/booths/index.html.haml b/app/views/booths/index.html.haml index d6c392dd..3ec4c222 100644 --- a/app/views/booths/index.html.haml +++ b/app/views/booths/index.html.haml @@ -24,7 +24,7 @@ - show_state = 'new' - else - show_state = booth.state - %span{ title: show_state, class: "fa #{booth_status_icon(booth)}" } + %span{ title: show_state, class: "fa #{status_icon(booth)}" } %td - if booth.logo_link = image_tag(booth.picture.thumb.url, width: '20%') diff --git a/app/views/proposals/index.html.haml b/app/views/proposals/index.html.haml index e40eb30e..cf57c644 100644 --- a/app/views/proposals/index.html.haml +++ b/app/views/proposals/index.html.haml @@ -67,7 +67,7 @@ - @events.each do |event| %tr %td{style: "padding:20px 8px 20px 8px;"} - %span{ title: event.state.humanize, class: "fa #{event_status_icon(event)}" } + %span{ title: event.state.humanize, class: "fa #{status_icon(event)}" } %td.col-md-7{style: "padding:20px 8px 20px 8px;"} = link_to event.title, conference_program_proposal_path(@conference.short_title, event.id)