组织模块功能实现

This commit is contained in:
ouyangxuhua 2015-11-12 09:32:00 +08:00
parent 283af137c6
commit a3443ba968
58 changed files with 761 additions and 193 deletions

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the org_document_comment controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the OrgMember controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the org_projects controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,54 @@
class OrgDocumentCommentsController < ApplicationController
before_filter :find_organization, :only => [:new, :create, :show, :index]
layout 'base_org'
def new
@org_document_comment = OrgDocumentComment.new
end
def create
@org_document_comment = OrgDocumentComment.new(:organization_id => @organization.id, :creator_id => User.current.id)
@org_document_comment.title = params[:org_document_comment][:title]
@org_document_comment.content = params[:org_document_comment][:content]
if @org_document_comment.save
#flash[:notice] = 'success'
OrgActivity
redirect_to organization_org_document_comments_path(@organization)
else
redirect_to new_org_document_comment_path(:organization_id => @organization.id)
end
end
def show
end
def index
@documents = @organization.org_document_comments.where("parent_id is null").order("created_at desc")
end
def update
end
def add_reply
@document = OrgDocumentComment.find(params[:id]).root
@comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id])
@comment.content = params[:org_content]
@document.children << @comment
@document.save
end
def find_organization
@organization = Organization.find(params[:organization_id])
end
def destroy
@org_document_comment = OrgDocumentComment.find(params[:id])
org = @org_document_comment.organization
if @org_document_comment.destroy
if @org_document_comment.id == org.id
org.home_id == nil
end
end
end
end

View File

@ -0,0 +1,53 @@
class OrgMemberController < ApplicationController
def org_member_autocomplete
@org = Organization.find(params[:org])
@flag = params[:flag] || false
respond_to do |format|
format.js
end
end
def create
@org = Organization.find(params[:org])
member_ids = params[:membership][:user_ids]
role_id = params[:orgRole]
member_ids.each do |user_id|
member = OrgMember.create(:user_id=>user_id)
@org.org_members << member
OrgMemberRole.create(:org_member_id => member.id, :role_id => role_id)
end
respond_to do |format|
format.js
end
end
def update
@member = OrgMember.find(params[:id])
#@member.change_role params[:org_member][:role_ids]
@member_role = @member.org_member_roles[0]
@member_role.role_id = params[:org_member][:role_ids][0]
@member_role.save
@org = @member.organization
respond_to do |format|
format.js
end
end
def new
end
def destroy
member = OrgMember.find(params[:id])
@org = member.organization
member.destroy
respond_to do |format|
format.js
end
end
def index
end
end

View File

@ -0,0 +1,18 @@
class OrgProjectsController < ApplicationController
def create
org_ids = params[:orgNames]
@project = Project.find(params[:project_id])
org_ids.each do |org_id|
OrgProject.create(:organization_id => org_id.to_i, :project_id => params[:project_id].to_i, :created_at => Time.now)
p 1
end
respond_to do |format|
format.js
end
end
def destroy
@project = Project.find(params[:project_id])
@org_project = OrgProject.find(params[:id])
@org_project.destroy
end
end

View File

@ -1,6 +1,6 @@
# encoding: utf-8
class OrganizationsController < ApplicationController
# before_filter :find_organization, :except => [:show,:new,:index,:create]
before_filter :find_organization, :only => [:show]
layout 'base_org'
def index
@ -26,7 +26,8 @@ class OrganizationsController < ApplicationController
def show
@organization = Organization.find(params[:id])
@activities = OrgActivity.where('(org_act_id = ? and org_act_type = ?)', @organization.id, 'CreateOrganization ')
@activities = OrgActivity.where('(org_act_id = ? and org_act_type = ?) || (container_id =? and org_act_type =? and org_act_id !=?)',
@organization.id, 'CreateOrganization ', @organization.id, 'OrgDocumentComment', @organization.home_id).order('updated_at desc')
@activities = paginateHelper @activities, 10
end
@ -67,4 +68,18 @@ class OrganizationsController < ApplicationController
def clear_org_avatar_temp
end
def set_homepage
org = Organization.find(params[:id])
org.home_id = params[:home_id]
org.save
end
def autocomplete_search
@project = Project.find(params[:project_id])
#@flag = params[:flag] || false
respond_to do |format|
format.js
end
end
end

View File

@ -69,6 +69,24 @@ class ProjectsController < ApplicationController
### added by william
include ActsAsTaggableOn::TagsHelper
#查找组织
def search_public_orgs_not_in_project
condition = '%%'
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
project_org_ids = OrgProject.find_by_sql("select distinct organization_id from org_projects where project_id = #{params[:id]}").map(&:organization_id)
if project_org_ids.empty?
@orgs_not_in_project = Organization.where("is_public = 1").where("name like ?", condition).page((params[:page].to_i || 1)-1).per(10)
@org_count = Organization.where("is_public = 1").where("name like ?", condition).count
else
project_org_ids = "(" + project_org_ids.join(',') + ")"
@orgs_not_in_project = Organization.where("id not in #{project_org_ids} and is_public = 1").where("name like ?", condition).page((params[:page].to_i || 1)-1).per(10)
@org_count = Organization.where("id not in #{project_org_ids} and is_public = 1").where("name like ?", condition)
end
render :json => {:orgs => @orgs_not_in_project, :count => @org_count}.to_json
end
def index
render_404
end
@ -338,6 +356,15 @@ class ProjectsController < ApplicationController
@wiki ||= @project.wiki
@select_tab = params[:tab]
#找出所有不属于项目的公共组织
project_org_ids = OrgProject.find_by_sql("select distinct organization_id from org_projects where project_id = #{@project.id}")
if project_org_ids.empty?
@orgs_not_in_project = Organization.where("is_public = 1")
else
project_org_ids = "(" + project_org_ids.join(',') + ")"
@orgs_not_in_project = Organization.where("id not in #{project_org_ids} and is_public = 1")
end
# 处理从新建版本库返回来的错误信息
if !params[:repository_error_message].to_s.blank?
html = ""
@ -826,5 +853,4 @@ class ProjectsController < ApplicationController
end
#gcmend
end

