Merge branch 'develop' of 10.0.47.245:/home/trustie2 into develop

This commit is contained in:
nieguanghui 2013-12-26 19:58:10 +08:00
commit 58ff68a9cc
12 changed files with 43 additions and 31 deletions

View File

@ -73,10 +73,10 @@ class WordsController < ApplicationController
end
def destroy
if User.current.admin? || User.current.id == @user.id
JournalsForMessage.delete_message(params[:object_id])
if User.current.admin? || @user.id == User.current.id || User.current.id == JournalsForMessage.find(params[:object_id]).jour_id
@journal_destroyed = JournalsForMessage.delete_message(params[:object_id])
end
@jours = @user.journals_for_messages.reverse
@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']

View File

@ -20,7 +20,6 @@ class JournalsForMessage < ActiveRecord::Base
belongs_to :at_user, :class_name => "User", :foreign_key => 'reply_id'
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
has_many :reply_for_journals, :dependent => :destroy
validates :notes, presence: true
after_create :act_as_activity #huang
@ -30,7 +29,8 @@ class JournalsForMessage < ActiveRecord::Base
# default_scope { where('m_parent_id IS NULL') }
def self.delete_message(message_id)
self.delete_all "id = #{message_id}"
self.find(message_id).destroy
# self.destroy_all "id = #{message_id}"
end
def reference_user

View File

@ -2,7 +2,7 @@
<div id="add-memo" style="display:none;">
<h3><%=l(:label_memo_new)%></h3>
<% if User.current.logged? %>
<%= labelled_form_for(@memo, :url => forum_memos_path(@forum)) do |f| %>
<%= labelled_form_for(@memo, :url => forum_memos_path(@forum), :html => {:multipart => true} ) do |f| %>
<% if @memo.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:</h2>

View File

@ -1,6 +1,6 @@
<% id = "journal_reply_ul_" + journal.id.to_s%>
<ul class="messages-for-user-reply" id = <%= id %> >
<ul class="messages-for-user-reply" id = '<%= id %>' >
<% fetch_user_leaveWord_reply(journal).each do |reply|%>
<%= render :partial => "words/journal_reply_items", :locals => {:reply => reply, :journal => journal, :m_reply_id => reply.id} %>
<% end %>

View File

@ -1,23 +1,23 @@
<% ids_r = 'reply_respond_form_'+ reply.id.to_s %>
<li onmouseover="$('#<%= ids_r %>').show()" onmouseout="$('#<%= ids_r %>').hide()">
<% ids_r = 'reply_respond_form_'+ reply.id.to_s %>
<li id='word_li_<%=reply.id.to_s%>' onmouseover="$('#<%= ids_r %>').show()" onmouseout="$('#<%= ids_r %>').hide()">
<span class="portrait">
<%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %>
</span>
<div class="body">
<% id = 'project_respond_form_'+ reply.id.to_s %>
<% id = 'project_respond_form_'+ reply.id.to_s %>
<span><%= link_to reply.user.name, user_path(reply.user) %>:&nbsp;</span>
<span class="message-notes"> <%= reply.notes %></span>
<% ids = 'project_respond_form_'+ journal.id.to_s%>
<%# ids = 'project_respond_form_'+ journal.id.to_s%>
<p>
<span class="time"><%= format_time reply.created_on %></span>
<span style="display: none; margin-left: 4px;" id=<%= ids_r %>>
<span style="display: none; margin-left: 4px;" id='<%=ids_r%>' >
<%= link_to l(:label_projects_feedback_respond),'',
{:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}:'); return false;"}
{:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{id}'), $('##{id} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}: '); return false;"}
%>
<% if @user == User.current %>
<%= link_to(l(:label_newfeedback_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => reply.user},
<%= link_to(l(:label_newfeedback_delete), {:controller => 'words', :action => 'destroy', :object_id => reply, :user_id => reply.user},
:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) if (User.current.id == reply.user_id) || journal.jour_id == User.current.id %></td>
<% end %>
</span>
@ -25,6 +25,6 @@
</div>
<div id='<%=id%>' class="respond-form">
<%= render :partial => "words/new_respond", :locals => {:journal => journal, :m_reply_id => m_reply_id} %>
</div>
<div style="clear: both;"></div>
</div>
<div style="clear: both;"></div>
</li>

View File

@ -3,7 +3,7 @@
<% remove_allowed = (User.current.id == jour.first.user_id) %>
<ul class="message-for-user">
<% 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="body">
<span class="user"><%= link_to journal.user, user_path(journal.user)%></span>
@ -19,7 +19,7 @@
<% ids = 'project_respond_form_'+ journal.id.to_s%>
<span>
<%= link_to l(:label_projects_feedback_respond),'',
{:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}:'); return false;"}
{:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}: '); $('##{ids} textarea') ;return false;"}
%>
<% if @user == User.current %>
@ -29,13 +29,13 @@
</span>
</span>
<div style="clear: both;"></div>
<div id=<%= ids %> class="respond-form">
<div id='<%= ids %>' class="respond-form">
<%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal.id} %>
</div>
<div>
<%= render :partial => "words/journal_reply", :locals => {:journal => journal } %>
</div>
</li>
</div>
<div>
<%= render :partial => "words/journal_reply", :locals => {:journal => journal } %>
</div>
</li>
<% end %>
</ul>
<% end %>

View File

@ -1,9 +1,10 @@
<% if @save_succ %>
$('#journal_reply_ul_<%=@jfm.m_parent_id%>').append(
'<%= j(
var pre_append = $('<%= j(
render :partial => "words/journal_reply_items",
:locals => {:reply => @jfm, :journal => @jfm.parent, :m_reply_id => @jfm.id}
) %>');
) %>').hide();
$('#journal_reply_ul_<%=@jfm.m_parent_id%>').append(pre_append);
pre_append.fadeIn(600);
$('#project_respond_form_<%=@jfm.m_reply_id.to_s%> textarea').val('');
$('#project_respond_form_<%=@jfm.m_reply_id.to_s%>').hide();
<% else %>

View File

@ -1,2 +1,11 @@
$('#message').html('<%= escape_javascript(render(:partial => 'words/message', :locals => {:jour => @jour, :state => false, :user => @user, :feedback_pages => @feedback_pages})) %>');
$('#new_form_reference_user_id').val("");
<% if @journal_destroyed.nil? %>
alert('<%=l(:notice_failed_delete)%>');
<% elsif (@journal_destroyed.jour_type == 'Principal')%>
var destroyedItem = $('#word_li_<%=@journal_destroyed.id%>')
destroyedItem.fadeOut(600,function(){
destroyedItem.remove();
});
<% else %>
$('#message').html('<%= escape_javascript(render(:partial => 'words/message', :locals => {:jour => @jour, :state => false, :user => @user, :feedback_pages => @feedback_pages})) %>');
$('#new_form_reference_user_id').val("");
<% end %>

View File

@ -155,6 +155,7 @@ en:
notice_successful_create: Successful creation.
notice_successful_update: Successful update.
notice_successful_delete: Successful deletion.
notice_failed_delete: Successful failure.
notice_successful_connection: Successful connection.
notice_file_not_found: The page you were trying to access doesn't exist or has been removed.
notice_locking_conflict: Data has been updated by another user.

View File

@ -164,6 +164,7 @@ zh:
notice_successful_create: 创建成功
notice_successful_update: 更新成功
notice_successful_delete: 删除成功
notice_failed_delete: 删除失败
notice_successful_connection: 连接成功
notice_file_not_found: 您访问的页面不存在或已被删除。
notice_locking_conflict: 数据已被另一位用户更新

View File

@ -592,7 +592,7 @@ function blockEventPropagation(event) {
function toggleAndSettingWordsVal(parent_widget, text_widget, value){
text_widget.val(value)
parent_widget.toggle(400)
parent_widget.slideToggle(400)
}
$(document).ready(setupAjaxIndicator);

View File

@ -2123,7 +2123,7 @@ ul.messages-for-user-reply li {
.respond-form{
display: none;
width: 100%;
width: 87%;
margin: auto;
clear:both;
}