desktop-finder 0.0.1.9 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/desktop/finder.rb +24 -17
- data/lib/desktop/finder/version.rb +1 -1
- metadata +1 -1
data/lib/desktop/finder.rb
CHANGED
@@ -32,25 +32,27 @@ module Desktop
|
|
32
32
|
html << "<form method='get'>"
|
33
33
|
end
|
34
34
|
first = options.first
|
35
|
-
|
35
|
+
search_params = params[:search_where] || {}
|
36
|
+
html << '<div class="search-where" id="J_searchWhere" style="'+ (search_params ? '' : 'display:none;') + '">'
|
36
37
|
select_option = []
|
37
38
|
options.each do |option|
|
39
|
+
next if option.blank?
|
38
40
|
case simple
|
39
41
|
when false
|
40
|
-
html << label_tag("", option[:label], {:class=>"search-label"})
|
42
|
+
html << Desktop::Finder.label_tag("", option[:label], {:class=>"search-label"})
|
41
43
|
else
|
42
44
|
select_option = select_option.push([option[:name], option[:label]])
|
43
45
|
end
|
44
46
|
html << '<div class="seach-value">'
|
45
47
|
case option[:type]
|
46
48
|
when 'select'
|
47
|
-
html << select_tag(option[:name],
|
49
|
+
html << Desktop::Finder.select_tag(option[:name], option[:value], search_params[option[:name]])
|
48
50
|
else
|
49
|
-
html << text_field_tag(option[:name],
|
51
|
+
html << Desktop::Finder.text_field_tag(option[:name], search_params[option[:name]], {:class=>"span2"})
|
50
52
|
end
|
51
53
|
html << '</div>'
|
52
54
|
end
|
53
|
-
html << submit_tag(
|
55
|
+
html << Desktop::Finder.submit_tag('Search', {:class=>"btn"})
|
54
56
|
html << '</div>'
|
55
57
|
|
56
58
|
if form
|
@@ -60,30 +62,35 @@ module Desktop
|
|
60
62
|
html.html_safe
|
61
63
|
end
|
62
64
|
|
63
|
-
def where(params)
|
64
|
-
where = params.reject{|p,v| p=='controller' or p=='action' or p=='search' or p=='commit' or v.empty?}
|
65
|
+
def Finder.where(params)
|
66
|
+
#where = params.reject{|p,v| p=='controller' or p=='action' or p=='search' or p=='commit' or v.empty?}
|
67
|
+
if !params.has_key?("search_where")
|
68
|
+
return {}
|
69
|
+
end
|
70
|
+
where = params[:search_where].reject{|p,v| v.empty?}
|
65
71
|
where
|
66
72
|
end
|
67
73
|
|
68
|
-
def submit_tag(label,
|
69
|
-
"<input type=\"button\" value='#{label}' class='#{
|
74
|
+
def Finder.submit_tag(label, o)
|
75
|
+
"<input type=\"button\" value='#{label}' class='#{o[:class]}' onclick=\"$(this).parents('form:first').submit();\" />"
|
70
76
|
end
|
71
77
|
|
72
|
-
def text_field_tag(name, value,
|
73
|
-
"<input type='text' name='#{name}' value='#{value}' class='#{
|
78
|
+
def Finder.text_field_tag(name, value, o)
|
79
|
+
"<input type='text' name='search_where[#{name}]' value='#{value}' class='#{o[:class]}' />"
|
74
80
|
end
|
75
81
|
|
76
|
-
def select_tag(name,
|
77
|
-
s = "<select name=\"#{name}\">"
|
78
|
-
|
79
|
-
|
82
|
+
def Finder.select_tag(name, o, value)
|
83
|
+
s = "<select name=\"search_where[#{name}]\">"
|
84
|
+
s << "<option value=''></option>"
|
85
|
+
o.each do|p|
|
86
|
+
s << '<option value="' << p.fetch(0).to_s << '" ' << (p.fetch(0).to_s==value.to_s ? 'selected="selected"' : '') << '>' << (p.many? ? p.fetch(1).to_s : p.fetch(0).to_s) << '</option>'
|
80
87
|
end
|
81
88
|
s << '</select>'
|
82
89
|
s
|
83
90
|
end
|
84
91
|
|
85
|
-
def label_tag(id, label,
|
86
|
-
"<label class='#{
|
92
|
+
def Finder.label_tag(id, label, o)
|
93
|
+
"<label class='#{o[:class]}'>#{label}</label>"
|
87
94
|
end
|
88
95
|
|
89
96
|
end
|