Class: KonoUtils::Object::Cell::Base

Inherits:
Trailblazer::Cell
  • Object
show all
Includes:
Kaminari::Cells, Kaminari::Helpers::HelperMethods, KonoUtilsBootstrapView4::ApplicationIconHelper, Pundit
Defined in:
app/concepts/kono_utils/object/cell/base.rb

Overview

class

Class Method Summary collapse

Instance Method Summary collapse

Methods included from KonoUtilsBootstrapView4::ApplicationIconHelper

#fa_icon, #icon

Class Method Details

.loggerLogger

Returns:

  • (Logger)


84
85
86
# File 'app/concepts/kono_utils/object/cell/base.rb', line 84

def self.logger
  KonoUtilsBootstrapView4.configuration.logger
end

Instance Method Details

#_prefixesObject



90
91
92
# File 'app/concepts/kono_utils/object/cell/base.rb', line 90

def _prefixes
  base_class.concept_prefix + super + parent_controller.lookup_context.view_paths.collect(&:to_path)
end

#base_classObject

Helpers di controller



16
17
18
# File 'app/concepts/kono_utils/object/cell/base.rb', line 16

def base_class
  context[:base_class] || (@_base_class ||= parent_controller.send(:base_class))
end

#concept(name, *args, &block) ⇒ Object

def concept(name, model = nil, options = {}, &block)



77
78
79
# File 'app/concepts/kono_utils/object/cell/base.rb', line 77

def concept(name, *args, &block)
  legacy_concept(base_class.concept_ns(name), *args, &block)
end

#content_for_layout(name, content = nil, options = {}, &block) ⇒ String

Registra il contenuto con una chiave, e lo renderizza poi dove è più necessario

Parameters:

  • name (String)
  • content (String) (defaults to: nil)
  • ] (Hash{null->null)

    options

  • block (Proc)

Returns:

  • (String)


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/concepts/kono_utils/object/cell/base.rb', line 53

def content_for_layout(name, content = nil, options = {}, &block)
  context[:_view_layout_flow] ||= ActionView::OutputFlow.new
  if content || block_given?
    if block_given?
      options = content if content
      content = capture(&block)
    end
    if content
      content = content.to_s.html_safe
      options[:flush] ? context[:_view_layout_flow].set(name, content) : context[:_view_layout_flow].append(name, content)
    end
    nil
  else
    context[:_view_layout_flow].get(name).presence
  end
end

#content_for_layout?(name) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
# File 'app/concepts/kono_utils/object/cell/base.rb', line 70

def content_for_layout?(name)
  context[:_view_layout_flow].get(name).present? rescue false
end

#destroy_custom_polymorphic_path(*rec) ⇒ Object



32
33
34
# File 'app/concepts/kono_utils/object/cell/base.rb', line 32

def destroy_custom_polymorphic_path(*rec)
  parent_controller.send(:destroy_custom_polymorphic_path, *rec)
end

#edit_custom_polymorphic_path(*rec) ⇒ Object



24
25
26
# File 'app/concepts/kono_utils/object/cell/base.rb', line 24

def edit_custom_polymorphic_path(*rec)
  parent_controller.send(:edit_custom_polymorphic_path, *rec)
end

#index_custom_polymorphic_path(*rec) ⇒ Object



28
29
30
# File 'app/concepts/kono_utils/object/cell/base.rb', line 28

def index_custom_polymorphic_path(*rec)
  parent_controller.send(:index_custom_polymorphic_path, *rec)
end

#kono_userObject Also known as: current_user



94
95
96
# File 'app/concepts/kono_utils/object/cell/base.rb', line 94

def kono_user
  context[:kono_user]
end

#legacy_conceptObject



74
# File 'app/concepts/kono_utils/object/cell/base.rb', line 74

alias_method :legacy_concept, :concept

#model_genderObject



134
135
136
# File 'app/concepts/kono_utils/object/cell/base.rb', line 134

def model_gender
  t("activerecord.modelgender.#{model.class.name.underscore.to_sym}", :default => :m).to_sym
end

#new_custom_polymorphic_path(*base_class) ⇒ Object



20
21
22
# File 'app/concepts/kono_utils/object/cell/base.rb', line 20

def new_custom_polymorphic_path(*base_class)
  parent_controller.send(:new_custom_polymorphic_path, *base_class)
end

#show(&block) ⇒ Object



40
41
42
43
44
# File 'app/concepts/kono_utils/object/cell/base.rb', line 40

def show(&block)
  ActiveSupport::Notifications.instrument "kono_utils_bootstrap_view4.#{self.class.name.underscore.gsub("/", ".")}", this: :data do
    super
  end
end

#show_custom_polymorphic_path(*rec) ⇒ Object



36
37
38
# File 'app/concepts/kono_utils/object/cell/base.rb', line 36

def show_custom_polymorphic_path(*rec)
  parent_controller.send(:show_custom_polymorphic_path, *rec)
end

#title_delObject



114
115
116
# File 'app/concepts/kono_utils/object/cell/base.rb', line 114

def title_del
  "#{t(:del)} #{model.mn}"
end

#title_del_gObject



126
127
128
# File 'app/concepts/kono_utils/object/cell/base.rb', line 126

def title_del_g
  "#{t("del_title_#{model_gender}", default: 'Cancella')} #{model.mn}"
end

#title_edit_gObject



118
119
120
# File 'app/concepts/kono_utils/object/cell/base.rb', line 118

def title_edit_g
  "#{t("edit_title_#{model_gender}", default: 'Modifica')} #{model.mn}"
end

#title_modObject



102
103
104
# File 'app/concepts/kono_utils/object/cell/base.rb', line 102

def title_mod
  "#{t(:edit)} #{model.mn}"
end

#title_newObject



106
107
108
# File 'app/concepts/kono_utils/object/cell/base.rb', line 106

def title_new
  "#{t(:new)} #{model.mn}"
end

#title_new_gObject



122
123
124
# File 'app/concepts/kono_utils/object/cell/base.rb', line 122

def title_new_g
  "#{t("new_title_#{model_gender}", default: 'Nuovo')} #{model.mn}"
end

#title_newaObject



110
111
112
# File 'app/concepts/kono_utils/object/cell/base.rb', line 110

def title_newa
  "#{t(:newa)} #{model.mn}"
end

#title_show_gObject



130
131
132
# File 'app/concepts/kono_utils/object/cell/base.rb', line 130

def title_show_g
  "#{t("show_title_#{model_gender}", default: 'Visualizza')} #{model.mn}"
end