Sha256: b3a845d6bd2683016c79fac7c9b360592fa0a89fb23c30645920af37adc542b2
Contents?: true
Size: 1.12 KB
Versions: 9
Compression:
Stored size: 1.12 KB
Contents
module Alchemy module Admin class PageSelect < ViewComponent::Base delegate :alchemy, to: :helpers def initialize(page = nil, url: nil, allow_clear: false, placeholder: Alchemy.t(:search_page), query_params: nil) @page = page @url = url @allow_clear = allow_clear @placeholder = placeholder @query_params = query_params end def call content_tag("alchemy-page-select", attributes) do stylesheet_link_tag("alchemy/admin/page-select") + content end end private def attributes options = { placeholder: @placeholder, url: @url || alchemy.api_pages_path } options = options.merge({"allow-clear": @allow_clear}) if @allow_clear options = options.merge({"query-params": @query_params.to_json}) if @query_params if @page selection = { id: @page.id, name: @page.name, url_path: @page.url_path } options = options.merge({selection: selection.to_json}) end options end end end end
Version data entries
9 entries across 9 versions & 1 rubygems