Sha256: 46575528dcbd40275415f3bda918b442f09600a4f84b9e356aed356a4d13c6d1

Contents?: true

Size: 1.12 KB

Versions: 63

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Decidim
  # This cell is used to render an iframe to embed an Etherpad from a
  # Paddable model.
  class PadIframeCell < Decidim::ViewModel
    include Decidim::ApplicationHelper
    include Decidim::Core::Engine.routes.url_helpers

    def show
      return unless current_user
      return unless paddable.pad_is_visible?
      return if blank_read_only_pad?

      render
    end

    def iframe_id
      "etherpad-#{paddable.id}"
    end

    def iframe_url
      @iframe_url ||= [base_iframe_url, "?", url_options].join
    end

    def url_options
      URI.encode_www_form(
        userName: current_user.nickname,
        showControls: true,
        showLineNumbers: true,
        lang: current_user.locale
      )
    end

    def base_iframe_url
      return paddable.pad_public_url if paddable.pad_is_writable?

      paddable.pad_read_only_url
    end

    def paddable
      model
    end

    def current_organization
      current_user.organization
    end

    def blank_read_only_pad?
      paddable.pad_is_visible? && !paddable.pad_is_writable? && paddable.pad.text.blank?
    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
decidim-core-0.28.4 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.27.9 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.28.3 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.27.8 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.28.2 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.27.7 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.28.1 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.27.6 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.26.10 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.26.9 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.28.0 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.27.5 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.28.0.rc5 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.28.0.rc4 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.26.8 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.27.4 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.27.3 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.26.7 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.26.5 app/cells/decidim/pad_iframe_cell.rb
decidim-core-0.27.2 app/cells/decidim/pad_iframe_cell.rb