Class: Trestle::Resource::Toolbar::Builder

Inherits:
Toolbar::Builder show all
Defined in:
lib/trestle/resource/toolbar.rb

Instance Method Summary collapse

Methods inherited from Toolbar::Builder

builder_method, #button, #dropdown, #initialize, #link

Constructor Details

This class inherits a constructor from Trestle::Toolbar::Builder

Instance Method Details

#deleteObject


16
17
18
# File 'lib/trestle/resource/toolbar.rb', line 16

def delete
  link(t("buttons.delete", default: "Delete %{model_name}"), instance, action: :destroy, method: :delete, style: :danger, icon: "fa fa-trash", data: { toggle: "confirm-delete", placement: "bottom" }) if action?(:destroy)
end

#dismissObject Also known as: ok


20
21
22
# File 'lib/trestle/resource/toolbar.rb', line 20

def dismiss
  button(t("buttons.ok", default: "OK"), style: :light, data: { dismiss: "modal" }) if @template.dialog_request?
end

#newObject


8
9
10
# File 'lib/trestle/resource/toolbar.rb', line 8

def new
  link(t("buttons.new", default: "New %{model_name}"), action: :new, style: :light, icon: "fa fa-plus", class: "btn-new-resource") if action?(:new)
end

#saveObject


12
13
14
# File 'lib/trestle/resource/toolbar.rb', line 12

def save
  button(t("buttons.save", default: "Save %{model_name}"), style: :success)
end

#save_or_dismiss(action = :update) ⇒ Object


25
26
27
28
29
30
31
# File 'lib/trestle/resource/toolbar.rb', line 25

def save_or_dismiss(action=:update)
  if action?(action)
    save
  else
    dismiss
  end
end