Sha256: cdc4291907fe1ec871706cf45e1ed006c13b1257661831de2c0a6cb311c2c67a

Contents?: true

Size: 926 Bytes

Versions: 36

Compression:

Stored size: 926 Bytes

Contents

module Alchemy
  module Admin
    class NodeSelect < ViewComponent::Base
      delegate :alchemy, to: :helpers

      def initialize(node = nil, url: nil, placeholder: Alchemy.t(:search_node), query_params: nil)
        @node = node
        @url = url
        @placeholder = placeholder
        @query_params = query_params
      end

      def call
        content_tag("alchemy-node-select", content, attributes)
      end

      private

      def attributes
        options = {
          "allow-clear": true,
          placeholder: @placeholder,
          url: @url || alchemy.api_nodes_path
        }

        if @query_params
          options[:"query-params"] = @query_params.to_json
        end

        if @node
          selection = ActiveModelSerializers::SerializableResource.new(@node, include: :ancestors)
          options[:selection] = selection.to_json
        end

        options
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
alchemy_cms-7.4.2 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.3.6 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.2.9 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.4.1 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.4.0 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.3.5 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.2.8 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.1.13 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.3.4 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.3.3 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.3.2 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.2.7 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.3.1 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.3.0 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.2.6 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.2.5 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.1.12 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.2.4 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.1.11 app/components/alchemy/admin/node_select.rb
alchemy_cms-7.2.3 app/components/alchemy/admin/node_select.rb