diff --git a/openbis-ipad/source/objc/Research/BisMac.xcodeproj/project.xcworkspace/xcuserdata/cramakri.xcuserdatad/UserInterfaceState.xcuserstate b/openbis-ipad/source/objc/Research/BisMac.xcodeproj/project.xcworkspace/xcuserdata/cramakri.xcuserdatad/UserInterfaceState.xcuserstate index 6da1fbcebacd721e0a73e8b2d29d42922b4d3b04..18409a5a621285bea1a274a497db52e1ab172d08 100644 Binary files a/openbis-ipad/source/objc/Research/BisMac.xcodeproj/project.xcworkspace/xcuserdata/cramakri.xcuserdatad/UserInterfaceState.xcuserstate and b/openbis-ipad/source/objc/Research/BisMac.xcodeproj/project.xcworkspace/xcuserdata/cramakri.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/openbis-ipad/source/objc/openBIS/openBIS.xcodeproj/project.xcworkspace/xcuserdata/cramakri.xcuserdatad/UserInterfaceState.xcuserstate b/openbis-ipad/source/objc/openBIS/openBIS.xcodeproj/project.xcworkspace/xcuserdata/cramakri.xcuserdatad/UserInterfaceState.xcuserstate index cb15037b2dd5aa3aa4ad4df3b0ab0526b3bcabfa..fde45a678a2375c9e603cd618dd8be23d00a9ab5 100644 Binary files a/openbis-ipad/source/objc/openBIS/openBIS.xcodeproj/project.xcworkspace/xcuserdata/cramakri.xcuserdatad/UserInterfaceState.xcuserstate and b/openbis-ipad/source/objc/openBIS/openBIS.xcodeproj/project.xcworkspace/xcuserdata/cramakri.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/openbis-ipad/source/objc/openBIS/openBIS/CISDOBMasterViewController.h b/openbis-ipad/source/objc/openBIS/openBIS/CISDOBMasterViewController.h index 3334e924c791753009f687d49a1ec8a1b56d6f86..4ca1378945fbbfe435d8c28125ceef3348d11a5a 100644 --- a/openbis-ipad/source/objc/openBIS/openBIS/CISDOBMasterViewController.h +++ b/openbis-ipad/source/objc/openBIS/openBIS/CISDOBMasterViewController.h @@ -37,7 +37,9 @@ @property (strong, nonatomic) CISDOBTableSearchState *searchState; // The state for the current searching or filtering mode. -@property (strong, nonatomic) CISDOBTableDisplayState *searchFilterState; +@property (weak, nonatomic) CISDOBTableDisplayState *searchFilterState; +// True if the user is currently browsing, false if she is searching +@property (nonatomic) BOOL browsing; @property (weak, nonatomic) IBOutlet UITableView *browseTableView; @property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator; diff --git a/openbis-ipad/source/objc/openBIS/openBIS/CISDOBMasterViewController.m b/openbis-ipad/source/objc/openBIS/openBIS/CISDOBMasterViewController.m index 2846976a6303e072f06ca15e89cdee7e00613ec9..05c1064d488ebce6666dc5870670bc1b439ec654 100644 --- a/openbis-ipad/source/objc/openBIS/openBIS/CISDOBMasterViewController.m +++ b/openbis-ipad/source/objc/openBIS/openBIS/CISDOBMasterViewController.m @@ -61,17 +61,18 @@ self.filterState = [[CISDOBTableFilterState alloc] initWithController: self]; self.searchState = [[CISDOBTableSearchState alloc] initWithController: self]; self.searchFilterState = self.filterState; + self.browsing = YES; [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(receiveSearchNotification:) - name:@"SearchNotification" - object:nil]; + addObserver:self + selector:@selector(receiveSearchNotification:) + name:@"SearchNotification" + object:nil]; [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(receiveDissmissNotification:) - name:@"DissmissNotification" - object:nil]; + addObserver:self + selector:@selector(receiveDissmissNotification:) + name:@"DissmissNotification" + object:nil]; } - (IBAction)refreshFromServer:(id)sender @@ -305,18 +306,20 @@ #pragma mark - UISearchDisplayDelegate -- (void) receiveSearchNotification:(NSNotification *) notification +- (void)receiveSearchNotification:(NSNotification *) notification { NSString * searchString = [notification object]; [self searchDisplayControllerWillBeginSearch: self.searchDisplayController]; self.searchDisplayController.searchBar.text = searchString; self.openBisModel.searchString = searchString; [self searchDisplayController: self.searchDisplayController shouldReloadTableForSearchScope: 0]; + self.browsing = NO; } -- (void) receiveDissmissNotification:(NSNotification *) notification +- (void)receiveDissmissNotification:(NSNotification *) notification { self.searchDisplayController.searchBar.selectedScopeButtonIndex = 0; + self.browsing = YES; } - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString @@ -332,17 +335,19 @@ self.openBisModel.searchString = @""; } // BUGFIX - - //Updating the state controller if the user presses a scope buttion - self.openBisModel.selectedSearchScopeIndex = searchOption; - self.searchFilterState = [self.openBisModel isSelectedSearchScopeIndexSearch] ? self.searchState : self.filterState; - - //Searching for barcodes or normal search + NSArray *options = [self scopeButtonTitles]; - + + // Searching for barcodes or normal search NSString* searchTitle = nil; - if(options != nil) { - searchTitle = options[searchOption]; + if([options count] > 0) { + // Updating the state controller if the user presses a scope button + if (searchOption < [options count]) + self.openBisModel.selectedSearchScopeIndex = searchOption; + else + self.openBisModel.selectedSearchScopeIndex = [options count] - 1; + self.searchFilterState = [self.openBisModel isSelectedSearchScopeIndexSearch] ? self.searchState : self.filterState; + searchTitle = options[self.openBisModel.selectedSearchScopeIndex]; } if (searchTitle != nil && [searchTitle isEqualToString:@"Barcode"]) { @@ -381,11 +386,15 @@ #pragma mark - Server Communication - (void)didConnectServiceManager:(CISDOBIpadServiceManager *)serviceManager { + __weak CISDOBMasterViewController *weakSelf = self; [self.openBisModel syncRootEntities: ^(id result) { - [self refreshTable]; + // We could be in search mode. In that case, do not refresh the table + [weakSelf refreshTable]; }]; - self.searchFilterState = [self.openBisModel isSearchSupported] ? self.searchState : self.filterState; + // If we are not already in search mode, switch to it if allowed. + if (self.searchFilterState == self.filterState) + self.searchFilterState = [self.openBisModel isSearchSupported] ? self.searchState : self.filterState; } diff --git a/openbis-ipad/source/objc/openBIS/openBIS/CISDOBOpenBisModel.m b/openbis-ipad/source/objc/openBIS/openBIS/CISDOBOpenBisModel.m index 67a2def495c5ecb8ff656e950c8055e47f9f7f89..1bd6772aa079638a3b59b61d010f66e93eb9996c 100644 --- a/openbis-ipad/source/objc/openBIS/openBIS/CISDOBOpenBisModel.m +++ b/openbis-ipad/source/objc/openBIS/openBIS/CISDOBOpenBisModel.m @@ -170,18 +170,18 @@ #pragma mark - Actions - (BOOL)insertNewObjectOrError:(NSError **)error { - NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext]; - // TODO Implement insert NSLog(@"Do not support adding new objects"); abort(); +// NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext]; + // NSEntityDescription *entity = [[self.openBisModel.fetchedResultsController fetchRequest] entity]; // NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context]; // Save the context. - return [context save: error]; +// return [context save: error]; } - (BOOL)deleteObjectAtIndexPath:(NSIndexPath *)indexPath error:(NSError **)error