lib/sugar/actionview.rb in krasivotokak-sugar-0.0.15 vs lib/sugar/actionview.rb in krasivotokak-sugar-0.0.18
- old
+ new
@@ -8,32 +8,46 @@
def view_name
action_name = controller.action_name
VIEW_PLACEHOLDERS[action_name] || action_name
end
+ def default_page_title
+ case action_name
+ when 'index'
+ controller_name.camelize
+ when 'new', 'create'
+ t("#{t('new')} #{controller_name.classify.human_name}")
+ when 'edit', 'update'
+ t("#{t('editing')} #{controller_name.classify.human_name}")
+ else
+ t("#{controller_name}.#{view_name}.title")
+ end
+ end
+
# Return page title for use in layout
def page_title(title = nil)
@page_title = if title
title
else
- @page_title || t("#{controller_name}.@{view_name}.title")
+ @page_title || default_page_title
end
end
# Put submit with proper text
def submit(form, title = nil)
- title ||= t("#{controller.controller_name}.#{view_name}.submit")
+ title ||= t("#{controller.controller_name}.#{view_name}.submit",
+ :default => form.object.new_record? ? "#{t('add')} #{form.object.class.human_name}" : "#{t('save')} #{form.object.class.human_name}")
form.submit(title)
end
# Build simple navigation list
def navigation_list(menu)
returning '' do |result|
menu.each do |item|
path = "/#{item}"
uri = request.request_uri
- title = t("#{item}.index.title")
+ title = t("#{item}.index.title", :default => item.to_s.camelize)
result << content_tag(:li, :class => uri.starts_with?(path) ? 'selected' : nil) do
link_to_unless_current(title, path) {
content_tag(:strong, title)
}
end
@@ -77,15 +91,15 @@
edit_polymorphic_path(something),
:class => 'ajax edit')
end
def button_to_delete(something, title = nil)
- title ||= t('.delete')
+ title ||= t('.delete', :default => "Delete #{something.class.human_name}")
button_to(title,
polymorphic_path(something),
:class => 'delete',
:method => :delete,
- :confirm => t('sure'))
+ :confirm => t('sure', :default => 'Are you sure?'))
end
def image_button_to_delete(something)
image_to('icons/delete.png',
t('.delete'),