View File

@ -0,0 +1,2 @@
module OrgDocumentCommentHelper
end

View File

@ -0,0 +1,16 @@
module OrgMemberHelper
include ApplicationHelper
def find_user_not_in_current_org_by_name org
if params[:q] && params[:q].lstrip.rstrip != ""
scope = Principal.active.sorted.not_member_of_org(org).like(params[:q])
else
scope = []
end
principals = paginateHelper scope,10
s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals')
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options|
link_to text, org_member_autocomplete_org_member_index_path(parameters.merge(:q => params[:q],:flag => true,:org=> org, :format => 'js')), :remote => true
}
s + content_tag('ul', links,:class => 'wlist', :id => "org_member_pagination_links" )
end
end

View File

@ -0,0 +1,2 @@
module OrgProjectsHelper
end

View File

@ -16,4 +16,5 @@ module OrganizationsHelper
}
s + content_tag('ul', links,:class => 'wlist', :id => "org_member_pagination_links" )
end
end

View File

@ -0,0 +1,5 @@
class OrgActivity < ActiveRecord::Base
# attr_accessible :title, :body
belongs_to :org_act ,:polymorphic => true
belongs_to :container,:polymorphic => true
end

View File

@ -0,0 +1,16 @@
class OrgDocumentComment < ActiveRecord::Base
attr_accessible :content, :creator_id, :organization_id, :parent_id, :reply_id, :title,:sticky,:locked
include Redmine::SafeAttributes
belongs_to :organization
belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id'
acts_as_tree :order => "#{OrgDocumentComment.table_name}.sticky asc, #{OrgDocumentComment.table_name}.created_at desc"
has_many :org_acts, :class_name => 'OrgActivity',:as =>:org_act ,:dependent => :destroy
after_create :document_save_as_org_activity
def document_save_as_org_activity
if(self.parent().nil?)
self.org_acts << OrgActivity.new(:user_id => User.current.id, :container_id => self.organization.id, :container_type => 'Organization')
end
end
end

View File

@ -0,0 +1,5 @@
class OrgProject < ActiveRecord::Base
# attr_accessible :title, :body
belongs_to :organization
belongs_to :project
end

View File

