From b9ae579622e024060f7f3fb3891a7b3e70ba86b1 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 23 Dec 2015 15:35:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E8=AF=BE=E7=A8=8B=E5=B8=96=E5=AD=90?= =?UTF-8?q?=E8=BD=AC=E5=8F=91=E8=87=B3=E7=BB=84=E7=BB=87=E5=B8=96=E5=AD=90?= =?UTF-8?q?=E6=A0=8F=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 20 ++++++- app/models/board.rb | 2 - app/models/message.rb | 2 + app/models/org_subfield.rb | 4 +- app/models/org_subfield_board.rb | 5 -- app/views/messages/_course_show.html.erb | 1 + .../messages/_join_org_subfield_menu.html.erb | 60 +++++++++++++++++++ .../messages/_show_org_subfields.html.erb | 13 ++++ .../messages/get_subfield_on_click_org.js.erb | 2 + app/views/messages/join_org_subfield.js.erb | 11 ++++ app/views/messages/join_org_subfields.js.erb | 2 + .../_org_left_subfield_list.html.erb | 1 + config/routes.rb | 3 + ...151221023622_create_org_subfield_boards.rb | 13 ---- ...8_add_board_type_to_org_subfield_boards.rb | 5 -- db/schema.rb | 8 +-- public/stylesheets/org.css | 15 ++++- public/stylesheets/public.css | 15 ++++- 18 files changed, 148 insertions(+), 34 deletions(-) delete mode 100644 app/models/org_subfield_board.rb create mode 100644 app/views/messages/_join_org_subfield_menu.html.erb create mode 100644 app/views/messages/_show_org_subfields.html.erb create mode 100644 app/views/messages/get_subfield_on_click_org.js.erb create mode 100644 app/views/messages/join_org_subfield.js.erb create mode 100644 app/views/messages/join_org_subfields.js.erb delete mode 100644 db/migrate/20151221023622_create_org_subfield_boards.rb delete mode 100644 db/migrate/20151222072758_add_board_type_to_org_subfield_boards.rb diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 6f173b7c2..957d77b8a 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -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 diff --git a/app/models/board.rb b/app/models/board.rb index ba1fae30a..67d59e599 100644 --- a/app/models/board.rb +++ b/app/models/board.rb @@ -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 diff --git a/app/models/message.rb b/app/models/message.rb index 4cdae1f6e..19531e270 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -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 diff --git a/app/models/org_subfield.rb b/app/models/org_subfield.rb index 062226e0e..b63883e81 100644 --- a/app/models/org_subfield.rb +++ b/app/models/org_subfield.rb @@ -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 diff --git a/app/models/org_subfield_board.rb b/app/models/org_subfield_board.rb deleted file mode 100644 index ac820e319..000000000 --- a/app/models/org_subfield_board.rb +++ /dev/null @@ -1,5 +0,0 @@ -class OrgSubfieldBoard < ActiveRecord::Base - belongs_to :org_subfield - belongs_to :board - # attr_accessible :title, :body -end diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index e06c04775..1b4c8a0f6 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -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' %> diff --git a/app/views/messages/_join_org_subfield_menu.html.erb b/app/views/messages/_join_org_subfield_menu.html.erb new file mode 100644 index 000000000..692195892 --- /dev/null +++ b/app/views/messages/_join_org_subfield_menu.html.erb @@ -0,0 +1,60 @@ + + + + + + + + + + +
+
转发到
+
+
+
+ +
+ 我的组织 +
+ +
+ <%= form_tag url_for(:controller => 'messages', :action => 'join_org_subfields', :id => id), :id => 'join-form', :remote => true %> +
+ <%= render :partial => 'show_org_subfields', :locals => {:org => nil} %> +
+
+
取消
+
确定
+
+ + + diff --git a/app/views/messages/_show_org_subfields.html.erb b/app/views/messages/_show_org_subfields.html.erb new file mode 100644 index 000000000..c1fa92990 --- /dev/null +++ b/app/views/messages/_show_org_subfields.html.erb @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/app/views/messages/get_subfield_on_click_org.js.erb b/app/views/messages/get_subfield_on_click_org.js.erb new file mode 100644 index 000000000..858236a96 --- /dev/null +++ b/app/views/messages/get_subfield_on_click_org.js.erb @@ -0,0 +1,2 @@ +$("#org_subfield_list").html(""); +$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'show_org_subfields', :locals => {:org => @org}) %>"); diff --git a/app/views/messages/join_org_subfield.js.erb b/app/views/messages/join_org_subfield.js.erb new file mode 100644 index 000000000..68e21d4e3 --- /dev/null +++ b/app/views/messages/join_org_subfield.js.erb @@ -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( + ""); +//$('#ajax-modal').css('position','absolute') +$('#ajax-modal').css("top","").css("left",""); +$('#ajax-modal').parent().addClass("resourceSharePopup"); + diff --git a/app/views/messages/join_org_subfields.js.erb b/app/views/messages/join_org_subfields.js.erb new file mode 100644 index 000000000..7cb64e228 --- /dev/null +++ b/app/views/messages/join_org_subfields.js.erb @@ -0,0 +1,2 @@ +hideModal(); +alert("转发成功!"); \ No newline at end of file diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index 4d85342a6..9032ba62e 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -9,6 +9,7 @@
diff --git a/config/routes.rb b/config/routes.rb index da04f63f3..c5e890d15 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/db/migrate/20151221023622_create_org_subfield_boards.rb b/db/migrate/20151221023622_create_org_subfield_boards.rb deleted file mode 100644 index 06f6f2f17..000000000 --- a/db/migrate/20151221023622_create_org_subfield_boards.rb +++ /dev/null @@ -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 diff --git a/db/migrate/20151222072758_add_board_type_to_org_subfield_boards.rb b/db/migrate/20151222072758_add_board_type_to_org_subfield_boards.rb deleted file mode 100644 index d53f9952f..000000000 --- a/db/migrate/20151222072758_add_board_type_to_org_subfield_boards.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddBoardTypeToOrgSubfieldBoards < ActiveRecord::Migration - def change - add_column :org_subfield_boards, :board_type, :string - end -end diff --git a/db/schema.rb b/db/schema.rb index f2c61ac5f..50575eca8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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| diff --git a/public/stylesheets/org.css b/public/stylesheets/org.css index 44dcc70e3..2ffefa48a 100644 --- a/public/stylesheets/org.css +++ b/public/stylesheets/org.css @@ -85,4 +85,17 @@ a.linkGrey8:hover {color:#585858;} .re_con_top span{ color:#999999; font-weight:bold;} 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;} \ No newline at end of file +.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;} \ No newline at end of file diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index d9f370c7d..f73f389ae 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -916,4 +916,17 @@ a.resourcesTypeUser {background:url(images/homepage_icon.png) -178px -453px no-r .list_style ul li{list-style-type: disc;margin-left: 20px;} /* @功能 定义 */ -span.at {color:#269ac9;} \ No newline at end of file +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;} \ No newline at end of file