ensl.org/app/views/topics/show.html.erb

75 lines
2.2 KiB
Text
Raw Normal View History

<div id="topic">
<%= render partial: 'breadcrumbs', locals: { topic: @topic } %>
<h2><%= namelink @topic %></h2>
<% if @posts.count > Topic::POSTS_PAGE %>
<%= will_paginate @posts %>
<% end %>
<div class="controls">
<% if @newpost.can_create? cuser %>
<%= link_to 'Reply', new_post_path(@newpost, id: @topic), class: 'button' %>
<% end %>
<% if @topic.can_update? cuser %>
<%= link_to 'Edit', edit_topic_path(@topic), class: 'button' %>
<% end %>
</div>
<div id="posts">
<% @posts.each_with_index do |post, n| %>
<%= render partial: "posts/post", locals: { post: post, n: n } %>
<% end %>
<% if @newpost.errors.count > 0 %>
2014-04-13 11:16:51 +00:00
<div class="flash warning">
<ul>
<% @newpost.error_messages.each do |m| %>
<li><%= h m %></li>
<% end %>
</ul>
</div>
<% end %>
</div>
<div id="reply">
<h5>New Reply</h5>
<%= form_for(@newpost, remote: true, html: { class: 'square' }) do |f| %>
<%= f.error_messages %>
<%= f.hidden_field :topic_id %>
<div class="fields horizontal">
<%= f.label "Enter your post text:" %>
<%= f.text_area :text, rows: 10 %>
</div>
<div class="controls horizontal">
<%= f.submit 'Post Message' %>
</div>
<% end %>
</div>
<%= will_paginate @posts %>
2014-04-13 11:16:51 +00:00
<div>
<% if @newpost.can_create? cuser %>
<%= link_to_function 'Fast Reply', "$('#reply').fadeIn('slow')", class: 'button' %>
<%= link_to 'Reply', new_post_path(@newpost, id: @topic), class: 'button' %>
<% end %>
<% if @topic.can_update? cuser %>
<%= link_to 'Edit', edit_topic_path(@topic), class: 'button' %>
<% end %>
<% if @lock.new_record? and @lock.can_create? cuser %>
<%= form_for @lock do |f| %>
<%= f.hidden_field :lockable_type %>
<%= f.hidden_field :lockable_id %>
<%= link_to_function "Lock", "this.parentNode.submit()", class: 'button' %>
<% end %>
<% elsif @lock.can_destroy? cuser %>
<%= link_to 'Unlock', @lock, class: 'button', confirm: 'Are you sure?', method: :delete %>
<% end %>
</div>
<%= render partial: 'breadcrumbs', locals: { topic: @topic } %>
</div>