desktop-finder 0.0.1.6 → 0.0.1.7

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