组织配置界面,成员列表分页

This commit is contained in:
daiao 2016-09-02 13:25:01 +08:00
parent 548a263f0f
commit 27ad94eac2
14 changed files with 73 additions and 35 deletions

View File

@ -8,18 +8,33 @@ class OrgMemberController < ApplicationController
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
@org = Organization.find(params[:org])
@organization = Organization.find(params[:org])
if params[:membership].nil?
@fail_hint = l(:label_blank_user_lists_for_org)
else
member_ids = params[:membership][:user_ids]
role_id = params[:orgRole]
member_ids.each do |user_id|
member = OrgMember.create(:user_id=>user_id, :created_at => Time.now)
@org.org_members << member
member = OrgMember.create(:user_id => user_id, :created_at => Time.now)
@organization.org_members << member
OrgMemberRole.create(:org_member_id => member.id, :role_id => role_id)
end
@members = (@organization.org_members).sort
@members = paginateHelper @members, 20
end
respond_to do |format|
format.js
@ -32,7 +47,11 @@ class OrgMemberController < ApplicationController
@member_role = @member.org_member_roles[0]
@member_role.role_id = params[:org_member][:role_ids][0]
@member_role.save
@org = @member.organization
@organization = @member.organization
# 成员编辑角色后分页
@members = (@organization.org_members).sort
@members = paginateHelper @members, 20
respond_to do |format|
format.js
end
@ -44,8 +63,10 @@ class OrgMemberController < ApplicationController
def destroy
member = OrgMember.find(params[:id])
@org = member.organization
@organization = member.organization
member.destroy
@members = (@organization.org_members).sort
@members = paginateHelper @members, 20
respond_to do |format|
format.js
end

View File

@ -422,6 +422,7 @@ class OrganizationsController < ApplicationController
if User.current.admin? || User.current.admin_of_org?(@organization)
@members = OrgMember.where(:organization_id => @organization.id).all.sort
@members = paginateHelper @members, 20
else
render_403
end

View File

@ -1,5 +1,6 @@
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])

View File

@ -1,8 +1,9 @@
<% if @fail_hint %>
alert("<%= @fail_hint %>");
<% 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('');
$("#org_members_count_id").html("<%= @org.org_members.count %>");
$("#org_members_count_id").html("<%= @organization.org_members.count %>");
$("#not_org_member_search").val("");
<% end %>

View File

@ -1,3 +1,4 @@
// 删除成员后,同步刷新成员列表与左侧成员显示数
$("#org_members_count_id").html("");
$("#org_members_count_id").html("<%= @org.org_members.count %>")
$("#org_member_list").html('<%= escape_javascript( render :partial=>"organizations/org_member_list",:locals=> {:members=>@org.org_members}) %>');
$("#org_members_count_id").html("<%= @organization.org_members.count %>");
$("#org_member_list").html('<%= escape_javascript( render :partial => "organizations/org_member_list", :locals=> {:members => @members}) %>');

View File

@ -1,3 +1,4 @@
// 组织成员删除后,同步刷新成员数和成员列表
$("#org_members_count_id").html("");
$("#org_members_count_id").html("<%= @org.org_members.count %>")
$("#org_member_list").html('<%= escape_javascript( render :partial=>"organizations/org_member_list",:locals=> {:members=>@org.org_members}) %>');
$("#org_members_count_id").html("<%= @organization.org_members.count %>");
$("#org_member_list").html('<%= escape_javascript( render :partial => "organizations/org_member_list", :locals => {:members => @members}) %>');

View File

@ -1,23 +1,23 @@
<% if @org%>
<% if @org %>
var checked = $("#principals_for_new_member input:checked").size();
if(checked > 0)
{
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)) %>');
<% else%>
$('#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");
collection.css("text-overflow","ellipsis");
collection.css("white-space","nowrap");
collection.css("width","200px");
collection.css("overflow","hidden");
for(i=0;i<collection.length;i++){ //增加悬浮显示
var label=collection[i];
var text=$(label).text();
$(label).attr("title",text);
<% end %>
var collection = $("#principals_for_new_member").children("#principals").children("label");
collection.css("text-overflow", "ellipsis");
collection.css("white-space", "nowrap");
collection.css("width", "200px");
collection.css("overflow", "hidden");
for(i = 0; i < collection.length; i++){ //增加悬浮显示
var label = collection[i];
var text = $(label).text();
$(label).attr("title", text);
}

View File

@ -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 %>

View File

@ -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}) %>');

View File

@ -40,4 +40,9 @@
</ul>
<div class="cl"></div>
<% 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>

View File

@ -1,7 +1,7 @@
<% if !@org_name.blank? %>
<%if @check == false %>
$checkName = false
<% if @config_page%>
$checkName = false;
<% if @config_page %>
$("#check_name_hint").html('<span class="c_red">名字不能重复<span>').show();
<% else%>
$("#organization_name_notice").html('<span class="c_red">名字不能重复<span>').show();
@ -10,7 +10,7 @@
<% else %>
$checkName = true;
<% if @config_page%>
<% if @config_page %>
$("#check_name_hint").html('<span class="c_green">名字可以使用</span>').show();
<% else%>

View File

@ -18,7 +18,7 @@
return false ;
}
$.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){
@ -248,3 +248,4 @@
});
}
</script>

View File

@ -116,6 +116,7 @@ RedmineApp::Application.routes.draw do
end
collection do
get 'org_member_autocomplete'
get 'org_member_paging'
get 'deleteOrgMember'
end
end

View File

@ -550,8 +550,8 @@ function observeSearchfield(fieldId, targetId, url) {
dataType: 'jsonp',
data: {q: $this.val()},
success: function(data){ if(targetId) $('#'+targetId).html(data); },
beforeSend: function(){ $this.addClass('ajax-loading'); },
complete: function(){ $this.removeClass('ajax-loading'); }
beforeSend: function(){ $this.addClass('ajax-loading'); }, // 添加成员加载完成前,显示载入中
complete: function(){ $this.removeClass('ajax-loading'); } // 完成后,移除
});
}
};