Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added button_to_delete helper

  • Loading branch information...
commit 242848c2f110bb618aef99f1285a56804a8bb03d 1 parent 73c6a2b
@alsemyonov authored
Showing with 26 additions and 6 deletions.
  1. +2 −2 config/locales/ru.yml
  2. +24 −4 lib/espresso/view/inherited_resources.rb
View
4 config/locales/ru.yml
@@ -11,8 +11,8 @@ ru:
new: Добавить {{resource_class}}
show: Просмотреть
edit: Редактировать
- destroy: Удалить
- confirm_destroy: Вы уверены, что хотите удалить?
+ delete: Удалить
+ confirm_delete: Вы уверены, что хотите удалить?
time:
formats:
compact: "%d.%m.%Y, %H:%M"
View
28 lib/espresso/view/inherited_resources.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.