diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.m
index 7976ab0..5710843 100644
--- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.m
+++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.m
@@ -39,6 +39,9 @@
@interface OZLProjectListViewController (){
NSMutableArray* _projectList;
MBProgressHUD * _HUD;
+
+ UIBarButtonItem* _editBtn;
+ UIBarButtonItem* _doneBtn;
}
@end
@@ -66,6 +69,9 @@
UIBarButtonItem* accountBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:self action:@selector(showAccountView:)];
[self.navigationItem setLeftBarButtonItem:accountBtn];
+ _editBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(editProjectList:)];
+ _doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(editProjectListDone:)];
+ [self.navigationItem setRightBarButtonItem:_editBtn];
[self.navigationItem setTitle:@"Projects"];
@@ -117,6 +123,19 @@
// animated:YES];
}
+-(void)editProjectList:(id)sender
+{
+ [_projectsTableview setEditing:YES animated:YES];
+ self.navigationItem.rightBarButtonItem = _doneBtn;
+
+}
+
+-(void)editProjectListDone:(id)sender
+{
+ [_projectsTableview setEditing:NO animated:YES];
+ self.navigationItem.rightBarButtonItem = _editBtn;
+}
+
- (IBAction)createProject:(id)sender {
//OZLProjectCreateViewController* creator = [[OZLProjectCreateViewController alloc] initWithNibName:@"OZLProjectCreateViewController" bundle:nil];
//[self.navigationController presentModalViewController:creator animated:YES];
@@ -165,44 +184,39 @@
return cell;
}
-/*
- // Override to support conditional editing of the table view.
- - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // Return NO if you do not want the specified item to be editable.
- return YES;
- }
- */
-/*
- // Override to support editing the table view.
- - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (editingStyle == UITableViewCellEditingStyleDelete) {
- // Delete the row from the data source
- [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
- }
- else if (editingStyle == UITableViewCellEditingStyleInsert) {
- // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
- }
- }
- */
+// Override to support conditional editing of the table view.
+- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ // Return NO if you do not want the specified item to be editable.
+ return YES;
+}
-/*
- // Override to support rearranging the table view.
- - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
- {
- }
- */
+// Override to support editing the table view.
+- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ if (editingStyle == UITableViewCellEditingStyleDelete) {
-/*
- // Override to support conditional rearranging of the table view.
- - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // Return NO if you do not want the item to be re-orderable.
- return YES;
- }
- */
+ _HUD.labelText = @"Deleting Project...";
+ [_HUD show:YES];
+ [OZLNetwork deleteProject:[[_projectList objectAtIndex:indexPath.row] index] withParams:nil andBlock:^(BOOL success, NSError *error) {
+ [_HUD hide:YES];
+ if (error) {
+ NSLog(@"failed to delete project");
+ _HUD.mode = MBProgressHUDModeText;
+
+ _HUD.labelText = @"Sorry, something wrong while deleting project.";
+ [_HUD show:YES];
+ [_HUD hide:YES afterDelay:1];
+ }else {
+ [_projectList removeObjectAtIndex:indexPath.row];
+ [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
+ }
+ }];
+ } else if (editingStyle == UITableViewCellEditingStyleInsert) {
+ // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
+ }
+}
#pragma mark - Table view delegate
diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.h b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.h
index 24359da..582f48f 100644
--- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.h
+++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.h
@@ -34,6 +34,7 @@
@property (nonatomic,strong) OZLModelProject* projectData;
- (IBAction)onNewIssue:(id)sender;
- (IBAction)onSortSetting:(id)sender;
+- (IBAction)onShowInfo:(id)sender;
@property (strong, nonatomic) NSArray* trackerList;
diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m
index 99ad4fd..afef5c5 100644
--- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m
+++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m
@@ -39,10 +39,12 @@
@interface OZLProjectViewController () {
- NSArray* _issuesList;
+ NSMutableArray* _issuesList;
float _sideviewOffset;
MBProgressHUD * _HUD;
+ UIBarButtonItem* _editBtn;
+ UIBarButtonItem* _doneBtn;
NSMutableDictionary* _issueListOption;
}
@@ -64,11 +66,9 @@
[super viewDidLoad];
// [self changeSideViewOffset:40];
-// UIBarButtonItem* projectListBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:self action:@selector(showProjectList)];
-// [self.navigationItem setLeftBarButtonItem:projectListBtn];
-
- UIBarButtonItem* inforBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(showProjectDetail)];
- [self.navigationItem setRightBarButtonItem:inforBtn];
+ _editBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(editIssueList:)];
+ _doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(editIssueListDone:)];
+ [self.navigationItem setRightBarButtonItem:_editBtn];
_HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:_HUD];
@@ -134,8 +134,7 @@
if (error) {
NSLog(@"error getIssueListForProject: %@",error.description);
}else {
- _issuesList = result;
-
+ _issuesList = [[NSMutableArray alloc] initWithArray: result];
[_issuesTableview reloadData];
}
[_HUD hide:YES];
@@ -237,15 +236,6 @@
}
-- (void) showProjectDetail
-{
- //OZLProjectDetailViewController* detail = [[OZLProjectDetailViewController alloc] initWithNibName:@"OZLProjectDetailViewController" bundle:nil];
- UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"OZLProjectDetailViewController" bundle:nil];
- OZLProjectDetailViewController* detail = [storyboard instantiateViewControllerWithIdentifier:@"OZLProjectDetailViewController"];
- [detail setProjectData:_projectData];
- [self.navigationController pushViewController:detail animated:YES];
-}
-
- (void) preloadLeft {
// OZLProjectListViewController *c = [[OZLProjectListViewController alloc] initWithNibName:@"OZLProjectListViewController" bundle:nil];
// [self.revealSideViewController preloadViewController:c
@@ -322,6 +312,39 @@
return cell;
}
+
+// Override to support conditional editing of the table view.
+- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ // Return NO if you do not want the specified item to be editable.
+ return YES;
+}
+
+// Override to support editing the table view.
+- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ if (editingStyle == UITableViewCellEditingStyleDelete) {
+
+ _HUD.labelText = @"Deleting Issue...";
+ [_HUD show:YES];
+ [OZLNetwork deleteIssue:[[_issuesList objectAtIndex:indexPath.row] index] withParams:nil andBlock:^(BOOL success, NSError *error) {
+ [_HUD hide:YES];
+ if (error) {
+ NSLog(@"failed to delete issue");
+ _HUD.mode = MBProgressHUDModeText;
+ _HUD.labelText = @"Sorry, something wrong while deleting issue.";
+ [_HUD show:YES];
+ [_HUD hide:YES afterDelay:1];
+ }else {
+ [_issuesList removeObjectAtIndex:indexPath.row];
+ [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
+ }
+ }];
+ } else if (editingStyle == UITableViewCellEditingStyleInsert) {
+ // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
+ }
+}
+
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
@@ -346,4 +369,25 @@
OZLIssueFilterViewController* filter = [[OZLIssueFilterViewController alloc] initWithStyle:UITableViewStyleGrouped];
[self.navigationController pushViewController:filter animated:YES];
}
+
+- (IBAction)onShowInfo:(id)sender {
+// UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"OZLProjectDetailViewController" bundle:nil];
+// OZLProjectDetailViewController* detail = [storyboard instantiateViewControllerWithIdentifier:@"OZLProjectDetailViewController"];
+ OZLProjectDetailViewController* detail = [[OZLProjectDetailViewController alloc] initWithNibName:@"OZLProjectDetailViewController" bundle:nil];
+ [detail setProjectData:_projectData];
+ [self.navigationController pushViewController:detail animated:YES];
+}
+
+-(void)editIssueList:(id)sender
+{
+ [_issuesTableview setEditing:YES animated:YES];
+ self.navigationItem.rightBarButtonItem = _doneBtn;
+
+}
+
+-(void)editIssueListDone:(id)sender
+{
+ [_issuesTableview setEditing:NO animated:YES];
+ self.navigationItem.rightBarButtonItem = _editBtn;
+}
@end
diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.xib b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.xib
index d31008a..e4a4abf 100644
--- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.xib
+++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.xib
@@ -80,6 +80,12 @@
10
+
@@ -167,6 +173,14 @@
14
+
@@ -202,6 +216,7 @@
+
@@ -220,6 +235,11 @@
+
+ 15
+
+
+
@@ -229,6 +249,7 @@
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
+ com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
@@ -237,7 +258,7 @@
- 14
+ 16
0