Sha256: 45883c82743752ae631d57851c26281edb047c42c274d68f30495f14de9b9445

Contents?: true

Size: 1.37 KB

Versions: 4

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

module Decidim
  # This cell renders the address of a meeting.
  class AddressCell < Decidim::ViewModel
    include Cell::ViewModel::Partial

    def show
      return render :online if options[:online]

      render
    end

    def has_location?
      model.respond_to?(:location)
    end

    def has_location_hints?
      model.respond_to?(:location_hints)
    end

    def location_hints
      decidim_sanitize_translated(model.location_hints)
    end

    def location
      decidim_sanitize_translated(model.location)
    end

    def address
      decidim_sanitize_translated(model.address)
    end

    def display_start_and_end_time?
      model.respond_to?(:start_time) && model.respond_to?(:end_time)
    end

    def start_and_end_time
      <<~HTML
        #{with_tooltip(l(model.start_time, format: :tooltip)) { start_time }}
        -
        #{with_tooltip(l(model.end_time, format: :tooltip)) { end_time }}
      HTML
    end

    def display_online_meeting_url?
      return true unless model.respond_to?(:online?)
      return true unless model.respond_to?(:iframe_access_level_allowed_for_user?)

      model.online? && model.iframe_access_level_allowed_for_user?(current_user)
    end

    private

    def start_time
      l model.start_time, format: "%H:%M %p"
    end

    def end_time
      l model.end_time, format: "%H:%M %p %Z"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-core-0.29.0.rc4 app/cells/decidim/address_cell.rb
decidim-core-0.29.0.rc3 app/cells/decidim/address_cell.rb
decidim-core-0.29.0.rc2 app/cells/decidim/address_cell.rb
decidim-core-0.29.0.rc1 app/cells/decidim/address_cell.rb