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.
@@ -32,25 +32,27 @@ module Desktop
32
32
  html << "<form method='get'>"
33
33
  end
34
34
  first = options.first
35
- html << '<div class="search-where" id="J_searchWhere" style="'+ (params[first[:name]] ? '' : 'display:none;') + '">'
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], options_from_collection_for_select(option[:value], "id", "name", params[option[:name]]), {:include_blank=>true})
49
+ html << Desktop::Finder.select_tag(option[:name], option[:value], search_params[option[:name]])
48
50
  else
49
- html << text_field_tag(option[:name], params[option[:name]], {:class=>"span2"})
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(t('Search'), {:class=>"btn"})
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, options)
69
- "<input type=\"button\" value='#{label}' class='#{options[:class]}' onclick='this.parent(\"form\").submit();' />"
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, options)
73
- "<input type='text' name='#{name}' value='#{value}' class='#{options[: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, options, value)
77
- s = "<select name=\"#{name}\">"
78
- options.each do|p|
79
- s << '<option value='+ p.fetch(0) +'>' + p.many? ? p.fetch(1) : p.fetch(0) + '</option>'
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, options)
86
- "<label class='#{options[:class]}'>#{label}</label>"
92
+ def Finder.label_tag(id, label, o)
93
+ "<label class='#{o[:class]}'>#{label}</label>"
87
94
  end
88
95
 
89
96
  end
@@ -1,5 +1,5 @@
1
1
  module Desktop
2
2
  module Finder
3
- VERSION = "0.0.1.9"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  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.9
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: