From 89ad696129f211739fbe54443cd979b35f385c85 Mon Sep 17 00:00:00 2001 From: Ryan Linton Date: Fri, 31 Oct 2014 14:26:01 -0700 Subject: [PATCH 1/2] Fix issue with index_path of filtered data --- lib/ProMotion/table/data/table_data.rb | 2 +- lib/ProMotion/table/table.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ProMotion/table/data/table_data.rb b/lib/ProMotion/table/data/table_data.rb index 664c533..eafaa89 100644 --- a/lib/ProMotion/table/data/table_data.rb +++ b/lib/ProMotion/table/data/table_data.rb @@ -24,7 +24,7 @@ module ProMotion def cell(params={}) params = index_path_to_section_index(params) - table_section = self.section(params[:section]) + table_section = params[:unfiltered] ? self.data[params[:section]] : self.section(params[:section]) c = table_section[:cells].at(params[:index].to_i) set_data_cell_defaults c end diff --git a/lib/ProMotion/table/table.rb b/lib/ProMotion/table/table.rb index a57675d..9ad2407 100644 --- a/lib/ProMotion/table/table.rb +++ b/lib/ProMotion/table/table.rb @@ -171,18 +171,18 @@ module ProMotion table_cell.send(:restyle!) if table_cell.respond_to?(:restyle!) # Teacup compatibility end - def tableView(table_view, heightForRowAtIndexPath:index_path) + def tableView(table_view, heightForRowAtIndexPath: index_path) (self.promotion_table_data.cell(index_path: index_path)[:height] || table_view.rowHeight).to_f end - def tableView(table_view, didSelectRowAtIndexPath:index_path) + def tableView(table_view, didSelectRowAtIndexPath: index_path) data_cell = self.promotion_table_data.cell(index_path: index_path) table_view.deselectRowAtIndexPath(index_path, animated: true) unless data_cell[:keep_selection] == true trigger_action(data_cell[:action], data_cell[:arguments], index_path) if data_cell[:action] end def tableView(table_view, editingStyleForRowAtIndexPath: index_path) - data_cell = self.promotion_table_data.cell(index_path: index_path) + data_cell = self.promotion_table_data.cell(index_path: index_path, unfiltered: true) map_cell_editing_style(data_cell[:editing_style]) end From 490909ac6ba7855e29e1723f5fa6657d390d9d90 Mon Sep 17 00:00:00 2001 From: Ryan Linton Date: Fri, 31 Oct 2014 14:34:51 -0700 Subject: [PATCH 2/2] Fixes Issue 523 --- lib/ProMotion/table/table.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/ProMotion/table/table.rb b/lib/ProMotion/table/table.rb index 9ad2407..d80151e 100644 --- a/lib/ProMotion/table/table.rb +++ b/lib/ProMotion/table/table.rb @@ -68,7 +68,7 @@ module ProMotion args[:animation] ||= UITableViewRowAnimationNone table_view.beginUpdates - table_view.reloadRowsAtIndexPaths(Array(args[:index_paths]), withRowAnimation:args[:animation]) + table_view.reloadRowsAtIndexPaths(Array(args[:index_paths]), withRowAnimation: args[:animation]) table_view.endUpdates else table_view.reloadData @@ -108,7 +108,7 @@ module ProMotion deletable_index_paths << index_path end end - table_view.deleteRowsAtIndexPaths(deletable_index_paths, withRowAnimation:map_row_animation_symbol(animation)) if deletable_index_paths.length > 0 + table_view.deleteRowsAtIndexPaths(deletable_index_paths, withRowAnimation: map_row_animation_symbol(animation)) if deletable_index_paths.length > 0 end def table_view_cell(params={}) @@ -144,11 +144,11 @@ module ProMotion end # Number of cells - def tableView(table_view, numberOfRowsInSection:section) + def tableView(table_view, numberOfRowsInSection: section) self.promotion_table_data.section_length(section) end - def tableView(table_view, titleForHeaderInSection:section) + def tableView(table_view, titleForHeaderInSection: section) section = promotion_table_data.section(section) section && section[:title] end @@ -160,7 +160,7 @@ module ProMotion nil end - def tableView(table_view, cellForRowAtIndexPath:index_path) + def tableView(table_view, cellForRowAtIndexPath: index_path) table_view_cell(index_path: index_path) end @@ -192,18 +192,18 @@ module ProMotion end end - def tableView(tableView, sectionForSectionIndexTitle:title, atIndex:index) + def tableView(tableView, sectionForSectionIndexTitle: title, atIndex: index) return index unless ["{search}", UITableViewIndexSearch].include?(self.table_data_index[0]) if index == 0 - tableView.scrollRectToVisible(CGRectMake(0.0, 0.0, 1.0, 1.0), animated:false) + tableView.scrollRectToVisible(CGRectMake(0.0, 0.0, 1.0, 1.0), animated: false) NSNotFound else index - 1 end end - def deleteRowsAtIndexPaths(index_paths, withRowAnimation:animation) + def deleteRowsAtIndexPaths(index_paths, withRowAnimation: animation) PM.logger.warn "ProMotion expects you to use 'delete_cell(index_paths, animation)'' instead of 'deleteRowsAtIndexPaths(index_paths, withRowAnimation:animation)'." delete_row(index_paths, animation) end