desktop-finder 0.0.1 → 0.0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/desktop/finder/version.rb +1 -1
- data/lib/desktop/finder.rb +52 -0
- metadata +1 -1
data/lib/desktop/finder.rb
CHANGED
@@ -6,5 +6,57 @@ module Desktop
|
|
6
6
|
def Finder.test
|
7
7
|
puts '-----------test finder gem--------------'
|
8
8
|
end
|
9
|
+
|
10
|
+
def Finder.create(params, simple=false, form=nil)
|
11
|
+
# options = options || [{:type => 'select', :name=>'staff_id', :lable=>t('Staff'), :value=>Staff.all}, {:type=>"text", :name=>"title", :lable=>t('Title'), :value=>''}]
|
12
|
+
options = options || [{:type=>"text", :name=>"title", :label=>t('Title'), :value=>''},{:type=>'select', :name=>'issue_type_id', :label=>t('Issue Type'), :value=>IssueType.all}]
|
13
|
+
options = options || {}
|
14
|
+
if options.empty?
|
15
|
+
return ''
|
16
|
+
end
|
17
|
+
html = '<a href="#" class="pull-right" onclick="$(\'#J_searchWhere\').slideToggle();">.</a>'
|
18
|
+
if form
|
19
|
+
html << "<form method='get'>"
|
20
|
+
end
|
21
|
+
first = options.first
|
22
|
+
html << '<div class="search-where" id="J_searchWhere" style="'+ (params[first[:name]] ? '' : 'display:none;') + '">'
|
23
|
+
select_option = []
|
24
|
+
options.each do |option|
|
25
|
+
case simple
|
26
|
+
when false
|
27
|
+
html << label_tag("", option[:label], {:class=>"search-label"})
|
28
|
+
else
|
29
|
+
select_option = select_option.push([option[:name], option[:label]])
|
30
|
+
end
|
31
|
+
html << '<div class="seach-value">'
|
32
|
+
case option[:type]
|
33
|
+
when 'select'
|
34
|
+
html << select_tag(option[:name], options_from_collection_for_select(option[:value], "id", "name", params[option[:name]]), {:include_blank=>true})
|
35
|
+
else
|
36
|
+
html << text_field_tag(option[:name], params[option[:name]], {:class=>"span2"})
|
37
|
+
end
|
38
|
+
html << '</div>'
|
39
|
+
end
|
40
|
+
html << submit_tag(t('Search'), {:class=>"btn"})
|
41
|
+
html << '</div>'
|
42
|
+
|
43
|
+
if form
|
44
|
+
html << '</form>'
|
45
|
+
end
|
46
|
+
|
47
|
+
html.html_safe
|
48
|
+
#<a href="#" onclick="$(this).parent('form').find('.search-where').show();" class="pull-right">.</a>
|
49
|
+
# <div class="search-where" style="display:none;">
|
50
|
+
# <table width="100%" class="table-form">
|
51
|
+
# <tr>
|
52
|
+
# </tr>
|
53
|
+
# </table>
|
54
|
+
# </div>
|
55
|
+
end
|
56
|
+
|
57
|
+
def Finder.where(params)
|
58
|
+
{}
|
59
|
+
#where = params.reject{|p,v| p=='controller' or p=='action' or p=='search' or p=='commit' or v.empty?}
|
60
|
+
end
|
9
61
|
end
|
10
62
|
end
|