Class: Trek::Form::ActionsComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/trek/form/actions_component.rb

Defined Under Namespace

Classes: LinkComponent

Instance Method Summary collapse

Methods included from StimulusHelpers

#stimulus_action, #stimulus_class, #stimulus_class_hash, #stimulus_class_key, #stimulus_target, #stimulus_target_hash, #stimulus_target_key, #stimulus_value, #stimulus_value_hash, #stimulus_value_key

Methods included from CssClassesHelpers

#class_for, #class_names_for, #root_class

Methods included from IdentifierHelper

#identifier

Instance Method Details

#classesObject



27
28
29
30
31
32
33
# File 'app/components/trek/form/actions_component.rb', line 27

def classes
  class_names_for(
    root_class,
    classnames,
    "aspect-#{aspect}": aspect
  )
end

#with_delete_button(object:, model_collection:) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/components/trek/form/actions_component.rb', line 12

def with_delete_button(object:, model_collection:)
  return unless object.persisted? && helpers.allowed_to?(:destroy?, object)

  with_button(
    text: helpers.t("admin.actions.delete"),
    to: [:admin, *helpers.model_element_route[0...-1], object],
    method: :delete,
    data: {
      turbo_confirm: helpers.t("admin.#{model_collection}.destroy.confirm")
    },
    color: :tomato,
    position: :right,
  )
end