Sha256: 3e6a4c29584db1d3e38a227820934b9986b69fdf43dd805f6f84b4b1190db736
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true module Maquina module Application class IndexHeader < Phlex::HTML include ApplicationView delegate :new_resource_path, to: :helpers def initialize(filter = nil) @filter = filter end def view_template div(class: "sm:flex sm:items-center") do div(class: "sm:flex-auto") do h1(class: "text-xl font-semibold text-skin-base") { model_human_name(plural: true) } p(class: "mt-2 text-sm text-skin-muted") { description } p(class: "mt-4 text-skin-base") { unsafe_raw t("index.search", search: @filter) } if @filter.present? end add_new_template end end private def add_new_template return if policy_class.blank? || !allowed_to?(:new?, with: policy_class) options = {} options[:data] = {controller: "modal-open", modal_open_modal_outlet: ".modal", action: "modal-open#open"} if policy_class.present? && allowed_to?(:new_modal?, with: policy_class) div(class: "mt-4 sm:mt-0 sm:ml-16 sm:flex-none") do a(href: new_resource_path, class: "inline-flex items-center justify-center button button-accented", **options) { add_new } end end def description t("index.#{resource_class.model_name.i18n_key}.description", default: "") end def add_new t("index.#{resource_class.model_name.i18n_key}.add_new", model: model_human_name.downcase, default: t("index.add_new", model: model_human_name.downcase)) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
maquina-0.5.2 | app/views/maquina/application/index_header.rb |
maquina-0.5.1 | app/views/maquina/application/index_header.rb |