Skip to content

Commit

Permalink
Spam waves: add time tooltips; renew, edit, cancel buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
makyen committed Jun 24, 2022
1 parent 26fbee4 commit 34c7f35
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
13 changes: 10 additions & 3 deletions app/views/spam_waves/_spam_wave.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<div class="spam-wave" data-id="<%= wave.id %>">
<h3><%= link_to wave.name, spam_wave_path(wave) %></h3>
<p class="text-muted">Created by <%= wave.user.username %> <%= time_ago_in_words(wave.created_at) %> ago.</p>
<p class="text-muted">Created by <%= wave.user.username %> <span title="<%= wave.created_at %>"><%= time_ago_in_words(wave.created_at) %></span> ago.</p>
<% if wave.expiry.past? %>
<p>Expired.</p>
<p title="<%= wave.expiry %>">Expired.</p>
<% else %>
<p>Expires in <%= distance_of_time_in_words(DateTime.now, wave.expiry) %>.</p>
<p>Expires in <span title="<%= wave.expiry %>"><%= distance_of_time_in_words(DateTime.now, wave.expiry) %></span>.</p>
<% end %>
<span class="button-container">
<%= link_to 'Edit', edit_spam_wave_path(@wave), class: 'btn btn-primary' %>
<%= link_to 'Renew Wave', renew_spam_wave_path(@wave), class: 'btn btn-warning', method: :post %>
<% if wave.expiry.past? %>
<%= link_to 'Cancel Wave', cancel_spam_wave_path(@wave), class: 'btn btn-danger', method: :post %>
<% end %>
</span>
</div>
<hr/>
14 changes: 7 additions & 7 deletions app/views/spam_waves/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<h1><%= @wave.name %></h1>
<h4 class="text-muted">Currently <strong><%= @wave.expiry.past? ? 'expired' : 'active' %>.</strong></h4>
<p class="text-muted">Created by <%= @wave.user.username %> <%= time_ago_in_words(@wave.created_at) %> ago.</p>
<p class="text-muted">Created by <%= @wave.user.username %> <span title="<%= wave.created_at %>"><%= time_ago_in_words(@wave.created_at) %> ago</span>.</p>

<% unless @wave.expiry.past? %>
<p>Expires in <%= distance_of_time_in_words(DateTime.now, @wave.expiry) %>.</p>
<% if @wave.expiry.past? %>
<p>Expired <span title="<%= @wave.expiry %>"><%= distance_of_time_in_words(DateTime.now, @wave.expiry) %> ago</span>.</p>
<% else %>
<p>Expires in <span title="<%= @wave.expiry %>"><%= distance_of_time_in_words(DateTime.now, @wave.expiry) %></span>.</p>
<% end %>
<%= link_to 'Edit', edit_spam_wave_path(@wave), class: 'btn btn-primary' %>
<%= link_to 'Renew Wave', renew_spam_wave_path(@wave), class: 'btn btn-warning', method: :post %>
<% unless @wave.expiry.past? %>
<%= link_to 'Edit', edit_spam_wave_path(@wave), class: 'btn btn-primary' %>
<%= link_to 'Cancel Wave', cancel_spam_wave_path(@wave), class: 'btn btn-danger', method: :post %>
<% end %>
<% if (@wave.expiry - DateTime.now) <= 2.hours && !@wave.expiry.past? %>
<%= link_to 'Renew Wave', renew_spam_wave_path(@wave), class: 'btn btn-warning', method: :post %>
<% end %>

<h3>Conditions</h3>
<pre>{
Expand Down

0 comments on commit 34c7f35

Please sign in to comment.