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 %> @@ -44,4 +44,4 @@
-<%= paginate @videos %> \ No newline at end of file +<%= paginate @videos %> diff --git a/app/views/dashboard/videos/index.html.erb b/app/views/dashboard/videos/index.html.erb index b592d505..bb27af92 100644 --- a/app/views/dashboard/videos/index.html.erb +++ b/app/views/dashboard/videos/index.html.erb @@ -8,6 +8,19 @@ <% content_for :toolbar do %> <%= link_to t('.new_video'), [:new, :dashboard, :video], class: 'btn btn-success' %> <% end %> + +<%= form_with method: :get do |f| %> +

+ <%= 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 %> +