File tree Expand file tree Collapse file tree 2 files changed +26
-5
lines changed
Expand file tree Collapse file tree 2 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -12,14 +12,23 @@ def index
1212 def projects
1313 page = params [ :page ] . to_i > 0 ? params [ :page ] . to_i : 1
1414 per_page = 50
15+ status_filter = params [ :status ]
1516
1617 @all_projects = Project . includes ( :user ) . order ( created_at : :desc )
17- @total_projects = @all_projects . count
18+
19+ if status_filter . present? && %w[ approved pending rejected in-review ] . include? ( status_filter )
20+ @filtered_projects = @all_projects . where ( status : status_filter )
21+ else
22+ @filtered_projects = @all_projects
23+ end
24+
25+ @total_projects = @filtered_projects . count
1826 @total_pages = ( @total_projects . to_f / per_page ) . ceil
1927 @current_page = page
28+ @status_filter = status_filter
2029
2130 offset = ( page - 1 ) * per_page
22- @projects = @all_projects . offset ( offset ) . limit ( per_page )
31+ @projects = @filtered_projects . offset ( offset ) . limit ( per_page )
2332 @pending_projects = @all_projects . where ( status : "in-review" ) . limit ( per_page )
2433 end
2534
Original file line number Diff line number Diff line change 8080 </ div >
8181 <% end %>
8282
83- < h2 style ="margin: 30px 0 12px; "> All Projects (Page <%= @current_page %> of <%= @total_pages %> )</ h2 >
84-
85- < div class ="admin-table ">
83+ < div style ="display: flex; justify-content: space-between; align-items: center; margin: 30px 0 12px; ">
84+ < h2 style ="margin: 0; "> All Projects (Page <%= @current_page %> of <%= @total_pages %> )</ h2 >
85+ < div style ="display: flex; align-items: center; gap: 0.5rem; ">
86+ < label for ="status-filter " style ="font-size: 14px; color: #666; font-weight: 600; "> Filter:</ label >
87+ < select id ="status-filter " style ="padding: 8px 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; cursor: pointer; " onchange ="window.location.href = this.value ">
88+ < option value ="/admin/projects?page=1 " <%= 'selected' if !@status_filter %> > All</ option >
89+ < option value ="/admin/projects?status=approved&page=1 " <%= 'selected' if @status_filter == 'approved' %> > Approved</ option >
90+ < option value ="/admin/projects?status=in-review&page=1 " <%= 'selected' if @status_filter == 'in-review' %> > In Review</ option >
91+ < option value ="/admin/projects?status=pending&page=1 " <%= 'selected' if @status_filter == 'pending' %> > Pending</ option >
92+ < option value ="/admin/projects?status=rejected&page=1 " <%= 'selected' if @status_filter == 'rejected' %> > Rejected</ option >
93+ </ select >
94+ </ div >
95+ </ div >
96+
97+ < div class ="admin-table ">
8698 <% @projects . each do |project | %>
8799 < a href ="<%= admin_project_path ( project ) %> " class ="admin-row card " style ="padding: 12px 16px; display: flex; justify-content: space-between; text-decoration: none; color: inherit; ">
88100 < div class ="admin-row__main ">
You can’t perform that action at this time.
0 commit comments