desktop-finder 0.0.1.1 → 0.0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Desktop
2
2
  module Finder
3
- VERSION = "0.0.1.1"
3
+ VERSION = "0.0.1.2"
4
4
  end
5
5
  end
@@ -8,55 +8,61 @@ module Desktop
8
8
  end
9
9
 
10
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 ''
11
+ record = Kernel.const_get(params[:controller].classify).new.attributes
12
+ options = record.each_key.collect{|key|
13
+ value = []
14
+ type = "text"
15
+ if key.include?("_id")
16
+ begin
17
+ value = Kernel.const_get(key.to_s.classify.sub('Id', '')).all.collect{|p|[p.id, p.name]}
18
+ rescue
19
+ next
20
+ end
21
+ type = "select"
16
22
  end
17
- html = '<a href="#" class="pull-right" onclick="$(\'#J_searchWhere\').slideToggle();">.</a>'
18
- if form
19
- html << "<form method='get'>"
23
+ {:type=>type, :name=>key, :label=>t(key), :value=>value}
24
+ }
25
+ #options = options || [{:type=>"text", :name=>"title", :label=>t('Title'), :value=>''},{:type=>'select', :name=>'issue_type_id', :label=>t('Issue Type'), :value=>IssueType.all}]
26
+ options = options || {}
27
+ if options.empty?
28
+ return ''
29
+ end
30
+ html = '<a href="#" class="pull-right" onclick="$(\'#J_searchWhere\').slideToggle();">.</a>'
31
+ if form
32
+ html << "<form method='get'>"
33
+ end
34
+ first = options.first
35
+ html << '<div class="search-where" id="J_searchWhere" style="'+ (params[first[:name]] ? '' : 'display:none;') + '">'
36
+ select_option = []
37
+ options.each do |option|
38
+ case simple
39
+ when false
40
+ html << label_tag("", option[:label], {:class=>"search-label"})
41
+ else
42
+ select_option = select_option.push([option[:name], option[:label]])
20
43
  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>'
44
+ html << '<div class="seach-value">'
45
+ case option[:type]
46
+ when 'select'
47
+ html << select_tag(option[:name], options_from_collection_for_select(option[:value], "id", "name", params[option[:name]]), {:include_blank=>true})
48
+ else
49
+ html << text_field_tag(option[:name], params[option[:name]], {:class=>"span2"})
39
50
  end
40
- html << submit_tag(t('Search'), {:class=>"btn"})
41
51
  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
52
  end
53
+ html << submit_tag(t('Search'), {:class=>"btn"})
54
+ html << '</div>'
56
55
 
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?}
56
+ if form
57
+ html << '</form>'
60
58
  end
59
+
60
+ html.html_safe
61
+ end
62
+
63
+ def Finder.where(params)
64
+ where = params.reject{|p,v| p=='controller' or p=='action' or p=='search' or p=='commit' or v.empty?}
65
+ where
66
+ end
61
67
  end
62
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: desktop-finder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.1
4
+ version: 0.0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: