Module: Crm::VideosHelper
- Defined in:
- app/helpers/crm/videos_helper.rb
Overview
View helper: videos.
Instance Method Summary collapse
- #applied_filters_count(q) ⇒ Object
- #current_sort_option ⇒ Object
- #format_video_duration(seconds) ⇒ Object
- #video_actions(video) ⇒ Object
- #video_info(video) ⇒ Object
- #video_sort_options ⇒ Object
Instance Method Details
#applied_filters_count(q) ⇒ Object
58 59 60 61 62 63 |
# File 'app/helpers/crm/videos_helper.rb', line 58 def applied_filters_count(q) return 0 unless q # Use Ransack's conditions method to get all applied conditions q.conditions.count end |
#current_sort_option ⇒ Object
53 54 55 56 |
# File 'app/helpers/crm/videos_helper.rb', line 53 def current_sort_option # Check for sort parameter in q[s] (Ransack format) or as a separate sort parameter params.dig(:q, :s) || params[:sort] || 'created_at desc' end |
#format_video_duration(seconds) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/helpers/crm/videos_helper.rb', line 65 def format_video_duration(seconds) return nil unless seconds.present? && seconds.to_i.positive? total_seconds = seconds.to_i hours = total_seconds / 3600 minutes = (total_seconds % 3600) / 60 secs = total_seconds % 60 if hours.positive? format('%d:%02d:%02d', hours, minutes, secs) else format('%d:%02d', minutes, secs) end end |
#video_actions(video) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/helpers/crm/videos_helper.rb', line 4 def video_actions(video) return [] unless can?(:update, video) links = [] links << link_to(fa_icon('wrench', text: 'Edit'), edit_video_path(video)) links << link_to(fa_icon('microphone', text: 'Generate Transcript'), (video)) links << link_to(fa_icon('cloud', text: 'Cloudflare Updates'), cloudflare_updates_video_path(video)) if video.is_cloudflare? links << link_to(fa_icon('image', text: 'Extract Poster'), extract_poster_video_path(video)) if video.is_cloudflare? links << link_to(fa_icon('broom', text: 'Flush Cache'), flush_cache_video_path(video), data: { turbo_method: :post }) if can?(:update, video) links << link_to(fa_icon('download', text: 'Download'), download_video_path(video)) links << :separator # Delete link - always go to confirmation page for safety links << link_to(fa_icon('trash', text: 'Delete'), delete_confirmation_video_path(video), class: 'text-danger') links end |
#video_info(video) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/helpers/crm/videos_helper.rb', line 24 def video_info(video) [ "Title: #{video.title}", "Slug: #{video.slug}", "Category: #{video.category}", "Series: #{video.series}", "ID: #{video.id}", "Tags: #{video..join(', ')}", "Locales: #{video.locales&.join(', ')}" ].join("\n") end |
#video_sort_options ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/helpers/crm/videos_helper.rb', line 36 def [ ['Newest First', 'created_at desc'], ['Oldest First', 'created_at asc'], ['Title A-Z', 'title asc'], ['Title Z-A', 'title desc'], ['Category A-Z', 'category asc'], ['Category Z-A', 'category desc'], ['Series A-Z', 'series asc'], ['Series Z-A', 'series desc'], ['Air Date Newest', 'air_date desc'], ['Air Date Oldest', 'air_date asc'], ['Duration Ascending', 'duration_in_seconds asc'], ['Duration Descending', 'duration_in_seconds desc'] ] end |