Permalink
Browse files

added topic field and display. also cleaned up comment layout a bit.

  • Loading branch information...
Eric Ryan Jones
Eric Ryan Jones committed Jul 25, 2013
1 parent 466bff0 commit 59dd8c24efbbe79721090b27309fdba5242ac2cf
@@ -13,7 +13,7 @@ jQuery ->
.removeClass('uneditable-input')
.removeAttr('disabled', 'disabled')
.val('');
- $(xhr.responseText).hide().insertAfter($(this)).show('slow')
+ $(xhr.responseText).hide().insertBefore($(this)).show('slow')
# Delete a comment
$(document)
.on "ajax:beforeSend", ".comment", ->
@@ -0,0 +1,7 @@
+// Place all the styles related to the Topics controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
+
+// this file is imported into the topics.css.scss file
+
+.commmentPostedAt{text-align: right; font-size: .75em;}
@@ -2,4 +2,8 @@
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
-#topicKeywordList{ list-style: none; display: inline; }
+#topicKeywordList{ list-style: none; display: inline; font-style: italic;}
+.topicPoster{ text-align: right;}
+.topicDetail{font-size: 2em; line-height: 1em;}
+
+@import "comments";
@@ -43,7 +43,7 @@ def edit
def show
@topic = Topic.find(params[:id])
- @comments = @topic.comment_threads.order('created_at desc')
+ @comments = @topic.comment_threads.order('created_at asc')
@new_comment = Comment.build_from(@topic, current_user.id, "")
end
View
@@ -9,6 +9,6 @@ class Topic < ActiveRecord::Base
belongs_to :user
- attr_accessible :is_private, :topic, :user_id, :keyword_list
+ attr_accessible :is_private, :topic, :user_id, :keyword_list, :detail
end
@@ -1,7 +1,12 @@
+<% if @comments.first.id == comment.id %><h2>Conversation</h2><% end %>
+<% if @comments.count > 0 %>
<div class="comment" id="comment-#{comment.id}">
-<hr>
-<%= link_to "×", comment_path(comment), :method => :delete, :remote => true, :confirm => "Are you sure you want to remove this comment?", :disable_with => "×", :class => 'close' %>
-<h4><%= comment.user.name %></h4>
-<%= comment.updated_at %>
-<%= comment.body %>
-</div>
+ <hr>
+ <%= link_to "×", comment_path(comment), :method => :delete, :remote => true, :confirm => "Are you sure you want to remove this comment?", :disable_with => "×", :class => 'close' %>
+ <h4><%= comment.user.name %> said:</h4>
+ <div class="commentBody"><%= comment.body %></div>
+ <div class="commmentPostedAt">Posted at: <%= comment.updated_at %></div>
+</div>
+<% else %>
+ <div class="noComments">No conversation started yet... how about getting the ball rolling?</div>
+<% end %>
@@ -1,8 +1,9 @@
<div class="comment-form">
-<%= simple_form_for comment, :remote => true do |f| %>
+ <h3>Add to the Conversation:</h3>
+ <%= simple_form_for comment, :remote => true do |f| %>
<%= f.input :body, :input_html => { :rows => "2" }, :label => false %>
<%= f.input :commentable_id, :as => :hidden, :value => comment.commentable_id %>
<%= f.input :commentable_type, :as => :hidden, :value => comment.commentable_type %>
<%= f.button :submit, :value =>"Post", :class => "btn btn-primary", :disable_with => "Submitting…" %>
-<% end %>
+ <% end %>
</div>
@@ -1,5 +1,6 @@
<%= simple_form_for @topic do |f| %>
<%= f.input :topic %>
+ <%= f.input :detail %>
<%= f.input :is_private %>
<%= f.input :keyword_list %>
<%= f.input :user_id, as: :hidden, input_html: { value: current_user.id }%>
@@ -1,12 +1,18 @@
-<h1><%= @topic.topic %></h1>
+<div class="page-header">
+ <h1><%= @topic.topic %></h1>
+</div>
+<div class="topicDetail">
+ <%= @topic.detail %>
+</div>
+<div class="topicMetaData">
+ <div class="topicPoster">Posted by: <%= @topic.user.name %></div>
+</div>
<div id="topicKeywordList">
<%= @topic.keyword_list %>
</div>
-<h2>Add to the Conversation:</h2>
+<div class="topicConversation">
+ <%= render :partial => 'comments/comment', :collection => @comments, :as => :comment %>
+</div>
+<div class="topicConversationForm">
<%= render :partial => 'comments/form', :locals => { :comment => @new_comment } %>
-<h2>Conversation</h2>
- <% if @comments.count > 0 %>
- <%= render :partial => 'comments/comment', :collection => @comments, :as => :comment %>
- <% else %>
- <p>No conversation started yet... how about getting the ball rolling?</p>
- <% end %>
+</div>
@@ -0,0 +1,5 @@
+class AddTopicDetails < ActiveRecord::Migration
+ def change
+ add_column :topics, :detail, :text
+ end
+end
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130705155025) do
+ActiveRecord::Schema.define(:version => 20130721192937) do
create_table "comments", :force => true do |t|
t.integer "commentable_id", :default => 0
@@ -66,6 +66,7 @@
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "slug"
+ t.text "detail"
end
add_index "topics", ["slug"], :name => "index_topics_on_slug", :unique => true

0 comments on commit 59dd8c2

Please sign in to comment.