Simplify conditions to render poll status icons
We were using a redundant `elsif` instead of an `else`. We were also using a negative condition in the main `if`, which made the code a bit harder to read. Since we usually use `current_user` instead of `user_signed_in?`, we're also changing that for consistency.Extract component to render the status of a poll
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
<div class="poll with-image">
|
||||
<% if !user_signed_in? %>
|
||||
<div class="icon-poll-answer not-logged-in" title="<%= t("polls.index.not_logged_in") %>">
|
||||
<span class="show-for-sr"><%= t("polls.index.not_logged_in") %></span>
|
||||
</div>
|
||||
<% elsif user_signed_in? %>
|
||||
<% if current_user %>
|
||||
<% if current_user.unverified? %>
|
||||
<div class="icon-poll-answer unverified" title="<%= t("polls.index.unverified") %>">
|
||||
<span class="show-for-sr"><%= t("polls.index.unverified") %></span>
|
||||
@@ -17,6 +13,10 @@
|
||||
<span class="show-for-sr"><%= t("polls.index.already_answer") %></span>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="icon-poll-answer not-logged-in" title="<%= t("polls.index.not_logged_in") %>">
|
||||
<span class="show-for-sr"><%= t("polls.index.not_logged_in") %></span>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="row" data-equalizer data-equalize-on="medium">
|
||||
<div class="small-12 medium-3 column">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Polls::PollComponent < ApplicationComponent
|
||||
attr_reader :poll
|
||||
use_helpers :cannot?, :user_signed_in?, :current_user, :link_to_poll
|
||||
use_helpers :cannot?, :current_user, :link_to_poll
|
||||
|
||||
def initialize(poll)
|
||||
@poll = poll
|
||||
|
||||
Reference in New Issue
Block a user