From 3f63a5149950e86a15e85ec15ca10810f66664fa Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 11 Apr 2019 16:28:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5=E7=9A=84?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 5 ++++ app/views/users/_l_course.html.erb | 31 ++++++++++++----------- app/views/users/_l_project.html.erb | 31 ++++++++++++----------- app/views/users/_l_shixun.html.erb | 38 +++++++++++++++-------------- app/views/users/_p_path.html.erb | 31 ++++++++++++----------- 5 files changed, 76 insertions(+), 60 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3868f5a5..9e51ebbb 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2559,6 +2559,11 @@ class UsersController < ApplicationController end end @objects_count = @objects.size + page = params[:page] ? params[:page].to_i : 1 + @new_icon = @user == User.current && page == 1 && ['a_course', 'a_shixun', 'a_project', 'a_path'].include?(@type) + + # 用户进自己主页的全部列表时有个新建入口,在objects头部加一个"new"元素以确保翻页的正确性 + @objects.unshift 'new' if @user == User.current && ['a_course', 'a_shixun', 'a_project', 'a_path'].include?(@type) @objects = paginateHelper @objects, 16 respond_to do |format| diff --git a/app/views/users/_l_course.html.erb b/app/views/users/_l_course.html.erb index 4a020502..eeb9f92a 100644 --- a/app/views/users/_l_course.html.erb +++ b/app/views/users/_l_course.html.erb @@ -16,30 +16,33 @@
- -
+ <% if @new_icon %> + +
- + -
-
+
+
新建课堂 +
-
-
+
+ <% @objects.shift %> + <% end %> <%#= render :partial => "users/course_item", :locals => {:objects => @objects} %> diff --git a/app/views/users/_l_project.html.erb b/app/views/users/_l_project.html.erb index 1c0792b5..0113c646 100644 --- a/app/views/users/_l_project.html.erb +++ b/app/views/users/_l_project.html.erb @@ -16,31 +16,34 @@
- -
+ <% if @new_icon %> + +
- -
-
+
+
新建项目 +
-
-
+
+ <% @objects.shift %> + <% end %> <% @objects.each do |object| %> <% allow_visit = object.is_public || User.current.admin? || User.current.member_of?(object) %> diff --git a/app/views/users/_l_shixun.html.erb b/app/views/users/_l_shixun.html.erb index a6a91904..68dcdf6c 100644 --- a/app/views/users/_l_shixun.html.erb +++ b/app/views/users/_l_shixun.html.erb @@ -35,32 +35,34 @@
- -
+ <% if @new_icon %> + +
- -
-
+
+
- - 新建实训 - + + 新建实训 + +
-
- -
+
+ <% @objects.shift %> + <% end %> <% @objects.each do |object| %>
diff --git a/app/views/users/_p_path.html.erb b/app/views/users/_p_path.html.erb index b4873366..96fe683b 100644 --- a/app/views/users/_p_path.html.erb +++ b/app/views/users/_p_path.html.erb @@ -23,31 +23,34 @@
- -
+ <% if @new_icon %> + +
- -
-
+
+
新建实训课程 +
-
-
+
+ <% @objects.shift %> + <% end %> <% @objects.each_with_index do |object, index| %>