From 74fc2c8744c57312282dd460d2a903f44e989f72 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sat, 10 Oct 2009 15:23:16 +0000 Subject: - Allow link arrows for foreign key links to work when used on a column with a foreign key link within the same table - this improves compatibility for Issue #428. --- Source/TableContent.m | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'Source') diff --git a/Source/TableContent.m b/Source/TableContent.m index 1fa9d193..8df1bbc1 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -1109,19 +1109,34 @@ // Save existing scroll position and details [spHistoryControllerInstance updateHistoryEntries]; - // Store the filter details to use when next loading the table NSString *targetFilterValue = [[tableValues objectAtIndex:[theArrowCell getClickedRow]] objectAtIndex:dataColumnIndex]; - NSDictionary *filterSettings = [NSDictionary dictionaryWithObjectsAndKeys: - [refDictionary objectForKey:@"column"], @"filterField", - targetFilterValue, @"filterValue", - ([targetFilterValue isNSNull]?@"IS NULL":nil), @"filterComparison", - nil]; - [self setFiltersToRestore:filterSettings]; - - // Attempt to switch to the new table - if (![tablesListInstance selectTableOrViewWithName:[refDictionary objectForKey:@"table"]]) { - NSBeep(); - [self setFiltersToRestore:nil]; + + // If the link is within the current table, apply filter settings manually + if ([[refDictionary objectForKey:@"table"] isEqualToString:selectedTable]) { + [fieldField selectItemWithTitle:[refDictionary objectForKey:@"column"]]; + [self setCompareTypes:self]; + if ([targetFilterValue isNSNull]) { + [compareField selectItemWithTitle:@"IS NULL"]; + } else { + [argumentField setStringValue:targetFilterValue]; + } + [self filterTable:self]; + + } else { + + // Store the filter details to use when loading the target table + NSDictionary *filterSettings = [NSDictionary dictionaryWithObjectsAndKeys: + [refDictionary objectForKey:@"column"], @"filterField", + targetFilterValue, @"filterValue", + ([targetFilterValue isNSNull]?@"IS NULL":nil), @"filterComparison", + nil]; + [self setFiltersToRestore:filterSettings]; + + // Attempt to switch to the target table + if (![tablesListInstance selectTableOrViewWithName:[refDictionary objectForKey:@"table"]]) { + NSBeep(); + [self setFiltersToRestore:nil]; + } } } -- cgit v1.2.3