lib/ProMotion/table/data/table_data.rb in ProMotion-1.0.2 vs lib/ProMotion/table/data/table_data.rb in ProMotion-1.0.3
- old
+ new
@@ -1,8 +1,8 @@
module ProMotion
class TableData
- attr_accessor :data, :filtered_data, :filtered, :table_view
+ attr_accessor :data, :filtered_data, :search_string, :original_search_string, :filtered, :table_view
def initialize(data, table_view)
self.data = data
self.table_view = table_view
end
@@ -43,18 +43,19 @@
def search(search_string)
self.filtered_data = []
self.filtered = true
- search_string = search_string.downcase.strip
+ self.original_search_string = search_string
+ self.search_string = search_string.downcase.strip
self.data.compact.each do |section|
new_section = {}
new_section[:cells] = []
new_section[:cells] = section[:cells].map do |cell|
- cell[:searchable] != false && "#{cell[:title]}\n#{cell[:search_text]}".downcase.strip.include?(search_string) ? cell : nil
+ cell[:searchable] != false && "#{cell[:title]}\n#{cell[:search_text]}".downcase.strip.include?(self.search_string) ? cell : nil
end.compact
if new_section[:cells] && new_section[:cells].length > 0
new_section[:title] = section[:title]
self.filtered_data << new_section
@@ -65,9 +66,11 @@
end
def stop_searching
self.filtered_data = []
self.filtered = false
+ self.search_string = false
+ self.original_search_string = false
end
def set_data_cell_defaults(data_cell)
data_cell[:cell_style] ||= UITableViewCellStyleDefault
data_cell[:cell_class] ||= PM::TableViewCell