OSDN Git Service

remove trace log
[quickedit/quick_edit.git] / app / helpers / application_helper.rb
1 #coding: utf-8
2
3 module ApplicationHelper
4    def quick_edit_link_to(caption, target_field, field_type, default_value, disabled)
5       help_message= l(:text_edit_confirm)
6
7       case field_type.to_s
8       when "string", "text"
9          pattern = ''
10       when "int"
11          pattern = '\d+'
12       when "date"
13          pattern = '\d{4}-\d{2}-\d{2}'
14          help_message += " (yyyy-mm-dd)"
15       end
16
17       pattern = h(pattern.gsub(/\\/,'\\\\\\\\'))
18
19       sprintf('<li>%s%s</li>',
20          context_menu_link(
21             h(caption),
22             "javascript:quick_edit_show_input_dialog('#{caption}', '#{target_field}', '#{field_type}', '#{pattern}', '#{help_message}', '#{default_value}')",
23             :class => 'icon-edit',
24             :disabled => disabled
25          ),
26          context_menu_link(
27             h(:dummy),
28             '#',
29             :id => 'context_edit_update_link_%s' % target_field.to_s().tr('[]','__'),
30             :style=>'display:none',
31             :method => :post,
32          )
33       ).html_safe()
34    end   
35 end
36