将课程帖子转发至组织帖子栏目

This commit is contained in:
ouyangxuhua 2015-12-23 15:35:26 +08:00
parent 9dc2cb8541
commit b9ae579622
18 changed files with 148 additions and 34 deletions

View File

@ -22,7 +22,7 @@ class MessagesController < ApplicationController
default_search_scope :messages
before_filter :find_board, :only => [:new, :preview,:edit]
before_filter :find_attachments, :only => [:preview]
before_filter :find_message, :except => [:new, :preview]
before_filter :find_message, :except => [:new, :preview, :join_org_subfield, :get_subfield_on_click_org, :join_org_subfields]
before_filter :authorize, :except => [:preview, :edit, :destroy, :new]
helper :boards
@ -301,6 +301,24 @@ class MessagesController < ApplicationController
render :partial => 'common/preview'
end
def join_org_subfield
@message = Message.find(params[:message_id])
@organizations = User.current.organizations
end
def get_subfield_on_click_org
@org = Organization.find(params[:organization_id])
end
def join_org_subfields
org_subfield_ids = params[:org_subfields]
@message = Message.find(params[:id])
type = @message.board.course_id.nil? ? "Project":"Course"
org_subfield_ids.each do |field_id|
OrgSubfieldMessage.create(:org_subfield_id => field_id.to_i, :message_id => @message.id, :message_type => type)
end
end
private
def find_message
return unless find_board

View File

@ -19,8 +19,6 @@ class Board < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :project,:touch => true
belongs_to :course,:touch=>true
has_many :org_subfield_boards
has_many :org_subfields, :class_name => "OrgSubfield", :through => :org_subfield_boards
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC"
belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id

View File

@ -23,6 +23,8 @@ class Message < ActiveRecord::Base
belongs_to :board,:touch => true
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
has_many :org_subfield_messages, :dependent => :destroy
has_many :org_subfields, :through => :org_subfield_messages
acts_as_tree :counter_cache => :replies_count, :order => "#{Message.table_name}.created_on ASC"
acts_as_attachable

View File

@ -2,8 +2,8 @@ class OrgSubfield < ActiveRecord::Base
belongs_to :organization, :foreign_key => :organization_id
has_many :org_document_comments, :dependent => :destroy
has_many :files
has_many :org_subfield_boards
has_many :boards, :through => :org_subfield_boards
has_many :org_subfield_messages, :dependent => :destroy
has_many :messages, :through => :org_subfield_messages
acts_as_attachable
def project

View File

@ -1,5 +0,0 @@
class OrgSubfieldBoard < ActiveRecord::Base
belongs_to :org_subfield
belongs_to :board
# attr_accessible :title, :body
end

View File

@ -57,6 +57,7 @@
:data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink'
) if @message.course_destroyable_by?(User.current) %>
<%= link_to "转发",messages_join_org_subfield_path(:message_id => @topic.id) , :remote=> true,:class => 'postOptionLink' %>
</li>
</ul>
</li>

View File

@ -0,0 +1,60 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
$(document).ready(function(){
$(".resourcePopupClose").click(function(){
$(".shareDP").css("display","none");
});
$(".sectionRow").toggle(
function(){
$(this).next().css("display","block");
},
function(){
$(this).next().css("display","none");
}
);
});
function join_org(){
if ($("#org_subfield_list input[type='checkbox']:checked").size() == 0)
{
alert("您还没有选择栏目!");
}
else
{
$("#join-form").submit();
}
}
</script>
</head>
<body>
<div>
<div class="relateText fl mb10">转发到</div>
</div>
<div class="cl"></div>
<div class="sectionWrap fl">
<div class="pl10 fontGrey3 sectionRow">
<span class="shareArrow"></span>我的组织
</div>
<ul class="fontGrey3 sectionContent" id="sectionContent3">
<% organizations.each do |org| %>
<li><span><%= link_to org.name, messages_get_subfield_on_click_org_path(:organization_id => org.id), :remote => true %></span></li>
<% end %>
</ul>
</div>
<%= form_tag url_for(:controller => 'messages', :action => 'join_org_subfields', :id => id), :id => 'join-form', :remote => true %>
<div id="org_subfield_list">
<%= render :partial => 'show_org_subfields', :locals => {:org => nil} %>
</div>
<div class="cl"></div>
<div class="courseSendCancel mr2" style="float:right;"><a href="javascript:void(0);" onclick="hideModal();" class="sendSourceText">取消</a></div>
<div class="courseSendSubmit" style="float:right;"><a href="javascript:void(0);" onclick="join_org();" class="sendSourceText">确定</a></div>
<div class="cl"></div>
</body>
</html>

View File

@ -0,0 +1,13 @@
<ul class="columnWrap fr">
<!--<span class="fontBlue pl10">请在左侧选择要转发的位置</span>-->
<% if !org.nil? %>
<span class="fontBlue pl10">组织:<%= org.name %></span>
<% org.org_subfields.where("field_type='Post'").each do |subfield| %>
<li>
<label><input type="checkbox" name='org_subfields[]' value='<%= subfield.id %>' class="mt3 fl mr5"/><span><%= subfield.name %></span></label>
</li>
<% end %>
<% else %>
<span class="fontBlue pl10">请在左侧选择要转发的位置</span>
<% end %>
</ul>