@ -14,6 +14,7 @@
<%= heads_for_theme %>
<%= stylesheet_link_tag 'pleft','prettify','jquery/jquery-ui-1.9.2','header','new_user','repository','org' %>
<%= javascript_include_tag 'cookie','project', 'header','prettify','select_list_move','org'%>
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= yield :header_tags -%>
@ -30,7 +31,6 @@
<% end %>
</div>
<div class="cl"></div>
<% @organization = Organization.find(params[:id])%>
<div class="homepageContentContainer">
<div class="homepageContent">
<div class="homepageLeft">
@ -50,11 +50,15 @@
<% end %>
<% end%>
</div>
<div class="orgName fl mb5 f14">组织id:<%= @organization.id %></div>
<div class="orgName fl mb5 f14">组织id<%= @organization.id %></div>
<a href="<%= setting_organization_path(@organization) %>" class="pr_join_a"><span class="pr_setting"></span>配置</a>
<div class="cl"></div>
<div class="f12 fontGrey3">文章&nbsp;(&nbsp;<a href="javascript:void(0);" class="linkBlue">3</a>&nbsp;)&nbsp;|&nbsp;成员&nbsp;(&nbsp;<a href="javascript:void(0);" class="linkBlue">10</a>&nbsp;)</div>
<div class="f12 fontGrey3">
<%= link_to '文章', organization_org_document_comments_path(@organization) %>&nbsp;(&nbsp;
<%= link_to OrgDocumentComment.where("organization_id =? and parent_id is null", @organization.id).count, organization_org_document_comments_path(@organization), :class => "linkBlue" %>
&nbsp;)&nbsp;|&nbsp;成员&nbsp;(&nbsp;<%= @organization.org_members.count %> &nbsp;)
</div>
</div>
<div class="homepageLeftMenuContainer">
<div class="homepageLeftMenuBlock"><a href="javascript:void(0);" class="homepageMenuText">动态</a></div>
@ -77,90 +81,9 @@
<%= call_hook :view_layouts_base_content %>
<div style="clear:both;"></div>
</div>
<!--<div class="homepageRight">-->
<!--<div class="homepageRightBanner">-->
<!--<div class="NewsBannerName">最新动态</div>-->
<!--<ul class="resourcesSelect">-->
<!--<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>-->
<!--<ul class="resourcesType">-->
<!--<li class="mt-4"><a href="javascript:void(0);" class="homepagePostTypeAll postTypeGrey">全部动态</a></li>-->
<!--<li class="mt-4"><a href="/users/8523/user_activities?type=current_user" class="homepagePostTypeMine postTypeGrey">我的动态</a> </li>-->
<!--</ul>-->
<!--</li>-->
<!--</ul>-->
<!--</div>-->
<!--<div class="resources mt10">-->
<!--<div class="homepagePostBrief">-->
<!--<div class="homepagePostPortrait"><a href="javascript:void(0);"><img src="images/homepageImage.jpg" width="50" height="50" alt="用户头像" /></a></div>-->
<!--<div class="homepagePostDes">-->
<!--<div class="homepagePostTo"><a href="javascript:void(0);" class="newsBlue mr15">尹教授</a> TO <a href="javascript:void(0);" class="newsBlue ml15">micROS研究团队 | 组织</a></div>-->
<!--<div class="homepagePostTitle"><a href="javascript:void(0);" class="postGrey">如何打造一场罗永浩式的精彩演讲?</a></div>-->
<!--<div class="homepagePostDate"> 发帖时间2015-11-02 11:25 </div>-->
<!--<div class="homepagePostIntro">罗永浩已经把他的主题演讲成功变成了一次次的重大的媒体事件,这让科技界和营销界的从业者们羡慕不已。事实上,老罗不仅从乔布斯那里继承了乔式审美,设计哲学,同时也继承了乔布斯的演讲艺术。乔布斯是人类历史上最伟大的演讲者。在一次又一次的"罗氏演讲"中,我们可以清晰看到老罗对乔布斯演讲的拆解,学习,模仿。每一次的公开演讲,都是一堂案例级的营销课程,值得每一位有志于从事营销相关的朋友分析研究。<br />-->
<!--下面,我们将从"故事"、"现场"、"准备"三个方面分析学习老罗的演讲技巧,教你如何打造一场"罗永浩式"的演讲。 </div>-->
<!--<div class="homepagePostSetting">-->
<!--<ul>-->
<!--<li class="homepagePostSettingIcon">-->
<!--<ul class="homepagePostSettiongText">-->
<!--<li><a href="javascript:void(0);" class="postOptionLink">设为首页</a></li>-->
<!--<li><a href="javascript:void(0);" class="postOptionLink">编辑文章</a></li>-->
<!--<li><a href="javascript:void(0);" class="postOptionLink">删除文章</a></li>-->
<!--</ul>-->
<!--</li>-->
<!--</ul>-->
<!--</div>-->
<!--</div>-->
<!--<div class="cl"></div>-->
<!--</div>-->
<!--<div class="homepagePostReply">-->
<!--<div class="homepagePostReplyBanner">-->
<!--<div class="homepagePostReplyBannerCount">回复2</div>-->
<!--&lt;!&ndash;<div class="homepagePostReplyBannerTime">2015-07-31</div>&ndash;&gt;-->
<!--&lt;!&ndash;<div class="homepagePostReplyBannerMore"><a href="javascript:void(0);" class="replyGrey">点击展开更多回复</a></div>&ndash;&gt;-->
<!--</div>-->
<!--<div class="homepagePostReplyContainer">-->
<!--<div class="homepagePostReplyPortrait"><a href="javascript:void(0);"><img src="images/homepageImage.jpg" width="33" height="33" alt="用户头像" /></a></div>-->
<!--<div class="homepagePostReplyDes">-->
<!--<div class="homepagePostReplyPublisher"><a href="javascript:void(0);" class="newsBlue mr10 f14">黄井泉 学生</a> 2015-11-03 12:26</div>-->
<!--<div class="homepagePostReplyContent">学习下!</div>-->
<!--</div>-->
<!--<div class="cl"></div>-->
<!--</div>-->
<!--<div class="homepagePostReplyContainer">-->
<!--<div class="homepagePostReplyPortrait"><a href="javascript:void(0);"><img src="images/homepageImage.jpg" width="33" height="33" alt="用户头像" /></a></div>-->
<!--<div class="homepagePostReplyDes">-->
<!--<div class="homepagePostReplyPublisher"><a href="javascript:void(0);" class="newsBlue mr10 f14">陈正东 学生</a> 2015-11-02 17:08</div>-->
<!--<div class="homepagePostReplyContent">锤子手机,卖的就是情怀</div>-->
<!--</div>-->
<!--<div class="cl"></div>-->
<!--</div>-->
<!--<div class="homepagePostReplyContainer">-->
<!--<div class="homepagePostReplyPortrait mr15"><a href="javascript:void(0);"><img src="images/homepageImage.jpg" width="33" height="33" alt="用户头像" /></a></div>-->
<!--<div class="homepagePostReplyInputContainer">-->
<!--<textarea class="homepagePostReplyInput fl mr15" placeholder="请输入回复"></textarea>-->
<!--<a href="javascript:void(0);" class="homepagePostReplyEmotion mt5"></a> <a href="javascript:void(0);" class="homepagePostReplySubmit postReplySubmit fl mt5">发送</a> </div>-->
<!--<div class="cl"></div>-->
<!--</div>-->
<!--<div class="cl"></div>-->
<!--</div>-->
<!--</div>-->
<!--<div class="resources mt10">-->
<!--<div class="homepagePostBrief">-->
<!--<div class="homepagePostPortrait"><a href="javascript:void(0);"><img src="images/homepageImage.jpg" width="50" height="50" alt="用户头像" /></a></div>-->
<!--<div class="homepagePostDes">-->
<!--<div class="homepagePostTo"><a href="javascript:void(0);" class="newsBlue mr10">唐湘政</a> 创建了 <a href="javascript:void(0);" class="newsBlue ml10">micROS研究团队-->
<!--| 组织</a></div>-->
<!--<div class="homepagePostTitle"><a href="javascript:void(0);" class="postGrey">micROS研究团队 </a></div>-->
<!--<div class="homepagePostDate"> 创建时间2015-10-29 11:23 </div>-->
<!--</div>-->
<!--<div class="cl"></div>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
</div>
</div>
<!--页面底部-->
<div class="cl"></div>
<%= render :partial => 'layouts/footer' %>

