Sha256: a2bc791dd8ee1d1c3a857ca1b6896ef33232bb09e4d5f64770daa0dcd5a535ab

Contents?: true

Size: 1.62 KB

Versions: 17

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

module Comfy
  module Admin
    module CmsHelper

      # Wrapper around ComfortableMexicanSofa::FormBuilder
      def comfy_form_with(**options, &block)
        form_options = options.merge(builder: ComfortableMexicanSofa::FormBuilder)
        form_options[:bootstrap]  = { layout: :horizontal }
        form_options[:local]      = true
        bootstrap_form_with(**form_options, &block)
      end

      def comfy_admin_partial(path, params = {})
        render path, params
      rescue ActionView::MissingTemplate
        if ComfortableMexicanSofa.config.reveal_cms_partials
          content_tag(:div, class: "comfy-admin-partial") do
            path
          end
        end
      end

      # Injects some content somewhere inside cms admin area
      def cms_hook(name, options = {})
        ComfortableMexicanSofa::ViewHooks.render(name, self, options)
      end

      # @param [String] fragment_id
      # @param [ActiveStorage::Blob] attachment
      # @param [Boolean] multiple
      # @return [String] {{ cms:page_file_link #{fragment_id}, ... }}
      def cms_page_file_link_tag(fragment_id:, attachment:, multiple:)
        filename  = ", filename: \"#{attachment.filename}\""  if multiple
        as        = ", as: image"                             if attachment.image?
        "{{ cms:page_file_link #{fragment_id}#{filename}#{as} }}"
      end

      # @param [Comfy::Cms::File] file
      # @return [String] {{ cms:file_link #{file.id}, ... }}
      def cms_file_link_tag(file)
        as = ", as: image" if file.attachment.image?
        "{{ cms:file_link #{file.id}#{as} }}"
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 6 rubygems

Version Path
comfortable_mexican_sofa-2.0.19 app/helpers/comfy/admin/cms_helper.rb
PixelForce_ETS-0.0.2 app/helpers/comfy/admin/cms_helper.rb
PixelForce_ETS-0.0.1 app/helpers/comfy/admin/cms_helper.rb
kcyEtsTest2-0.0.4 app/helpers/comfy/admin/cms_helper.rb
kcyEtsTest2-0.0.3 app/helpers/comfy/admin/cms_helper.rb
kcyEtsTest2-0.0.2 app/helpers/comfy/admin/cms_helper.rb
kcyEtsTest2-0.0.1 app/helpers/comfy/admin/cms_helper.rb
kcyEtsTest-0.0.1 app/helpers/comfy/admin/cms_helper.rb
kcyEtsTest-2.2.19 app/helpers/comfy/admin/cms_helper.rb
ComfortableMexicanSofa-2.0.18 app/helpers/comfy/admin/cms_helper.rb
kcy1-1.0 app/helpers/comfy/admin/cms_helper.rb
comfortable_mexican_sofa-2.0.18 app/helpers/comfy/admin/cms_helper.rb
comfortable_mexican_sofa-2.0.17 app/helpers/comfy/admin/cms_helper.rb
comfortable_mexican_sofa-2.0.16 app/helpers/comfy/admin/cms_helper.rb
comfortable_mexican_sofa-2.0.15 app/helpers/comfy/admin/cms_helper.rb
comfortable_mexican_sofa-2.0.14 app/helpers/comfy/admin/cms_helper.rb
comfortable_mexican_sofa-2.0.13 app/helpers/comfy/admin/cms_helper.rb