From 1396cae14c9a29d5afad0fba4692eb46c2256759 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 3 Jun 2016 08:59:17 +0800 Subject: [PATCH 01/41] =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=BC=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 4 ++++ app/views/layouts/_logined_header.html.erb | 24 +++++++++++++++++++++- public/stylesheets/new_user.css | 12 +++++++++++ public/stylesheets/public.css | 11 ++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 44ef54c95..a07f2421f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -370,6 +370,10 @@ class User < Principal messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count end + def user_messages_unviewed + + end + # 查询指派给我的缺陷记录 def issue_status_update self.status_updates diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index f5b421f62..e3fad5c6a 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -78,12 +78,28 @@ - @@ -95,6 +111,12 @@ $("#navHomepageSearchType").hide(); }); + $("#user_messages").mouseover(function(){ + $("#user_messages_list").show(); + }).mouseout(function(){ + $("#user_messages_list").hide(); + }); + $("#navHomepageProfile").mouseenter(function(){ $("#homepageProfileMenuIcon").addClass("homepageProfileMenuIconhover"); $("#topnav_login_list").show(); diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 0231f6a8a..1edb4ff80 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1616,3 +1616,15 @@ ul.wlist li a{ border:1px solid #15bccf; padding: 1px 4px 1px 4px; margin-left:3 ul.wlist li a:hover{ background:#15bccf; color:#fff; text-decoration:none;} /*.wlist_select { background-color:#64bdd9; color:#fff; padding: 1px 5px 0px 5px; margin-left:3px;margin-top: -2px; border:1px solid #64bdd9;}*/ .wlist_select a{background-color: #64bdd9;cursor: default;} + +/*消息弹框*/ +.shadowbox_news{ width:305px; background-color:#fff; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); position: absolute; left: -131px; top: 45px; z-index: 9999;} +.shadowbox_news_title{ height:40px; line-height:40px;padding-left:10px; font-size:12px; color:#333;border-bottom:1px solid #eee;} +.shadowbox_news font{ border: 1px solid #dddddd; display: block; border-width: 8px; position: absolute; top: -15px;left: 140px; border-style:solid; border-color: transparent transparent #fff transparent;font-size: 0;line-height: 0; box-shadow:2px rgba(146, 153, 169, 0.5); } +.shadowbox_news_list{ max-height:200px; overflow:hidden;} +.shadowbox_news_list a{ color:#999;} +.shadowbox_news_list li{ height:40px; border-bottom:1px dashed #ebebeb; line-height:40px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis; padding:0 10px;} +.shadowbox_news_list li:hover{ background-color:#eee;} +a.shadowbox_news_user{ color:#3b94d6;} +a.shadowbox_news_all{ display:block; width:305px; height:40px; line-height:40px; color:#3b94d6; text-align:center;border-top:1px solid #eee;} + diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 98fd0ec20..c28560506 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -1144,3 +1144,14 @@ a.st_down{ display: block; width:8px; float:left; height:13px; background:url(.. /*弹框*/ .apply_content{ border:1px solid #ddd;line-height: 16px; height:80px;width:420px; background:#fff; margin-bottom:10px;} + +/*消息弹框*/ +.shadowbox_news{ width:305px; background-color:#fff; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); position: absolute; left: -131px; top: 45px; z-index: 9999;} +.shadowbox_news_title{ height:40px; line-height:40px;padding-left:10px; font-size:12px; color:#333;border-bottom:1px solid #eee;} +.shadowbox_news font{ border: 1px solid #dddddd; display: block; border-width: 8px; position: absolute; top: -15px;left: 140px; border-style:solid; border-color: transparent transparent #fff transparent;font-size: 0;line-height: 0; box-shadow:2px rgba(146, 153, 169, 0.5); } +.shadowbox_news_list{ max-height:200px; overflow:hidden;} +.shadowbox_news_list a{ color:#999;} +.shadowbox_news_list li{ height:40px; border-bottom:1px dashed #ebebeb; line-height:40px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis; padding:0 10px;} +.shadowbox_news_list li:hover{ background-color:#eee;} +a.shadowbox_news_user{ color:#3b94d6;} +a.shadowbox_news_all{ display:block; width:305px; height:40px; line-height:40px; color:#3b94d6; text-align:center;border-top:1px solid #eee;} From d27a050ffa428c7f09d0f5805e0eda8de7ba9f1b Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 3 Jun 2016 16:28:11 +0800 Subject: [PATCH 02/41] =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 14 ++++ app/models/user.rb | 4 - app/views/layouts/_logined_header.html.erb | 23 ++---- app/views/layouts/_message_loading.html.erb | 6 ++ .../layouts/_show_messages_list.html.erb | 74 +++++++++++++++++++ app/views/users/_user_message_course.html.erb | 4 +- app/views/users/user_messages_unviewed.js.erb | 1 + config/routes.rb | 1 + public/stylesheets/new_user.css | 2 +- public/stylesheets/public.css | 2 +- 10 files changed, 107 insertions(+), 24 deletions(-) create mode 100644 app/views/layouts/_message_loading.html.erb create mode 100644 app/views/layouts/_show_messages_list.html.erb create mode 100644 app/views/users/user_messages_unviewed.js.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4cb838b8c..e201d8611 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -123,6 +123,20 @@ class UsersController < ApplicationController end + #未读消息弹窗 + def user_messages_unviewed + @message_alls = [] + messages = MessageAll.where("user_id =?", User.current.id).includes(:message).order("created_at desc") + onclick_time = User.current.onclick_time.onclick_time + messages.each do |message_all| + # 未读的消息存放在数组 + if (message_all.message_type != "SystemMessage"&& !message_all.message.nil? && message_all.message.viewed == 0) || (message_all.message_type == "SystemMessage"&& !message_all.message.nil? && message_all.message.created_at > onclick_time) + @message_alls << message_all.message + break if @message_alls.length == 5 + end + end + end + # 用户消息 # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅;works_reply:作品回复,exercise:课程测验 # issue:问题;journal:缺陷状态更新; forum:公共贴吧: user_feedback: 用户留言; new_reply:新闻回复(comment) diff --git a/app/models/user.rb b/app/models/user.rb index a07f2421f..44ef54c95 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -370,10 +370,6 @@ class User < Principal messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count end - def user_messages_unviewed - - end - # 查询指派给我的缺陷记录 def issue_status_update self.status_updates diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index e3fad5c6a..7ba0a23be 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -85,20 +85,7 @@ <% end %> <%#= link_to User.current.count_new_message, user_message_path(User.current), :class => "homepageNewsIcon" %> @@ -111,10 +98,14 @@ $("#navHomepageSearchType").hide(); }); - $("#user_messages").mouseover(function(){ + $("#user_messages").mouseenter(function(){ $("#user_messages_list").show(); - }).mouseout(function(){ + $.get('<%=user_messages_unviewed_users_path %>'); + $("#ajax-indicator").hide(); + }).mouseleave(function(){ $("#user_messages_list").hide(); + $("#user_messages_list").html("<%=escape_javascript(render :partial => 'layouts/message_loading') %>"); + }); $("#navHomepageProfile").mouseenter(function(){ diff --git a/app/views/layouts/_message_loading.html.erb b/app/views/layouts/_message_loading.html.erb new file mode 100644 index 000000000..aae55205c --- /dev/null +++ b/app/views/layouts/_message_loading.html.erb @@ -0,0 +1,6 @@ + +
+ + 正在加载中,请稍后... +
+
\ No newline at end of file diff --git a/app/views/layouts/_show_messages_list.html.erb b/app/views/layouts/_show_messages_list.html.erb new file mode 100644 index 000000000..27e1d8896 --- /dev/null +++ b/app/views/layouts/_show_messages_list.html.erb @@ -0,0 +1,74 @@ + +

