1.实现作业添加成员的翻页功能

2.美化作业成员界面显示
This commit is contained in:
sw 2014-06-10 17:33:31 +08:00
parent cbb348dc0e
commit 130f9f87c2
6 changed files with 35 additions and 6 deletions

View File

@ -80,6 +80,8 @@ class HomeworkAttachController < ApplicationController
if User.current.admin? || User.current.member_of?(@bid.courses.first) if User.current.admin? || User.current.member_of?(@bid.courses.first)
#该课程的学生的集合 #该课程的学生的集合
@members = @bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id <> #{User.current.id}", {:role_id => [5, 10]}) @members = @bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id <> #{User.current.id}", {:role_id => [5, 10]})
@members = paginateHelper @members,10
#@all_user = [] #@all_user = []
#@bid.courses.first.members.each do |member| #@bid.courses.first.members.each do |member|
# @all_user << member.user # @all_user << member.user
@ -96,6 +98,22 @@ class HomeworkAttachController < ApplicationController
end end
end end
def get_homework_member_list
@bid = Bid.find(params[:bid_id])
if User.current.admin? || User.current.member_of?(@bid.courses.first)
#该课程的学生的集合
@members = @bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id <> #{User.current.id}", {:role_id => [5, 10]})
@members = paginateHelper @members,10
else
raise "error"
end
respond_to do |format|
format.js
end
end
#获取指定作业的所有成员 #获取指定作业的所有成员
def members_for_homework homework def members_for_homework homework
people = [] people = []

View File

@ -19,7 +19,8 @@ module HomeworkAttachHelper
def render_new_members_for_homework members def render_new_members_for_homework members
#scope = Principal.active.sorted.not_member_of(project).like(params[:q]) #scope = Principal.active.sorted.not_member_of(project).like(params[:q])
#scope = project.members #scope = project.members
principals = paginateHelper members,10 #principals = paginateHelper members,10
principals = members
#principal_count = members.count #principal_count = members.count
#limit = 10 #limit = 10
#principal_pages = Redmine::Pagination::Paginator.new principal_count, limit, params['page'] #by young #principal_pages = Redmine::Pagination::Paginator.new principal_count, limit, params['page'] #by young
@ -27,7 +28,7 @@ module HomeworkAttachHelper
#principals = members[offset, limit] #principals = members[offset, limit]
s = content_tag('div', member_check_box_tags_ex('membership[user_ids][]', principals), :id => 'principals') s = content_tag('div', member_check_box_tags_ex('membership[user_ids][]', principals), :id => 'principals')
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false) {|text, parameters, options| links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false) {|text, parameters, options|
link_to text, new_homework_attach_path( parameters.merge(:q => params[:q], :format => 'js')), :remote => true } link_to text, get_homework_member_list_homework_attach_index_path( parameters.merge(:q => params[:q], bid_id: params[:id]||@bid)), :remote => true }
return s + content_tag('div', content_tag('ul', links), :class => 'pagination_new') return s + content_tag('div', content_tag('ul', links), :class => 'pagination_new')
end end

View File

@ -1,23 +1,26 @@
<%= error_messages_for 'member' %> <%= error_messages_for 'member' %>
<div style="float:left; width:60%;height:410px;padding-left: 10px;padding-right: 10px"> <div style="float:left; width:60%;height:400px;padding-left: 10px;padding-right: 10px">
<table class="list members" style="width: 100%"> <table class="list members" style="width: 100%">
<thead> <thead>
<tr> <tr>
<th><%= l(:label_user) %></th> <th><%= l(:label_user) %></th>
<th><%= l(:label_role_plural) %></th> <th><%= l(:label_role_plural) %></th>
<th style="width:15%"></th> <th style="width:10%"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% for m in (1..10) %>
<tr id="member-<%= User.current.id %>" class="<%= cycle 'odd', 'even' %> member" style="text-align: center"> <tr id="member-<%= User.current.id %>" class="<%= cycle 'odd', 'even' %> member" style="text-align: center">
<td style="width: 40%"><%= link_to_user User.current %></td> <td style="width: 40%"><%= link_to_user User.current %></td>
<td style="text-align: center;width: 60%"> 发布人员 </td> <td style="text-align: center;width: 50%"> 发布人员 </td>
<td><a>删除</a></td>
</tr> </tr>
<% end %>
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="splitcontentright" style="width: 37%"> <div class="splitcontentright" style="width: 37%;height: 400px">
<fieldset> <fieldset>
<legend><%= l(:label_member_new) %></legend> <legend><%= l(:label_member_new) %></legend>

View File

@ -0,0 +1,3 @@
<div id="principals_for_new_member">
<%= render_new_members_for_homework(members) %>
</div>

View File

@ -0,0 +1,2 @@
$('#principals_for_new_member').replaceWith('<%= j(render :partial => "member_list_partial", locals:{members: @members})%>');

View File

@ -26,11 +26,13 @@ RedmineApp::Application.routes.draw do
resources :homework_attach do resources :homework_attach do
collection do collection do
get 'get_homework_member_list'
match 'addjours', via: [:get, :post] match 'addjours', via: [:get, :post]
match 'add_jour_reply', via: [:get,:post] match 'add_jour_reply', via: [:get,:post]
match 'destroy_jour', via: [:get,:post] match 'destroy_jour', via: [:get,:post]
end end
end end
resources :open_source_projects do resources :open_source_projects do
collection do collection do
match 'search', via: [:get, :post] match 'search', via: [:get, :post]