Commit b2ad753b2b0197b4ed5d1e34461dcfd2e236e9a9

Authored by Daniela Feitosa
1 parent f7418835

Allowing reply of scraps reply

Fixing activities comments submit
app/controllers/public/profile_controller.rb
... ... @@ -179,7 +179,7 @@ class ProfileController < PublicController
179 179 @tab_action = params[:tab_action]
180 180 @message = @scrap.save ? _("Message successfully sent.") : _("You can't leave an empty message.")
181 181 @activities = @profile.activities.paginate(:per_page => 30, :page => params[:page]) if params[:not_load_scraps].nil?
182   - render :partial => 'leave_scrap'
  182 + render :partial => 'profile_activities_list'
183 183 end
184 184  
185 185 def leave_comment_on_activity
... ... @@ -192,7 +192,7 @@ class ProfileController < PublicController
192 192 @tab_action = params[:tab_action]
193 193 @message = @comment.save ? _("Comment successfully added.") : _("You can't leave an empty comment.")
194 194 @activities = @profile.activities.paginate(:per_page => 30, :page => params[:page]) if params[:not_load_scraps].nil?
195   - render :partial => 'leave_comment_on_activity'
  195 + render :partial => 'profile_activities_list'
196 196 end
197 197  
198 198 def view_more_scraps
... ...
app/views/profile/_profile_activity.rhtml
... ... @@ -3,7 +3,7 @@
3 3 <hr />
4 4  
5 5 <% if logged_in? && current_person.follows?(activity.user) %>
6   - <span class='profile-wall-send-reply'><%= link_to_function _('Comment'), "hide_and_show(['#profile-wall-reply-response-#{activity.id}'],['#profile-wall-reply-#{activity.id}', '#profile-wall-reply-form-#{activity.id}']);$('reply_content_#{activity.id}').value='';$('activity_id_#{activity.id}').value='#{activity.id}';return false", :class => "profile-send-reply" %></span>
  6 + <span class='profile-wall-send-reply'><%= link_to_function _('Comment'), "hide_and_show(['#profile-wall-reply-response-#{activity.id}'],['#profile-wall-reply-#{activity.id}', '#profile-wall-reply-form-#{activity.id}']);$('reply_content_#{activity.id}').value='';$('reply_content_#{activity.id}').focus();$('activity_id_#{activity.id}').value='#{activity.id}';return false", :class => "profile-send-reply" %></span>
7 7 <% end %>
8 8  
9 9 <ul class="profile-wall-activities-comments" style='padding-left: 50px;width:auto'>
... ...
app/views/profile/_profile_comment_form.rhtml
1 1 <div id='profile-wall-reply-<%= activity.id%>'>
2 2 <div id='profile-wall-reply-form-<%= activity.id%>'>
3 3 <p class='profile-wall-reply'>
4   - <% form_tag :url => {:controller => 'profile', :action => 'leave_comment_on_activity'}, :update => 'profile_activities' do %>
  4 + <% form_remote_tag :url => {:controller => 'profile', :action => 'leave_comment_on_activity'}, :update => 'profile_activities' do %>
5 5 <%= text_area :comment, :body, {:id => "reply_content_#{activity.id}", :cols => 50, :rows => 1, :class => 'submit-with-keypress'} %>
6 6 <%= hidden_field_tag :source_id, activity.id, :id => "activity_id_#{activity.id}" %>
7 7 <% end %>
... ...
app/views/profile/_profile_scrap.rhtml
... ... @@ -10,8 +10,8 @@
10 10 <p class='profile-wall-text'><%= txt2html scrap.content %></p>
11 11 <p class='profile-wall-time'><%= time_ago_as_sentence(scrap.created_at) + ' ' + _('ago') %></p>
12 12 <div class='profile-wall-actions'>
13   - <% if logged_in? && current_person.follows?(scrap.sender) && scrap.root.nil? %>
14   - <span class='profile-wall-send-reply'><%= link_to_function _('Comment'), "hide_and_show(['#profile-wall-reply-response-#{scrap.id}'],['#profile-wall-reply-#{scrap.id}', '#profile-wall-reply-form-#{scrap.id}']);$('reply_content_#{scrap.id}').value='';$('scrap_id_#{scrap.id}').value='#{scrap.id}';return false", :class => "profile-send-reply" %></span>
  13 + <% if logged_in? && current_person.follows?(scrap.sender) %>
  14 + <span class='profile-wall-send-reply'><%= link_to_function _('Comment'), "hide_and_show(['#profile-wall-reply-response-#{scrap.id}'],['#profile-wall-reply-#{scrap.id}', '#profile-wall-reply-form-#{scrap.id}']);$('reply_content_#{scrap.id}').value='';$('reply_content_#{scrap.id}').focus();$('scrap_id_#{scrap.id}').value='#{scrap.id}';return false", :class => "profile-send-reply" %></span>
15 15 <% end %>
16 16 <%= link_to_remote(content_tag(:span, _('Remove')), :url =>{:action => 'remove_scrap', :scrap_id => scrap.id}, :update => "profile-wall-item-#{scrap.id}") if logged_in? && user.can_control_scrap?(scrap) %>
17 17 <% end %>
... ... @@ -34,17 +34,6 @@
34 34 </div>
35 35 <div id='profile-wall-message-response-<%=scrap.id%>' class='profile-wall-message-response'></div>
36 36 </div>
37   - <div id='profile-wall-reply-<%= scrap.id%>' style='display:none;'>
38   - <div id='profile-wall-reply-form-<%= scrap.id%>' style='display:none;'>
39   - <p class='profile-wall-reply'>
40   - <% form_remote_tag :url => {:controller => 'profile', :action => 'leave_scrap'}, :update => "profile_activities", :success =>"hide_and_show(['#profile-wall-reply-form-#{scrap.id}'],['#profile-wall-reply-response-#{scrap.id}'])" do %>
41   - <%= text_area :scrap, :content, { :id => "reply_content_#{scrap.id}", :cols => 50, :rows => 2, :class => 'submit-with-keypress' } %>
42   - <%= hidden_field :scrap, :scrap_id, :id => "scrap_id_#{scrap.id}" %>
43   - <%= hidden_field_tag 'receiver_id', scrap.sender.id %>
44   - <% end %>
45   - </p>
46   - </div>
47   - <div id='profile-wall-message-response-<%=scrap.id%>' class='profile-wall-message-response'></div>
48   - </div>
  37 + <%= render :partial => 'profile_scrap_reply_form', :locals => { :scrap => scrap } %>
49 38 <hr />
50 39 </li>
... ...