issue and project delete functionality
This commit is contained in:
parent
0c5986735b
commit
4b6d683b50
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -80,6 +80,12 @@
|
|||
<reference key="IBUIToolbar" ref="366696023"/>
|
||||
<int key="IBUISystemItemIdentifier">10</int>
|
||||
</object>
|
||||
<object class="IBUIBarButtonItem" id="294602840">
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<int key="IBUIStyle">1</int>
|
||||
<reference key="IBUIToolbar" ref="366696023"/>
|
||||
<int key="IBUISystemItemIdentifier">11</int>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
</array>
|
||||
|
@ -167,6 +173,14 @@
|
|||
</object>
|
||||
<int key="connectionID">14</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchEventConnection" key="connection">
|
||||
<string key="label">onShowInfo:</string>
|
||||
<reference key="source" ref="294602840"/>
|
||||
<reference key="destination" ref="372490531"/>
|
||||
</object>
|
||||
<int key="connectionID">16</int>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<array key="orderedObjects">
|
||||
|
@ -202,6 +216,7 @@
|
|||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="512025889"/>
|
||||
<reference ref="917877130"/>
|
||||
<reference ref="294602840"/>
|
||||
</array>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
|
@ -220,6 +235,11 @@
|
|||
<reference key="object" ref="917877130"/>
|
||||
<reference key="parent" ref="366696023"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">15</int>
|
||||
<reference key="object" ref="294602840"/>
|
||||
<reference key="parent" ref="366696023"/>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<dictionary class="NSMutableDictionary" key="flattenedProperties">
|
||||
|
@ -229,6 +249,7 @@
|
|||
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="13.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="15.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="7.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="8.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
|
@ -237,7 +258,7 @@
|
|||
<nil key="activeLocalization"/>
|
||||
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">14</int>
|
||||
<int key="maxID">16</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes"/>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
|
|
Loading…
Reference in New Issue