Class: Crm::PublicationPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- BasePresenter
- Crm::PublicationPresenter
- Defined in:
- app/presenters/crm/publication_presenter.rb
Instance Attribute Summary
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Delegated Instance Attributes collapse
-
#cover_image_url ⇒ Object
Alias for Publication#cover_image_url.
Methods inherited from BasePresenter
#can?, #capture, #concat, #content_tag, #fa_icon, #link_to, #number_to_currency, #simple_format
Instance Method Summary collapse
- #auto_locale_urls ⇒ Object
- #available_service_locales_with_urls ⇒ Object
- #has_attachment? ⇒ Boolean
- #publication_tab_options ⇒ Object
- #revisions_count ⇒ Object
Methods inherited from BasePresenter
Methods inherited from BasePresenter
#h, #initialize, #present, presents, #r, #safe_present, #u
Constructor Details
This class inherits a constructor from Crm::BasePresenter
Instance Method Details
#auto_locale_urls ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'app/presenters/crm/publication_presenter.rb', line 34 def auto_locale_urls return nil unless publication.available_to_all_locales? { pdf_url: h.publication_url(id: publication.sku, locale: '', host: WEB_URL, format: :pdf), html_url: h.publication_url(id: publication.sku, locale: '', host: WEB_URL) } end |
#available_service_locales_with_urls ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'app/presenters/crm/publication_presenter.rb', line 23 def available_service_locales_with_urls publication.available_service_locales.map do |locale| { locale: locale, country_name: LocaleUtility.iso3166_for_locale(locale).common_name, pdf_url: h.publication_url(id: publication.sku, locale: locale, host: WEB_URL, format: :pdf), html_url: h.publication_url(id: publication.sku, locale: locale, host: WEB_URL) } end end |
#cover_image_url ⇒ Object
Alias for Publication#cover_image_url
43 |
# File 'app/presenters/crm/publication_presenter.rb', line 43 delegate :cover_image_url, to: :publication |
#has_attachment? ⇒ Boolean
45 46 47 |
# File 'app/presenters/crm/publication_presenter.rb', line 45 def publication.literature&. end |
#publication_tab_options ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/presenters/crm/publication_presenter.rb', line 6 def tabs = {} tabs[:overview] = { remote_href: h.tab_overview_publication_path(r.id) } tabs[:attributes] = { remote_href: h.tab_attributes_publication_path(r.id) } tabs[:description] = { remote_href: h.tab_description_publication_path(r.id) } if publication.detailed_description_html.present? tabs[:ai_embedding] = { remote_href: h.(r.id) } tabs[:revisions] = { remote_href: h.tab_revisions_publication_path(r.id), counter: revisions_count } tabs[:store_items] = { remote_href: h.tab_store_items_publication_path(r.id), counter: publication.store_items.size } tabs[:catalogs] = { remote_href: h.tab_catalogs_publication_path(r.id), counter: publication.catalog_items.size } tabs[:specific_items] = { remote_href: h.tab_specific_items_publication_path(r.id), counter: publication.specific_items.size } if publication.specific_items.any? tabs end |
#revisions_count ⇒ Object
19 20 21 |
# File 'app/presenters/crm/publication_presenter.rb', line 19 def revisions_count Item.publications.where('sku ILIKE ?', "#{publication.canonical_sku}%").count end |