Skip to content
Snippets Groups Projects
Commit e17fdb0d authored by cramakri's avatar cramakri
Browse files

Master view controller now fully uses the model

SVN: 27168
parent 73eee0e3
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
@interface CISDOBMasterViewController () @interface CISDOBMasterViewController ()
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath; - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;
- (void)initializeDrillDownFrom:(CISDOBMasterViewController *)parent;
@end @end
@implementation CISDOBMasterViewController @implementation CISDOBMasterViewController
...@@ -126,14 +127,13 @@ ...@@ -126,14 +127,13 @@
// Segue to the detail view unless we are on the ipad // Segue to the detail view unless we are on the ipad
if ([[UIDevice currentDevice] userInterfaceIdiom] != UIUserInterfaceIdiomPad) return; if ([[UIDevice currentDevice] userInterfaceIdiom] != UIUserInterfaceIdiomPad) return;
CISDOBIpadEntity *object = [self.openBisModel objectAtIndexPath: indexPath]; CISDOBIpadEntity *object = [self.openBisModel selectObjectAtIndexPath: indexPath];
if ([object.childrenPermIds count] > 0) { if ([self.openBisModel isSelectionGroup]) {
UIStoryboard *storyboard = self.storyboard; UIStoryboard *storyboard = self.storyboard;
CISDOBMasterViewController *controller = [storyboard instantiateViewControllerWithIdentifier: @"Master"]; CISDOBMasterViewController *child = [storyboard instantiateViewControllerWithIdentifier: @"Master"];
controller.openBisModel = self.openBisModel; [child initializeDrillDownFrom: self];
controller.title = object.summaryHeader;
[self.navigationController pushViewController: controller animated: YES]; [self.navigationController pushViewController: child animated: YES];
} else { } else {
self.detailViewController.detailItem = object; self.detailViewController.detailItem = object;
} }
...@@ -161,6 +161,12 @@ ...@@ -161,6 +161,12 @@
} }
} }
- (void)initializeDrillDownFrom:(CISDOBMasterViewController *)parent
{
self.openBisModel = parent.openBisModel;
self.title = self.openBisModel.selectedObject.summaryHeader;
}
#pragma mark - Fetched results controller #pragma mark - Fetched results controller
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller - (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
......
...@@ -28,20 +28,25 @@ ...@@ -28,20 +28,25 @@
* \brief A model for the interaction with openBIS. * \brief A model for the interaction with openBIS.
*/ */
@interface CISDOBOpenBisModel : NSObject <NSFetchedResultsControllerDelegate> { @interface CISDOBOpenBisModel : NSObject <NSFetchedResultsControllerDelegate> {
CISDOBIpadEntity *_selectedObject;
} }
@property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController; @property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
@property (strong, nonatomic) NSManagedObjectContext *managedObjectContext; @property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (weak, nonatomic) id <NSFetchedResultsControllerDelegate> delegate; @property (weak, nonatomic) id <NSFetchedResultsControllerDelegate> delegate;
@property (readonly) CISDOBIpadEntity *selectedObject;
// Model // Model
- (NSInteger)numberOfSections; //!< Get the number of categories for the current selection - (NSInteger)numberOfSections; //!< Get the number of categories for the current selection
- (NSInteger)numberOfEntitiesInSection:(NSInteger)section; - (NSInteger)numberOfEntitiesInSection:(NSInteger)section;
- (NSString *)titleForHeaderInSection:(NSInteger)section; - (NSString *)titleForHeaderInSection:(NSInteger)section;
- (CISDOBIpadEntity *)objectAtIndexPath:(NSIndexPath *)indexPath; - (CISDOBIpadEntity *)objectAtIndexPath:(NSIndexPath *)indexPath;
// Selection
//! Select the object and return it
- (CISDOBIpadEntity *)selectObjectAtIndexPath:(NSIndexPath *)indexPath;
- (BOOL)isSelectionGroup; //!< Return YES if the selected object is a group (has children)
// Actions // Actions
- (BOOL)insertNewObjectOrError:(NSError **)error; //!< Return YES if operation succeeded - (BOOL)insertNewObjectOrError:(NSError **)error; //!< Return YES if operation succeeded
- (BOOL)deleteObjectAtIndexPath:(NSIndexPath *)indexPath error:(NSError **)error; //!< Return YES if operation succeeded - (BOOL)deleteObjectAtIndexPath:(NSIndexPath *)indexPath error:(NSError **)error; //!< Return YES if operation succeeded
......
...@@ -51,6 +51,18 @@ ...@@ -51,6 +51,18 @@
return [self.fetchedResultsController objectAtIndexPath:indexPath]; return [self.fetchedResultsController objectAtIndexPath:indexPath];
} }
#pragma mark - Selection
- (CISDOBIpadEntity *)selectObjectAtIndexPath:(NSIndexPath *)indexPath
{
_selectedObject = [self objectAtIndexPath: indexPath];
return _selectedObject;
}
- (BOOL)isSelectionGroup
{
return [_selectedObject.childrenPermIds count] > 0;
}
#pragma mark - Actions #pragma mark - Actions
- (BOOL)insertNewObjectOrError:(NSError **)error - (BOOL)insertNewObjectOrError:(NSError **)error
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment