diff --git a/RedmineMobile/RedmineMobile/OZLAppDelegate.m b/RedmineMobile/RedmineMobile/OZLAppDelegate.m index c95fefd..6b3ffd0 100644 --- a/RedmineMobile/RedmineMobile/OZLAppDelegate.m +++ b/RedmineMobile/RedmineMobile/OZLAppDelegate.m @@ -67,11 +67,11 @@ if (lastProjectID < 0) { }else { - OZLProjectViewController* projectview = [[OZLProjectViewController alloc] initWithNibName:@"OZLProjectViewController" bundle:nil]; - OZLModelProject* data = [[OZLModelProject alloc] init]; - data.index = lastProjectID; - [projectview setProjectData:data]; - [_navigationController pushViewController:projectview animated:NO]; +// OZLProjectViewController* projectview = [[OZLProjectViewController alloc] initWithNibName:@"OZLProjectViewController" bundle:nil]; +// OZLModelProject* data = [[OZLModelProject alloc] init]; +// data.index = lastProjectID; +// [projectview setProjectData:data]; +// [_navigationController pushViewController:projectview animated:NO]; } self.window.rootViewController = _navigationController; diff --git a/RedmineMobile/RedmineMobile/Utils/OZLSingleton.h b/RedmineMobile/RedmineMobile/Utils/OZLSingleton.h index 9307f86..013e6fc 100644 --- a/RedmineMobile/RedmineMobile/Utils/OZLSingleton.h +++ b/RedmineMobile/RedmineMobile/Utils/OZLSingleton.h @@ -27,6 +27,10 @@ // THE SOFTWARE. #import +#import "OZLModelTracker.h" +#import "OZLModelUser.h" +#import "OZLModelIssueStatus.h" +#import "OZLModelIssuePriority.h" @interface OZLSingleton : NSObject @@ -52,6 +56,9 @@ @property (strong, nonatomic) NSArray* statusList; @property (strong, nonatomic) NSArray* userList; @property (strong, nonatomic) NSArray* timeEntryActivityList; - +-(OZLModelTracker*)trackerWithId:(int)index; +-(OZLModelIssuePriority*)issuePriorityWithId:(int)index; +-(OZLModelIssueStatus*)issueStatusWithId:(int)index; +-(OZLModelUser*)userWithId:(int)index; @end diff --git a/RedmineMobile/RedmineMobile/Utils/OZLSingleton.m b/RedmineMobile/RedmineMobile/Utils/OZLSingleton.m index 8de6b4a..1ea0acb 100644 --- a/RedmineMobile/RedmineMobile/Utils/OZLSingleton.m +++ b/RedmineMobile/RedmineMobile/Utils/OZLSingleton.m @@ -64,6 +64,7 @@ static OZLSingleton* sharedInstance = nil; return sharedInstance; } +#pragma mark getter and setter -(NSString*)redmineHomeURL { NSUserDefaults* userdefaults = [NSUserDefaults standardUserDefaults]; @@ -160,4 +161,48 @@ static OZLSingleton* sharedInstance = nil; [userdefaults setObject:[NSNumber numberWithInt:issueListSortType] forKey:USER_DEFAULTS_ISSUE_LIST_SORT]; [userdefaults synchronize]; } + + +#pragma mark - +#pragma mark data retrival +-(OZLModelTracker*)trackerWithId:(int)index +{ + for (OZLModelTracker* tracker in _trackerList) { + if (tracker.index == index) { + return tracker; + } + } + return nil; +} +-(OZLModelIssuePriority*)issuePriorityWithId:(int)index +{ + for (OZLModelIssuePriority* priority in _priorityList) { + if (priority.index == index) { + return priority; + } + } + return nil; + +} +-(OZLModelIssueStatus*)issueStatusWithId:(int)index +{ + for (OZLModelIssueStatus* status in _statusList) { + if (status.index == index) { + return status; + } + } + return nil; + +} +-(OZLModelUser*)userWithId:(int)index +{ + for (OZLModelUser* user in _userList) { + if (user.index == index) { + return user; + } + } + return nil; + +} + @end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.storyboard b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.storyboard index e1c5ff2..842e619 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.storyboard +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.storyboard @@ -74,17 +74,17 @@ - @@ -98,18 +98,18 @@ - @@ -117,26 +117,101 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -146,7 +221,7 @@ - + @@ -164,7 +239,7 @@ - + @@ -181,7 +256,7 @@ - + @@ -199,7 +274,7 @@ - + @@ -226,14 +301,14 @@ - - + + - - + + - - + + diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.m index 98ef1cd..ee214da 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.m @@ -32,6 +32,7 @@ #import "OZLNetwork.h" #import "OZLModelIssueJournal.h" #import "OZLModelIssueJournalDetail.h" +#import "OZLSingleton.h" @interface OZLIssueHistoryViewController () { MBProgressHUD* _HUD; @@ -54,7 +55,7 @@ - (void)viewDidLoad { [super viewDidLoad]; - + // Uncomment the following line to preserve selection between presentations. // self.clearsSelectionOnViewWillAppear = NO; @@ -65,7 +66,7 @@ [self.view addSubview:_HUD]; _HUD.labelText = @"Refreshing..."; - [self.navigationItem setTitle:_issueData.subject]; + [self.navigationItem setTitle:@"History"]; } @@ -92,12 +93,12 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 1; + return _journalList.count; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return _journalList.count; + return [[[_journalList objectAtIndex:section] detailArray] count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath @@ -107,11 +108,74 @@ if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; + cell.selectionStyle = UITableViewCellSelectionStyleNone; + cell.textLabel.textColor = [UIColor darkTextColor]; + cell.textLabel.font = [UIFont systemFontOfSize:14]; } - OZLModelIssueJournal* journal = [_journalList objectAtIndex:indexPath.row]; - [cell.textLabel setText: journal.user.name]; - [cell.detailTextLabel setText:[NSString stringWithFormat:@"number of change: %d",journal.detailArray.count]]; + OZLModelIssueJournalDetail* detail = [[[_journalList objectAtIndex:indexPath.section] detailArray] objectAtIndex:indexPath.row]; + NSString* content; + if ([detail.name isEqualToString:@"done_ratio"]) { + content = [NSString stringWithFormat:@"Done changed from %@ to %@",detail.oldValue,detail.freshValue]; + }else if([detail.name isEqualToString:@"tracker_id"]){ + OZLModelTracker* old = [[OZLSingleton sharedInstance] trackerWithId:[detail.oldValue intValue]]; + OZLModelTracker* new = [[OZLSingleton sharedInstance] trackerWithId:[detail.freshValue intValue]]; + content = [NSString stringWithFormat:@"Tracker changed from %@ to %@", old.name, new.name]; + + }else if([detail.name isEqualToString:@"priority_id"]) { + OZLModelIssuePriority* old = [[OZLSingleton sharedInstance] issuePriorityWithId:[detail.oldValue intValue]]; + OZLModelIssuePriority* new = [[OZLSingleton sharedInstance] issuePriorityWithId:[detail.freshValue intValue]]; + content = [NSString stringWithFormat:@"Priority changed from %@ to %@", old.name, new.name]; + + }else if([detail.name isEqualToString:@"status_id"]) { + OZLModelIssueStatus* old = [[OZLSingleton sharedInstance] issueStatusWithId:[detail.oldValue intValue]]; + OZLModelIssueStatus* new = [[OZLSingleton sharedInstance] issueStatusWithId:[detail.freshValue intValue]]; + content = [NSString stringWithFormat:@"Status changed from %@ to %@", old.name, new.name]; + }else if([detail.name isEqualToString:@"assigned_to_id"]) { + OZLModelUser* new = [[OZLSingleton sharedInstance] userWithId:[detail.freshValue intValue]]; + content = [NSString stringWithFormat:@"Assignee set to %@", new.name]; + }else if([detail.name isEqualToString:@"estimated_hours"]){ + content = [NSString stringWithFormat:@"Estimated time changed from %.2f to %.2f", [detail.oldValue floatValue], [detail.freshValue floatValue]]; + }else if([detail.name isEqualToString:@"subject"]) { + //content = [NSString stringWithFormat:@"Subject changed from %@ to %@",detail.oldValue, detail.freshValue]; + content = [NSString stringWithFormat:@"Subject changed to %@",detail.freshValue]; + } + + [cell.textLabel setText:content]; return cell; } +-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section +{ + UIView* view = [[UIView alloc ] initWithFrame:CGRectMake(0, 0, 320, 44)]; + view.backgroundColor = [UIColor lightGrayColor]; + + OZLModelIssueJournal* journal = [_journalList objectAtIndex:section]; + UILabel* nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 2, 160, 20)]; + [nameLabel setText: journal.user.name]; + nameLabel.font = [UIFont systemFontOfSize:12]; + nameLabel.backgroundColor = [UIColor clearColor]; + nameLabel.textColor = [UIColor darkTextColor]; + [view addSubview:nameLabel]; + + UILabel* timeLable = [[UILabel alloc] initWithFrame:CGRectMake(160, 2, 160, 20)]; + [timeLable setText: journal.createdOn]; + timeLable.font = [UIFont systemFontOfSize:12]; + timeLable.backgroundColor = [UIColor clearColor]; + timeLable.textColor = [UIColor lightTextColor]; + [view addSubview:timeLable]; + + UILabel* notesLable = [[UILabel alloc] initWithFrame:CGRectMake(10, 24, 300, 20)]; + [notesLable setText: journal.notes]; + notesLable.font = [UIFont systemFontOfSize:12]; + notesLable.backgroundColor = [UIColor clearColor]; + notesLable.textColor = [UIColor lightTextColor]; + [view addSubview:notesLable]; + + return view; +} + +- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section +{ + return 44.0; +} @end