View File

@ -581,10 +581,7 @@
}
});
//查询学校
$("input[name='province']").on('input', function (e) {
throttle(shcool_search_fn,window,e);
});
function throttle(method,context,e){
clearTimeout(method.tId);
@ -606,7 +603,10 @@
type: 'post',
success: function (data) {
schoolsResult = data.schools;
count = data.count;
count = data.count; //查询学校
$("input[name='province']").on('input', function (e) {
throttle(shcool_search_fn,window,e);
});
maxPage = Math.ceil(count/100) //最大页码值
if(schoolsResult.length != undefined && schoolsResult.length != 0) {
var i = 0;

View File

@ -0,0 +1,40 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg'%>
<script>
function check_org_title(title)
{
if($("#document_title").val().trim() == "")
{
$("#doc_title_hint").html("<span class='c_red'>标题不能为空</span>").show();
}
else
{
$("#doc_title_hint").hide();
}
}
</script>
<%= form_tag organization_org_document_comments_path(:organization_id => @organization.id), :id => 'new_org_document_form' do |f| %>
<div class="resources">
<div>
<input class="postDetailInput fl mr15" style="margin-bottom:15px;" name="org_document_comment[title]" id="document_title" style="resize:none;" onfocus = "$('#org_document_editor').show();" onblur="check_org_title();" placeholder="请输入文章标题"></input>
</div>
<div id="doc_title_hint"></div>
<div id="org_document_editor" class="mt15" style="display: none">
<div class="mt10">
<%= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %>
</div>
<div class="cl"></div>
<p id="homework_course_id_span" class="c_red mt5"></p>
<div class="cl"></div>
<div class="mt5">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="org_document_description_editor.sync();$('#new_org_document_form').submit();">确定</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" onclick="$('#org_document_editor').hide(); $('#doc_title_hint').hide();" class="fr mr10 mt3">取消</a>
<div class="cl"></div>
</div>
</div>
</div>
<% end %>

View File

@ -0,0 +1,3 @@
$("#organization_document_<%= @document.id %>").html("");
$("#organization_document_<%= @document.id %>").html("<%= escape_javascript(render :partial => 'organizations/show_org_document', :locals => {:document => @document}) %>");
init_activity_KindEditor_data(<%= @document.id %>,"","87%");

View File

@ -0,0 +1 @@
location.reload();

View File

@ -0,0 +1,26 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor" %>
<style type="text/css">
/*回复框*/
.homepagePostReplyInputContainer .ke-toolbar {display: none; width: 400px; border: none; background: none; padding: 0px 0px;}
.homepagePostReplyInputContainer .ke-toolbar-icon {line-height: 26px; font-size: 14px; padding-left: 26px;}
.homepagePostReplyInputContainer .ke-toolbar-icon-url {background-image: url(/images/public_icon.png)}
.homepagePostReplyInputContainer .ke-outline {padding: 0px 0px; line-height: 26px; font-size: 14px;}
.homepagePostReplyInputContainer .ke-icon-emoticons {background-position: 0px -671px; width: 50px; height: 26px;}
.homepagePostReplyInputContainer .ke-icon-emoticons:hover {background-position: -79px -671px; width: 50px; height: 26px;}
.homepagePostReplyInputContainer .ke-outline {border: none;}
.homepagePostReplyInputContainer .ke-inline-block {display: none;}
.homepagePostReplyInputContainer .ke-container {float: left;}
</style>
<%= render :partial => 'new' %>
<% unless @documents.nil? %>
<% @documents.each do |document| %>
<script>
$(function() {
init_activity_KindEditor_data(<%= document.id%>, null, "87%");
});
</script>
<div id="organization_document_<%= document.id %>">
<%= render :partial => 'organizations/show_org_document', :locals => {:document => document} %>
</div>
<% end %>
<% end %>

View File

@ -0,0 +1,40 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg'%>
<script>
function check_org_title(title)
{
if($("#document_title").val().trim() == "")
{
$("#doc_title_hint").html("<span class='c_red'>标题不能为空</span>").show();
}
else
{
$("#doc_title_hint").hide();
}
}
</script>
<%= form_tag organization_org_document_comments_path(:organization_id => @organization.id), :id => 'new_org_document_form' do |f| %>
<div class="resources">
<div>
<textarea class="postDetailInput fl mr15" style="margin-bottom:15px;" name="org_document_comment[title]" id="document_title" style="resize:none;" onfocus = "$('#org_document_editor').show();" onblur="check_org_title();" placeholder="请输入文章标题"></textarea>
</div>
<div id="doc_title_hint"></div>
<div id="org_document_editor" class="mt15" style="display: none">
<div class="mt10">
<%= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %>
</div>
<div class="cl"></div>
<p id="homework_course_id_span" class="c_red mt5"></p>
<div class="cl"></div>
<div class="mt5">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="org_document_description_editor.sync();$('#new_org_document_form').submit();">确定</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" onclick="$('#org_document_editor').hide(); $('#doc_title_hint').hide();" class="fr mr10 mt3">取消</a>
<div class="cl"></div>
</div>
</div>
</div>
<% end %>

View File

@ -0,0 +1,4 @@
$("#search_orgs_result_list").next().html("");
$("#added_orgs").html("");
$("#added_orgs").html('<%= escape_javascript(render :partial => "projects/settings/added_orgs", :locals => {:orgs => @project.organizations, :project_id => @project.id}) %>')

View File

@ -0,0 +1,2 @@
$("#added_orgs").html("");
$("#added_orgs").html('<%= escape_javascript(render :partial => "projects/settings/added_orgs", :locals => {:orgs => @project.organizations, :project_id => @project.id}) %>')

View File

@ -1,21 +0,0 @@
<%= error_messages_for 'project' %>
<!--[form:project]-->
<% unless @organizations.new_record? %>
<p>
<%= render :partial=>"avatar/avatar_form",:locals=> {source:@organizations} %>
</p>
<% end %>
<p>
<label for="project_description">
<%= l(:label_organization_name)%>
<span class="required">&nbsp;&nbsp;</span>
</label>
<%= f.text_field :name, :required => true, :size => 60, :style => "width:290px;" %>
</p>
<!--<p>-->
<!--<label for="project_description">-->
<%#= l(:field_description)%>
<!--<span class="required">&nbsp;&nbsp;</span>-->
<!--</label>-->
<!--<%#= f.text_area :description, :required => true, :size => 60, :style => "width:490px;" %>-->
<!--</p>-->

View File

@ -1,25 +0,0 @@
<%= form_for(@organization) do |f|%>
<h3>
<%=l(:label_organization_edit)%>
</h3>
<div class="box tabular" >
<%= error_messages_for 'project' %>
<p>
<%= render :partial=>"avatar/avatar_form",:locals=> {source:@organization} %>
</p>
<p>
<label for="project_description">
<%= l(:label_organization_name)%>
<span class="required">&nbsp;&nbsp;</span>
</label>
<%= f.text_field :name, :required => true, :size => 60, :style => "width:290px;" %>
</p>
<span style="padding-left: 60px">
<%= submit_tag l(:button_create), :class => "enterprise"%>
</span>
</div>
<%#= submit_tag l(:button_create_and_continue), :name => 'continue' %>
<%= javascript_tag "$('#project_name').focus();" %>
<% end %>
<% html_title(l(:label_organization_edit)) -%>

View File

@ -1,31 +0,0 @@
<title>
<%= l(:label_all_enterprises) %>
</title>
<div class="content_syqy">
<div class="list">
<%= l(:label_all_enterprises) %>
</div>
<div class="syqy_box">
<% if @organizations.empty? %>
<h3>
<%= l(:label_enterprise_nil) %>
</h3>
<% else %>
<% @organizations.each do |organization| %>
<% unless organization.name.blank? %>
<ul>
<li >
<img src="/images/organization_logo.jpg" width="30" height="30" alt="<%= organization.name%>" />
<%= link_to organization.name, home_path(:organization => organization.id) %>
</li>
</ul>
<% end %>
<% end %>
<% end %>
</div>
</div>
<div style="clear: both"></div>
<div class="school-index">
<ul id="schoollist" style="line-height: 25px"></ul>
</div>
<% html_title(l(:label_enterprise_all)) -%>

View File

@ -1,18 +0,0 @@
<%= form_for(@organizations, :method => :post,
:name => 'new_form',
:url => {:controller => 'organization',
:action => 'create'}) do |f|%>
<h3>
<%=l(:label_organization_new)%>
</h3>
<div class="box tabular" >
<%= render :partial => 'form', :locals => { :f => f } %>
<span style="padding-left: 60px">
<%= submit_tag l(:button_create), :class => "enterprise"%>
</span>
</div>
<%#= submit_tag l(:button_create_and_continue), :name => 'continue' %>
<%= javascript_tag "$('#project_name').focus();" %>
<% end %>
<% html_title(l(:label_organization_new)) -%>

View File

@ -0,0 +1,90 @@
<div class="resources mt10">
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(User.find(document.creator_id)), :width => 45, :heigth => 45), user_path(document.creator_id) %>
</div>
<div class="homepagePostDes">
<div class="homepagePostTo">
<%= link_to User.find(document.creator_id), user_path(document.creator.id), :class => "newsBlue mr15" %>
TO<%= link_to document.organization.name, organization_path(document.organization) %> | 组织
</div>
<div class="homepagePostTitle postGrey"><%= document.title %></div>
<div class="homepagePostDate">
发帖时间:<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %></div>
<% unless document.content.blank? %>
<div class="homepagePostIntro">
<%= document.content.html_safe %>
</div>
<% end %>
<div class="homepagePostSetting">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<%= form_for('new_form',:url => {:controller => 'organizations',:action => 'set_homepage',:id => document.organization_id, :home_id => document.id},:method => "put",:remote => true) do |f|%>
<a href="javascript:void(0);" class="postOptionLink" onclick="$(this).parent().submit();">设为首页</a>
<% end %>
</li>
<li><a href="javascript:void(0);" class="postOptionLink">编辑文章</a></li>
<li>
<%= link_to "删除文章", org_document_comment_path(:id => document.id, :organization_id => document.organization_id), :method => 'delete',:remote => true, :class => 'postOptionLink' %>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="cl"></div>
</div>
<% comments_for_doc = document.children.reorder("created_at desc") %>
<div class="homepagePostReply" style="background-color: #f1f1f1;">
<div class="homepagePostReplyBanner">
<div class="homepagePostReplyBannerCount">回复(<%= document.children.count() %></div>
<% if count > 3 %>
<div class="homepagePostReplyBannerMore">
<a id="reply_btn_<%= document.id %>" onclick="expand_reply('#reply_div_<%= document.id %> li','#reply_btn_<%=document.id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help">
展开更多
</a>
</div>
<% end %>
<!--<div class="homepagePostReplyBannerTime">2015-07-31</div>-->
<!--<div class="homepagePostReplyBannerMore"><a href="javascript:void(0);" class="replyGrey">点击展开更多回复</a></div>-->
<div class="homepagePostReplyContainer">
<% comments_for_doc.each do |comment| %>
<div class="homepagePostReplyPortrait"><%= image_tag(url_to_avatar(User.find(comment.creator_id)), :width => 33, :height => 33, :alt => "用户头像") %></div>
<div class="homepagePostReplyDes">
<div class="homepagePostReplyPublisher">
<%= link_to User.find(comment.creator_id), user_path(comment.creator_id), :class => "newsBlue mr10 f14" %>
<%= format_activity_day(comment.created_at) %> <%= format_time(comment.created_at, false) %>
</div>
<% unless comment.content.blank? %>
<div class="homepagePostReplyContent"><%= comment.content.html_safe %></div>
<% end %>
</div>
<div class="cl"></div>
<% end %>
</div>
<div class="homepagePostReplyContainer">
<div class="homepagePostReplyPortrait mr15">
<%= image_tag(url_to_avatar(User.current), :width => "33", :height => "33", :alt => "用户头像") %>
</div>
<div class="homepagePostReplyInputContainer">
<div nhname='new_message_<%= document.id %>' style="display:none;">
<%= form_for('new_form', :url => add_reply_org_document_comment_path(:id => document.id), :method => "post", :remote => true) do |f| %>
<input type="hidden" name="user_activity_id" value="<%= document.id %>">
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= document.id %>' name="org_content"></textarea>
<div nhname='toolbar_container_<%= document.id %>' style="float:left;padding-top:3px; margin-left: 5px;"></div>
<a id="new_message_submit_btn_<%= document.id %>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:6px;line-height:18px;">发送</a>
<div class="cl"></div>
<p nhname='contentmsg_<%= document.id %>'></p>
<% end %>
</div>
</div>
<div class="cl"></div>
</div>
<div class="cl"></div>
</div>
</div>
</div>

View File

@ -0,0 +1,13 @@
<% if @project%>
var checked = $("#not_org_members input:checked").size();
if(checked > 0)
{
alert('翻页或搜索后将丢失当前选择的用户数据!');
}
<% if @flag == "true"%>
$('#new_orgs_for_project').html('<%= escape_javascript(search_public_orgs_not_in_project(@project.id)) %>');
<% else%>
$('#new_orgs_for_project').html('<%= escape_javascript(search_public_orgs_not_in_project(@project.id)) %>');
<% end%>
<%end%>

View File

@ -0,0 +1 @@
location.reload();

View File

@ -89,7 +89,8 @@
<%= javascript_tag "observeSearchfield('not_org_member_search', null, '#{ escape_javascript org_member_autocomplete_org_member_index_path(:org=>@organization, :format => 'js') }')" %>
<div id="principals_for_new_member">
<%= find_user_not_in_current_org_by_name(@project) %>
</div><div class="cl"></div>
</div>
<div class="cl"></div>
<ul class="orgAddRole">
<li class="fontGrey3 fb mb10">角色</li>
<li>

View File

@ -1,5 +1,7 @@
<%= javascript_include_tag "jquery.infinitescroll.js" %>
<% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 %>
<%= render :partial => 'show_org_document', :locals => {:document => OrgDocumentComment.find(@organization.home_id)} %>
<% end %>
<div class="homepageRightBanner">
<div class="NewsBannerName">最新动态</div>
<ul class="resourcesSelect">
@ -28,6 +30,9 @@
</div>
</div>
<% end %>
<% if act.org_act_type == 'OrgDocumentComment' %>
<%= render :partial => 'show_org_document', :locals => {:document => act.org_act} %>
<% end %>
<% end %>
<ul class="wlist" style=" border:none; padding-top: 15px;">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>

View File

@ -12,6 +12,7 @@
project_setting(6);
$("#pro_st_edit_ku").toggle();
<%else%>
project_setting(5);
<% end%>
<% end%>
$("div[nhname='pro_setting']").show();
@ -36,6 +37,7 @@
<% if User.current.allowed_to?(:manage_members, @project) %>
<li id="pro_st_tb_3" class="<%= show_memu == 'manage_members' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(3);">成员</li>
<% end %>
<li id="pro_st_tb_5" class="<%= show_memu == 'join_org' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(5);">组织</li>
<% if User.current.allowed_to?(:manage_versions, @project) %>
<li id="pro_st_tb_4" class="<%= show_memu == 'manage_versions' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(4);">版本</li>
<% end %>
@ -63,6 +65,7 @@
<%= render :partial=>"projects/settings/new_members" if User.current.allowed_to?(:manage_members, @project)%>
</div><!--tbc_03 end-->
<div class="<%= show_memu == 'manage_versions' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_04">
<%= render :partial=>"projects/settings/new_versions" if User.current.allowed_to?(:manage_versions, @project)%>
</div><!--tbc_04 end-->
@ -70,6 +73,9 @@
<!--<div class="pro_st_undis" id="pro_st_tbc_05">-->
<!--<%#= render :partial=>"projects/settings/new_issue_categories" %>-->
<!--</div>&lt;!&ndash;tbc_05 end&ndash;&gt;-->
<div class="<%= show_memu == 'join_org' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_05">
<%= render :partial=>"projects/settings/join_org" %>
</div>
<div class="<%= show_memu == 'manage_repository' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_06">
<%= render :partial=>"projects/settings/new_repositories" if User.current.allowed_to?(:manage_repository, @project)%>

View File

@ -0,0 +1,9 @@
<ul>
<li><span class="relatedListName fb fl">名称</span><span class="relatedListOption fb fl">操作</span></li>
<% orgs.each do |org| %>
<li><a href="javascript:void(0);" class="relatedListName linkBlue fl"><%= org.name %></a>
<%= link_to "取消关联", org_project_path(:id => OrgProject.where(:organization_id => org.id, :project_id => project_id).first.id, :project_id => project_id),
:method => 'delete',:remote => true, :class => "relatedListOption fl linkGrey3" %>
</li>
<% end %>
</ul>

View File

@ -0,0 +1,108 @@
<!--<div class="members_left">-->
<!--<input type="text" id="orgs_not_project_member_search" name="orgAddSearch" placeholder="支持姓名、邮箱、昵称搜索" class="orgAddSearch mb20" />-->
<!--<%#= javascript_tag "observeSearchfield('orgs_not_project_member_search', null, '#{ escape_javascript autocomplete_search_organizations_path(:project_id=> @project.id, :format => 'js') }')" %>-->
<!--<div id="new_orgs_for_project">-->
<!--</div>-->
<!--</div>-->
<%= stylesheet_link_tag 'org' %>
<ul class="mb10">
<li class="orgSettingOp orgOpActive" id="orgSetting_1">组织</li>
<li class="orgBorder" style="width:625px;"></li>
<div class="cl"></div>
</ul>
<div>
<div class="relateOrg fl">
<span class="pic_add fl mr5 mt3"></span><span class="f14 fontBlue fl">关联组织</span>
<div class="cl mb5"></div>
<%= form_tag url_for(:controller => 'org_projects', :action => 'create', :project_id => @project.id), :id => 'join_orgs_for_project', :remote => true %>
<input type="text" name="orgs" class="searchOrg mb5 ml20" placeholder="请输入组织名称" />
<div id="search_orgs_result_list"></div>
<ul class="ml20">
</ul>
<a href="javascript:void(0);" class="saveBtn db fl ml20 mr15 mb5" onclick="$('#join_orgs_for_project').submit();">关联</a>
<a href="javascript:void(0);" class="cancelBtn db fl" onclick="cancel_join_orgs();">取消</a>
</div>
<div class="relatedList fr">
<div class="fr mr15">
<span class="f14 fontBlue">已关联组织</span>
<div id="added_orgs">
<%= render :partial => 'projects/settings/added_orgs', :locals => {:orgs => @project.organizations, :project_id => params[:id]} %>
</div>
<div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var lastSearchCondition = '';
var page = 1;
var count = 0;
var maxPage = 0;
function search_orgs(e){
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
{
return;
}
lastSearchCondition = $(e.target).val().trim();
page = 1;
$.ajax({
url: '<%= url_for(:controller => 'projects', :action => 'search_public_orgs_not_in_project') %>'+'?name='+ e.target.value+'&page='+page,
type:'post',
success: function(data){
orgs = data.orgs;
count = data.count;
maxPage = Math.ceil(count/10);
$("#search_orgs_result_list").next().html("");
if(orgs.length != undefined && orgs.length != 0){
var i = 0;
for(; i<orgs.length; i++){
link = "<li><label><input type='checkbox'class='mr5 fl mt3' name='orgNames[]' value='"+ orgs[i].organization.id + "'/><span class='relateOrgName fl'>" + orgs[i].organization.name + "</span></label></li><div class='cl mt5'></div>";
console.log(link)
$("#search_orgs_result_list").next().append(link );
}
}
}
});
}
function throttle(method,context,e){
clearTimeout(method.tId);
method.tId=setTimeout(function(){
method.call(context,e);
},500);
}
//查询组织
$("input[name='orgs']").on('input', function (e) {
throttle(search_orgs,window,e);
});
$(document).ready(function(){
$.ajax({
url: '<%= url_for(:controller => 'projects', :action => 'search_public_orgs_not_in_project') %>'+'?page=1',
type:'post',
success: function(data){
orgs = data.orgs;
count = data.count;
maxPage = Math.ceil(count/10);
$("#search_orgs_result_list").next().html("");
if(orgs.length != undefined && orgs.length != 0){
var i = 0;
for(; i<orgs.length; i++){
link = "<li><label><input type='checkbox'class='mr5 fl mt3' name='orgNames[]' value='"+ orgs[i].organization.id + "'/><span class='relateOrgName fl'>" + orgs[i].organization.name + "</span></label></li><div class='cl mt5'></div>";
console.log(link)
$("#search_orgs_result_list").next().append(link );
}
}
}
});
});
function cancel_join_orgs() {
$("#search_orgs_result_list").next().html("");
}
</script>

View File

@ -35,9 +35,19 @@ RedmineApp::Application.routes.draw do
member do
get 'setting'#, :action => 'settings', :as => 'settings'
get 'clear_org_avatar_temp'
put 'set_homepage'
end
collection do
get 'check_uniq'
get 'autocomplete_search'
end
resources :org_document_comments do
member do
end
collection do
end
end
end
@ -50,6 +60,25 @@ RedmineApp::Application.routes.draw do
end
end
resources :org_document_comments do
member do
post 'add_reply'
end
collection do
end
end
resources :org_projects do
member do
end
collection do
end
end
#match '/organizations/:organization_id/org_document_comments/new', :to => 'org_document_comments#new', :as => 'new_org_documents', :via => [:get, :post]
#match '/organizations/:organization_id/org_document_comments/create', :to => 'org_document_comments#create', :as => 'create_org_documents', :via => [:post]
resources :homework_users
resources :no_uses
delete 'no_uses', :to => 'no_uses#delete'
@ -493,6 +522,7 @@ RedmineApp::Application.routes.draw do
post 'unarchive'
post 'close'
post 'reopen'
post 'search_public_orgs_not_in_project'
match 'copy', :via => [:get, :post]
end

View File

@ -0,0 +1,13 @@
class CreateOrgDocumentComments < ActiveRecord::Migration
def change
create_table :org_document_comments do |t|
t.string :title
t.text :content
t.integer :organization_id
t.integer :creator_id
t.integer :parent_id
t.integer :reply_id
t.timestamps
end
end
end

View File

@ -0,0 +1,6 @@
class AddLockedAndStickyColumnToEntityOrgDocumentComments < ActiveRecord::Migration
def change
add_column :org_document_comments,:locked,:boolean,:default => false
add_column :org_document_comments,:sticky,:integer,:default => 0
end
end

View File

@ -0,0 +1,16 @@
class CreateOrgActivity < ActiveRecord::Migration
def up
create_table :org_activities do |t|
t.integer :user_id
t.integer :act_id
t.string :act_type
t.integer :container_id
t.string :container_type
t.timestamps
end
end
def down
end
end

View File

@ -0,0 +1,11 @@
class CreateOrgProjects < ActiveRecord::Migration
def up
create_table :org_projects do |t|
t.integer :organization_id
t.integer :project_id
end
end
def down
end
end

View File

@ -0,0 +1,8 @@
class DeleteColumnRoleFromOrgMembers < ActiveRecord::Migration
def up
remove_column :org_members, :role
end
def down
end
end

View File

@ -0,0 +1,6 @@
class RenameColumnForOrgActivity < ActiveRecord::Migration
def change
rename_column :org_activities,:act_id,:org_act_id
rename_column :org_activities,:act_type,:org_act_type
end
end

View File

@ -0,0 +1,11 @@
class CreateOrgMemberRoles < ActiveRecord::Migration
def up
create_table :org_member_roles do |t|
t.integer :org_member_id
t.integer :role_id
end
end
def down
end
end

View File

@ -0,0 +1,5 @@
class AddTimeToOrgProject < ActiveRecord::Migration
def change
add_column :org_projects, :created_at, :timestamp
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 => 20151104090032) do
ActiveRecord::Schema.define(:version => 20151110011003) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -1209,8 +1209,9 @@ ActiveRecord::Schema.define(:version => 20151104090032) do
end
create_table "org_projects", :force => true do |t|
t.integer "organization_id"
t.integer "project_id"
t.integer "organization_id"
t.integer "project_id"
t.datetime "created_at"
end
create_table "organizations", :force => true do |t|

View File

@ -30,4 +30,15 @@ a.saveBtn:hover {background-color:#297fb8;}
.upbtn { margin: 40px 0px 0px 15px;
display: block;
padding: 2px 5px;
border: 1px solid #EAEAEA;}
border: 1px solid #EAEAEA;}
/*项目关联css*/
.relateOrg {width:335px;}
.relatedList {width:335px;}
.searchOrg {height:24px; width:200px; color:#9b9b9b9; border:1px solid #15bccf;}
a.cancelBtn {padding:3px 5px; background-color:#D9D9D9; color:#656565;}
a.cancelBtn:hover {background-color:#717171; color:#ffffff;}
.relatedList ul li {border-bottom:1px solid #e4e4e4; width:320px; height:22px; vertical-align:middle; line-height:22px;}
.relatedListName {width:240px; text-align:left; max-width:240px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;}
.relatedListOption {width:80px; text-align:center;}
.relateOrgName {width:240px; max-width:240px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;color:#656565;}

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe OrgDocumentCommentController, :type => :controller do
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe OrgMemberController, :type => :controller do
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe OrgProjectsController, :type => :controller do
end

View File

@ -0,0 +1,6 @@
FactoryGirl.define do
factory :org_activity do
end
end

View File

@ -0,0 +1,11 @@
FactoryGirl.define do
factory :org_document_comment do
title "MyString"
content "MyText"
organization_id 1
creator_id 1
parent_id 1
reply_id 1
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe OrgActivity, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe OrgDocumentComment, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end