View File

@ -0,0 +1,2 @@
$("#org_subfield_list").html("");
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'show_org_subfields', :locals => {:org => @org}) %>");

View File

@ -0,0 +1,11 @@
$('#topnav_course_menu').hide();
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'join_org_subfield_menu', :locals => {:organizations => @organizations, :id => @message.id}) %>');
showModal('ajax-modal', '430px');
$('#ajax-modal').siblings().hide();
$('#ajax-modal').before(
"<a href='javascript:' onclick='hideModal();' class='resourceClose' style='margin-left: 410px;'></a>");
//$('#ajax-modal').css('position','absolute')
$('#ajax-modal').css("top","").css("left","");
$('#ajax-modal').parent().addClass("resourceSharePopup");

View File

@ -0,0 +1,2 @@
hideModal();
alert("转发成功!");

View File

@ -9,6 +9,7 @@
</div>
<div class="homepageLeftMenuCourses" id="homepageLeftMenuProjects" style="display:<%= organization.projects.count == 0?'none':'' %>">
<ul >
<%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%>
</ul>
</div>

View File

@ -415,6 +415,9 @@ RedmineApp::Application.routes.draw do
post 'boards/:board_id/topics/:id/replies', :to => 'messages#reply'
post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy'
match 'messages/join_org_subfield', :to => 'messages#join_org_subfield'
match 'messages/get_subfield_on_click_org', :to => 'messages#get_subfield_on_click_org'
match 'messages/join_org_subfields', :to => 'messages#join_org_subfields'
# boards end
# Misc issue routes. TODO: move into resources

View File

@ -1,13 +0,0 @@
class CreateTableOrgSubfieldBoards < ActiveRecord::Migration
def up
create_table :org_subfield_boards do |t|
t.integer :org_subfield_id
t.integer :board_id
t.timestamps
end
end
def down
drop_table :org_subfield_boards
end
end

View File

@ -1,5 +0,0 @@
class AddBoardTypeToOrgSubfieldBoards < ActiveRecord::Migration
def change
add_column :org_subfield_boards, :board_type, :string
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20151222072758) do
ActiveRecord::Schema.define(:version => 20151223062932) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -1196,12 +1196,12 @@ ActiveRecord::Schema.define(:version => 20151222072758) do
t.datetime "created_at"
end
create_table "org_subfield_boards", :force => true do |t|
create_table "org_subfield_messages", :force => true do |t|
t.integer "org_subfield_id"
t.integer "board_id"
t.integer "message_id"
t.string "message_type"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "board_type"
end
create_table "org_subfields", :force => true do |t|

View File

@ -86,3 +86,16 @@ a.linkGrey8:hover {color:#585858;}
ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; }
.popbox_polls{width:300px;height:100px;position:fixed !important;z-index:100;left:50%;top:50%;margin:-100px 0 0 -150px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}
/*转发样式*/
.shareDP {width:415px; height:auto; border:3px solid #269ac9; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; z-index:1000;}
.shareArrow {background:url(../images/arrowList.png) -90px -108px no-repeat; display:inline-block; width:5px; height:10px; margin-right:3px;}
.sectionWrap {float:left; max-height:150px; margin-bottom:10px; overflow:auto; overflow-x:hidden; width:220px; background-color:#f1f1f1; min-height:150px; padding-top:5px;}
.columnWrap {float:left; max-height:148px; margin-bottom:10px; overflow:auto; overflow-x:hidden; width:178px; background-color:#fffff; min-height:148px; padding-top:5px; border:1px solid #f1f1f1;}
.columnWrap li {padding-left:10px; color:#585858;}
.columnWrap span {width:150px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; display:inline-block;}
.sectionRow:hover {background-color:#cccccc; cursor:pointer;}
.sectionContent {display:none;}
.sectionContent li {padding-left:30px;}
.sectionContent li:hover {background-color:#cccccc; cursor:pointer;}
.sectionContent span {width:175px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; display:inline-block; height:18px; vertical-align:middle;}

View File

@ -917,3 +917,16 @@ a.resourcesTypeUser {background:url(images/homepage_icon.png) -178px -453px no-r
/* @功能 定义 */
span.at {color:#269ac9;}
/*转发样式*/
.shareDP {width:415px; height:auto; border:3px solid #269ac9; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; z-index:1000;}
.shareArrow {background:url(../images/arrowList.png) -90px -108px no-repeat; display:inline-block; width:5px; height:10px; margin-right:3px;}
.sectionWrap {float:left; max-height:150px; margin-bottom:10px; overflow:auto; overflow-x:hidden; width:220px; background-color:#f1f1f1; min-height:150px; padding-top:5px;}
.columnWrap {float:left; max-height:148px; margin-bottom:10px; overflow:auto; overflow-x:hidden; width:178px; background-color:#fffff; min-height:148px; padding-top:5px; border:1px solid #f1f1f1;}
.columnWrap li {padding-left:10px; color:#585858;}
.columnWrap span {width:150px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; display:inline-block;}
.sectionRow:hover {background-color:#cccccc; cursor:pointer;}
.sectionContent {display:none;}
.sectionContent li {padding-left:30px;}
.sectionContent li:hover {background-color:#cccccc; cursor:pointer;}
.sectionContent span {width:175px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; display:inline-block; height:18px; vertical-align:middle;}