Sha256: 60ad769adaf88d261530a3ae57f0a5deaf9f14bf6e72031caa87baaf67bf0204
Contents?: true
Size: 883 Bytes
Versions: 65
Compression:
Stored size: 883 Bytes
Contents
# frozen_string_literal: true module Koi module Header class NewComponent < ViewComponent::Base attr_reader :model delegate :with_breadcrumb, :with_action, to: :@header def initialize(model:, title: nil) super @model = model @title = title @header = HeaderComponent.new(title: self.title) end def call render @header do |header| # render block, if any (delegating slots to header) content # add our breadcrumbs and actions add_index(header) end end def title @title || "New #{model.model_name.human.downcase}" end def add_index(header) header.with_breadcrumb(model.model_name.human.pluralize, url_for(action: :index)) rescue ActionController::UrlGenerationError nil end end end end
Version data entries
65 entries across 65 versions & 1 rubygems