From c362315ea55c3b0592e26171eaa2ce5d67a8f185 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 18 Jul 2024 15:32:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E7=B1=BB=E5=88=AB=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admins/projects_controller.rb | 10 ++++++++++ app/views/admins/projects/index.html.erb | 13 ++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/controllers/admins/projects_controller.rb b/app/controllers/admins/projects_controller.rb index fd576b8c8..5589c66c2 100644 --- a/app/controllers/admins/projects_controller.rb +++ b/app/controllers/admins/projects_controller.rb @@ -7,6 +7,16 @@ class Admins::ProjectsController < Admins::BaseController sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc' search = params[:search].to_s.strip projects = Project.where("name like ? OR identifier LIKE ?", "%#{search}%", "%#{search}%").order("#{sort_by} #{sort_direction}") + case params[:category] + when 'public' + projects = projects.where(is_public: true) + when 'private' + projects = projects.where(is_public: false) + when 'fork' + projects = projects.where.not(forked_from_project_id: nil) + when 'original' + projects = projects.where(forked_from_project_id: nil, project_type: 'common') + end @projects = paginate projects.includes(:owner, :members, :issues, :versions, :attachments, :project_score) end diff --git a/app/views/admins/projects/index.html.erb b/app/views/admins/projects/index.html.erb index 35d931b02..be36229fd 100644 --- a/app/views/admins/projects/index.html.erb +++ b/app/views/admins/projects/index.html.erb @@ -3,10 +3,15 @@ <% end %>
- <%= form_tag(admins_projects_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> + <%= form_tag(admins_projects_path, method: :get, class: 'form-inline search-form flex-1', id: 'project-list-form', remote: true) do %> <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '项目名称/标识检索') %> <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> +
+ + <% type_options = [['全部项目', ''], ['公开项目', 'public'], ['私有项目', 'private'], ['Fork项目', 'fork'], ['原创项目', 'original']] %> + <%= select_tag(:category, options_for_select(type_options, params[:category]), class: 'form-control', id: 'project-category') %> +
<% end %>
@@ -16,3 +21,9 @@
+ + \ No newline at end of file