Skip to content

Commit

Permalink
Added button_to_delete helper
Browse files Browse the repository at this point in the history
  • Loading branch information
alsemyonov committed Nov 3, 2010
1 parent 73c6a2b commit 242848c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
4 changes: 2 additions & 2 deletions config/locales/ru.yml
Expand Up @@ -11,8 +11,8 @@ ru:
new: Добавить {{resource_class}}
show: Просмотреть
edit: Редактировать
destroy: Удалить
confirm_destroy: Вы уверены, что хотите удалить?
delete: Удалить
confirm_delete: Вы уверены, что хотите удалить?
time:
formats:
compact: "%d.%m.%Y, %H:%M"
28 changes: 24 additions & 4 deletions lib/espresso/view/inherited_resources.rb
Expand Up @@ -55,12 +55,32 @@ def link_to_destroy(object=nil, path=nil)
class_underscored = object.class.name.underscore
link_to(t("helpers.action.#{class_underscored}.edit",
:resource => object.to_s,
:default => [:'helpers.action.destroy', 'Destroy']),
:default => [:'helpers.action.delete', 'Delete']),
path,
:class => Espresso::View.block_classes('action', %w(destroy)),
:class => Espresso::View.block_classes('action', %w(delete)),
:method => :delete,
:confirm => t("helpers.action.#{class_underscored}.confirm_destroy",
:default => [:'helpers.action.confirm_destroy', 'are you sure?']))
:confirm => t("helpers.action.#{class_underscored}.confirm_delete",
:default => [:'helpers.action.confirm_delete', 'are you sure?']))
end

def button_to_delete(object=nil, path=nil)
object ||= resource
path ||= if object == resource
resource_path
else
object
end
class_underscored = object.class.name.underscore
button_to(t("helpers.action.#{class_underscored}.edit",
:resource => object.to_s,
:default => [:'helpers.action.delete', 'Delete']),
path,
'data-role' => 'button',
'data-icon' => 'delete',
:class => Espresso::View.block_classes('action', %w(delete)),
:method => :delete,
:confirm => t("helpers.action.#{class_underscored}.confirm_delete",
:default => [:'helpers.action.confirm_delete', 'Are you sure?']))
end

def link_to_index
Expand Down

0 comments on commit 242848c

Please sign in to comment.