Module | SearchHelper
In: | app/helpers/search_helper.rb

### Methods

button_box li_for_search_condition_item link_to_destroy radio_box_condition_pattern radio_box_order_by radio_box_with sortable_search_condition

### Public Instance methods

button_box(suffix)

[Source]

        # File app/helpers/search_helper.rb, line 44
    44:   def button_box(suffix)
    45:     template = escape_javascript(li_for_search_condition_item(SearchConditionItem.new))
    46:     buttons = {
    47:       :left   => link_to_close({"_" => suffix},
    48:                                {:controller => "product", :product_id => @display.product_id, :action => "list"},
    49:                                {:class => "button"}),
    50:       :center => submit_tag(h(s_("search|Execute")), :name => "submit", :class => "button"),
    51:       :right => link_to_remote(h(s_("Search|Add")), {
    52:                                  :before => "add_new_search_condition_item('#{template}');",
    53:                                  :update => "space_condition",
    54:                                  :url => {:action => "add_item", :display_id => @display.id, :id => @search_condition.id},
    55:                                }, {
    56:                                  :class => "button",
    57:                                }),
    58:     }
    59:     return lcr_button_box(buttons)
    60:   end

li_for_search_condition_item(item)

[Source]

        # File app/helpers/search_helper.rb, line 75
    75:   def li_for_search_condition_item(item)
    76:     prefix = item.new_record? ? "newbie_\#{n}" : "item_#{item.id}"
    77:     o = options_for_select @display.proper_items.select(&:search?).map {|i| [i.name, i.id]}, item.item_id
    78:     s = select_tag("#{prefix}_item_id", o)
    79:     th = content_tag(:th, s, :class => "block")
    80:     inputs = [ text_field_tag("#{prefix}_condition_value", item.condition_value),
    81:                radio_box_condition_pattern(item),
    82:                radio_box_order_by(item),
    83:                link_to_destroy(item),
    84:              ]
    85:     tds = inputs.map {|input| content_tag(:td, input, :class => "block")}
    86:     tds.unshift(th)
    87:     tr = content_tag(:tr, tds)
    88:     table = content_tag(:table, tr)
    89:     content_tag(:li, table, :id => prefix, :class => "item draggable")
    90:   end

link_to_destroy(item)

[Source]

        # File app/helpers/search_helper.rb, line 62
    62:   def link_to_destroy(item)
    63:     f = item.new_record? ? "remove_new_search_condition_item" : "remove_old_search_condition_item"
    64:     n = item.new_record? ? "\#{n}" : item.id
    65:     link_to_remote(h(s_("button|Destroy")), {
    66:                      :confirm => s_('confirm|Are you sure?'),
    67:                      :before => "#{f}(#{n})",
    68:                      :update => "space_condition",
    69:                      :url => {:action => "add_item", :display_id => @display.id, :id => @search_condition.id},
    70:                    }, {
    71:                      :class => "button",
    72:                    })
    73:   end

radio_box_condition_pattern(item)

[Source]

        # File app/helpers/search_helper.rb, line 17
    17:   def radio_box_condition_pattern(item)
    18:     values = [
    19:       [s_("SearchConditionItem|eq"),      "eq"],
    20:       [s_("SearchConditionItem|neq"),     "neq"],
    21:       [s_("SearchConditionItem|head"),    "head"],
    22:       [s_("SearchConditionItem|tail"),    "tail"],
    23:       [s_("SearchConditionItem|include"), "include"],
    24:       [s_("SearchConditionItem|exclude"), "exclude"],
    25:       [s_("SearchConditionItem|ge"),      "ge"],
    26:       [s_("SearchConditionItem|le"),      "le"],
    27:       [s_("SearchConditionItem|gt"),      "gt"],
    28:       [s_("SearchConditionItem|lt"),      "lt"],
    29:       [s_("SearchConditionItem|null"),    "null"],
    30:       [s_("SearchConditionItem|not null"),"not-null"],
    31:     ]
    32:     radio_box_with(item, 'condition_pattern', values, 'eq')
    33:   end

radio_box_order_by(item)

[Source]

        # File app/helpers/search_helper.rb, line 35
    35:   def radio_box_order_by(item)
    36:     values = [
    37:      [s_("SearchConditionItem|None"), "none"],
    38:      [s_("SearchConditionItem|Asc"),  "asc"],
    39:      [s_("SearchConditionItem|Desc"), "desc"],
    40:     ]
    41:     radio_box_with(item, 'order_by', values, 'none')
    42:   end

radio_box_with(item, column_name, values, default_value)

[Source]

        # File app/helpers/search_helper.rb, line 3
     3:   def radio_box_with(item, column_name, values, default_value)
     4:     values.map do |label, value|
     5:       o = {}
     6:       if item.new_record?
     7:         o[:id] = "newbie_\#{n}_#{value}"
     8:         b = radio_button_tag("newbie_\#{n}_#{column_name}", value, (value == default_value), o)
     9:       else
    10:         o[:id] = "item_#{item.id}_#{value}"
    11:         b = radio_button_tag("item_#{item.id}_#{column_name}", value, (value == item.__send__(column_name)), o)
    12:       end
    13:       b + content_tag(:label, label, {:for => o[:id]})
    14:     end.join("&nbsp;")
    15:   end

sortable_search_condition()

[Source]

        # File app/helpers/search_helper.rb, line 92
    92:   def sortable_search_condition
    93:     sortable_element("search_condition",
    94:                      :format => "/^(item_[0-9]+|newbie_[0-9]+)$/",
    95:                      :update => "space_condition",
    96:                      :complete => visual_effect(:highlight, "space_condition"),
    97:                      :url => {:action => "order_item", :display_id => @display.id, :id => @search_condition.id})
    98:   end

[Validate]