From 2ee04d55f22131fb99501754e842c843f15c34b9 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 12 Mar 2015 15:46:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B9=E7=9B=AE=E9=82=80?= =?UTF-8?q?=E8=AF=B7=E7=94=A8=E6=88=B7=E7=9A=84=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/members_controller.rb | 1 + app/helpers/application_helper.rb | 9 ++++ app/helpers/members_helper.rb | 27 ++++++++++-- app/views/members/autocomplete.js.erb | 18 +++++--- app/views/projects/invite_members.html.erb | 51 +++++++++++++--------- public/stylesheets/application.css | 12 ++++- 6 files changed, 85 insertions(+), 33 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index ce899eff5..a8760a6ef 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -310,6 +310,7 @@ class MembersController < ApplicationController end def autocomplete + @flag = params[:flag] || false respond_to do |format| format.js end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a36f4b183..9629ed437 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -490,6 +490,15 @@ module ApplicationHelper s.html_safe end + #项目成员列表复选框生成 + def project_member_check_box_tags_ex name, principals + s = '' + principals.each do |principal| + s << "
  • #{ check_box_tag name, principal.id, false, :id => nil } #{h link_to principal.userInfo, user_path( principal.id)}
  • \n" + end + s.html_safe + end + #扩展的checkbox生成 def principals_check_box_tags_ex(name, principals) s = '' diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb index 6c11199fb..ed18b7ae4 100644 --- a/app/helpers/members_helper.rb +++ b/app/helpers/members_helper.rb @@ -23,15 +23,22 @@ module MembersHelper principal_count = scope.count principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page'] #by young principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all - s = content_tag('div', principals_check_box_tags_ex('membership[user_ids][]', principals), :id => 'principals') - links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options| link_to text, autocomplete_project_memberships_path(project, parameters.merge(:q => params[:q], :format => 'js')), :remote => true } - s + content_tag('div', content_tag('ul', links), :class => 'pagination_new') + end + #获取项目可邀请的成员列表 + def render_project_members project + scope = Principal.active.sorted.not_member_of(project).like(params[:q]) + principals = paginateHelper scope,10 + s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :style => "margin-left: -40px;") + links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options| + link_to text, autocomplete_project_memberships_path(project, parameters.merge(:q => params[:q],:flag => true, :format => 'js')), :remote => true + } + s + content_tag('ul', links,:class => 'wlist') end # add by nwb @@ -71,4 +78,18 @@ module MembersHelper s + content_tag('div', content_tag('ul', links), :class => 'applied_new') end + private + def paginateHelper obj, pre_size=20 + @obj_count = obj.count + @obj_pages = Redmine::Pagination::Paginator.new @obj_count, pre_size, params['page'] + if obj.kind_of? ActiveRecord::Base or obj.kind_of? ActiveRecord::Relation + obj.limit(@obj_pages.per_page).offset(@obj_pages.offset) + elsif obj.kind_of? Array + obj[@obj_pages.offset, @obj_pages.per_page] + else + logger.error "[ApplicationController] Error : application_controller#paginateHelper ===> unknow category: #{obj.class}" + raise RuntimeError, 'unknow type, Please input you type into this helper.' + end + end + end diff --git a/app/views/members/autocomplete.js.erb b/app/views/members/autocomplete.js.erb index 16809de48..f7f9de151 100644 --- a/app/views/members/autocomplete.js.erb +++ b/app/views/members/autocomplete.js.erb @@ -1,12 +1,16 @@ <% if @project%> -$('#principals_for_new_member').html('<%= escape_javascript(render_principals_for_new_members(@project)) %>'); + <% if @flag == "true"%> + $('#principals_for_new_member').html('<%= escape_javascript(render_project_members(@project)) %>'); + <% else%> + $('#principals_for_new_member').html('<%= escape_javascript(render_principals_for_new_members(@project)) %>'); + <% end%> <% elsif @course%> - var checked = $("#principals input:checked").size(); - if(checked > 0) - { - alert('翻页或搜索后将丢失当前选择的用户数据!'); - } - $('#principals_for_new_member').html('<%= escape_javascript(render_principals_for_new_course_members(@course)) %>'); + var checked = $("#principals input:checked").size(); + if(checked > 0) + { + alert('翻页或搜索后将丢失当前选择的用户数据!'); + } + $('#principals_for_new_member').html('<%= escape_javascript(render_principals_for_new_course_members(@course)) %>'); <%end%> var collection=$("#principals_for_new_member").children("#principals").children("label"); collection.css("text-overflow","ellipsis"); diff --git a/app/views/projects/invite_members.html.erb b/app/views/projects/invite_members.html.erb index d31a5bbe8..e2456f2b1 100644 --- a/app/views/projects/invite_members.html.erb +++ b/app/views/projects/invite_members.html.erb @@ -14,36 +14,45 @@
    -
    +
    + +

    邀请Trustie注册用户

    <% if roles.any? %> <%= form_for(@member, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %> +
    diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index e10004db6..b934d2dda 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -8,6 +8,13 @@ h3, .wiki h2 {font-size: 15px; padding-left: 5px} h4, .wiki h3 {font-size: 13px;} h4 {border-bottom: 1px dotted #bbb;} +/****翻页***/ +ul.wlist{ margin-left: -40px; border-bottom:none; } +ul.wlist li{float: left;} +ul.wlist li a{ border:1px solid #15bccf; padding:4px; margin-left:3px;} +ul.wlist li a:hover{ background:#15bccf; color:#fff; text-decoration:none;} +.wlist_select { background-color:#64bdd9; color:#fff; padding: 3px; margin-left:3px;margin-top: -4px; border:1px solid #64bdd9;} + /*20150203项目界面优化样式 By: huangjignquan*/ .project_new{font-size: 15px; padding: 5px;} .project_new .description{font-size: 12px; color: #ff7450; margin-bottom: 2px;} @@ -101,13 +108,14 @@ a:hover.more{ color:#64bdd9;} .icon_addm:hover{background:url(../images/img_floatbox.png) 0 -61px no-repeat; } .icon_removem{ background:url(../images/img_floatbox.png) -22px -33px no-repeat;width:16px; height:16px; display:block; margin:5px 0 0 5px} .icon_removem:hover{background:url(../images/img_floatbox.png) -22px -61px no-repeat;} -.btn_free{ background:#ff5722; display:block; width:80px; text-align:center; color:#fff; height:26px; padding-top:3px; margin-bottom:10px;} +.btn_free{ background:#ff5722; display:block; width:80px; text-align:center; color:#fff !important; height:26px; padding-top:8px; margin-bottom:10px;} .btn_free:hover{ background:#d63502;} /*成员邀请*/ -.invi_search{ width:295px; margin:0 auto;} +.invi_search{ width:345px; margin:0 auto;} .invi_search_input{ border:1px solid #15bccf; width:180px; height:24px; color:#9b9b9b; padding-left:5px; margin-bottom:10px;} .invi_search_btn{ background:#15bccf; color:#fff; text-align: center; width:40px; height:22px;border:1px solid #15bccf; padding-top:2px; cursor:pointer;} .invi_search_btn:hover{ background:#0da1b2; border:1px solid #0da1b2;} +.rolebox{ margin-left: -40px;} /*问题跟踪*/ .problem_top{ margin:10px 0 ;} .problem_search_input{ border:1px solid #64bdd9; width:180px; height:24px; color:#9b9b9b; padding-left:5px; margin-bottom:10px;}