项目留言.

This commit is contained in:
yanxd 2013-12-30 17:13:44 +08:00
parent 36289eba41
commit ebc803a88a
5 changed files with 47 additions and 41 deletions

View File

@ -181,9 +181,7 @@ class ProjectsController < ApplicationController
@s_type = 2 @s_type = 2
end end
else else
logger.debug("-------------------------------------------------")
@projects = Project.visible.where("project_type = ?", 1).order("created_on desc").offset(@project_pages.offset).limit(@limit).all @projects = Project.visible.where("project_type = ?", 1).order("created_on desc").offset(@project_pages.offset).limit(@limit).all
logger.debug("-------------------------------------------------")
@s_type = 0 @s_type = 0
end end
respond_to do |format| respond_to do |format|
@ -316,7 +314,6 @@ class ProjectsController < ApplicationController
# flash[:notice]=l(:label_projects_feedback_respond_success) # flash[:notice]=l(:label_projects_feedback_respond_success)
respond_to do |format| respond_to do |format|
format.html { redirect_to :back } format.html { redirect_to :back }
format.js format.js

View File

@ -39,11 +39,10 @@ class WordsController < ApplicationController
#format.api { render_api_ok } #format.api { render_api_ok }
end end
end end
def create_reply def create_reply
# deny api. api useless # deny api. api useless
user_id = request.headers["Referer"].match((%r|/([0-9]{1,})/|))[1]
@user = User.find(user_id)
parent_id = params[:reference_id] parent_id = params[:reference_id]
author_id = User.current.id author_id = User.current.id
reply_user_id = params[:reference_user_id] reply_user_id = params[:reference_user_id]
@ -55,7 +54,8 @@ class WordsController < ApplicationController
:reply_id => reply_user_id, :reply_id => reply_user_id,
:notes => content, :notes => content,
:is_readed => false} :is_readed => false}
@jfm = @user.add_jour(nil, nil, nil, options) @obj = obj_distinguish_url_origin
@jfm = add_reply_adapter @obj, options
respond_to do |format| respond_to do |format|
# format.html { # format.html {
@ -74,21 +74,8 @@ class WordsController < ApplicationController
def destroy def destroy
@journal_destroyed = JournalsForMessage.delete_message(params[:object_id]) @journal_destroyed = JournalsForMessage.delete_message(params[:object_id])
@jours = @user.journals_for_messages.where('m_parent_id IS NULL').reverse
@limit = 10
@feedback_count = @jours.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
@jour = @jours[@offset, @limit]
# if a_message.size > 5
# @message = a_message[-5, 5]
# else
# @message = a_message
# end
# @message_count = a_message.count
respond_to do |format| respond_to do |format|
format.html { redirect_to :back }
format.js format.js
#format.api { render_api_ok } #format.api { render_api_ok }
end end
@ -187,5 +174,27 @@ class WordsController < ApplicationController
render_404 render_404
end end
def obj_distinguish_url_origin
referer = request.headers["Referer"]
obj_id = referer.match((%r|/([0-9]{1,})/|))[1]
if referer.match(/project/)
obj = Project.find_by_id(obj_id)
elsif referer.match(/user/)
obj = User.find_by_id(obj_id)
else
raise 'create reply obj unknow type.'
end
obj
end
def add_reply_adapter obj, options
if obj.kind_of? User
obj.add_jour(nil, nil, nil, options)
elsif obj.kind_of? Project
Project.add_new_jour(nil, nil, obj.id, options)
else
raise 'create reply obj unknow type.'
end
end
#######end of message #######end of message
end end

View File

@ -14,32 +14,32 @@
<% if @jour.size >0 %> <% if @jour.size >0 %>
<ul class="message-for-user"> <ul class="message-for-user">
<% for journal in @jour%> <% for journal in @jour%>
<li class="outer-message-for-user"> <li id='word_li_<%=journal.id.to_s%>' class="outer-message-for-user">
<span class="portrait"><%= image_tag(url_to_avatar(journal.user), :class => "avatar") %></span> <span class="portrait"><%= image_tag(url_to_avatar(journal.user), :class => "avatar") %></span>
<span class="body"> <span class="body">
<span class="user"><%= link_to journal.user, user_path(journal.user)%></span> <span class="user"><%= link_to journal.user, user_path(journal.user)%></span>
<span class="font_lighter"><%= l(:label_projects_feedback) %></span> <span class="font_lighter"><%= l(:label_projects_feedback) %></span>
<p > <%= textilizable journal.notes%>
<%= textilizable journal.notes%> <span class="font_lighter"> <%= l :label_update_time %>: <%= format_time journal.created_on %></span>
</p> <% id = 'project_respond_form_'+journal.id.to_s%>
<span class="font_lighter"> <%= l :label_update_time %>: <%= format_time journal.created_on %></span> <span>
<% id = 'project_respond_form_'+journal.id.to_s%> <%= link_to l(:label_projects_feedback_respond),'',
<span><%= link_to l(:label_projects_feedback_respond),'', {:focus => 'project_respond',
{:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{id}'),
:onclick => "toggleAndSettingWordsVal($('##{id}'), $('##{id} textarea'),
$('##{id} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}: ');
'#{l(:label_reply_plural)} #{m_reply_id.user.show_name}: '); return false;"} %>
return false;"} %></span> </span>
</span> </span>
<div style="clear: both;"></div> <div style="clear: both;"></div>
<div id='<%= id %>' class="respond-form"> <div id='<%= id %>' class="respond-form">
<%= render :partial => 'new_respond', :locals => {:journal => journal, :m_reply_id => journal} %> <%= render :partial => 'new_respond', :locals => {:journal => journal, :m_reply_id => journal} %>
</div> </div>
<div style="clear: both;"></div> <div style="clear: both;"></div>
<div> <div>
<%= render :partial => "words/journal_reply", :locals => {:journal => journal } %> <%= render :partial => "words/journal_reply", :locals => {:journal => journal } %>
</div> </div>
</li> </li>
<% end %> <% end %>
</ul> </ul>
<% end %> <% end %>

View File

@ -1,6 +1,6 @@
<% if @journal_destroyed.nil? %> <% if @journal_destroyed.nil? %>
alert('<%=l(:notice_failed_delete)%>'); alert('<%=l(:notice_failed_delete)%>');
<% elsif (@journal_destroyed.jour_type == 'Principal')%> <% elsif (['Principal','Project'].include? @journal_destroyed.jour_type)%>
var destroyedItem = $('#word_li_<%=@journal_destroyed.id%>') var destroyedItem = $('#word_li_<%=@journal_destroyed.id%>')
destroyedItem.fadeOut(600,function(){ destroyedItem.fadeOut(600,function(){
destroyedItem.remove(); destroyedItem.remove();