Sha256: 15511475f4aba93a3a221c4eb449bf1addd8eba857903d1e2fef80079cc1f8cf

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 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 online_meeting_url
      URI::Parser.new.escape(model.online_meeting_url)
    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

2 entries across 2 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/cells/decidim/address_cell.rb
decidim-core-0.29.0 app/cells/decidim/address_cell.rb