diff --git a/app/controllers/dashboard/videos_controller.rb b/app/controllers/dashboard/videos_controller.rb index 179f9dec..b8d3be3a 100644 --- a/app/controllers/dashboard/videos_controller.rb +++ b/app/controllers/dashboard/videos_controller.rb @@ -8,7 +8,8 @@ class VideosController < Dashboard::DashboardController def index @sorter = VideoSorter.new(query: params[:sort] || DEFAULT_SORT_CRITERIA) - @videos = @sorter.videos.page(params[:page]) + @videos = @sorter.videos.where(filter_criteria).page(params[:page]) + @playlists = Playlist.select(:id, :title).order(:topic_id, :created_at) end def show; end @@ -75,5 +76,9 @@ def video_params video_params[:tags] = video_params[:tags].split if video_params[:tags].present? end end + + def filter_criteria + params.permit(:playlist_id).compact_blank + end end end diff --git a/app/views/dashboard/pending/show_notes/show.html.erb b/app/views/dashboard/pending/show_notes/show.html.erb index 50525e0b..b28cd394 100644 --- a/app/views/dashboard/pending/show_notes/show.html.erb +++ b/app/views/dashboard/pending/show_notes/show.html.erb @@ -17,7 +17,7 @@ <%= f.submit 'Apply filters', type: :submit, name: nil, class: 'btn btn-primary btn-sm' %> <%= link_to 'Reset', dashboard_pending_show_notes_path, class: 'btn btn-light btn-sm' %>
- <% end %> +<% end %>+ <%= f.label :playlist_id, 'Playlist' %> + <%= f.select :playlist_id, @playlists.pluck(:title, :id), selected: params[:playlist_id], include_blank: '(ninguna)' %> +
++ <%= hidden_field_tag :sort, params[:sort] %> + <%= f.submit 'Apply filters', type: :submit, name: nil, class: 'btn btn-primary btn-sm' %> + <%= link_to 'Reset', dashboard_videos_path, class: 'btn btn-light btn-sm' %> +
+<% end %> +