Permalink
Browse files

[Feaure #16379051] Request\Action page styling and fixes.

Centered action sentence on Item Request page

Expanded width of Item Request discussion textarea

Aligned the 'time ago' text

Extracted partial for the comments on the Item Request section

Extracted partial for the new comment form on the Item Request page

Fix ajax response mismatch on the Item Request page

Updated info text from 'Discuss' to 'Discuss Privately'

Removed 'strong' styling on item type

Added some separation between the action buttons and the action sentence
  • Loading branch information...
1 parent 8304123 commit 9e4a767cb60120e8a90eda5c204ba941e18137d4 Juan Hawa committed Aug 19, 2011
@@ -157,6 +157,23 @@ def complete
end
end
end
+
+ def new_comment
+ model_name = params[:comment][:commentable_type]
+ record_commentable = model_name.constantize.find(params[:comment][:commentable_id])
+
+ @comment = record_commentable.comments.create(:commentable => record_commentable,
+ :user_id => current_user.id,
+ :comment => params[:comment][:comment] )
+
+ respond_to do |format|
+ format.json do
+ @comment_html = render_to_string(:partial => 'item_requests/comment.html.erb',
+ :locals => { :comment => @comment } )
+ render :json => { :success => true, :comment_html => @comment_html }
+ end
+ end
+ end
private
@@ -1,9 +1,20 @@
+<% is_private ||= false %>
<li class="no-bg">
<%=form_for(Comment.new, :format => ActionFormat::FORMAT) do |f|%>
- <%=f.hidden_field :commentable_id, :value=> commentable.id, :class => 'new-comment-commentable-id' %>
- <%= f.hidden_field :commentable_type, :value => commentable.class.name, :class => 'new-comment-commentable-type' %>
+ <%=f.hidden_field :commentable_id,
+ :value => commentable.id,
+ :class => 'new-comment-commentable-id' %>
+ <%= f.hidden_field :commentable_type,
+ :value => commentable.class.name,
+ :class => 'new-comment-commentable-type' %>
+
<div class="comment-box">
- <%=f.text_area :comment, :rows => '1', :cols => '13', :id => :comment, :class => 'new-comment-text', :value => 'Write a comment...' %>
+ <%=f.text_area :comment,
+ :rows => '1',
+ :cols => '13',
+ :id => :comment,
+ :class => 'new-comment-text',
+ :value => (is_private ? 'Discuss privately' : 'Write a comment...') %>
</div>
<%=f.submit "Add comment"%>
<%end%>
@@ -0,0 +1,13 @@
+<% person = comment.user.person %>
+<li class="<%= cycle :even, '' %> clearfix" style="width:430px;">
+ <div class="time-ago" style="margin-top:3px;width:140px;text-align:right;margin-right:10px;">
+ <%= time_ago_in_words(comment.created_at) %> ago
+ </div>
+
+ <%= image_tag person.avatar(:square), :class => "thumb" %>
+
+ <p>
+ <a href="#"><strong><%= link_to person.name, person_path(person) %></strong></a>
+ <%= comment.comment %>
+ </p>
+</li>
@@ -0,0 +1,27 @@
+<li class="<%= cycle :even, '' %> clearfix" style="width:430px;">
+ <div class="comment-box">
+
+ <%=form_for Comment.new,
+ :url => new_comment_request_path(item_request),
+ :format => :json do |f|%>
+
+ <%=f.hidden_field :commentable_id,
+ :value=> item_request.id,
+ :class => 'new-comment-commentable-id' %>
+ <%= f.hidden_field :commentable_type,
+ :value => item_request.class.name,
+ :class => 'new-comment-commentable-type' %>
+
+ <div class="comment-box">
+ <%=f.text_area :comment,
+ :rows => '1',
+ :value => 'Discuss privately',
+ :cols => '13',
+ :id => :comment,
+ :class => 'new-comment-text',
+ :style => 'width:418px;' %>
+ </div>
+ <%=f.submit "Add comment"%>
+ <%end%>
+ </div>
+</li>
@@ -1,19 +1,19 @@
<div id="request-page">
- <div id="content" class="item-request">
+ <div id="content" class="item-request" style="width: 596px;">
<div class="content-box-holder no-bg">
<ul>
- <li class="content-box clearfix">
+ <li class="content-box clearfix" style="width: 596px;">
<%= image_tag @item_request.requester.avatar(:large), :class => "thumb" %>
- <div class="inner-content">
+ <div class="inner-content" style="margin-left: 55px;">
<%= render :partial => "shared/item_request_sentence", :locals => { :req => @item_request, :dashboard => false } %>
<%= image_tag @item_request.item.photo.url(:medium), :class => "pic-medium" if @item_request.item.photo? %>
- <ul class="action-buttons-list clearfix">
+ <ul class="action-buttons-list clearfix" style="margin-top: 30px;">
<% if @item_request.status == ItemRequest::STATUS_REQUESTED %>
@@ -76,40 +76,10 @@
<% if (@item_request.gifter?(current_user.person) || @item_request.requester?(current_user.person)) && !@item_request.completed? %>
<li class="content-box clearfix">
-
- <div class="discussion-holder">
-
+ <div class="discussion-holder" style="margin-left:170px;width:430px;">
<ul class="comment-list">
-
- <li class="<%= cycle :even, '' %> clearfix">
- <div class="comment-box">
- <%commentable = @item_request%>
- <%=form_for(Comment.new, :format => :json) do |f|%>
- <%=f.hidden_field :commentable_id, :value=> commentable.id, :class => 'new-comment-commentable-id' %>
- <%= f.hidden_field :commentable_type, :value => commentable.class.name, :class => 'new-comment-commentable-type' %>
- <div class="comment-box">
- <%=f.text_area :comment, :rows => '1', :value => 'Discuss', :cols => '13', :id => :comment, :class => 'new-comment-text' %>
- </div>
- <%=f.submit "Add comment"%>
- <%end%>
- </div>
- </li>
- <% @comments.each do |c| -%>
- <% person = c.user.person %>
- <li class="<%= cycle :even, '' %> clearfix">
- <div class="time-ago">
- <%= time_ago_in_words(c.created_at) %> ago
- </div>
- <%= image_tag person.avatar(:square), :class => "thumb" %>
- <p>
- <a href="#">
- <strong><%= link_to person.name, person_path(person) %></strong>
- </a>
- <%= c.comment %>
- </p>
- </li>
- <% end unless @comments.nil?-%>
-
+ <%= render 'comment_form', :item_request => @item_request %>
+ <%= render :partial => 'comment', :collection => @comments %>
</ul>
</div><!-- /discussion-holder -->
@@ -120,7 +90,7 @@
</div><!-- /content -->
- <div id="sidebar">
+ <div id="sidebar" style="margin-left:50px;">
<%= render :partial => "shared/trust_profile", :locals => { :person => (@item_request.gifter?(current_user.person) ? @item_request.requester : @item_request.gifter), :name => true } %>
@@ -20,7 +20,8 @@
</li>
<% end unless comments.empty? -%>
- <%= render :partial => 'comments/new.html.erb', :locals => { :commentable => req } %>
+ <%= render :partial => 'comments/new.html.erb', :locals => { :commentable => req,
+ :is_private => true } %>
</ul>
</div><!-- /inner-content -->
@@ -56,7 +56,7 @@
<h2>
<span>
<%= person_one %>
- <%= (sentence + " " + person_two).html_safe %> <strong><%= item %></strong>
+ <%= (sentence + " " + person_two).html_safe %><%= item %>
</span>
</h2>
<% end -%>
View
@@ -71,6 +71,7 @@
put "complete"
put "cancel"
put "collected"
+ post 'new_comment'
end
resources :feedbacks
end

0 comments on commit 9e4a767

Please sign in to comment.