组织配置界面,成员列表分页
This commit is contained in:
parent
548a263f0f
commit
27ad94eac2
|
@ -8,18 +8,33 @@ class OrgMemberController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 组织子成员,及其分页
|
||||||
|
def org_member_paging
|
||||||
|
@organization = Organization.find(params[:org])
|
||||||
|
|
||||||
|
if User.current.admin? || User.current.admin_of_org?(@organization)
|
||||||
|
@members = OrgMember.where(:organization_id => @organization.id).all.sort
|
||||||
|
@members = paginateHelper @members, 20
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@org = Organization.find(params[:org])
|
@organization = Organization.find(params[:org])
|
||||||
if params[:membership].nil?
|
if params[:membership].nil?
|
||||||
@fail_hint = l(:label_blank_user_lists_for_org)
|
@fail_hint = l(:label_blank_user_lists_for_org)
|
||||||
else
|
else
|
||||||
member_ids = params[:membership][:user_ids]
|
member_ids = params[:membership][:user_ids]
|
||||||
role_id = params[:orgRole]
|
role_id = params[:orgRole]
|
||||||
member_ids.each do |user_id|
|
member_ids.each do |user_id|
|
||||||
member = OrgMember.create(:user_id=>user_id, :created_at => Time.now)
|
member = OrgMember.create(:user_id => user_id, :created_at => Time.now)
|
||||||
@org.org_members << member
|
@organization.org_members << member
|
||||||
OrgMemberRole.create(:org_member_id => member.id, :role_id => role_id)
|
OrgMemberRole.create(:org_member_id => member.id, :role_id => role_id)
|
||||||
end
|
end
|
||||||
|
@members = (@organization.org_members).sort
|
||||||
|
@members = paginateHelper @members, 20
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
|
@ -32,7 +47,11 @@ class OrgMemberController < ApplicationController
|
||||||
@member_role = @member.org_member_roles[0]
|
@member_role = @member.org_member_roles[0]
|
||||||
@member_role.role_id = params[:org_member][:role_ids][0]
|
@member_role.role_id = params[:org_member][:role_ids][0]
|
||||||
@member_role.save
|
@member_role.save
|
||||||
@org = @member.organization
|
@organization = @member.organization
|
||||||
|
# 成员编辑角色后分页
|
||||||
|
@members = (@organization.org_members).sort
|
||||||
|
@members = paginateHelper @members, 20
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
@ -44,8 +63,10 @@ class OrgMemberController < ApplicationController
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
member = OrgMember.find(params[:id])
|
member = OrgMember.find(params[:id])
|
||||||
@org = member.organization
|
@organization = member.organization
|
||||||
member.destroy
|
member.destroy
|
||||||
|
@members = (@organization.org_members).sort
|
||||||
|
@members = paginateHelper @members, 20
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
|
|
@ -422,6 +422,7 @@ class OrganizationsController < ApplicationController
|
||||||
|
|
||||||
if User.current.admin? || User.current.admin_of_org?(@organization)
|
if User.current.admin? || User.current.admin_of_org?(@organization)
|
||||||
@members = OrgMember.where(:organization_id => @organization.id).all.sort
|
@members = OrgMember.where(:organization_id => @organization.id).all.sort
|
||||||
|
@members = paginateHelper @members, 20
|
||||||
else
|
else
|
||||||
render_403
|
render_403
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
module OrgMemberHelper
|
module OrgMemberHelper
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
def find_user_not_in_current_org_by_name org
|
def find_user_not_in_current_org_by_name org
|
||||||
if params[:q] && params[:q].lstrip.rstrip != ""
|
if params[:q] && params[:q].lstrip.rstrip != ""
|
||||||
scope = Principal.active.sorted.not_member_of_org(org).like(params[:q])
|
scope = Principal.active.sorted.not_member_of_org(org).like(params[:q])
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<% if @fail_hint %>
|
<% if @fail_hint %>
|
||||||
alert("<%= @fail_hint %>");
|
alert("<%= @fail_hint %>");
|
||||||
<% else %>
|
<% else %>
|
||||||
$("#org_member_list").html('<%= escape_javascript( render :partial=>"organizations/org_member_list",:locals=> {:members=>@org.org_members}) %>');
|
// 组织添加成员后,同步刷新成员列表,左侧成员数
|
||||||
|
$("#org_member_list").html('<%= escape_javascript( render :partial => "organizations/org_member_list", :locals => {:members => @members}) %>');
|
||||||
$("#principals_for_new_member").html('');
|
$("#principals_for_new_member").html('');
|
||||||
$("#org_members_count_id").html("<%= @org.org_members.count %>");
|
$("#org_members_count_id").html("<%= @organization.org_members.count %>");
|
||||||
$("#not_org_member_search").val("");
|
$("#not_org_member_search").val("");
|
||||||
<% end %>
|
<% end %>
|
|
@ -1,3 +1,4 @@
|
||||||
|
// 删除成员后,同步刷新成员列表与左侧成员显示数
|
||||||
$("#org_members_count_id").html("");
|
$("#org_members_count_id").html("");
|
||||||
$("#org_members_count_id").html("<%= @org.org_members.count %>")
|
$("#org_members_count_id").html("<%= @organization.org_members.count %>");
|
||||||
$("#org_member_list").html('<%= escape_javascript( render :partial=>"organizations/org_member_list",:locals=> {:members=>@org.org_members}) %>');
|
$("#org_member_list").html('<%= escape_javascript( render :partial => "organizations/org_member_list", :locals=> {:members => @members}) %>');
|
|
@ -1,3 +1,4 @@
|
||||||
|
// 组织成员删除后,同步刷新成员数和成员列表
|
||||||
$("#org_members_count_id").html("");
|
$("#org_members_count_id").html("");
|
||||||
$("#org_members_count_id").html("<%= @org.org_members.count %>")
|
$("#org_members_count_id").html("<%= @organization.org_members.count %>");
|
||||||
$("#org_member_list").html('<%= escape_javascript( render :partial=>"organizations/org_member_list",:locals=> {:members=>@org.org_members}) %>');
|
$("#org_member_list").html('<%= escape_javascript( render :partial => "organizations/org_member_list", :locals => {:members => @members}) %>');
|
|
@ -1,23 +1,23 @@
|
||||||
<% if @org%>
|
<% if @org %>
|
||||||
var checked = $("#principals_for_new_member input:checked").size();
|
var checked = $("#principals_for_new_member input:checked").size();
|
||||||
if(checked > 0)
|
if(checked > 0)
|
||||||
{
|
{
|
||||||
alert('翻页或搜索后将丢失当前选择的用户数据!');
|
alert('翻页或搜索后将丢失当前选择的用户数据!');
|
||||||
}
|
}
|
||||||
<% if @flag == "true"%>
|
<%# if @flag == "true"%>
|
||||||
|
// $('#principals_for_new_member').html('<%#= escape_javascript(find_user_not_in_current_org_by_name(@org)) %>');
|
||||||
|
<%# else%>
|
||||||
$('#principals_for_new_member').html('<%= escape_javascript(find_user_not_in_current_org_by_name(@org)) %>');
|
$('#principals_for_new_member').html('<%= escape_javascript(find_user_not_in_current_org_by_name(@org)) %>');
|
||||||
<% else%>
|
<%# end%>
|
||||||
$('#principals_for_new_member').html('<%= escape_javascript(find_user_not_in_current_org_by_name(@org)) %>');
|
|
||||||
<% end%>
|
|
||||||
|
|
||||||
<%end%>
|
<% end %>
|
||||||
var collection=$("#principals_for_new_member").children("#principals").children("label");
|
var collection = $("#principals_for_new_member").children("#principals").children("label");
|
||||||
collection.css("text-overflow","ellipsis");
|
collection.css("text-overflow", "ellipsis");
|
||||||
collection.css("white-space","nowrap");
|
collection.css("white-space", "nowrap");
|
||||||
collection.css("width","200px");
|
collection.css("width", "200px");
|
||||||
collection.css("overflow","hidden");
|
collection.css("overflow", "hidden");
|
||||||
for(i=0;i<collection.length;i++){ //增加悬浮显示
|
for(i = 0; i < collection.length; i++){ //增加悬浮显示
|
||||||
var label=collection[i];
|
var label = collection[i];
|
||||||
var text=$(label).text();
|
var text = $(label).text();
|
||||||
$(label).attr("title",text);
|
$(label).attr("title", text);
|
||||||
}
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
<% if @organization %>
|
||||||
|
// 局部更新组织页面子模块 id = org_member_list
|
||||||
|
$('#org_member_list').html("<%= escape_javascript(render :partial => 'organizations/org_member_list', :locals => {:members => @members}) %>");
|
||||||
|
<% end %>
|
|
@ -1 +1,2 @@
|
||||||
$("#org_member_list").html('<%= escape_javascript( render :partial=>"organizations/org_member_list",:locals=> {:members=>@org.org_members}) %>');
|
// 编辑成员列表角色后,刷新成员列表
|
||||||
|
$("#org_member_list").html('<%= escape_javascript( render :partial => "organizations/org_member_list",:locals => {:members => @members}) %>');
|
|
@ -40,4 +40,9 @@
|
||||||
</ul>
|
</ul>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<ul class="wlist">
|
||||||
|
<!-- 组织配置页面,成员子页面单独分页 -->
|
||||||
|
<%= pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){ |text, parameters, options|
|
||||||
|
link_to text, org_member_paging_org_member_index_path( parameters.merge(:flag => true, :org => @organization.id, :format => 'js')), :remote => true
|
||||||
|
} %>
|
||||||
|
</ul>
|
|
@ -1,7 +1,7 @@
|
||||||
<% if !@org_name.blank? %>
|
<% if !@org_name.blank? %>
|
||||||
<%if @check == false %>
|
<%if @check == false %>
|
||||||
$checkName = false
|
$checkName = false;
|
||||||
<% if @config_page%>
|
<% if @config_page %>
|
||||||
$("#check_name_hint").html('<span class="c_red">名字不能重复<span>').show();
|
$("#check_name_hint").html('<span class="c_red">名字不能重复<span>').show();
|
||||||
<% else%>
|
<% else%>
|
||||||
$("#organization_name_notice").html('<span class="c_red">名字不能重复<span>').show();
|
$("#organization_name_notice").html('<span class="c_red">名字不能重复<span>').show();
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<% else %>
|
<% else %>
|
||||||
$checkName = true;
|
$checkName = true;
|
||||||
<% if @config_page%>
|
<% if @config_page %>
|
||||||
$("#check_name_hint").html('<span class="c_green">名字可以使用</span>').show();
|
$("#check_name_hint").html('<span class="c_green">名字可以使用</span>').show();
|
||||||
<% else%>
|
<% else%>
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
$.get(
|
$.get(
|
||||||
'<%= check_uniq_organizations_path%>'+'?org_name='+$("#organization_name").val().trim()+"&config_page=Y" + "&org_id="+id
|
'<%= check_uniq_organizations_path %>'+'?org_name='+$("#organization_name").val().trim()+"&config_page=Y" + "&org_id="+id
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
function update_org(id, old_value, input_value){
|
function update_org(id, old_value, input_value){
|
||||||
|
@ -248,3 +248,4 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,7 @@ RedmineApp::Application.routes.draw do
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
get 'org_member_autocomplete'
|
get 'org_member_autocomplete'
|
||||||
|
get 'org_member_paging'
|
||||||
get 'deleteOrgMember'
|
get 'deleteOrgMember'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -550,8 +550,8 @@ function observeSearchfield(fieldId, targetId, url) {
|
||||||
dataType: 'jsonp',
|
dataType: 'jsonp',
|
||||||
data: {q: $this.val()},
|
data: {q: $this.val()},
|
||||||
success: function(data){ if(targetId) $('#'+targetId).html(data); },
|
success: function(data){ if(targetId) $('#'+targetId).html(data); },
|
||||||
beforeSend: function(){ $this.addClass('ajax-loading'); },
|
beforeSend: function(){ $this.addClass('ajax-loading'); }, // 添加成员加载完成前,显示载入中
|
||||||
complete: function(){ $this.removeClass('ajax-loading'); }
|
complete: function(){ $this.removeClass('ajax-loading'); } // 完成后,移除
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue