From 548a263f0fcca06f47f4dbed1843e691a991f313 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 31 Aug 2016 17:09:02 +0800 Subject: [PATCH 01/40] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=96=B0=E9=97=BB=E5=8F=91=E9=80=81=E8=87=B3=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=90=8E=EF=BC=8C=E4=BD=8D=E4=BA=8E=E8=AE=A8?= =?UTF-8?q?=E8=AE=BA=E5=8C=BA=E4=B8=8B=E7=9A=84bug=202.=E8=B5=84=E6=96=99?= =?UTF-8?q?=E6=9C=AA=E5=AE=8C=E5=96=84=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C?= =?UTF-8?q?=E2=80=9C=E4=BF=AE=E6=94=B9=E8=B5=84=E6=96=99=E2=80=9D=E5=8F=AF?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=203.=E7=BB=84=E7=BB=87=E6=88=90=E5=91=98?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=A2=9E=E5=8A=A0=E5=88=86=E9=A1=B5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=88=E9=85=8D=E7=BD=AE=E6=88=90=E5=91=98=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=88=86=E9=A1=B5=E4=B8=BA=E5=AE=8C=E6=88=90=EF=BC=89?= =?UTF-8?q?=204.=E4=BF=AE=E5=A4=8D=E5=9B=9E=E5=A4=8D=E8=A1=A8=E6=83=85?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 4 ++-- app/controllers/organizations_controller.rb | 4 +++- app/controllers/projects_controller.rb | 1 + app/controllers/users_controller.rb | 3 ++- app/views/forums/index.html.erb | 2 -- .../layouts/_logined_header_show.html.erb | 4 ++-- app/views/memos/show.html.erb | 2 +- .../_org_left_subfield_list.html.erb | 14 ++++++------- .../organizations/_org_member_list.html.erb | 12 ++++++----- app/views/organizations/_org_members.html.erb | 2 +- app/views/organizations/setting.html.erb | 20 +++++++++++-------- .../projects/_project_member_list.html.erb | 5 ++++- app/views/projects/member.html.erb | 2 +- app/views/users/_project_news.html.erb | 2 +- .../users/_share_news_to_course.html.erb | 2 +- public/javascripts/org.js | 1 + 16 files changed, 45 insertions(+), 35 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 669da5502..02dfe9a45 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -30,7 +30,7 @@ class AccountController < ApplicationController user = UserExtensions.where(:user_id => User.current.id).first if user.gender.nil? || user.school_id.nil? || User.current.lastname.nil? redirect_to my_account_path(:tip => 1) - elsif user.identity == 3 && user.occupation.nil? + elsif user.identity == 3 && user.school_id.nil? redirect_to my_account_path(:tip => 1) else redirect_to user_path(User.current) @@ -359,7 +359,7 @@ class AccountController < ApplicationController user = UserExtensions.where(:user_id => User.current.id).first if user.gender.nil? || user.school_id.nil? || User.current.lastname.nil? redirect_to my_account_path(:tip => 1) - elsif user.identity == 3 && user.occupation.nil? + elsif user.identity == 3 && user.school_id.nil? redirect_to my_account_path(:tip => 1) else redirect_back_or_default User.current diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index b36ef592d..7fcdc0d27 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -421,6 +421,7 @@ class OrganizationsController < ApplicationController @organization = Organization.find(params[:id]) if User.current.admin? || User.current.admin_of_org?(@organization) + @members = OrgMember.where(:organization_id => @organization.id).all.sort else render_403 end @@ -451,10 +452,11 @@ class OrganizationsController < ApplicationController def members if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) - @members = OrgMember.where("organization_id =?", @organization.id) + @members = OrgMember.where(:organization_id => @organization.id).all.sort else render_403 end + @members = paginateHelper @members, 20 end def more_org_projects diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 5dcf493ee..8d4c09ded 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -580,6 +580,7 @@ class ProjectsController < ApplicationController end end @members = paginateHelper @members + end def update_message_status(user, project) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e929153ad..642051599 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2628,7 +2628,8 @@ class UsersController < ApplicationController project_ids.each do |project_id| project = Project.find(project_id) if project.news.map(&:id).exclude?(news.id) - message = Message.create(:board_id => project.boards.first.id, :subject => news.title, :content => news.description, :author_id => User.current.id) + # message = Message.create(:board_id => project.boards.first.id, :subject => news.title, :content => news.description, :author_id => User.current.id) + message = News.create(:project_id => project.id, :title => news.title, :summary => news.summary, :description => news.description, :author_id => User.current.id, :created_on => Time.now ) # record forward to table forwards if new record is valid if message.valid? news.forwards << Forward.new(:to_type => message.class.name, :to_id => message.id) diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index 889def55e..376ca420a 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -74,7 +74,6 @@ }); function check_and_submit(doc){ $("#error").html('').hide(); - check_forum_name(); if( $("textarea[name='forum[name]']").val().trim() == "" && $("textarea[name='forum[description]']").val().trim() != "" ){ $("#error").html("名称不能为空").show(); return; @@ -98,7 +97,6 @@ '<%= check_forum_name_forums_path %>', {"forum_name":encodeURIComponent(name)}, function(data){ - if( data == 'true'){ $("#error").html("贴吧名称已经存在").show(); check_pass = false; diff --git a/app/views/layouts/_logined_header_show.html.erb b/app/views/layouts/_logined_header_show.html.erb index a6721501e..7a2dd6ced 100644 --- a/app/views/layouts/_logined_header_show.html.erb +++ b/app/views/layouts/_logined_header_show.html.erb @@ -36,7 +36,7 @@ <%= image_tag(url_to_avatar(User.current),:width =>"40",:height => "40",:alt=>"头像", :id => "nh_user_logo", :class => "portraitRadius") %> diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index 69e36ca34..435fd0f9e 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -90,7 +90,7 @@
<%= reply.author.name%><%= format_date(reply.created_at) %>
-
<%= h reply.content%>
+
<%= h reply.content.html_safe%>
<%= submit_tag '',:class=>'searchIcon2',:onfocus=>"this.blur();",:style=>'border-style:none' %> diff --git a/public/javascripts/org.js b/public/javascripts/org.js index a2b2bd361..f1520a0ec 100644 --- a/public/javascripts/org.js +++ b/public/javascripts/org.js @@ -1,4 +1,5 @@ //�����֯��Ա���ύ���� +// 组织:新增成员 function submit_add_org_members(){ $("#org_member_add_form").submit(); } From 27ad94eac2bb3ac886101ea92943edd4532fb997 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 2 Sep 2016 13:25:01 +0800 Subject: [PATCH 02/40] =?UTF-8?q?=E7=BB=84=E7=BB=87=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=EF=BC=8C=E6=88=90=E5=91=98=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_member_controller.rb | 31 ++++++++++++++++--- app/controllers/organizations_controller.rb | 1 + app/helpers/org_member_helper.rb | 1 + app/views/org_member/create.js.erb | 5 +-- app/views/org_member/deleteOrgMember.js.erb | 5 +-- app/views/org_member/destroy.js.erb | 5 +-- .../org_member/org_member_autocomplete.js.erb | 30 +++++++++--------- app/views/org_member/org_member_paging.js.erb | 4 +++ app/views/org_member/update.js.erb | 3 +- .../organizations/_org_member_list.html.erb | 7 ++++- app/views/organizations/check_uniq.js.erb | 6 ++-- app/views/organizations/setting.html.erb | 5 +-- config/routes.rb | 1 + public/javascripts/application.js | 4 +-- 14 files changed, 73 insertions(+), 35 deletions(-) create mode 100644 app/views/org_member/org_member_paging.js.erb diff --git a/app/controllers/org_member_controller.rb b/app/controllers/org_member_controller.rb index 2eaa790cd..a01956f56 100644 --- a/app/controllers/org_member_controller.rb +++ b/app/controllers/org_member_controller.rb @@ -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 diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 7fcdc0d27..56ffc77e2 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -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 diff --git a/app/helpers/org_member_helper.rb b/app/helpers/org_member_helper.rb index e16051eaf..28a279eb4 100644 --- a/app/helpers/org_member_helper.rb +++ b/app/helpers/org_member_helper.rb @@ -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]) diff --git a/app/views/org_member/create.js.erb b/app/views/org_member/create.js.erb index 25bbded34..44fb6fe93 100644 --- a/app/views/org_member/create.js.erb +++ b/app/views/org_member/create.js.erb @@ -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 %> \ No newline at end of file diff --git a/app/views/org_member/deleteOrgMember.js.erb b/app/views/org_member/deleteOrgMember.js.erb index d87e62c17..23c6ead2e 100644 --- a/app/views/org_member/deleteOrgMember.js.erb +++ b/app/views/org_member/deleteOrgMember.js.erb @@ -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}) %>'); \ No newline at end of file +$("#org_members_count_id").html("<%= @organization.org_members.count %>"); +$("#org_member_list").html('<%= escape_javascript( render :partial => "organizations/org_member_list", :locals=> {:members => @members}) %>'); \ No newline at end of file diff --git a/app/views/org_member/destroy.js.erb b/app/views/org_member/destroy.js.erb index d87e62c17..7cf0fad02 100644 --- a/app/views/org_member/destroy.js.erb +++ b/app/views/org_member/destroy.js.erb @@ -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}) %>'); \ No newline at end of file +$("#org_members_count_id").html("<%= @organization.org_members.count %>"); +$("#org_member_list").html('<%= escape_javascript( render :partial => "organizations/org_member_list", :locals => {:members => @members}) %>'); \ No newline at end of file diff --git a/app/views/org_member/org_member_autocomplete.js.erb b/app/views/org_member/org_member_autocomplete.js.erb index 05cf3947c..4ef7970be 100644 --- a/app/views/org_member/org_member_autocomplete.js.erb +++ b/app/views/org_member/org_member_autocomplete.js.erb @@ -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 +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); } \ No newline at end of file diff --git a/app/views/org_member/org_member_paging.js.erb b/app/views/org_member/org_member_paging.js.erb new file mode 100644 index 000000000..824692971 --- /dev/null +++ b/app/views/org_member/org_member_paging.js.erb @@ -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 %> \ No newline at end of file diff --git a/app/views/org_member/update.js.erb b/app/views/org_member/update.js.erb index 8bd949fde..e9e7f5ade 100644 --- a/app/views/org_member/update.js.erb +++ b/app/views/org_member/update.js.erb @@ -1 +1,2 @@ -$("#org_member_list").html('<%= escape_javascript( render :partial=>"organizations/org_member_list",:locals=> {:members=>@org.org_members}) %>'); \ No newline at end of file +// 编辑成员列表角色后,刷新成员列表 +$("#org_member_list").html('<%= escape_javascript( render :partial => "organizations/org_member_list",:locals => {:members => @members}) %>'); \ No newline at end of file diff --git a/app/views/organizations/_org_member_list.html.erb b/app/views/organizations/_org_member_list.html.erb index 3e305c14d..904558965 100644 --- a/app/views/organizations/_org_member_list.html.erb +++ b/app/views/organizations/_org_member_list.html.erb @@ -40,4 +40,9 @@
<% end %> - + \ No newline at end of file diff --git a/app/views/organizations/check_uniq.js.erb b/app/views/organizations/check_uniq.js.erb index f38578025..2257c5a67 100644 --- a/app/views/organizations/check_uniq.js.erb +++ b/app/views/organizations/check_uniq.js.erb @@ -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('名字不能重复').show(); <% else%> $("#organization_name_notice").html('名字不能重复').show(); @@ -10,7 +10,7 @@ <% else %> $checkName = true; - <% if @config_page%> + <% if @config_page %> $("#check_name_hint").html('名字可以使用').show(); <% else%> diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index 11ea480a5..109c78c25 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -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){ @@ -247,4 +247,5 @@ $this.bind('blur', reset); }); } - \ No newline at end of file + + diff --git a/config/routes.rb b/config/routes.rb index 6cbc0812d..7c7a9aad1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -116,6 +116,7 @@ RedmineApp::Application.routes.draw do end collection do get 'org_member_autocomplete' + get 'org_member_paging' get 'deleteOrgMember' end end diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 504fea3cb..e50c57957 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -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'); } // 完成后,移除 }); } }; From 9a3603c778bb8e45a5ba5cc03c262fa96cbe32a8 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 2 Sep 2016 16:11:14 +0800 Subject: [PATCH 03/40] =?UTF-8?q?1.=E5=9F=BA=E6=9C=AC=E8=B5=84=E6=96=99?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=EF=BC=8C=E8=BA=AB=E4=BB=BD=E4=B8=BA=E4=BB=8E?= =?UTF-8?q?=E4=B8=9A=E8=80=85=E6=97=B6=EF=BC=8C=E7=9B=B4=E6=8E=A5=E7=82=B9?= =?UTF-8?q?=E7=A1=AE=E5=AE=9A=E6=8A=A5=E6=8F=90=E7=A4=BA=E9=97=AE=E9=A2=98?= =?UTF-8?q?=202.=E5=BC=BA=E5=88=B6=E4=BF=AE=E6=94=B9=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E8=B5=84=E6=96=99=EF=BC=8C=E4=BF=AE=E6=94=B9=E8=B5=84=E6=96=99?= =?UTF-8?q?=E6=8C=89=E9=94=AE=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_logined_header_show.html.erb | 2 +- app/views/layouts/new_base_user_show.html.erb | 6 +++--- app/views/my/account.html.erb | 15 ++++++++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/views/layouts/_logined_header_show.html.erb b/app/views/layouts/_logined_header_show.html.erb index 7a2dd6ced..df694db11 100644 --- a/app/views/layouts/_logined_header_show.html.erb +++ b/app/views/layouts/_logined_header_show.html.erb @@ -36,7 +36,7 @@ <%= image_tag(url_to_avatar(User.current),:width =>"40",:height => "40",:alt=>"头像", :id => "nh_user_logo", :class => "portraitRadius") %>