Class: Decidim::Gallery::MainCell
- Inherits:
-
ViewModel
- Object
- ViewModel
- Decidim::Gallery::MainCell
- Defined in:
- app/cells/decidim/gallery/main_cell.rb
Defined Under Namespace
Instance Method Summary collapse
- #browser ⇒ Object
- #collection ⇒ Object
- #current_participatory_space ⇒ Object
- #gallery_component ⇒ Object
- #gallery_path(**options) ⇒ Object
- #items ⇒ Object
- #list_items ⇒ Object
- #show ⇒ Object
- #stubbed_video_object(item) ⇒ Object
- #title ⇒ Object
Instance Method Details
#browser ⇒ Object
58 59 60 61 62 63 |
# File 'app/cells/decidim/gallery/main_cell.rb', line 58 def browser @browser ||= Browser.new( request.headers["User-Agent"], accept_language: request.headers["Accept-Language"] ) end |
#collection ⇒ Object
15 16 17 |
# File 'app/cells/decidim/gallery/main_cell.rb', line 15 def collection render "#{gallery_type}_collection" end |
#current_participatory_space ⇒ Object
65 66 67 |
# File 'app/cells/decidim/gallery/main_cell.rb', line 65 def current_participatory_space controller.try(:current_participatory_space) end |
#gallery_component ⇒ Object
54 55 56 |
# File 'app/cells/decidim/gallery/main_cell.rb', line 54 def gallery_component @gallery_component ||= Decidim::Component.find_by(id: model.gallery_id) end |
#gallery_path(**options) ⇒ Object
34 35 36 37 |
# File 'app/cells/decidim/gallery/main_cell.rb', line 34 def gallery_path(**) current_params = try(:params) || {} EngineRouter.main_proxy(gallery_component).root_path({ locale: current_params[:locale] }.reverse_merge()) end |
#items ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'app/cells/decidim/gallery/main_cell.rb', line 25 def items @items ||= Decidim::Gallery::GalleryItem .published .where(decidim_component_id: gallery_component.id) .order(weight: :asc, published_at: :asc) .page([:page]) .per(per_page) end |
#list_items ⇒ Object
19 20 21 22 23 |
# File 'app/cells/decidim/gallery/main_cell.rb', line 19 def list_items return "" if gallery_type == "video" render "#{gallery_type}_list" end |
#show ⇒ Object
9 10 11 12 13 |
# File 'app/cells/decidim/gallery/main_cell.rb', line 9 def show snippets.add(:foot, helpers.javascript_pack_tag("decidim_gallery", defer: false)) render gallery_type.to_sym if gallery_component.present? end |
#stubbed_video_object(item) ⇒ Object
42 43 44 45 46 47 48 |
# File 'app/cells/decidim/gallery/main_cell.rb', line 42 def stubbed_video_object(item) Video.new(settings: Settings.new( video_url: translated_attribute(item.video_url), title: translated_attribute(item.title) ), cache_key_with_version: item.cache_key_with_version) end |
#title ⇒ Object
50 51 52 |
# File 'app/cells/decidim/gallery/main_cell.rb', line 50 def title translated_attribute(gallery_component.name) end |