<% @title = t ".title", :name => @user_block.user.display_name %>
+
+<% content_for :heading_class, "pb-0" %>
<% content_for :heading do %>
- <h1><%= t(".heading_html",
- :name => link_to(@user_block.user.display_name,
- user_path(@user_block.user))) %></h1>
- <ul class='secondary-actions clearfix'>
- <li><%= link_to t(".show"), @user_block %></li>
- <li><%= link_to t(".back"), user_blocks_path %></li>
- </ul>
+ <h1><%= t(".heading_html", :name => link_to(@user_block.user.display_name, @user_block.user)) %></h1>
+ <%= render :partial => "navigation" %>
<% end %>
<%= bootstrap_form_for(@user_block) do |f| %>
<%= f.richtext_field :reason, :cols => 80, :rows => 20, :format => @user_block.reason_format %>
- <%= f.form_group do %>
- <%= label_tag "user_block_period", t(".period") %><br />
- <%= select_tag("user_block_period", options_for_select(UserBlock::PERIODS.collect { |h| [block_duration_in_words(h.hours), h.to_s] }, params[:user_block_period])) %>
- <% end %>
+ <% if @user_block.active? && @user_block.creator == current_user %>
+ <%= f.form_group do %>
+ <%= label_tag "user_block_period", t(".period"), :class => "form-label" %>
+ <%= select_tag "user_block_period",
+ options_for_select(UserBlock::PERIODS.collect { |h| [block_duration_in_words(h.hours), h.to_s] },
+ UserBlock::PERIODS.min_by { |h| (params[:user_block_period].to_i - h).abs }),
+ :class => "form-select" %>
+ <% end %>
- <%= f.form_group :needs_view do %>
- <%= f.check_box :needs_view %>
- <% end %>
+ <%= f.form_group :needs_view do %>
+ <%= f.check_box :needs_view %>
+ <% end %>
- <%= f.primary %>
+ <%= f.primary %>
+ <% else %>
+ <div class="alert alert-info">
+ <% if @user_block.active? %>
+ <%= t "user_blocks.update.only_creator_can_edit_without_revoking" %>
+ <% else %>
+ <%= t "user_blocks.update.inactive_block_cannot_be_reactivated" %>
+ <% end %>
+ </div>
+
+ <%= hidden_field_tag "user_block_period", 0 %>
+ <%= hidden_field_tag "user_block[needs_view]", false %>
+
+ <% if @user_block.active? %>
+ <%= f.submit t(".revoke"), :class => "btn btn-danger" %>
+ <% else %>
+ <%= f.primary %>
+ <% end %>
+ <% end %>
<% end %>