未读消息

+ +<%= link_to '查看全部', user_message_path(User.current), :class => "shadowbox_news_all", :target =>"_Blank" %> \ No newline at end of file diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 60d5b6ed8..0c18dbcc3 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -259,7 +259,7 @@ '您申请引用作业"'+HomeworkCommon.find(ma.course_message_id).name+'"的申请已通过' : '您申请引用作业"'+HomeworkCommon.find(ma.course_message_id).name+'"的申请被拒绝' %> - <% if User.current.member_of_course?(ma.course_message.course) || User.current.admin? || ma.course_message.is_open == 1 %> + <% if User.current.member_of_course?(ma.course_message.course) || User.current.admin? || (ma.course_message.is_open == 1 && ma.course_message.course.is_public == 1) %> <%= link_to link_str, student_work_index_path(:homework => ma.course_message.id), :title => link_str,:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey "}", :target => '_blank' %> <% else %> <%=link_str %> @@ -399,7 +399,7 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> - <% elsif ma.course_message.jour_type == 'HomeworkCommon' %> + <% elsif ma.course_message.jour_type == 'HomeworkCommon' %> + <% elsif field.field_type == "Comptec" %> +
  • + <%= link_to "#{field.name}", teachers_organization_path(@organization, :org_subfield_id => field.id, :type => "famous"), :class => "sn-link-white", :target => "_blank" %> +
  • + <% elsif field.field_type == "Compstu" %> +
  • + <%= link_to "#{field.name}", students_organization_path(@organization, :org_subfield_id => field.id, :type => "famous"), :class => "sn-link-white", :target => "_blank" %> +
  • + <% elsif field.field_type == "Comppro" %> +
  • + <%= link_to "#{field.name}", projects_organization_path(@organization, :org_subfield_id => field.id, :type => "famous"), :class => "sn-link-white", :target => "_blank" %> +
  • + <% elsif field.field_type == "Compcou" %> +
  • + <%= link_to "#{field.name}", courses_organization_path(@organization, :org_subfield_id => field.id, :type => "famous"), :class => "sn-link-white", :target => "_blank" %> +
  • + <% elsif field.field_type == "Compact" %> +
  • + <%= link_to "#{field.name}", acts_organization_path(@organization, :org_subfield_id => field.id), :class => "sn-link-white", :target => "_blank" %> +
  • <% elsif field.field_type == "Resource" && field.hide == 0 %> -
  • <%= link_to field.name, org_subfield_files_path(field), :class => "sn-link-white", :target => "_blank" %>
  • <% end %> diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index 30234c300..c1cc3a20f 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -125,10 +125,6 @@
    <%= link_to "#{field.name}", students_organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %>
    - <% elsif field.field_type == "Compstu" && User.current.admin? %> -
    - <%= link_to "#{field.name}", students_organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %> -
    <% elsif field.field_type == "Comppro" && User.current.admin? %>
    <%= link_to "#{field.name}", projects_organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %> From eee8a8adb683be02a0243a3e59e30049297cbd59 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 7 Jun 2016 16:43:37 +0800 Subject: [PATCH 25/41] fix --- public/javascripts/wechat/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 730226df8..3fc14f60c 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -525,7 +525,7 @@ app.directive('loadingSpinner', function ($http) { }; }); -app.config(['$routeProvider',"$httpProvider",function ($routeProvider, $httpProvider, $locationProvider) { +app.config(['$routeProvider',"$httpProvider", "$locationProvider",function ($routeProvider, $httpProvider, $locationProvider) { var rootPath = '/assets/wechat/' $locationProvider.html5Mode(true); $routeProvider From 90ac57ed6abeda7810c34d106519f2a2dbcf7561 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 7 Jun 2016 16:46:10 +0800 Subject: [PATCH 26/41] base --- public/assets/wechat/app.html | 1 + 1 file changed, 1 insertion(+) diff --git a/public/assets/wechat/app.html b/public/assets/wechat/app.html index 63e88490f..98363b36e 100644 --- a/public/assets/wechat/app.html +++ b/public/assets/wechat/app.html @@ -1,6 +1,7 @@ + 最新动态 From 81e35de2b650c397d576c174a2c72138c351cfb6 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 7 Jun 2016 16:47:06 +0800 Subject: [PATCH 27/41] base --- app/views/wechats/user_activities.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/wechats/user_activities.html.erb b/app/views/wechats/user_activities.html.erb index b45587ae0..7eddb2861 100644 --- a/app/views/wechats/user_activities.html.erb +++ b/app/views/wechats/user_activities.html.erb @@ -1,6 +1,7 @@ + 最新动态 From 09ff5954bd9cf9a6e6ebecb2dc7a45b1584f5717 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 7 Jun 2016 16:56:20 +0800 Subject: [PATCH 28/41] =?UTF-8?q?=E5=AD=97=E4=BD=93=E8=BF=87=E9=95=BF?= =?UTF-8?q?=E6=BC=94=E7=A4=BA=E9=97=AE=E9=A2=98=EF=BC=88=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=BA=8C=E5=AD=90=E9=A1=B5=E9=9D=A2=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_show_custom_org_document_comment.html.erb | 6 +++--- .../organizations/_show_custom_org_subfield.html.erb | 8 ++++---- public/stylesheets/org2.css | 8 -------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/app/views/org_document_comments/_show_custom_org_document_comment.html.erb b/app/views/org_document_comments/_show_custom_org_document_comment.html.erb index ec2a1ca8f..d3c98da13 100644 --- a/app/views/org_document_comments/_show_custom_org_document_comment.html.erb +++ b/app/views/org_document_comments/_show_custom_org_document_comment.html.erb @@ -1,11 +1,11 @@
    -
    您的位置:<%= link_to "首页", organization_path(@organization), :class => "sn-link-grey2" %> > +
    您的位置:<%= link_to "首页", organization_path(@organization), :class => "sn-link-grey2" %> > <%=link_to @org_subfield.name, organization_path(@organization, :org_subfield_id => @org_subfield.id), :class => "sn-link-grey2" %> > - <%= @document.title %> + <%= @document.title %>
    -
    +

    <%= @document.title %>

    来源:<%= @org_subfield.name %> 发布时间:<%= format_date(@document.created_at) %>

    diff --git a/app/views/organizations/_show_custom_org_subfield.html.erb b/app/views/organizations/_show_custom_org_subfield.html.erb index 473a5757d..10ac31637 100644 --- a/app/views/organizations/_show_custom_org_subfield.html.erb +++ b/app/views/organizations/_show_custom_org_subfield.html.erb @@ -3,13 +3,13 @@
    -
    +
    您的位置:<%= link_to "首页", organization_path(@organization), :class => "sn-link-grey2" %> > - <%=link_to @org_subfield.name, organization_path(@organization, :org_subfield_id => @org_subfield.id), :class => "sn-link-grey2" %> + <%= @org_subfield.name %>
    -
    -

    <%= @organization.name %>

    +
    +

    <%= @org_subfield.name %>

      <% @subfield_acts.each do |act| %> <% title = subfield_title_type(act) %> diff --git a/public/stylesheets/org2.css b/public/stylesheets/org2.css index 6672eb073..9e19fb5cb 100644 --- a/public/stylesheets/org2.css +++ b/public/stylesheets/org2.css @@ -1,14 +1,6 @@ @charset "utf-8"; /* CSS Document */ /* 样式重置 */ -body,h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,form,fieldset,legend,button,input,textarea,th,td{ margin:0; padding:0;} -body,table,input,textarea,select,button { font-family: "微软雅黑","宋体"; font-size:12px;line-height:1.9; background:#f2f2f2;} -div,img,tr,td,table{ border:0;} -table,tr,td{border:0;cellspacing:0; cellpadding:0;} -ol,ul,li{ list-style-type:none} -a:link,a:visited{color:#000;text-decoration:none;} -a:hover,a:active{color:#24366e;} - .sn-fl {float:left;} .sn-fr {float:right;} .sn-cl {clear:both;content:".";display:block;font-size:0;height:0;line-height:0;visibility:hidden} From b01a671fb40e5dc294635b6f83994fe4c67ed815 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 7 Jun 2016 16:59:26 +0800 Subject: [PATCH 29/41] base --- public/javascripts/wechat/app.js | 55 +++++++++----------------------- 1 file changed, 15 insertions(+), 40 deletions(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 3fc14f60c..5e201fca4 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -75,38 +75,10 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h console.log("ActivityController load"); $scope.page = 0; - var current_page = rms.get('current_page'); - if(typeof current_page !== 'undefined'){ - $scope.page = current_page; - } - $scope.activities = rms.get("activities") || []; - var savePageConfig = function(){ - rms.save('current_page', $scope.current_page); - rms.save('has_more', $scope.has_more); - rms.save('activities', $scope.activities); - } - - var loadPageConfig = function(){ - - var has_more = rms.get('has_more'); - var activities = rms.get('activities'); - - - if(typeof has_more !== 'undefined'){ - $scope.has_more = has_more; - } - - } var loadActData = function(page){ - if (page > 0 && $scope.activities.length >0){ //应该是返回过来的 - loadPageConfig(); - var yOffset = rms.get("yoffset"); - $location.hash(yOffset); - return; - } $scope.page = page; $http({ @@ -126,19 +98,22 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h console.log(response.data); - rms.save('current_page', $scope.page); - rms.save('has_more', $scope.has_more); - rms.save('activities', $scope.activities); }, function errorCallback(response) { }); }; - auth.getOpenId().then( - function successCallback(response){ - loadActData($scope.page); - }, function errorCallback(response) { - alert("获取openid出错:"+response); - } - ); + + if($scope.activities.length<=0){ + + auth.getOpenId().then( + function successCallback(response){ + loadActData($scope.page); + }, function errorCallback(response) { + alert("获取openid出错:"+response); + } + ); + + } + $scope.loadActData = loadActData; @@ -529,7 +504,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",function ($rou var rootPath = '/assets/wechat/' $locationProvider.html5Mode(true); $routeProvider - .when('/activities', { + .when('/', { templateUrl: rootPath + 'activities.html', controller: 'ActivityController' }) @@ -562,7 +537,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",function ($rou controller: 'BlogController' }) .otherwise({ - redirectTo: '/activities' + redirectTo: '/' }); //监听异步请求,实现加载中显隐标记 From 5fe41d80e97b85127c32363f2836a7b794f099c3 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 7 Jun 2016 17:06:13 +0800 Subject: [PATCH 30/41] base --- public/javascripts/wechat/app.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 5e201fca4..b1b1f3858 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -77,6 +77,10 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h $scope.page = 0; $scope.activities = rms.get("activities") || []; + if($scope.activities.length>0){ + return; + } + var loadActData = function(page){ @@ -94,6 +98,9 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h } else { $scope.activities = response.data.data; } + + rms.save("activities", $scope.activities); + $scope.has_more = (response.data.count + response.data.page * 10) < response.data.all_count; console.log(response.data); From 8fb88dfdead7e3e78f923ac4e175250e175cd092 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 7 Jun 2016 17:17:14 +0800 Subject: [PATCH 31/41] base --- public/javascripts/wechat/app.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index b1b1f3858..91dc41015 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -67,7 +67,7 @@ app.factory('rms', function(){ return {save: save, get: get}; }); -app.controller('ActivityController',function($anchorScroll, $location,$scope, $http, auth, rms, common){ +app.controller('ActivityController',function($anchorScroll, $location,$scope, $http, $document,$window, auth, rms, common){ $scope.replaceUrl = function(url){ return url; }; @@ -78,6 +78,12 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h $scope.activities = rms.get("activities") || []; if($scope.activities.length>0){ + + $timeout(function () { + $window.scroll(0,rms.get("yoffset")); + }); + + return; } @@ -101,6 +107,8 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h rms.save("activities", $scope.activities); + rms.save("yoffset", $document.body.scrollHeight); + $scope.has_more = (response.data.count + response.data.page * 10) < response.data.all_count; console.log(response.data); From f993fa87ff6ec497cfd49dfe757a5b4302bf286c Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 7 Jun 2016 17:18:28 +0800 Subject: [PATCH 32/41] base --- public/javascripts/wechat/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 91dc41015..5dc1e90fd 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -107,7 +107,7 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h rms.save("activities", $scope.activities); - rms.save("yoffset", $document.body.scrollHeight); + $scope.has_more = (response.data.count + response.data.page * 10) < response.data.all_count; @@ -135,7 +135,7 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h //跳到详情页 $scope.goDetail = function(type, act_id,id){ - rms.save("yoffset",'act_'+id); + rms.save("yoffset", $document.body.scrollHeight); $location.path('/'+type+'/'+act_id); } From a8b68d64ee4873ee43dac2216f32343d4095af56 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 7 Jun 2016 17:19:19 +0800 Subject: [PATCH 33/41] =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 10 +++++----- .../organizations/_org_container.html.erb | 4 +++- .../organizations/_org_custom_header.html.erb | 8 ++++---- .../_org_left_subfield_list.html.erb | 18 +++++++++--------- .../organizations/_org_students_list.html.erb | 2 +- .../organizations/_org_teachers_list.html.erb | 9 +-------- 6 files changed, 23 insertions(+), 28 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index a75a0e698..ae1119609 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -30,7 +30,7 @@ class OrganizationsController < ApplicationController include UsersHelper include OrganizationsHelper before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout, :teachers, :students, :projects, :courses] - before_filter :allow_as_admin, :only => [:students, :teachers, :projects, :courses, :acts] + # before_filter :allow_as_admin, :only => [:students, :teachers, :projects, :courses, :acts] layout 'base_org' def index @@ -180,7 +180,7 @@ class OrganizationsController < ApplicationController q = params[:search].nil? ? "" : "#{params[:search].strip}" @field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Comptec").first : OrgSubfield.find(params[:org_subfield_id]) @type = params[:type] - if @type == "courses" || @type.nil? + if @type.blank? @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") elsif @type == "famous" @@ -204,7 +204,7 @@ class OrganizationsController < ApplicationController q = params[:search].nil? ? "" : "#{params[:search].strip}" @field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Compstu").first : OrgSubfield.find(params[:org_subfield_id]) @type = params[:type] - if @type == "courses" || @type.nil? + if @type.blank? @org_students = User.find_by_sql("select u.*, ue.student_id, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity= 1 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") elsif @type == "famous" @@ -240,7 +240,7 @@ class OrganizationsController < ApplicationController q = params[:search].nil? ? "" : "#{params[:search].strip}" @field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Comppro").first : OrgSubfield.find(params[:org_subfield_id]) @type = params[:type] - if @type.nil? + if @type.blank? @containers = Project.find_by_sql("select p.*, (select count(*) from forge_activities where forge_activities.project_id = p.id) as project_count from projects p where p.status =1 and p.is_public =1 and name like '%#{q}%' order by project_count desc;") elsif @type == "famous" @@ -254,7 +254,7 @@ class OrganizationsController < ApplicationController q = params[:search].nil? ? "" : "#{params[:search].strip}" @field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Compstu").first : OrgSubfield.find(params[:org_subfield_id]) @type = params[:type] - if @type.nil? + if @type.blank? @containers = Course.find_by_sql("select c.*, (select count(*) from course_activities where course_activities.course_id = c.id) as course_count from courses c where c.is_delete =0 and c.is_public =1 and name like '%#{q}%' order by course_count desc;") elsif @type == "famous" diff --git a/app/views/organizations/_org_container.html.erb b/app/views/organizations/_org_container.html.erb index 59ac4d95c..d91ed649e 100644 --- a/app/views/organizations/_org_container.html.erb +++ b/app/views/organizations/_org_container.html.erb @@ -16,7 +16,9 @@
      资源
    - <%= container.class == Course ? (container.is_excellent == 0 ? "设为精品" : "取消精品") : (container.hot ==0 ? "设为热门" : "取消热门") %> + <% if User.current.admin? %> + <%= container.class == Course ? (container.is_excellent == 0 ? "设为精品" : "取消精品") : (container.hot ==0 ? "设为热门" : "取消热门") %> + <% end %>
    diff --git a/app/views/organizations/_org_custom_header.html.erb b/app/views/organizations/_org_custom_header.html.erb index 7d2043904..91ca5aafb 100644 --- a/app/views/organizations/_org_custom_header.html.erb +++ b/app/views/organizations/_org_custom_header.html.erb @@ -65,19 +65,19 @@
    <% elsif field.field_type == "Comptec" %>
  • - <%= link_to "#{field.name}", teachers_organization_path(@organization, :org_subfield_id => field.id, :type => "famous"), :class => "sn-link-white", :target => "_blank" %> + <%= link_to "#{field.name}", teachers_organization_path(@organization, :org_subfield_id => field.id, :type => "#{User.current.admin? ? "" : "famous"}"), :class => "sn-link-white", :target => "_blank" %>
  • <% elsif field.field_type == "Compstu" %>
  • - <%= link_to "#{field.name}", students_organization_path(@organization, :org_subfield_id => field.id, :type => "famous"), :class => "sn-link-white", :target => "_blank" %> + <%= link_to "#{field.name}", students_organization_path(@organization, :org_subfield_id => field.id, :type => "#{User.current.admin? ? "" : "famous"}"), :class => "sn-link-white", :target => "_blank" %>
  • <% elsif field.field_type == "Comppro" %>
  • - <%= link_to "#{field.name}", projects_organization_path(@organization, :org_subfield_id => field.id, :type => "famous"), :class => "sn-link-white", :target => "_blank" %> + <%= link_to "#{field.name}", projects_organization_path(@organization, :org_subfield_id => field.id, :type => "#{User.current.admin? ? "" : "famous"}"), :class => "sn-link-white", :target => "_blank" %>
  • <% elsif field.field_type == "Compcou" %>
  • - <%= link_to "#{field.name}", courses_organization_path(@organization, :org_subfield_id => field.id, :type => "famous"), :class => "sn-link-white", :target => "_blank" %> + <%= link_to "#{field.name}", courses_organization_path(@organization, :org_subfield_id => field.id, :type => "#{User.current.admin? ? "" : "famous"}"), :class => "sn-link-white", :target => "_blank" %>
  • <% elsif field.field_type == "Compact" %>
  • diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index c1cc3a20f..ddc504640 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -117,23 +117,23 @@
  • <% end %> - <% elsif field.field_type == "Comptec" && User.current.admin? %> + <% elsif field.field_type == "Comptec" %>
    - <%= link_to "#{field.name}", teachers_organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %> + <%= link_to "#{field.name}", teachers_organization_path(organization, :org_subfield_id => field.id, :type => "#{User.current.admin? ? "" : "famous"}"), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %>
    - <% elsif field.field_type == "Compstu" && User.current.admin? %> + <% elsif field.field_type == "Compstu" %>
    - <%= link_to "#{field.name}", students_organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %> + <%= link_to "#{field.name}", students_organization_path(organization, :org_subfield_id => field.id, :type => "#{User.current.admin? ? "" : "famous"}"), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %>
    - <% elsif field.field_type == "Comppro" && User.current.admin? %> + <% elsif field.field_type == "Comppro" %>
    - <%= link_to "#{field.name}", projects_organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %> + <%= link_to "#{field.name}", projects_organization_path(organization, :org_subfield_id => field.id, :type => "#{User.current.admin? ? "" : "famous"}"), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %>
    - <% elsif field.field_type == "Compcou" && User.current.admin? %> + <% elsif field.field_type == "Compcou" %>
    - <%= link_to "#{field.name}", courses_organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %> + <%= link_to "#{field.name}", courses_organization_path(organization, :org_subfield_id => field.id, :type => "#{User.current.admin? ? "" : "famous"}"), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %>
    - <% elsif field.field_type == "Compact" && User.current.admin? %> + <% elsif field.field_type == "Compact" %>
    <%= link_to "#{field.name}", acts_organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %>
    diff --git a/app/views/organizations/_org_students_list.html.erb b/app/views/organizations/_org_students_list.html.erb index d3db6fbf6..482447c56 100644 --- a/app/views/organizations/_org_students_list.html.erb +++ b/app/views/organizations/_org_students_list.html.erb @@ -21,7 +21,7 @@
    资源数
    - <% if User.current.admin_of_org?(@organization) %> + <% if User.current.admin? %> <%= org_student.excellent_student ==0 ? "设为学霸" : "取消设置" %> <% end %>
    diff --git a/app/views/organizations/_org_teachers_list.html.erb b/app/views/organizations/_org_teachers_list.html.erb index f2523fb9f..90467d870 100644 --- a/app/views/organizations/_org_teachers_list.html.erb +++ b/app/views/organizations/_org_teachers_list.html.erb @@ -28,15 +28,8 @@
    资源数
    - <% if User.current.admin_of_org?(@organization) %> + <% if User.current.admin? %> <%= org_teacher.excellent_teacher==0?"设为名师":"取消设置" %> - - <% else %> - - - - - <% end %>
    From fbfb382d789da8fad45249693dd70be11baddc3c Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 7 Jun 2016 17:22:57 +0800 Subject: [PATCH 34/41] base --- public/javascripts/wechat/app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 5dc1e90fd..a2351b367 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -67,7 +67,7 @@ app.factory('rms', function(){ return {save: save, get: get}; }); -app.controller('ActivityController',function($anchorScroll, $location,$scope, $http, $document,$window, auth, rms, common){ +app.controller('ActivityController',function($anchorScroll, $location,$scope, $http, auth, rms, common){ $scope.replaceUrl = function(url){ return url; }; @@ -80,7 +80,7 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h if($scope.activities.length>0){ $timeout(function () { - $window.scroll(0,rms.get("yoffset")); + window.scroll(0,rms.get("yoffset")); }); @@ -135,7 +135,7 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h //跳到详情页 $scope.goDetail = function(type, act_id,id){ - rms.save("yoffset", $document.body.scrollHeight); + rms.save("yoffset", window.document.body.scrollHeight); $location.path('/'+type+'/'+act_id); } From 5b34f498c957a26c49e429ed41f2cc26da726e18 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 7 Jun 2016 17:23:56 +0800 Subject: [PATCH 35/41] base --- public/javascripts/wechat/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index a2351b367..06a1d86d9 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -67,7 +67,7 @@ app.factory('rms', function(){ return {save: save, get: get}; }); -app.controller('ActivityController',function($anchorScroll, $location,$scope, $http, auth, rms, common){ +app.controller('ActivityController',function($anchorScroll, $location,$scope, $http, $timeout, auth, rms, common){ $scope.replaceUrl = function(url){ return url; }; From 37975552c98e00c3d1a3c834b63ccac2db167b36 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 7 Jun 2016 17:27:17 +0800 Subject: [PATCH 36/41] base --- public/javascripts/wechat/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 06a1d86d9..0fceed85f 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -135,7 +135,7 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h //跳到详情页 $scope.goDetail = function(type, act_id,id){ - rms.save("yoffset", window.document.body.scrollHeight); + rms.save("yoffset", window.document.body.scrollTop); $location.path('/'+type+'/'+act_id); } From 1251e31061d781e2108ff3db2f9a0a9bf4d3dd49 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 7 Jun 2016 17:36:11 +0800 Subject: [PATCH 37/41] =?UTF-8?q?=20=20=E4=B8=8D=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/app.js | 45 ++++++++------------------------ 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 0fceed85f..54c4bd90e 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -74,21 +74,11 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h console.log("ActivityController load"); - $scope.page = 0; + $scope.page = rms.get('page') || 0; $scope.activities = rms.get("activities") || []; + $scope.has_more = rms.get("has_more"); - if($scope.activities.length>0){ - - $timeout(function () { - window.scroll(0,rms.get("yoffset")); - }); - - - return; - } - - - var loadActData = function(page){ + $scope.loadActData = function(page){ $scope.page = page; $http({ @@ -96,20 +86,16 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h url: apiUrl+ "activities", data: {openid: auth.openid(), page: page} }).then(function successCallback(response) { - $scope.current_page = 0; - console.log($scope.current_page); - console.log(response.data.page); - if($scope.current_page < response.data.page) { + if(response.data.page >0) { $scope.activities = $scope.activities.concat(response.data.data); } else { $scope.activities = response.data.data; } rms.save("activities", $scope.activities); - - - $scope.has_more = (response.data.count + response.data.page * 10) < response.data.all_count; + rms.save('has_more', $scope.has_more); + rms.save('page', response.data.page); console.log(response.data); @@ -118,20 +104,14 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h }; if($scope.activities.length<=0){ - auth.getOpenId().then( function successCallback(response){ - loadActData($scope.page); + $scope.loadActData(0); }, function errorCallback(response) { alert("获取openid出错:"+response); } ); - - } - - - - $scope.loadActData = loadActData; + }; //跳到详情页 $scope.goDetail = function(type, act_id,id){ @@ -146,9 +126,6 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h $scope.decreasePraise = function(act){ common.decreaseCommonPraise(act); }; - - - }); app.factory('common', function($http, auth, $routeParams){ @@ -517,9 +494,9 @@ app.directive('loadingSpinner', function ($http) { app.config(['$routeProvider',"$httpProvider", "$locationProvider",function ($routeProvider, $httpProvider, $locationProvider) { var rootPath = '/assets/wechat/' - $locationProvider.html5Mode(true); + //$locationProvider.html5Mode(true); $routeProvider - .when('/', { + .when('/activites', { templateUrl: rootPath + 'activities.html', controller: 'ActivityController' }) @@ -552,7 +529,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",function ($rou controller: 'BlogController' }) .otherwise({ - redirectTo: '/' + redirectTo: '/activites' }); //监听异步请求,实现加载中显隐标记 From 9c01bb63e77a9a7997138ac7a8be4c4017465a90 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 7 Jun 2016 17:36:33 +0800 Subject: [PATCH 38/41] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E6=A0=8F=E7=9B=AE=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/organizations_helper.rb | 10 +++++----- app/views/organizations/_subfield_list.html.erb | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 181dfccb9..60714f597 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -213,11 +213,11 @@ module OrganizationsHelper # 系统栏目只有管理员才能看到 def subfield_to_addmin?(org) - if User.current.admin? - @organization.org_subfields.order("priority") - else - @organization.org_subfields.select { |os| (os.field_type != "Comptec" && os.field_type != "Compstu" && os.field_type != "Comppro" && os.field_type != "Compcou" && os.field_type != "Compact") }.sort_by {|os| os.priority} - end + # if User.current.admin? + @organization.org_subfields.order("priority") + # else + # @organization.org_subfields.select { |os| (os.field_type != "Comptec" && os.field_type != "Compstu" && os.field_type != "Comppro" && os.field_type != "Compcou" && os.field_type != "Compact") }.sort_by {|os| os.priority} + # end end def get_subfield_acts field diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb index 946043a62..aa1084304 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -89,7 +89,11 @@
  • <%= field.hide==0?"隐藏":"可见" %> | - <%= link_to "删除", org_subfield_path(field), :method => 'delete', :remote => true, :confirm => "您确定删除吗?", :class => "linkGrey fr ml5 mr5" %> + <% if (field.field_type == "Comptec" || field.field_type == "Compstu" || field.field_type == "Comppro" || field.field_type == "Compcou" || field.field_type == "Compact") && !User.current.admin? %> + 默认 + <% else %> + <%= link_to "删除", org_subfield_path(field), :method => 'delete', :remote => true, :confirm => "您确定删除吗?", :class => "linkGrey fr ml5 mr5" %> + <% end %> | 编辑 <% unless field.field_type == "Resource" || field.field_type == "Comptec" || field.field_type == "Compstu" || field.field_type == "Comppro" || field.field_type == "Compcou" || field.field_type == "Compact" %> From 8b05b33e38747e7d0a9b23017ffb9526c867a689 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 7 Jun 2016 17:38:38 +0800 Subject: [PATCH 39/41] =?UTF-8?q?=20=20=E4=B8=8D=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/app.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 54c4bd90e..4e1df0381 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -111,7 +111,12 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h alert("获取openid出错:"+response); } ); - }; + } else { + $timeout(function(){ + window.scrollTo(0, rms.get("yoffset")); + }); + + } //跳到详情页 $scope.goDetail = function(type, act_id,id){ From e4f48f046be13c2a13992892da7fbc73d714b135 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 8 Jun 2016 09:16:57 +0800 Subject: [PATCH 40/41] =?UTF-8?q?=E5=AD=90=E9=A1=B5=E9=9D=A2=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=86=85=E5=AE=B9=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 9 +++- .../_show_custom_org_subfield.html.erb | 1 + app/views/organizations/acts.html.erb | 45 +++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 app/views/organizations/acts.html.erb diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index ae1119609..098cefceb 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -29,7 +29,7 @@ class OrganizationsController < ApplicationController helper :issues include UsersHelper include OrganizationsHelper - before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout, :teachers, :students, :projects, :courses] + before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout, :teachers, :students, :projects, :courses, :acts] # before_filter :allow_as_admin, :only => [:students, :teachers, :projects, :courses, :acts] layout 'base_org' def index @@ -265,6 +265,13 @@ class OrganizationsController < ApplicationController end def acts + @subfield_content = @organization.org_subfields.order("priority") + @org_subfield = OrgSubfield.where(:id => params[:org_subfield_id]).first + @subfield_acts = get_subfield_acts(@org_subfield) + respond_to do |format| + format.html{render :layout => 'base_org_custom'} + format.js + end end def searchmember_by_name members, name diff --git a/app/views/organizations/_show_custom_org_subfield.html.erb b/app/views/organizations/_show_custom_org_subfield.html.erb index 10ac31637..54416b6f0 100644 --- a/app/views/organizations/_show_custom_org_subfield.html.erb +++ b/app/views/organizations/_show_custom_org_subfield.html.erb @@ -1,4 +1,5 @@ <% if @subfield_acts.blank? %> +

    该模块暂时没有相关内容

    <% else %>
    diff --git a/app/views/organizations/acts.html.erb b/app/views/organizations/acts.html.erb new file mode 100644 index 000000000..da6b79ee6 --- /dev/null +++ b/app/views/organizations/acts.html.erb @@ -0,0 +1,45 @@ +<% if @subfield_acts.blank? %> +

    该模块暂时没有相关内容

    +<% else %> +
    +
    +
    +
    + 您的位置:<%= link_to "首页", organization_path(@organization), :class => "sn-link-grey2" %> > + <%= @org_subfield.name %> +
    +
    +
    +

    <%= @org_subfield.name %>

    +
      + <% @subfield_acts.each do |act| %> + <% title = subfield_title_type(act) %> + <% time = subfield_time_type(act) %> + <% reply_count = subfield_reply_count_type(act) %> + <% document = act.org_act %> +
    • +
      + <% if act.org_act_type == "OrgDocumentComment" %> + <%=link_to title, org_document_comment_path(act.org_act, :organization_id => @organization.id), :class => "sn-newslist-titile fl", :target => "_blank" %> + <% elsif act.org_act_type == "News" %> + <%=link_to title, news_path(act.org_act), :class => "sn-newslist-titile fl", :target => "_blank" %> + <% elsif act.org_act_type == "Message" %> + <%=link_to title, board_message_path(act.org_act.board.id, act.org_act.id), :class => "sn-newslist-titile fl", :target => "_blank" %> + <% end %> + <%= format_date(time) %> + 回复(<%= reply_count %>) +
      +
    • + <% end %> +
    + + + + + + + +
    +
    +
    +<% end %> From 67f0cad331227dd5d3fe05718ec92553ea915d85 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 8 Jun 2016 09:40:05 +0800 Subject: [PATCH 41/41] =?UTF-8?q?=E7=BB=84=E7=BB=87=E7=BD=91=E7=AB=99?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=96=B0=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 8 +++++- app/helpers/organizations_helper.rb | 15 ++++++++++ app/views/organizations/acts.html.erb | 31 +++++++++++++-------- 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 098cefceb..97fd65aa7 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -267,7 +267,13 @@ class OrganizationsController < ApplicationController def acts @subfield_content = @organization.org_subfields.order("priority") @org_subfield = OrgSubfield.where(:id => params[:org_subfield_id]).first - @subfield_acts = get_subfield_acts(@org_subfield) + shield_project_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id) + shield_course_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id) + project_ids = (@organization.projects.map(&:id) - shield_project_ids) << 0 + course_ids = (@organization.courses.map(&:id) - shield_course_ids) << 0 + @org_acts = UserActivity.find_by_sql("SELECT * FROM `user_activities` where act_type in ('HomeworkCommon', 'News', 'Message', 'Issue') and + ((container_type = 'Course' and container_id in (#{course_ids.join(',')})) or (container_type = 'Project' and container_id in (#{project_ids.join(',')}))) + order by updated_at desc limit 6;") respond_to do |format| format.html{render :layout => 'base_org_custom'} format.js diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 60714f597..4099ea451 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -115,6 +115,19 @@ module OrganizationsHelper end end + def org_reply_count_type obj + case obj.act_type + when "HomeworkCommon" + obj.act.journals_for_messages.count + when "Issue" + obj.act.journals.count + when "Message" + obj.act.children.count + when "News" + obj.act.comments_count + end + end + # 组织的栏目类型标题 def subfield_title_type obj case obj.org_act_type @@ -124,6 +137,8 @@ module OrganizationsHelper obj.org_act.parent_id.nil? ? obj.org_act.subject : obj.org_act.parent.subject when "News" obj.org_act.title + when "Issue" + obj.org_act.subject end end diff --git a/app/views/organizations/acts.html.erb b/app/views/organizations/acts.html.erb index da6b79ee6..8bd664711 100644 --- a/app/views/organizations/acts.html.erb +++ b/app/views/organizations/acts.html.erb @@ -1,4 +1,4 @@ -<% if @subfield_acts.blank? %> +<% if @org_acts.blank? %>

    该模块暂时没有相关内容

    <% else %>
    @@ -12,20 +12,27 @@

    <%= @org_subfield.name %>

      - <% @subfield_acts.each do |act| %> - <% title = subfield_title_type(act) %> - <% time = subfield_time_type(act) %> - <% reply_count = subfield_reply_count_type(act) %> - <% document = act.org_act %> + <% @org_acts.each do |obj| %> + <% user = org_user_by_type(obj) %> + <% title = org_title_by_type(obj) %> + <% content = org_content_by_type(obj) %> + <% time = org_time_by_type(obj) %> + <% reply_count = org_reply_count_type(obj) %>
    • - <% if act.org_act_type == "OrgDocumentComment" %> - <%=link_to title, org_document_comment_path(act.org_act, :organization_id => @organization.id), :class => "sn-newslist-titile fl", :target => "_blank" %> - <% elsif act.org_act_type == "News" %> - <%=link_to title, news_path(act.org_act), :class => "sn-newslist-titile fl", :target => "_blank" %> - <% elsif act.org_act_type == "Message" %> - <%=link_to title, board_message_path(act.org_act.board.id, act.org_act.id), :class => "sn-newslist-titile fl", :target => "_blank" %> + <% if obj.act_type == "Message" %> + <%= link_to title, board_message_path(obj.act.board.id, obj.act.id), :class => "sn-newslist-titile fl", :target => "_blank" %> + <% elsif obj.act_type == "News" %> + <%= link_to title, news_path(obj.act.id), :class => "sn-newslist-titile fl", :target => "_blank" %> + <% elsif obj.act_type == "HomeworkCommon" %> + <%= link_to title, student_work_index_url_in_org(obj.act.id), :class => "sn-newslist-titile fl", :target => "_blank" %> + <% elsif obj.act_type == "Issue" %> + <%= link_to title, issue_path(obj.act.id), :class => "sn-newslist-titile fl", :target => "_blank" %> <% end %> + + + + <%= format_date(time) %> 回复(<%= reply_count %>)