From 448d2a4982dc9edb49cc8fe355676514f862fdf6 Mon Sep 17 00:00:00 2001 From: zhijie Date: Mon, 22 Jul 2013 20:12:34 +0800 Subject: [PATCH 1/9] issue activity histroy, still under dev --- .../RedmineMobile.xcodeproj/project.pbxproj | 13 ++ .../Models/OZLModelTimeEntries.h | 53 +++++++ .../Models/OZLModelTimeEntries.m | 58 +++++++ .../RedmineMobile/Utils/OZLNetwork.h | 5 +- .../RedmineMobile/Utils/OZLNetwork.m | 46 ++++++ .../OZLIssueDetailViewController.m | 67 +------- .../OZLIssueHistoryViewController.h | 37 +++++ .../OZLIssueHistoryViewController.m | 144 ++++++++++++++++++ 8 files changed, 357 insertions(+), 66 deletions(-) create mode 100644 RedmineMobile/RedmineMobile/Models/OZLModelTimeEntries.h create mode 100644 RedmineMobile/RedmineMobile/Models/OZLModelTimeEntries.m create mode 100644 RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.h create mode 100644 RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.m diff --git a/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj b/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj index 687b58b..87d38a0 100644 --- a/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj +++ b/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj @@ -30,6 +30,8 @@ 2BC4DD8E179928C80090F52C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5DB805B1792F2BF0081662A /* Foundation.framework */; }; 2BC4DD94179928C80090F52C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2BC4DD92179928C80090F52C /* InfoPlist.strings */; }; 2BC4DD97179928C80090F52C /* RedmineMobileUnitTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BC4DD96179928C80090F52C /* RedmineMobileUnitTest.m */; }; + 2BCC0FCF179D5458003DFB44 /* OZLIssueHistoryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCC0FCE179D5458003DFB44 /* OZLIssueHistoryViewController.m */; }; + 2BCC0FD2179D56BA003DFB44 /* OZLModelTimeEntries.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCC0FD1179D56BA003DFB44 /* OZLModelTimeEntries.m */; }; 2BCCA0541795312E00FA8B1A /* OZLConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCCA0531795312E00FA8B1A /* OZLConstants.m */; }; 2BCF880C1793A26A006FC859 /* MBProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCF880B1793A26A006FC859 /* MBProgressHUD.m */; }; 2BCF88101793ABA0006FC859 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCF880F1793ABA0006FC859 /* Reachability.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; @@ -118,6 +120,10 @@ 2BC4DD95179928C80090F52C /* RedmineMobileUnitTest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RedmineMobileUnitTest.h; sourceTree = ""; }; 2BC4DD96179928C80090F52C /* RedmineMobileUnitTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RedmineMobileUnitTest.m; sourceTree = ""; }; 2BC4DD98179928C80090F52C /* RedmineMobileUnitTest-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RedmineMobileUnitTest-Prefix.pch"; sourceTree = ""; }; + 2BCC0FCD179D5458003DFB44 /* OZLIssueHistoryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLIssueHistoryViewController.h; path = ViewControllers/OZLIssueHistoryViewController.h; sourceTree = ""; }; + 2BCC0FCE179D5458003DFB44 /* OZLIssueHistoryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLIssueHistoryViewController.m; path = ViewControllers/OZLIssueHistoryViewController.m; sourceTree = ""; }; + 2BCC0FD0179D56BA003DFB44 /* OZLModelTimeEntries.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLModelTimeEntries.h; path = Models/OZLModelTimeEntries.h; sourceTree = ""; }; + 2BCC0FD1179D56BA003DFB44 /* OZLModelTimeEntries.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLModelTimeEntries.m; path = Models/OZLModelTimeEntries.m; sourceTree = ""; }; 2BCCA0521795312E00FA8B1A /* OZLConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLConstants.h; path = Models/OZLConstants.h; sourceTree = ""; }; 2BCCA0531795312E00FA8B1A /* OZLConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLConstants.m; path = Models/OZLConstants.m; sourceTree = ""; }; 2BCF880A1793A26A006FC859 /* MBProgressHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBProgressHUD.h; sourceTree = ""; }; @@ -325,6 +331,8 @@ 2B62D0E0179649A800AC3C19 /* OZLIssueDetailViewController.storyboard */, 2B62D0E61796A8D800AC3C19 /* OZLIssueFilterViewController.h */, 2B62D0E71796A8D800AC3C19 /* OZLIssueFilterViewController.m */, + 2BCC0FCD179D5458003DFB44 /* OZLIssueHistoryViewController.h */, + 2BCC0FCE179D5458003DFB44 /* OZLIssueHistoryViewController.m */, ); name = Issue; sourceTree = ""; @@ -504,6 +512,8 @@ 2BCF882F1793F5CE006FC859 /* OZLModelUser.m */, 2B9968A91794F71B0086F115 /* OZLModelIssueCategory.h */, 2B9968AA1794F71B0086F115 /* OZLModelIssueCategory.m */, + 2BCC0FD0179D56BA003DFB44 /* OZLModelTimeEntries.h */, + 2BCC0FD1179D56BA003DFB44 /* OZLModelTimeEntries.m */, ); name = Models; sourceTree = ""; @@ -678,6 +688,8 @@ 2B8A11E217963CE500906D34 /* OZLIssueDetailViewController.m in Sources */, 2B62D0E81796A8D800AC3C19 /* OZLIssueFilterViewController.m in Sources */, 2B6F38371797A00A00D06F51 /* MLTableAlert.m in Sources */, + 2BCC0FCF179D5458003DFB44 /* OZLIssueHistoryViewController.m in Sources */, + 2BCC0FD2179D56BA003DFB44 /* OZLModelTimeEntries.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -837,6 +849,7 @@ 2BC4DD9B179928C80090F52C /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; D5DB80511792F2BF0081662A /* Build configuration list for PBXProject "RedmineMobile" */ = { isa = XCConfigurationList; diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntries.h b/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntries.h new file mode 100644 index 0000000..1a7786b --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntries.h @@ -0,0 +1,53 @@ +// +// OZLModelTimeEntries.h +// RedmineMobile +// +// Created by lizhijie on 7/22/13. + +// This code is distributed under the terms and conditions of the MIT license. + +// Copyright (c) 2013 Zhijie Lee(onezeros.lee@gmail.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import +#import "OZLModelProject.h" +#import "OZLModelIssue.h" +#import "OZLModelUser.h" + + +@interface OZLModelTimeEntries : NSObject +//"id":3880,"project":{"id":14848,"name":"TVS-SCS DEMO PROJ 1"},"issue":{"id":16697},"user":{"id":20600,"name":"Derek Halford"},"activity":{"id":9,"name":"Development"},"hours":1.0,"comments":"Issue has been confirmed","spent_on":"2013-07-22","created_on":"2013-07-22T10:36:57Z","updated_on":"2013-07-22T10:36:57Z" +@property(nonatomic) int index; +@property(nonatomic, strong) OZLModelProject* project; +@property(nonatomic, strong) OZLModelUser* user; +@property(nonatomic, strong) OZLModelIssue* issue; +@property(nonatomic) float hours; +@property(nonatomic, strong) NSString* comments; +@property(nonatomic, strong) NSString* spentOn; +@property(nonatomic, strong) NSString* createdOn; +@property(nonatomic, strong) NSString* updatedOn; + + +-(id)initWithDictionary:(NSDictionary*)dic; +-(NSMutableDictionary*) toParametersDic; + + +@end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntries.m b/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntries.m new file mode 100644 index 0000000..cfbdbd0 --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntries.m @@ -0,0 +1,58 @@ +// +// OZLModelTimeEntries.m +// RedmineMobile +// +// Created by lizhijie on 7/22/13. + +// This code is distributed under the terms and conditions of the MIT license. + +// Copyright (c) 2013 Zhijie Lee(onezeros.lee@gmail.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "OZLModelTimeEntries.h" + +@implementation OZLModelTimeEntries + +-(id)initWithDictionary:(NSDictionary*)dic +{ + self = [super init]; + if (!self) { + return nil; + } + _index = [[dic objectForKey:@"id"] intValue]; + _project = [[OZLModelProject alloc] initWithDictionary:[dic objectForKey:@"project"]]; + _user = [[OZLModelUser alloc] initWithDictionary:[dic objectForKey:@"user"] ]; + _issue = [[OZLModelIssue alloc] initWithDictionary:[dic objectForKey:@"issue"]]; + _hours = [[dic objectForKey:@"hours"] floatValue]; + _comments = [dic objectForKey:@"comments"]; + _spentOn = [dic objectForKey:@"spent_on"]; + _createdOn = [dic objectForKey:@"created_on"]; + _updatedOn = [dic objectForKey:@"updated_on"]; + return self; +} + +-(NSMutableDictionary*) toParametersDic +{ + +} + + +@end diff --git a/RedmineMobile/RedmineMobile/Utils/OZLNetwork.h b/RedmineMobile/RedmineMobile/Utils/OZLNetwork.h index 35ab89c..19921ed 100644 --- a/RedmineMobile/RedmineMobile/Utils/OZLNetwork.h +++ b/RedmineMobile/RedmineMobile/Utils/OZLNetwork.h @@ -60,5 +60,8 @@ // tracker +(void)getTrackerListWithParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block; - +// time entries ++(void)getTimeEntriesWithParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block; ++(void)getTimeEntriesForIssueId:(int)issueid withParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block; ++(void)getTimeEntriesForProjectId:(int)projectid withParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block; @end diff --git a/RedmineMobile/RedmineMobile/Utils/OZLNetwork.m b/RedmineMobile/RedmineMobile/Utils/OZLNetwork.m index 7bec7e8..dfbc0f1 100644 --- a/RedmineMobile/RedmineMobile/Utils/OZLNetwork.m +++ b/RedmineMobile/RedmineMobile/Utils/OZLNetwork.m @@ -472,4 +472,50 @@ } }]; } + + +#pragma mark - +#pragma mark time entries +// time entries ++(void)getTimeEntriesWithParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block +{ + NSString* path = @"/time_entries.json"; + NSMutableDictionary* paramsDic = [[NSMutableDictionary alloc] initWithDictionary:params]; + NSString* accessKey = [[OZLSingleton sharedInstance] redmineUserKey]; + if (accessKey.length > 0) { + [paramsDic setObject:accessKey forKey:@"key"]; + } + + [[OZLNetworkBase sharedClient] setAuthorizationHeader]; + [[OZLNetworkBase sharedClient] getPath:path parameters:paramsDic success:^(AFHTTPRequestOperation *operation, id responseObject) { + + if (block) { + NSLog(@"the repsonse:%@",responseObject); + NSMutableArray* priorities = [[NSMutableArray alloc] init]; + + NSArray* dic = [responseObject objectForKey:@"time_entries"]; + for (NSDictionary* p in dic) { + [priorities addObject:[[OZLModelTracker alloc] initWithDictionary:p]]; + } + block(priorities,nil); + } + + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + + if (block) { + block([NSArray array], error); + } + }]; + +} + ++(void)getTimeEntriesForIssueId:(int)issueid withParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block +{ + +} + ++(void)getTimeEntriesForProjectId:(int)projectid withParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block +{ + +} @end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m index 6bc8892..7b77994 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m @@ -65,6 +65,8 @@ _assignedTo.text = _issueData.assignedTo.login; _startTime.text = _issueData.startDate; _dueTime.text = _issueData.dueDate; + + [self.navigationItem setTitle:@"Issue Details"]; } - (void)didReceiveMemoryWarning @@ -73,71 +75,6 @@ // Dispose of any resources that can be recreated. } -#pragma mark - Table view data source - -//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView -//{ -//#warning Potentially incomplete method implementation. -// // Return the number of sections. -// return 1; -//} -// -//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section -//{ -//#warning Incomplete method implementation. -// // Return the number of rows in the section. -// return 2; -//} -// -//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -//{ -// static NSString *CellIdentifier = @"Cell"; -// UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; -// -// // Configure the cell... -// -// 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 rearranging the table view. -//- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath -//{ -//} -//*/ -// -///* -//// 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; -//} -//*/ - #pragma mark - Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.h b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.h new file mode 100644 index 0000000..322b8f5 --- /dev/null +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.h @@ -0,0 +1,37 @@ +// +// OZLIssueHistoryViewController.h +// RedmineMobile +// +// Created by lizhijie on 7/22/13. + +// This code is distributed under the terms and conditions of the MIT license. + +// Copyright (c) 2013 Zhijie Lee(onezeros.lee@gmail.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import +#import "OZLModelIssue.h" + +@interface OZLIssueHistoryViewController : UITableViewController + +@property(nonatomic,strong) OZLModelIssue* issueData; + +@end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.m new file mode 100644 index 0000000..8890ab8 --- /dev/null +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.m @@ -0,0 +1,144 @@ +// +// OZLIssueHistoryViewController.m +// RedmineMobile +// +// Created by lizhijie on 7/22/13. + +// This code is distributed under the terms and conditions of the MIT license. + +// Copyright (c) 2013 Zhijie Lee(onezeros.lee@gmail.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "OZLIssueHistoryViewController.h" + +@interface OZLIssueHistoryViewController () + +@end + +@implementation OZLIssueHistoryViewController + +- (id)initWithStyle:(UITableViewStyle)style +{ + self = [super initWithStyle:style]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + // Uncomment the following line to preserve selection between presentations. + // self.clearsSelectionOnViewWillAppear = NO; + + // Uncomment the following line to display an Edit button in the navigation bar for this view controller. + // self.navigationItem.rightBarButtonItem = self.editButtonItem; + + [self.navigationItem setTitle:_issueData.subject]; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ +#warning Potentially incomplete method implementation. + // Return the number of sections. + return 0; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ +#warning Incomplete method implementation. + // Return the number of rows in the section. + return 0; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *CellIdentifier = @"Cell"; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; + + // Configure the cell... + + 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 rearranging the table view. +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath +{ +} +*/ + +/* +// 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; +} +*/ + +#pragma mark - Table view delegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + // Navigation logic may go here. Create and push another view controller. + /* + <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; + // ... + // Pass the selected object to the new view controller. + [self.navigationController pushViewController:detailViewController animated:YES]; + */ +} + +@end From e60bd809d122afb2cf596b96487fd34a11c8c1c6 Mon Sep 17 00:00:00 2001 From: zhijie Date: Tue, 23 Jul 2013 15:45:41 +0800 Subject: [PATCH 2/9] issue log time && ui of revision history --- .../RedmineMobile.xcodeproj/project.pbxproj | 28 +++ .../Models/OZLModelIssueCategory.m | 8 +- .../Models/OZLModelIssueJournal.h | 66 ++++++ .../Models/OZLModelIssueJournal.m | 59 ++++++ .../Models/OZLModelIssueJournalDetail.h | 51 +++++ .../Models/OZLModelIssueJournalDetail.m | 50 +++++ .../Models/OZLModelTimeEntries.h | 3 + .../Models/OZLModelTimeEntries.m | 38 +++- .../Models/OZLModelTimeEntryActivity.h | 39 ++++ .../Models/OZLModelTimeEntryActivity.m | 48 +++++ .../RedmineMobile/Utils/OZLNetwork.h | 9 + .../RedmineMobile/Utils/OZLNetwork.m | 101 ++++++++- .../OZLIssueCreateViewController.m | 10 +- .../OZLIssueDetailViewController.h | 6 +- .../OZLIssueDetailViewController.m | 22 +- .../OZLIssueHistoryViewController.m | 98 ++++----- .../OZLIssueLogtimeViewController.h | 23 +++ .../OZLIssueLogtimeViewController.m | 194 ++++++++++++++++++ .../OZLIssueLogtimeViewController.storyboard | 141 +++++++++++++ .../OZLProjectViewController.h | 9 +- .../OZLProjectViewController.m | 23 ++- 21 files changed, 931 insertions(+), 95 deletions(-) create mode 100644 RedmineMobile/RedmineMobile/Models/OZLModelIssueJournal.h create mode 100644 RedmineMobile/RedmineMobile/Models/OZLModelIssueJournal.m create mode 100644 RedmineMobile/RedmineMobile/Models/OZLModelIssueJournalDetail.h create mode 100644 RedmineMobile/RedmineMobile/Models/OZLModelIssueJournalDetail.m create mode 100644 RedmineMobile/RedmineMobile/Models/OZLModelTimeEntryActivity.h create mode 100644 RedmineMobile/RedmineMobile/Models/OZLModelTimeEntryActivity.m create mode 100644 RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.h create mode 100644 RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.m create mode 100644 RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.storyboard diff --git a/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj b/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj index 87d38a0..dd6ade0 100644 --- a/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj +++ b/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj @@ -25,11 +25,16 @@ 2B9968AB1794F71B0086F115 /* OZLModelIssueCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B9968AA1794F71B0086F115 /* OZLModelIssueCategory.m */; }; 2B9968AF1794FC0A0086F115 /* OZLProjectCreateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B9968AD1794FC0A0086F115 /* OZLProjectCreateViewController.m */; }; 2B9968B417951A5C0086F115 /* OZLIssueCreateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B9968B217951A5C0086F115 /* OZLIssueCreateViewController.m */; }; + 2BBE440F179E500E00FD9E20 /* OZLIssueLogtimeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BBE440E179E500E00FD9E20 /* OZLIssueLogtimeViewController.m */; }; + 2BBE4411179E503100FD9E20 /* OZLIssueLogtimeViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2BBE4410179E503100FD9E20 /* OZLIssueLogtimeViewController.storyboard */; }; + 2BBE4414179E586B00FD9E20 /* OZLModelTimeEntryActivity.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BBE4413179E586B00FD9E20 /* OZLModelTimeEntryActivity.m */; }; 2BC4DD8C179928C80090F52C /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2BC4DD8B179928C80090F52C /* SenTestingKit.framework */; }; 2BC4DD8D179928C80090F52C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5DB80591792F2BF0081662A /* UIKit.framework */; }; 2BC4DD8E179928C80090F52C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5DB805B1792F2BF0081662A /* Foundation.framework */; }; 2BC4DD94179928C80090F52C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2BC4DD92179928C80090F52C /* InfoPlist.strings */; }; 2BC4DD97179928C80090F52C /* RedmineMobileUnitTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BC4DD96179928C80090F52C /* RedmineMobileUnitTest.m */; }; + 2BCBA81D179E292800E5FD46 /* OZLModelIssueJournal.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCBA81C179E292800E5FD46 /* OZLModelIssueJournal.m */; }; + 2BCBA820179E2AA500E5FD46 /* OZLModelIssueJournalDetail.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCBA81F179E2AA400E5FD46 /* OZLModelIssueJournalDetail.m */; }; 2BCC0FCF179D5458003DFB44 /* OZLIssueHistoryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCC0FCE179D5458003DFB44 /* OZLIssueHistoryViewController.m */; }; 2BCC0FD2179D56BA003DFB44 /* OZLModelTimeEntries.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCC0FD1179D56BA003DFB44 /* OZLModelTimeEntries.m */; }; 2BCCA0541795312E00FA8B1A /* OZLConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCCA0531795312E00FA8B1A /* OZLConstants.m */; }; @@ -113,6 +118,11 @@ 2B9968AD1794FC0A0086F115 /* OZLProjectCreateViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLProjectCreateViewController.m; path = ViewControllers/OZLProjectCreateViewController.m; sourceTree = ""; }; 2B9968B117951A5C0086F115 /* OZLIssueCreateViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLIssueCreateViewController.h; path = ViewControllers/OZLIssueCreateViewController.h; sourceTree = ""; }; 2B9968B217951A5C0086F115 /* OZLIssueCreateViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLIssueCreateViewController.m; path = ViewControllers/OZLIssueCreateViewController.m; sourceTree = ""; }; + 2BBE440D179E500E00FD9E20 /* OZLIssueLogtimeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLIssueLogtimeViewController.h; path = ViewControllers/OZLIssueLogtimeViewController.h; sourceTree = ""; }; + 2BBE440E179E500E00FD9E20 /* OZLIssueLogtimeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLIssueLogtimeViewController.m; path = ViewControllers/OZLIssueLogtimeViewController.m; sourceTree = ""; }; + 2BBE4410179E503100FD9E20 /* OZLIssueLogtimeViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = OZLIssueLogtimeViewController.storyboard; path = ViewControllers/OZLIssueLogtimeViewController.storyboard; sourceTree = ""; }; + 2BBE4412179E586B00FD9E20 /* OZLModelTimeEntryActivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLModelTimeEntryActivity.h; path = Models/OZLModelTimeEntryActivity.h; sourceTree = ""; }; + 2BBE4413179E586B00FD9E20 /* OZLModelTimeEntryActivity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLModelTimeEntryActivity.m; path = Models/OZLModelTimeEntryActivity.m; sourceTree = ""; }; 2BC4DD8A179928C80090F52C /* RedmineMobileUnitTest.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RedmineMobileUnitTest.octest; sourceTree = BUILT_PRODUCTS_DIR; }; 2BC4DD8B179928C80090F52C /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; 2BC4DD91179928C80090F52C /* RedmineMobileUnitTest-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "RedmineMobileUnitTest-Info.plist"; sourceTree = ""; }; @@ -120,6 +130,10 @@ 2BC4DD95179928C80090F52C /* RedmineMobileUnitTest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RedmineMobileUnitTest.h; sourceTree = ""; }; 2BC4DD96179928C80090F52C /* RedmineMobileUnitTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RedmineMobileUnitTest.m; sourceTree = ""; }; 2BC4DD98179928C80090F52C /* RedmineMobileUnitTest-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RedmineMobileUnitTest-Prefix.pch"; sourceTree = ""; }; + 2BCBA81B179E292800E5FD46 /* OZLModelIssueJournal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLModelIssueJournal.h; path = Models/OZLModelIssueJournal.h; sourceTree = ""; }; + 2BCBA81C179E292800E5FD46 /* OZLModelIssueJournal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLModelIssueJournal.m; path = Models/OZLModelIssueJournal.m; sourceTree = ""; }; + 2BCBA81E179E2AA400E5FD46 /* OZLModelIssueJournalDetail.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLModelIssueJournalDetail.h; path = Models/OZLModelIssueJournalDetail.h; sourceTree = ""; }; + 2BCBA81F179E2AA400E5FD46 /* OZLModelIssueJournalDetail.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLModelIssueJournalDetail.m; path = Models/OZLModelIssueJournalDetail.m; sourceTree = ""; }; 2BCC0FCD179D5458003DFB44 /* OZLIssueHistoryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLIssueHistoryViewController.h; path = ViewControllers/OZLIssueHistoryViewController.h; sourceTree = ""; }; 2BCC0FCE179D5458003DFB44 /* OZLIssueHistoryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLIssueHistoryViewController.m; path = ViewControllers/OZLIssueHistoryViewController.m; sourceTree = ""; }; 2BCC0FD0179D56BA003DFB44 /* OZLModelTimeEntries.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLModelTimeEntries.h; path = Models/OZLModelTimeEntries.h; sourceTree = ""; }; @@ -333,6 +347,9 @@ 2B62D0E71796A8D800AC3C19 /* OZLIssueFilterViewController.m */, 2BCC0FCD179D5458003DFB44 /* OZLIssueHistoryViewController.h */, 2BCC0FCE179D5458003DFB44 /* OZLIssueHistoryViewController.m */, + 2BBE440D179E500E00FD9E20 /* OZLIssueLogtimeViewController.h */, + 2BBE440E179E500E00FD9E20 /* OZLIssueLogtimeViewController.m */, + 2BBE4410179E503100FD9E20 /* OZLIssueLogtimeViewController.storyboard */, ); name = Issue; sourceTree = ""; @@ -514,6 +531,12 @@ 2B9968AA1794F71B0086F115 /* OZLModelIssueCategory.m */, 2BCC0FD0179D56BA003DFB44 /* OZLModelTimeEntries.h */, 2BCC0FD1179D56BA003DFB44 /* OZLModelTimeEntries.m */, + 2BCBA81B179E292800E5FD46 /* OZLModelIssueJournal.h */, + 2BCBA81C179E292800E5FD46 /* OZLModelIssueJournal.m */, + 2BCBA81E179E2AA400E5FD46 /* OZLModelIssueJournalDetail.h */, + 2BCBA81F179E2AA400E5FD46 /* OZLModelIssueJournalDetail.m */, + 2BBE4412179E586B00FD9E20 /* OZLModelTimeEntryActivity.h */, + 2BBE4413179E586B00FD9E20 /* OZLModelTimeEntryActivity.m */, ); name = Models; sourceTree = ""; @@ -617,6 +640,7 @@ 2B6F38341797A00A00D06F51 /* MLTableAlertButtonPressed@2x.png in Resources */, 2B6F38351797A00A00D06F51 /* MLTableAlertShadowMask.png in Resources */, 2B6F38361797A00A00D06F51 /* MLTableAlertShadowMask@2x.png in Resources */, + 2BBE4411179E503100FD9E20 /* OZLIssueLogtimeViewController.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -690,6 +714,10 @@ 2B6F38371797A00A00D06F51 /* MLTableAlert.m in Sources */, 2BCC0FCF179D5458003DFB44 /* OZLIssueHistoryViewController.m in Sources */, 2BCC0FD2179D56BA003DFB44 /* OZLModelTimeEntries.m in Sources */, + 2BCBA81D179E292800E5FD46 /* OZLModelIssueJournal.m in Sources */, + 2BCBA820179E2AA500E5FD46 /* OZLModelIssueJournalDetail.m in Sources */, + 2BBE440F179E500E00FD9E20 /* OZLIssueLogtimeViewController.m in Sources */, + 2BBE4414179E586B00FD9E20 /* OZLModelTimeEntryActivity.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelIssueCategory.m b/RedmineMobile/RedmineMobile/Models/OZLModelIssueCategory.m index cda8288..f6c37d9 100644 --- a/RedmineMobile/RedmineMobile/Models/OZLModelIssueCategory.m +++ b/RedmineMobile/RedmineMobile/Models/OZLModelIssueCategory.m @@ -41,9 +41,9 @@ _name = [dic objectForKey:@"name"]; return self; } -//-(NSMutableDictionary*) toParametersDic -//{ -// -//} +-(NSMutableDictionary*) toParametersDic +{ + return nil; +} @end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelIssueJournal.h b/RedmineMobile/RedmineMobile/Models/OZLModelIssueJournal.h new file mode 100644 index 0000000..44fd59b --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelIssueJournal.h @@ -0,0 +1,66 @@ +// +// OZLModelIssueJournal.h +// RedmineMobile +// +// Created by lizhijie on 7/23/13. + +// This code is distributed under the terms and conditions of the MIT license. + +// Copyright (c) 2013 Zhijie Lee(onezeros.lee@gmail.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import +#import "OZLModelUser.h" +#import "OZLModelIssueJournalDetail.h" + +/* + { + "id": 12353, + "user": { + "id": 20043, + "name": "wang lei" + }, + "notes": "fdfcasvawefqwf\r\n\r\nasdfasd\r\nasdfasdf", + "created_on": "2013-07-22T08:47:47Z", + "details": [ + { + "property": "attr", + "name": "done_ratio", + "old_value": "0", + "new_value": "20" + } + ] + } + + */ +@interface OZLModelIssueJournal : NSObject + +@property(nonatomic) int index; +@property(nonatomic, strong) NSString* notes; +@property(nonatomic, strong) NSString* createdOn; +@property(nonatomic, strong) OZLModelUser* user; +@property(nonatomic, strong) NSArray* detailArray; + +-(id)initWithDictionary:(NSDictionary*)dic; +-(NSMutableDictionary*) toParametersDic; + + +@end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelIssueJournal.m b/RedmineMobile/RedmineMobile/Models/OZLModelIssueJournal.m new file mode 100644 index 0000000..e6e4121 --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelIssueJournal.m @@ -0,0 +1,59 @@ +// +// OZLModelIssueJournal.m +// RedmineMobile +// +// Created by lizhijie on 7/23/13. + +// This code is distributed under the terms and conditions of the MIT license. + +// Copyright (c) 2013 Zhijie Lee(onezeros.lee@gmail.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "OZLModelIssueJournal.h" + +@implementation OZLModelIssueJournal + + +-(id)initWithDictionary:(NSDictionary*)dic +{ + self = [super init]; + if (!self) { + return nil; + } + _index = [[dic objectForKey:@"index"] intValue]; + _notes = [dic objectForKey:@"notes"]; + _createdOn = [dic objectForKey:@"created_on"]; + _user = [[ OZLModelUser alloc] initWithDictionary:[dic objectForKey:@"user"]]; + NSMutableArray* detailItems = [[NSMutableArray alloc] init]; + NSArray* dataArray = [dic objectForKey:@"details"]; + for (NSDictionary* detailDic in dataArray) { + [detailItems addObject:[[OZLModelIssueJournalDetail alloc] initWithDictionary:detailDic]]; + } + _detailArray = detailItems; + return self; + +} + +-(NSMutableDictionary*) toParametersDic +{ + return nil; +} + +@end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelIssueJournalDetail.h b/RedmineMobile/RedmineMobile/Models/OZLModelIssueJournalDetail.h new file mode 100644 index 0000000..3796584 --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelIssueJournalDetail.h @@ -0,0 +1,51 @@ +// +// OZLModelIssueJournalDetail.h +// RedmineMobile +// +// Created by lizhijie on 7/23/13. + +// This code is distributed under the terms and conditions of the MIT license. + +// Copyright (c) 2013 Zhijie Lee(onezeros.lee@gmail.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +/* + "details": [ + { + "property": "attr", + "name": "done_ratio", + "old_value": "0", + "new_value": "20" + } + ] + */ +@interface OZLModelIssueJournalDetail : NSObject + +@property(nonatomic, strong) NSString* property; +@property(nonatomic, strong) NSString* name; +@property(nonatomic, strong) NSString* oldValue; +@property(nonatomic, strong) NSString* freshValue; + +-(id)initWithDictionary:(NSDictionary*)dic; +-(NSMutableDictionary*) toParametersDic; + + +@end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelIssueJournalDetail.m b/RedmineMobile/RedmineMobile/Models/OZLModelIssueJournalDetail.m new file mode 100644 index 0000000..89b554c --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelIssueJournalDetail.m @@ -0,0 +1,50 @@ +// +// OZLModelIssueJournalDetail.m +// RedmineMobile +// +// Created by lizhijie on 7/23/13. + +// This code is distributed under the terms and conditions of the MIT license. + +// Copyright (c) 2013 Zhijie Lee(onezeros.lee@gmail.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "OZLModelIssueJournalDetail.h" + +@implementation OZLModelIssueJournalDetail + +-(id)initWithDictionary:(NSDictionary*)dic +{ + self = [super init]; + if (!self) { + return nil; + } + _name = [dic objectForKey:@"name"]; + _property = [dic objectForKey:@"property"]; + _oldValue = [dic objectForKey:@"old_value"]; + _freshValue = [dic objectForKey:@"new_value"]; + return self; +} + +-(NSMutableDictionary*) toParametersDic +{ + return nil; +} +@end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntries.h b/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntries.h index 1a7786b..486c2f0 100644 --- a/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntries.h +++ b/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntries.h @@ -31,6 +31,7 @@ #import "OZLModelProject.h" #import "OZLModelIssue.h" #import "OZLModelUser.h" +#import "OZLModelTimeEntryActivity.h" @interface OZLModelTimeEntries : NSObject @@ -39,6 +40,7 @@ @property(nonatomic, strong) OZLModelProject* project; @property(nonatomic, strong) OZLModelUser* user; @property(nonatomic, strong) OZLModelIssue* issue; +@property(nonatomic, strong) OZLModelTimeEntryActivity* activity; @property(nonatomic) float hours; @property(nonatomic, strong) NSString* comments; @property(nonatomic, strong) NSString* spentOn; @@ -46,6 +48,7 @@ @property(nonatomic, strong) NSString* updatedOn; + -(id)initWithDictionary:(NSDictionary*)dic; -(NSMutableDictionary*) toParametersDic; diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntries.m b/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntries.m index cfbdbd0..05edc7b 100644 --- a/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntries.m +++ b/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntries.m @@ -38,9 +38,22 @@ return nil; } _index = [[dic objectForKey:@"id"] intValue]; - _project = [[OZLModelProject alloc] initWithDictionary:[dic objectForKey:@"project"]]; - _user = [[OZLModelUser alloc] initWithDictionary:[dic objectForKey:@"user"] ]; - _issue = [[OZLModelIssue alloc] initWithDictionary:[dic objectForKey:@"issue"]]; + id project = [dic objectForKey:@"project"]; + if (project != nil) { + _project = [[OZLModelProject alloc] initWithDictionary:project]; + } + id user = [dic objectForKey:@"user"]; + if (user != nil) { + _user = [[OZLModelUser alloc] initWithDictionary: user]; + } + id issue = [dic objectForKey:@"issue"]; + if (issue != nil ) { + _issue = [[OZLModelIssue alloc] initWithDictionary:issue]; + } + id activity = [dic objectForKey:@"activity"]; + if (activity != nil) { + _activity = [[OZLModelTimeEntryActivity alloc] initWithDictionary:activity]; + } _hours = [[dic objectForKey:@"hours"] floatValue]; _comments = [dic objectForKey:@"comments"]; _spentOn = [dic objectForKey:@"spent_on"]; @@ -51,7 +64,24 @@ -(NSMutableDictionary*) toParametersDic { - + NSMutableDictionary* entryDic = [[NSMutableDictionary alloc] init]; + [entryDic setObject:[NSNumber numberWithFloat:_hours] forKey:@"hours"];//required + if (_issue) { + [entryDic setObject:[NSNumber numberWithInt:_issue.index] forKey:@"issue_id"]; + }else if(_project){ + [entryDic setObject:[NSNumber numberWithInt:_project.index] forKey:@"project_id"]; + } + if (_spentOn) { + [entryDic setObject:_spentOn forKey:@"spent_on"]; + } + if (_activity) { + [entryDic setObject:[NSNumber numberWithInt:_activity.index] forKey:@"activity_id"]; + } + if (_comments) { + [entryDic setObject:_comments forKey:@"comments"]; + } + + return [[NSMutableDictionary alloc] initWithObjectsAndKeys:entryDic,@"time_entry",nil]; } diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntryActivity.h b/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntryActivity.h new file mode 100644 index 0000000..0412aab --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntryActivity.h @@ -0,0 +1,39 @@ +// +// OZLModelTimeEntryActivity.h +// RedmineMobile +// +// Created by lizhijie on 7/23/13. + +// This code is distributed under the terms and conditions of the MIT license. + +// Copyright (c) 2013 Zhijie Lee(onezeros.lee@gmail.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +@interface OZLModelTimeEntryActivity : NSObject + +@property(nonatomic) int index; +@property(nonatomic,strong) NSString* name; + +-(id)initWithDictionary:(NSDictionary*)dic; +-(NSMutableDictionary*) toParametersDic; + +@end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntryActivity.m b/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntryActivity.m new file mode 100644 index 0000000..d6401c2 --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelTimeEntryActivity.m @@ -0,0 +1,48 @@ +// +// OZLModelTimeEntryActivity.m +// RedmineMobile +// +// Created by lizhijie on 7/23/13. + +// This code is distributed under the terms and conditions of the MIT license. + +// Copyright (c) 2013 Zhijie Lee(onezeros.lee@gmail.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "OZLModelTimeEntryActivity.h" + +@implementation OZLModelTimeEntryActivity +-(id)initWithDictionary:(NSDictionary*)dic +{ + self = [super init]; + if (!self) { + return nil; + } + _index = [[dic objectForKey:@"id"] intValue]; + _name = [dic objectForKey:@"name"]; + return self; +} + +-(NSMutableDictionary*) toParametersDic +{ + return nil; +} + +@end diff --git a/RedmineMobile/RedmineMobile/Utils/OZLNetwork.h b/RedmineMobile/RedmineMobile/Utils/OZLNetwork.h index 19921ed..a1e3cbf 100644 --- a/RedmineMobile/RedmineMobile/Utils/OZLNetwork.h +++ b/RedmineMobile/RedmineMobile/Utils/OZLNetwork.h @@ -33,6 +33,10 @@ #import "OZLModelIssueStatus.h" #import "OZLModelTracker.h" #import "OZLModelUser.h" +#import "OZLModelTimeEntries.h" +#import "OZLModelIssueJournal.h" +#import "OZLModelIssueJournalDetail.h" +#import "OZLModelTimeEntryActivity.h" @interface OZLNetwork : NSObject @@ -50,6 +54,7 @@ +(void)createIssue:(OZLModelIssue*)issueData withParams:(NSDictionary*)params andBlock:(void (^)(BOOL success, NSError *error))block; +(void)updateIssue:(OZLModelIssue*)issueData withParams:(NSDictionary*)params andBlock:(void (^)(BOOL success, NSError *error))block; +(void)deleteIssue:(int)issueid withParams:(NSDictionary*)params andBlock:(void (^)(BOOL success, NSError *error))block; ++(void)getJournalListForIssue:(int)issueid withParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block; // priority +(void)getPriorityListWithParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block; @@ -64,4 +69,8 @@ +(void)getTimeEntriesWithParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block; +(void)getTimeEntriesForIssueId:(int)issueid withParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block; +(void)getTimeEntriesForProjectId:(int)projectid withParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block; ++(void)getTimeEntryListWithParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block; ++(void)createTimeEntry:(OZLModelTimeEntries*)timeEntry withParams:(NSDictionary*)params andBlock:(void (^)(BOOL success, NSError *error))block; + + @end diff --git a/RedmineMobile/RedmineMobile/Utils/OZLNetwork.m b/RedmineMobile/RedmineMobile/Utils/OZLNetwork.m index dfbc0f1..42ce7ea 100644 --- a/RedmineMobile/RedmineMobile/Utils/OZLNetwork.m +++ b/RedmineMobile/RedmineMobile/Utils/OZLNetwork.m @@ -335,6 +335,37 @@ }]; } ++(void)getJournalListForIssue:(int)issueid withParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block +{ + NSString* path = [NSString stringWithFormat:@"/issues/%d.json?include=journals",issueid]; + NSMutableDictionary* paramsDic = [[NSMutableDictionary alloc] initWithDictionary:params]; + NSString* accessKey = [[OZLSingleton sharedInstance] redmineUserKey]; + if (accessKey.length > 0) { + [paramsDic setObject:accessKey forKey:@"key"]; + } + + [[OZLNetworkBase sharedClient] getPath:path parameters:paramsDic success:^(AFHTTPRequestOperation *operation, id responseObject) { + + if (block) { + NSLog(@"the repsonse:%@",responseObject); + + NSMutableArray* journals = [[NSMutableArray alloc] init]; + + NSArray* journalsDic = [[responseObject objectForKey:@"issue"] objectForKey:@"journals"]; + for (NSDictionary* p in journalsDic) { + [journals addObject:[[OZLModelIssueJournal alloc] initWithDictionary:p]]; + } + block(journals,nil); + } + + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + + if (block) { + block([NSArray array], error); + } + + }]; +} #pragma mark - #pragma mark priority api @@ -495,7 +526,7 @@ NSArray* dic = [responseObject objectForKey:@"time_entries"]; for (NSDictionary* p in dic) { - [priorities addObject:[[OZLModelTracker alloc] initWithDictionary:p]]; + [priorities addObject:[[OZLModelTimeEntries alloc] initWithDictionary:p]]; } block(priorities,nil); } @@ -511,11 +542,75 @@ +(void)getTimeEntriesForIssueId:(int)issueid withParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block { - + NSDictionary* param = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithInt:issueid],@"issue_id", nil]; + [OZLNetwork getTimeEntriesWithParams:param andBlock:block]; } +(void)getTimeEntriesForProjectId:(int)projectid withParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block { - + + NSDictionary* param = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithInt:projectid],@"project_id", nil]; + [OZLNetwork getTimeEntriesWithParams:param andBlock:block]; } + ++(void)getTimeEntryListWithParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block +{ + NSString* path = @"/enumerations/time_entry_activities.json"; + NSMutableDictionary* paramsDic = [[NSMutableDictionary alloc] initWithDictionary:params]; + NSString* accessKey = [[OZLSingleton sharedInstance] redmineUserKey]; + if (accessKey.length > 0) { + [paramsDic setObject:accessKey forKey:@"key"]; + } + + [[OZLNetworkBase sharedClient] setAuthorizationHeader]; + [[OZLNetworkBase sharedClient] getPath:path parameters:paramsDic success:^(AFHTTPRequestOperation *operation, id responseObject) { + + if (block) { + NSLog(@"the repsonse:%@",responseObject); + NSMutableArray* activities = [[NSMutableArray alloc] init]; + + NSArray* dic = [responseObject objectForKey:@"time_entry_activities"]; + for (NSDictionary* p in dic) { + [activities addObject:[[OZLModelTimeEntryActivity alloc] initWithDictionary:p]]; + } + block(activities,nil); + } + + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + + if (block) { + block([NSArray array], error); + } + }]; +} ++(void)createTimeEntry:(OZLModelTimeEntries*)timeEntry withParams:(NSDictionary*)params andBlock:(void (^)(BOOL success, NSError *error))block +{ + NSString* path = [NSString stringWithFormat:@"/time_entries.json"]; + + //project info + NSMutableDictionary* paramsDic = [[NSMutableDictionary alloc] initWithDictionary:params]; + [paramsDic addEntriesFromDictionary:[timeEntry toParametersDic]]; + + NSString* accessKey = [[OZLSingleton sharedInstance] redmineUserKey]; + if (accessKey.length > 0) { + [paramsDic setObject:accessKey forKey:@"key"]; + } + + [[OZLNetworkBase sharedClient] postPath:path parameters:paramsDic success:^(AFHTTPRequestOperation *operation, id responseObject) { + + if (block) { + NSLog(@"the repsonse:%@",responseObject); + block(YES,nil); + } + + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + + if (block) { + block(NO, error); + } + + }]; +} + + @end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m index 2f75d9d..f9f3b95 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m @@ -90,7 +90,7 @@ UIToolbar* inputAccessoryView = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 40)]; UIBarButtonItem* accessoryDoneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(accessoryDoneClicked:)]; UIBarButtonItem* flexleft = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; - inputAccessoryView.items = [NSArray arrayWithObjects:flexleft, accessoryDoneButton, nil];; + inputAccessoryView.items = [NSArray arrayWithObjects:flexleft, accessoryDoneButton, nil]; _startDateLabel.inputView = datePicker; _startDateLabel.inputAccessoryView = inputAccessoryView; @@ -288,16 +288,16 @@ }else if( indexPath.section == 2){ switch (indexPath.row) { case 0:{//start date - + [_startDateLabel becomeFirstResponder]; }break; case 1:{//due date - + [_dueDateLabel becomeFirstResponder]; }break; case 2:{//estimated hours - + [_estimatedHoursLabel becomeFirstResponder]; }break; case 3:{//done - + [_doneProgressLabel becomeFirstResponder]; }break; default: diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.h b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.h index a19d017..46430cb 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.h +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.h @@ -28,9 +28,13 @@ #import #import "OZLModelIssue.h" +#import "OZLModelTimeEntryActivity.h" @interface OZLIssueDetailViewController : UITableViewController -@property(nonatomic,strong) OZLModelIssue* issueData; + +@property(nonatomic, strong) OZLModelIssue* issueData; +@property(nonatomic, strong) NSArray* timeEntryActivityList; + @property (weak, nonatomic) IBOutlet UILabel *subject; @property (weak, nonatomic) IBOutlet UILabel *description; @property (weak, nonatomic) IBOutlet UIProgressView *progressbar; diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m index 7b77994..a91eaeb 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m @@ -27,6 +27,8 @@ // THE SOFTWARE. #import "OZLIssueDetailViewController.h" +#import "OZLIssueHistoryViewController.h" +#import "OZLIssueLogtimeViewController.h" @interface OZLIssueDetailViewController () @@ -81,16 +83,22 @@ { if (indexPath.section == 1) { switch (indexPath.row) { - case 0:{ - + case 0:{//history + OZLIssueHistoryViewController* history = [[OZLIssueHistoryViewController alloc] init]; + [history setIssueData:_issueData]; + [self.navigationController pushViewController:history animated:YES]; }break; - case 1:{ - + case 1:{// add sub task + }break; - case 2:{ - + case 2:{//logtime + UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueLogtimeViewController" bundle:nil]; + OZLIssueLogtimeViewController* creator = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueLogtimeViewController"]; + [creator setTimeEntryActivityList:_timeEntryActivityList]; + [creator setIssueData:_issueData]; + [self.navigationController pushViewController:creator animated:YES]; }break; - + default: break; } diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.m index 8890ab8..22aab0a 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.m @@ -28,8 +28,15 @@ #import "OZLIssueHistoryViewController.h" +#import "MBProgressHUD.h" +#import "OZLNetwork.h" +#import "OZLModelIssueJournal.h" +#import "OZLModelIssueJournalDetail.h" -@interface OZLIssueHistoryViewController () +@interface OZLIssueHistoryViewController () { + MBProgressHUD* _HUD; + NSMutableArray* _journalList; +} @end @@ -54,9 +61,27 @@ // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem; + _HUD = [[MBProgressHUD alloc] initWithView:self.view]; + [self.view addSubview:_HUD]; + _HUD.labelText = @"Refreshing..."; + [self.navigationItem setTitle:_issueData.subject]; } + +-(void) viewWillAppear:(BOOL)animated +{ + [_HUD show:YES]; + // refresh journal list + [OZLNetwork getJournalListForIssue:_issueData.index withParams:nil andBlock:^(NSArray *result, NSError *error) { + NSLog(@"respond:%@",result.description); + _journalList = [[NSMutableArray alloc] initWithArray: result]; + [self.tableView reloadData]; + [_HUD hide:YES]; + }]; + +} + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; @@ -67,78 +92,25 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { -#warning Potentially incomplete method implementation. - // Return the number of sections. - return 0; + return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { -#warning Incomplete method implementation. - // Return the number of rows in the section. - return 0; + return _journalList.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - static NSString *CellIdentifier = @"Cell"; + static NSString *CellIdentifier = @"timeEntryCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; - - // Configure the cell... - + if (!cell) { + cell = [[UITableViewCell alloc] + initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; + } + OZLModelIssueJournal* journal = [_journalList objectAtIndex:indexPath.row]; + cell.textLabel.text = journal.user.name; 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 rearranging the table view. -- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath -{ -} -*/ - -/* -// 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; -} -*/ - -#pragma mark - Table view delegate - -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath -{ - // Navigation logic may go here. Create and push another view controller. - /* - <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; - // ... - // Pass the selected object to the new view controller. - [self.navigationController pushViewController:detailViewController animated:YES]; - */ -} - @end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.h b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.h new file mode 100644 index 0000000..c5fdb97 --- /dev/null +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.h @@ -0,0 +1,23 @@ +// +// OZLIssueLogtimeViewController.h +// RedmineMobile +// +// Created by lizhijie on 7/23/13. +// Copyright (c) 2013 Lee Zhijie. All rights reserved. +// + +#import +#import "OZLModelIssue.h" +#import "OZLModelTimeEntryActivity.h" + +@interface OZLIssueLogtimeViewController : UITableViewController + +@property (nonatomic, strong) OZLModelIssue* issueData; +@property (nonatomic, strong) NSArray* timeEntryActivityList; + +@property (weak, nonatomic) IBOutlet UITextField *hours; +@property (weak, nonatomic) IBOutlet UITextField *activity; +@property (weak, nonatomic) IBOutlet UITextField *dateLabel; +@property (weak, nonatomic) IBOutlet UITextView *comment; + +@end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.m new file mode 100644 index 0000000..375accb --- /dev/null +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.m @@ -0,0 +1,194 @@ +// +// OZLIssueLogtimeViewController.m +// RedmineMobile +// +// Created by lizhijie on 7/23/13. +// Copyright (c) 2013 Lee Zhijie. All rights reserved. +// + +#import "OZLIssueLogtimeViewController.h" +#import "MBProgressHUD.h" +#import "MLTableAlert.h" +#import "OZLNetwork.h" + +@interface OZLIssueLogtimeViewController () { + MBProgressHUD* _HUD; + float _hourValue; + OZLModelTimeEntries* _entry; +} +@end + +@implementation OZLIssueLogtimeViewController + +- (id)initWithStyle:(UITableViewStyle)style +{ + self = [super initWithStyle:style]; + if (self) { + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + // initialize data + _hourValue = 0; + _entry = [[OZLModelTimeEntries alloc] init]; + + UIBarButtonItem* cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(onCancel:)]; + [self.navigationItem setLeftBarButtonItem:cancelBtn]; + UIBarButtonItem* saveBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(onSave:)]; + [self.navigationItem setRightBarButtonItem:saveBtn]; + + [self.navigationItem setTitle:@"Log Time"]; + + [self setupInputViews]; + + // hud + _HUD = [[MBProgressHUD alloc] initWithView:self.view]; + [self.view addSubview:_HUD]; + _HUD.labelText = @"Loading..."; +} + +-(void)setupInputViews +{ + [_activity setUserInteractionEnabled:NO]; + + // setup time picker inputview + UIDatePicker* timerPicker = [[UIDatePicker alloc]init]; + [timerPicker setDatePickerMode:UIDatePickerModeCountDownTimer]; + [timerPicker addTarget:self action:@selector(datePickerValueChanged:) forControlEvents:UIControlEventValueChanged]; + timerPicker.minuteInterval = 5; + // setup datapicker inputview + UIDatePicker* datePicker = [[UIDatePicker alloc]init]; + [datePicker setDatePickerMode:UIDatePickerModeDate]; + [datePicker addTarget:self action:@selector(datePickerValueChanged:) forControlEvents:UIControlEventValueChanged]; + // accessoryview + UIToolbar* inputAccessoryView = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 40)]; + UIBarButtonItem* accessoryDoneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(accessoryDoneClicked:)]; + UIBarButtonItem* flexleft = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; + inputAccessoryView.items = [NSArray arrayWithObjects:flexleft, accessoryDoneButton, nil]; + + _hours.inputView = timerPicker; + _hours.inputAccessoryView = inputAccessoryView; + _dateLabel.inputView = datePicker; + _dateLabel.inputAccessoryView = inputAccessoryView; +} +-(void) onCancel:(id)sender +{ + [self.navigationController popViewControllerAnimated:YES]; +} + +-(void) onSave:(id)sender +{ + _HUD.mode = MBProgressHUDModeIndeterminate; + _HUD.labelText = @"Logging time ..."; + [_HUD show:YES]; + + // build entry + _entry.issue = _issueData; + _entry.hours = _hourValue; + if (_comment.text.length > 0) { + _entry.comments = _comment.text; + } + if (_dateLabel.text.length > 0) { + _entry.createdOn = _dateLabel.text; + } + + [OZLNetwork createTimeEntry:_entry withParams:nil andBlock:^(BOOL success, NSError *error){ + if (error) { + NSLog(@"log time error: %@",error.description); + }else { + + [self.navigationController popViewControllerAnimated:YES]; + + } + [_HUD hide:YES]; + }]; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Table view delegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + if (indexPath.section == 0 && indexPath.row == 1) {//activity + MLTableAlert* tableAlert = [MLTableAlert tableAlertWithTitle:@"Activty" cancelButtonTitle:@"Cancel" numberOfRows:^NSInteger (NSInteger section) + { + return [_timeEntryActivityList count] + 1; + } + andCells:^UITableViewCell* (MLTableAlert *anAlert, NSIndexPath *alertIndexPath) + { + static NSString *CellIdentifier = @"CellIdentifier"; + UITableViewCell *cell = [anAlert.table dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; + + if (alertIndexPath.row == 0) { + cell.textLabel.text = @"None"; + }else { + cell.textLabel.text = [[_timeEntryActivityList objectAtIndex:alertIndexPath.row - 1] name]; + } + return cell; + }]; + + // Setting custom alert height + tableAlert.height = 350; + + // configure actions to perform + [tableAlert configureSelectionBlock:^(NSIndexPath *selectedIndex){ + if (selectedIndex.row == 0) { + _activity.text = @"None"; + _entry.activity = nil; + }else { + _activity.text = [[ _timeEntryActivityList objectAtIndex:selectedIndex.row - 1] name]; + _entry.activity = [_timeEntryActivityList objectAtIndex:selectedIndex.row -1]; + } + [_activity sizeToFit]; + } andCompletionBlock:^{ + + }]; + + [tableAlert show]; + } +} + +- (void)viewDidUnload { + [self setHours:nil]; + [self setActivity:nil]; + [self setDateLabel:nil]; + [self setComment:nil]; + [super viewDidUnload]; +} + +#pragma mark data picker value changed +-(void)datePickerValueChanged:(id)sender +{ + UIDatePicker* datepicker = (UIDatePicker*)sender; + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + + if (_hours.isFirstResponder) { + + NSString* timeStr = [NSString stringWithFormat:@"%d Mins",(int)datepicker.countDownDuration/60]; + _hours.text = timeStr; + _hourValue = (int)(datepicker.countDownDuration/3600.f); + }else { + [dateFormatter setDateFormat:@"yyyy-MM-dd"]; + + NSString* dateStr = [dateFormatter stringFromDate:datepicker.date]; + _dateLabel.text = dateStr; + } +} + +-(void)accessoryDoneClicked:(id)sender +{ + [self.view endEditing:YES]; +} + +@end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.storyboard b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.storyboard new file mode 100644 index 0000000..14cef0d --- /dev/null +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.storyboard @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.h b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.h index 2fad8c6..24359da 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.h +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.h @@ -36,9 +36,10 @@ - (IBAction)onSortSetting:(id)sender; -@property (weak, nonatomic) NSArray* trackerList; -@property (weak, nonatomic) NSArray* priorityList; -@property (weak, nonatomic) NSArray* statusList; -@property (weak, nonatomic) NSArray* userList; +@property (strong, nonatomic) NSArray* trackerList; +@property (strong, nonatomic) NSArray* priorityList; +@property (strong, nonatomic) NSArray* statusList; +@property (strong, nonatomic) NSArray* userList; +@property (strong, nonatomic) NSArray* timeEntryActivityList; @end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m index 3f576a1..75ef8e5 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m @@ -149,6 +149,7 @@ _issueListOption = [[NSMutableDictionary alloc] init]; static int doneCount = 0; + const int totalCount = 5; [OZLNetwork getTrackerListWithParams:nil andBlock:^(NSArray *result, NSError *error) { if (!error) { _trackerList = result; @@ -156,7 +157,7 @@ NSLog(@"get tracker list error : %@",error.description); } doneCount ++; - if (doneCount == 4) { + if (doneCount == totalCount) { [self loadProjectDetail]; doneCount = 0; } @@ -169,7 +170,7 @@ NSLog(@"get issue status list error : %@",error.description); } doneCount ++; - if (doneCount == 4) { + if (doneCount == totalCount) { [self loadProjectDetail]; doneCount = 0; } @@ -181,7 +182,7 @@ NSLog(@"get priority list error : %@",error.description); } doneCount ++; - if (doneCount == 4) { + if (doneCount == totalCount) { [self loadProjectDetail]; doneCount = 0; } @@ -193,7 +194,20 @@ NSLog(@"get user list error : %@",error.description); } doneCount ++; - if (doneCount == 4) { + if (doneCount == totalCount) { + [self loadProjectDetail]; + doneCount = 0; + } + }]; + + [OZLNetwork getTimeEntryListWithParams:nil andBlock:^(NSArray *result, NSError *error) { + if (!error) { + _timeEntryActivityList = result; + }else { + NSLog(@"get user list error : %@",error.description); + } + doneCount ++; + if (doneCount == totalCount) { [self loadProjectDetail]; doneCount = 0; } @@ -340,6 +354,7 @@ UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueDetailViewController" bundle:nil]; OZLIssueDetailViewController* detail = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueDetailViewController"]; [detail setIssueData:[_issuesList objectAtIndex:indexPath.row]]; + [detail setTimeEntryActivityList:_timeEntryActivityList]; [self.navigationController pushViewController:detail animated:YES]; } From d086ff1b2ceb84193a9a89e5b0dd847db52cc46d Mon Sep 17 00:00:00 2001 From: zhijie Date: Tue, 23 Jul 2013 16:24:03 +0800 Subject: [PATCH 3/9] issue history logic done, with rough ui --- RedmineMobile/RedmineMobile/Models/OZLModelIssueJournal.m | 3 ++- RedmineMobile/RedmineMobile/Models/OZLModelUser.m | 6 +++++- .../ViewControllers/OZLIssueHistoryViewController.m | 7 ++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelIssueJournal.m b/RedmineMobile/RedmineMobile/Models/OZLModelIssueJournal.m index e6e4121..d046f8e 100644 --- a/RedmineMobile/RedmineMobile/Models/OZLModelIssueJournal.m +++ b/RedmineMobile/RedmineMobile/Models/OZLModelIssueJournal.m @@ -44,7 +44,8 @@ NSMutableArray* detailItems = [[NSMutableArray alloc] init]; NSArray* dataArray = [dic objectForKey:@"details"]; for (NSDictionary* detailDic in dataArray) { - [detailItems addObject:[[OZLModelIssueJournalDetail alloc] initWithDictionary:detailDic]]; + OZLModelIssueJournalDetail* detail = [[OZLModelIssueJournalDetail alloc] initWithDictionary:detailDic]; + [detailItems addObject:detail]; } _detailArray = detailItems; return self; diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelUser.m b/RedmineMobile/RedmineMobile/Models/OZLModelUser.m index c910ed6..306885d 100644 --- a/RedmineMobile/RedmineMobile/Models/OZLModelUser.m +++ b/RedmineMobile/RedmineMobile/Models/OZLModelUser.m @@ -45,7 +45,11 @@ _createdOn = [dic objectForKey:@"created_on"]; _lastLoginIn = [dic objectForKey:@"last_login_on"]; - _name = _login; + _name = [dic objectForKey:@"name"]; + if (_name == nil) { + _name = _login; + } + return self; } diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.m index 22aab0a..98ef1cd 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueHistoryViewController.m @@ -103,13 +103,14 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"timeEntryCell"; - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier ]; if (!cell) { cell = [[UITableViewCell alloc] - initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; + initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; } OZLModelIssueJournal* journal = [_journalList objectAtIndex:indexPath.row]; - cell.textLabel.text = journal.user.name; + [cell.textLabel setText: journal.user.name]; + [cell.detailTextLabel setText:[NSString stringWithFormat:@"number of change: %d",journal.detailArray.count]]; return cell; } From d8c01cef288e53c3cc7414f354750d686ca06d1c Mon Sep 17 00:00:00 2001 From: zhijie Date: Wed, 24 Jul 2013 11:23:41 +0800 Subject: [PATCH 4/9] refactor common used data to sington --- .../RedmineMobile/Models/OZLConstants.h | 2 +- .../RedmineMobile/Models/OZLConstants.m | 2 +- .../RedmineMobile/Utils/OZLSingleton.h | 6 + .../OZLIssueCreateViewController.m | 7 + .../OZLIssueDetailViewController.m | 4 +- .../OZLIssueFilterViewController.m | 1 - .../OZLIssueLogtimeViewController.m | 2 + .../OZLProjectViewController.m | 183 ++++++++---------- 8 files changed, 97 insertions(+), 110 deletions(-) diff --git a/RedmineMobile/RedmineMobile/Models/OZLConstants.h b/RedmineMobile/RedmineMobile/Models/OZLConstants.h index 4417e24..555b29c 100644 --- a/RedmineMobile/RedmineMobile/Models/OZLConstants.h +++ b/RedmineMobile/RedmineMobile/Models/OZLConstants.h @@ -27,7 +27,7 @@ // THE SOFTWARE. #import -extern const NSString* NOTIFICATION_REDMINE_ACCOUNT_CHANGED; +extern NSString* NOTIFICATION_REDMINE_ACCOUNT_CHANGED; @interface OZLConstants : NSObject diff --git a/RedmineMobile/RedmineMobile/Models/OZLConstants.m b/RedmineMobile/RedmineMobile/Models/OZLConstants.m index 99e80b1..0f402ab 100644 --- a/RedmineMobile/RedmineMobile/Models/OZLConstants.m +++ b/RedmineMobile/RedmineMobile/Models/OZLConstants.m @@ -27,7 +27,7 @@ // THE SOFTWARE. #import "OZLConstants.h" -const NSString* NOTIFICATION_REDMINE_ACCOUNT_CHANGED = @"NOTIFICATION_REDMINE_ACCOUNT_CHANGED"; +NSString* NOTIFICATION_REDMINE_ACCOUNT_CHANGED = @"NOTIFICATION_REDMINE_ACCOUNT_CHANGED"; @implementation OZLConstants diff --git a/RedmineMobile/RedmineMobile/Utils/OZLSingleton.h b/RedmineMobile/RedmineMobile/Utils/OZLSingleton.h index b895d91..9307f86 100644 --- a/RedmineMobile/RedmineMobile/Utils/OZLSingleton.h +++ b/RedmineMobile/RedmineMobile/Utils/OZLSingleton.h @@ -46,6 +46,12 @@ //app status @property(nonatomic) int lastProjectID;// last viewed project id +// app data +@property (strong, nonatomic) NSArray* trackerList; +@property (strong, nonatomic) NSArray* priorityList; +@property (strong, nonatomic) NSArray* statusList; +@property (strong, nonatomic) NSArray* userList; +@property (strong, nonatomic) NSArray* timeEntryActivityList; @end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m index f9f3b95..6088eb3 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m @@ -34,6 +34,7 @@ #import "OZLModelUser.h" #import "OZLModelIssueStatus.h" #import "MLTableAlert.h" +#import "OZLSingleton.h" @interface OZLIssueCreateViewController () { @@ -66,6 +67,12 @@ { [super viewDidLoad]; + OZLSingleton* singleton = [OZLSingleton sharedInstance]; + _trackerList = singleton.trackerList; + _statusList = singleton.statusList; + _userList = singleton.userList; + _priorityList = singleton.priorityList; + UIBarButtonItem* cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(onCancel:)]; [self.navigationItem setLeftBarButtonItem:cancelBtn]; UIBarButtonItem* saveBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(onSave:)]; diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m index a91eaeb..c29be83 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m @@ -29,6 +29,7 @@ #import "OZLIssueDetailViewController.h" #import "OZLIssueHistoryViewController.h" #import "OZLIssueLogtimeViewController.h" +#import "OZLSingleton.h" @interface OZLIssueDetailViewController () @@ -58,6 +59,8 @@ { [super viewDidLoad]; + _timeEntryActivityList = [[OZLSingleton sharedInstance] timeEntryActivityList]; + _subject.text = _issueData.subject; _description.text = _issueData.description; _progressbar.progress = _issueData.doneRatio/100; @@ -94,7 +97,6 @@ case 2:{//logtime UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueLogtimeViewController" bundle:nil]; OZLIssueLogtimeViewController* creator = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueLogtimeViewController"]; - [creator setTimeEntryActivityList:_timeEntryActivityList]; [creator setIssueData:_issueData]; [self.navigationController pushViewController:creator animated:YES]; }break; diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueFilterViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueFilterViewController.m index 4a6124c..7f94766 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueFilterViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueFilterViewController.m @@ -78,7 +78,6 @@ { OZLSingleton* singleton =[OZLSingleton sharedInstance]; - [singleton setIssueListFilterType:_checkedCell[0]]; [singleton setIssueListSortType:_checkedCell[1]]; [singleton setIssueListSortAscending:_checkedCell[2]]; diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.m index 375accb..1e6f82d 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.m @@ -10,6 +10,7 @@ #import "MBProgressHUD.h" #import "MLTableAlert.h" #import "OZLNetwork.h" +#import "OZLSingleton.h" @interface OZLIssueLogtimeViewController () { MBProgressHUD* _HUD; @@ -35,6 +36,7 @@ // initialize data _hourValue = 0; _entry = [[OZLModelTimeEntries alloc] init]; + _timeEntryActivityList = [[OZLSingleton sharedInstance] timeEntryActivityList]; UIBarButtonItem* cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(onCancel:)]; [self.navigationItem setLeftBarButtonItem:cancelBtn]; diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m index 75ef8e5..99ad4fd 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m @@ -148,70 +148,85 @@ { _issueListOption = [[NSMutableDictionary alloc] init]; - static int doneCount = 0; - const int totalCount = 5; - [OZLNetwork getTrackerListWithParams:nil andBlock:^(NSArray *result, NSError *error) { - if (!error) { - _trackerList = result; - }else { - NSLog(@"get tracker list error : %@",error.description); - } - doneCount ++; - if (doneCount == totalCount) { - [self loadProjectDetail]; - doneCount = 0; - } - }]; + OZLSingleton* singleton = [OZLSingleton sharedInstance]; + if (singleton.userList != nil) { + _trackerList = singleton.trackerList; + _statusList = singleton.statusList; + _userList = singleton.userList; + _priorityList = singleton.priorityList; + _timeEntryActivityList = singleton.timeEntryActivityList; + [self loadProjectDetail]; + }else { + static int doneCount = 0; + const int totalCount = 5; + [OZLNetwork getTrackerListWithParams:nil andBlock:^(NSArray *result, NSError *error) { + if (!error) { + _trackerList = result; + singleton.trackerList = _trackerList; + }else { + NSLog(@"get tracker list error : %@",error.description); + } + doneCount ++; + if (doneCount == totalCount) { + [self loadProjectDetail]; + doneCount = 0; + } + }]; - [OZLNetwork getIssueStatusListWithParams:nil andBlock:^(NSArray *result, NSError *error) { - if (!error) { - _statusList = result; - }else { - NSLog(@"get issue status list error : %@",error.description); - } - doneCount ++; - if (doneCount == totalCount) { - [self loadProjectDetail]; - doneCount = 0; - } - }]; - [OZLNetwork getPriorityListWithParams:nil andBlock:^(NSArray *result, NSError *error) { - if (!error) { - _priorityList = result; - }else { - NSLog(@"get priority list error : %@",error.description); - } - doneCount ++; - if (doneCount == totalCount) { - [self loadProjectDetail]; - doneCount = 0; - } - }]; - [OZLNetwork getUserListWithParams:nil andBlock:^(NSArray *result, NSError *error) { - if (!error) { - _userList = result; - }else { - NSLog(@"get user list error : %@",error.description); - } - doneCount ++; - if (doneCount == totalCount) { - [self loadProjectDetail]; - doneCount = 0; - } - }]; + [OZLNetwork getIssueStatusListWithParams:nil andBlock:^(NSArray *result, NSError *error) { + if (!error) { + _statusList = result; + singleton.statusList = _statusList; + }else { + NSLog(@"get issue status list error : %@",error.description); + } + doneCount ++; + if (doneCount == totalCount) { + [self loadProjectDetail]; + doneCount = 0; + } + }]; + [OZLNetwork getPriorityListWithParams:nil andBlock:^(NSArray *result, NSError *error) { + if (!error) { + _priorityList = result; + singleton.priorityList = _priorityList; + }else { + NSLog(@"get priority list error : %@",error.description); + } + doneCount ++; + if (doneCount == totalCount) { + [self loadProjectDetail]; + doneCount = 0; + } + }]; + [OZLNetwork getUserListWithParams:nil andBlock:^(NSArray *result, NSError *error) { + if (!error) { + _userList = result; + singleton.userList = _userList; + }else { + NSLog(@"get user list error : %@",error.description); + } + doneCount ++; + if (doneCount == totalCount) { + [self loadProjectDetail]; + doneCount = 0; + } + }]; - [OZLNetwork getTimeEntryListWithParams:nil andBlock:^(NSArray *result, NSError *error) { - if (!error) { - _timeEntryActivityList = result; - }else { - NSLog(@"get user list error : %@",error.description); - } - doneCount ++; - if (doneCount == totalCount) { - [self loadProjectDetail]; - doneCount = 0; - } - }]; + [OZLNetwork getTimeEntryListWithParams:nil andBlock:^(NSArray *result, NSError *error) { + if (!error) { + _timeEntryActivityList = result; + singleton.timeEntryActivityList = _timeEntryActivityList; + }else { + NSLog(@"get user list error : %@",error.description); + } + doneCount ++; + if (doneCount == totalCount) { + [self loadProjectDetail]; + doneCount = 0; + } + }]; + } } @@ -307,45 +322,6 @@ 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 rearranging the table view. - - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath - { - } - */ - -/* - // 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; - } - */ - #pragma mark - Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath @@ -354,7 +330,6 @@ UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueDetailViewController" bundle:nil]; OZLIssueDetailViewController* detail = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueDetailViewController"]; [detail setIssueData:[_issuesList objectAtIndex:indexPath.row]]; - [detail setTimeEntryActivityList:_timeEntryActivityList]; [self.navigationController pushViewController:detail animated:YES]; } @@ -363,10 +338,6 @@ UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueCreateViewController" bundle:nil]; OZLIssueCreateViewController* creator = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueCreateViewController"]; [creator setParentProject:_projectData]; - creator.userList = _userList; - creator.trackerList = _trackerList; - creator.priorityList = _priorityList; - creator.statusList = _statusList; //[self.navigationController presentModalViewController:creator animated:YES]; [self.navigationController pushViewController:creator animated:YES]; } From d58b8f73ed65bee8aa2370f795328f9827992437 Mon Sep 17 00:00:00 2001 From: zhijie Date: Wed, 24 Jul 2013 11:33:55 +0800 Subject: [PATCH 5/9] add sub issue done --- .../OZLIssueCreateViewController.m | 19 +++++++++++++++++-- .../OZLIssueDetailViewController.m | 7 ++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m index 6088eb3..dafed77 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m @@ -172,10 +172,11 @@ issueData.status = _currentStatus; issueData.priority = _currentPriority; issueData.assignedTo = _currentUser; - issueData.projectId = _parentProject.index; - if (_parentIssue) { issueData.parentIssueId = _parentIssue.index; + issueData.projectId = _parentIssue.projectId; + }else { + issueData.projectId = _parentProject.index; } issueData.description = _descriptionTextview.text; issueData.startDate = _startDateLabel.text; @@ -315,6 +316,20 @@ [self.tableView reloadData]; } +-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section +{ + if (section == 0) { + NSString* tip ; + if (_parentIssue) { + tip = [NSString stringWithFormat:@"Add sub issue to #%d",_parentIssue.index]; + }else { + tip = [NSString stringWithFormat:@"Add issue to project:%@",_parentProject.name]; + } + return tip; + } + return @""; +} + #pragma mark - #pragma mark delegate of textfield inputview diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m index c29be83..3f57049 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m @@ -30,6 +30,7 @@ #import "OZLIssueHistoryViewController.h" #import "OZLIssueLogtimeViewController.h" #import "OZLSingleton.h" +#import "OZLIssueCreateViewController.h" @interface OZLIssueDetailViewController () @@ -92,7 +93,11 @@ [self.navigationController pushViewController:history animated:YES]; }break; case 1:{// add sub task - + UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueCreateViewController" bundle:nil]; + OZLIssueCreateViewController* creator = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueCreateViewController"]; + [creator setParentIssue:_issueData]; + //[self.navigationController presentModalViewController:creator animated:YES]; + [self.navigationController pushViewController:creator animated:YES]; }break; case 2:{//logtime UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueLogtimeViewController" bundle:nil]; From 0c5986735bfcd339deb6a8a69229653fa7f6692c Mon Sep 17 00:00:00 2001 From: zhijie Date: Wed, 24 Jul 2013 14:16:00 +0800 Subject: [PATCH 6/9] update issue functionality done --- .../OZLIssueCreateViewController.h | 6 +- .../OZLIssueCreateViewController.m | 150 +++++++++++++----- .../OZLIssueDetailViewController.m | 9 +- .../OZLIssueDetailViewController.storyboard | 36 +++-- 4 files changed, 138 insertions(+), 63 deletions(-) diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.h b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.h index fb24b2f..a16a228 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.h +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.h @@ -55,5 +55,9 @@ @property(nonatomic,strong) OZLModelProject* parentProject; @property(nonatomic,strong) OZLModelIssue* parentIssue; -@property(nonatomic,strong) NSArray* issueList; +@property(nonatomic, strong) OZLModelIssue* issueData;// used for update issue +@property(nonatomic) int isUpdatingIssue; + +//@property(nonatomic,strong) NSArray* issueList; + @end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m index dafed77..a7183ed 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m @@ -38,11 +38,6 @@ @interface OZLIssueCreateViewController () { - OZLModelTracker* _currentTracker; - OZLModelIssuePriority* _currentPriority; - OZLModelIssueStatus* _currentStatus; - OZLModelUser* _currentUser; - NSDate* _currentStartDate; NSDate* _currentDueDate; int _currentEstimatedTime;//minutes @@ -79,6 +74,7 @@ [self.navigationItem setRightBarButtonItem:saveBtn]; [self setupInputviews]; + [self initializeViewValues]; // hud _HUD = [[MBProgressHUD alloc] initWithView:self.view]; @@ -125,6 +121,38 @@ _doneProgressLabel.delegate = self; } +-(void)initializeViewValues +{ + if (_isUpdatingIssue) { // initial values for ui elements + _subjectTextField.text = _issueData.subject; + if (_issueData.tracker) { + _trackerLabel.text = _issueData.tracker.name; + } + if (_issueData.status) { + _statusLabel.text = _issueData.status.name; + } + if (_issueData.priority) { + _priorityLabel.text = _issueData.priority.name; + } + if (_issueData.assignedTo) { + _assigneeLabel.text = _issueData.assignedTo.name; + } + if (_issueData.startDate) { + _startDateLabel.text = _issueData.startDate; + } + if (_issueData.dueDate) { + _dueDateLabel.text = _issueData.dueDate; + } + _estimatedHoursLabel.text = [NSString stringWithFormat:@"%f",_issueData.estimatedHours]; + _doneProgressLabel.text = [NSString stringWithFormat:@"%d %%",(int)_issueData.doneRatio]; + + + }else { + _issueData = [[OZLModelIssue alloc] init]; + } + +} + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; @@ -144,21 +172,21 @@ [_HUD hide:YES afterDelay:1]; return; } - if (_currentUser == nil) { + if (_issueData.tracker == nil) { _HUD.mode = MBProgressHUDModeText; _HUD.labelText = @"tracker can not be empty."; [_HUD show:YES]; [_HUD hide:YES afterDelay:1]; return; } - if (_currentStatus == nil) { + if (_issueData.status == nil) { _HUD.mode = MBProgressHUDModeText; _HUD.labelText = @"status can not be empty."; [_HUD show:YES]; [_HUD hide:YES afterDelay:1]; return; } - if (_currentPriority == nil) { + if (_issueData.priority == nil) { _HUD.mode = MBProgressHUDModeText; _HUD.labelText = @"priority can not be empty."; [_HUD show:YES]; @@ -166,38 +194,63 @@ return; } - OZLModelIssue* issueData = [[OZLModelIssue alloc] init]; - issueData.subject = _subjectTextField.text; - issueData.tracker = _currentTracker; - issueData.status = _currentStatus; - issueData.priority = _currentPriority; - issueData.assignedTo = _currentUser; + _issueData.subject = _subjectTextField.text; if (_parentIssue) { - issueData.parentIssueId = _parentIssue.index; - issueData.projectId = _parentIssue.projectId; - }else { - issueData.projectId = _parentProject.index; + _issueData.parentIssueId = _parentIssue.index; + _issueData.projectId = _parentIssue.projectId; + }else if(_parentProject){ + _issueData.projectId = _parentProject.index; } - issueData.description = _descriptionTextview.text; - issueData.startDate = _startDateLabel.text; - issueData.dueDate = _dueDateLabel.text; - issueData.doneRatio = [_doneProgressLabel.text integerValue]; - issueData.estimatedHours = _currentEstimatedTime/60.0f; + if (_isUpdatingIssue) { + _issueData.notes = _descriptionTextview.text; + }else { + _issueData.description = _descriptionTextview.text; + } + _issueData.startDate = _startDateLabel.text; + _issueData.dueDate = _dueDateLabel.text; + _issueData.doneRatio = [_doneProgressLabel.text integerValue]; + _issueData.estimatedHours = _currentEstimatedTime/60.0f; //TODO: is_public is not processed yet _HUD.mode = MBProgressHUDModeIndeterminate; - _HUD.labelText = @"Creating Project..."; - [_HUD show:YES]; - [OZLNetwork createIssue:issueData withParams:nil andBlock:^(BOOL success, NSError *error){ - if (error) { - NSLog(@"create project error: %@",error.description); - }else { + if (_isUpdatingIssue) { + _HUD.labelText = @"Updating Issue ..."; + [_HUD show:YES]; + [OZLNetwork updateIssue:_issueData withParams:nil andBlock:^(BOOL success, NSError *error){ + [_HUD hide:YES]; + + if (error) { + NSLog(@"update issue error: %@",error.description); - } - [_HUD hide:YES]; - }]; + _HUD.mode = MBProgressHUDModeText; + _HUD.labelText = @"Sorry, something wrong while updating issue."; + [_HUD show:YES]; + [_HUD hide:YES afterDelay:1]; + }else { + [self.navigationController popViewControllerAnimated:YES]; + } + }]; + }else { + _HUD.labelText = @"Creating New Issue ..."; + [_HUD show:YES]; + [OZLNetwork createIssue:_issueData withParams:nil andBlock:^(BOOL success, NSError *error){ + [_HUD hide:YES]; + + if (error) { + NSLog(@"create issue error: %@",error.description); + + _HUD.mode = MBProgressHUDModeText; + _HUD.labelText = @"Sorry, something wrong while creating issue."; + [_HUD show:YES]; + [_HUD hide:YES afterDelay:1]; + + }else { + [self.navigationController popViewControllerAnimated:YES]; + } + }]; + } } - (void)viewDidUnload { @@ -248,16 +301,16 @@ if (selectedIndex.row == 0) { switch (indexPath.row) { case 0:{//tracker - _currentTracker = nil; + _issueData.tracker = nil; }break; case 1:{//status - _currentStatus = nil; + _issueData.status = nil; }break; case 2:{//priority - _currentPriority = nil; + _issueData.priority = nil; }break; case 3:{//assignee - _currentUser = nil; + _issueData.assignedTo = nil; }break; default: break; @@ -268,16 +321,16 @@ id data = [[dataArray objectAtIndex:indexPath.row ] objectAtIndex:selectedIndex.row - 1]; switch (indexPath.row) { case 0:{//tracker - _currentUser = data; + _issueData.tracker = data; }break; case 1:{//status - _currentStatus = data; + _issueData.status = data; }break; case 2:{//priority - _currentPriority = data; + _issueData.priority = data; }break; case 3:{//assignee - _currentUser = data; + _issueData.assignedTo = data; }break; default: @@ -320,13 +373,24 @@ { if (section == 0) { NSString* tip ; - if (_parentIssue) { - tip = [NSString stringWithFormat:@"Add sub issue to #%d",_parentIssue.index]; + if (_isUpdatingIssue) { + tip = [NSString stringWithFormat:@"Update issue #%d",_issueData.index]; }else { - tip = [NSString stringWithFormat:@"Add issue to project:%@",_parentProject.name]; + if (_parentIssue) { + tip = [NSString stringWithFormat:@"Add sub issue to #%d",_parentIssue.index]; + }else { + tip = [NSString stringWithFormat:@"Add issue to project:%@",_parentProject.name]; + } } return tip; + }else if(section == 3) { + if (_isUpdatingIssue) { + return @"Notes"; + }else { + return @"Description"; + } } + return @""; } diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m index 3f57049..b0c1780 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m @@ -96,7 +96,6 @@ UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueCreateViewController" bundle:nil]; OZLIssueCreateViewController* creator = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueCreateViewController"]; [creator setParentIssue:_issueData]; - //[self.navigationController presentModalViewController:creator animated:YES]; [self.navigationController pushViewController:creator animated:YES]; }break; case 2:{//logtime @@ -105,7 +104,13 @@ [creator setIssueData:_issueData]; [self.navigationController pushViewController:creator animated:YES]; }break; - + case 3:{ // update + UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueCreateViewController" bundle:nil]; + OZLIssueCreateViewController* creator = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueCreateViewController"]; + [creator setIssueData:_issueData]; + [creator setIsUpdatingIssue:YES]; + [self.navigationController pushViewController:creator animated:YES]; + }break; default: break; } diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.storyboard b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.storyboard index 990f929..e1c5ff2 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.storyboard +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.storyboard @@ -181,7 +181,7 @@ - + @@ -198,6 +198,24 @@ + + + + + + + + + + + + @@ -224,22 +242,6 @@ - - - - - - - - - - - - - - - - From 4b6d683b50940f4ce53f9530912fdbca464b772e Mon Sep 17 00:00:00 2001 From: zhijie Date: Wed, 24 Jul 2013 16:31:12 +0800 Subject: [PATCH 7/9] issue and project delete functionality --- .../OZLProjectListViewController.m | 84 +++++++++++-------- .../OZLProjectViewController.h | 1 + .../OZLProjectViewController.m | 78 +++++++++++++---- .../OZLProjectViewController.xib | 23 ++++- 4 files changed, 133 insertions(+), 53 deletions(-) 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 + + IBCocoaTouchFramework + 1 + + 11 + @@ -167,6 +173,14 @@ 14 + + + onShowInfo: + + + + 16 + @@ -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 From da265616a750774a2305d996e4a15bee476fcaaa Mon Sep 17 00:00:00 2001 From: zhijie Date: Wed, 24 Jul 2013 17:04:14 +0800 Subject: [PATCH 8/9] rewrite project detail view --- .../RedmineMobile.xcodeproj/project.pbxproj | 30 +- .../OZLIssueCreateViewController.h | 7 + .../OZLProjectDetailViewController.h | 43 -- .../OZLProjectDetailViewController.m | 80 --- .../OZLProjectDetailViewController.xib | 583 ------------------ ...oller.h => OZLProjectInfoViewController.h} | 14 +- ...oller.m => OZLProjectInfoViewController.m} | 47 +- ...> OZLProjectInfoViewController.storyboard} | 22 +- .../OZLProjectListViewController.m | 9 +- .../OZLProjectViewController.m | 8 +- 10 files changed, 80 insertions(+), 763 deletions(-) delete mode 100644 RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.h delete mode 100644 RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.m delete mode 100644 RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.xib rename RedmineMobile/RedmineMobile/ViewControllers/{OZLProjectCreateViewController.h => OZLProjectInfoViewController.h} (84%) rename RedmineMobile/RedmineMobile/ViewControllers/{OZLProjectCreateViewController.m => OZLProjectInfoViewController.m} (85%) rename RedmineMobile/RedmineMobile/ViewControllers/{OZLProjectCreateViewController.storyboard => OZLProjectInfoViewController.storyboard} (92%) diff --git a/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj b/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj index dd6ade0..812e107 100644 --- a/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj +++ b/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj @@ -9,7 +9,7 @@ /* Begin PBXBuildFile section */ 2B62D0DF1796498800AC3C19 /* OZLIssueCreateViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2B62D0DE1796498800AC3C19 /* OZLIssueCreateViewController.storyboard */; }; 2B62D0E1179649A800AC3C19 /* OZLIssueDetailViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2B62D0E0179649A800AC3C19 /* OZLIssueDetailViewController.storyboard */; }; - 2B62D0E31796A15C00AC3C19 /* OZLProjectCreateViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2B62D0E21796A15C00AC3C19 /* OZLProjectCreateViewController.storyboard */; }; + 2B62D0E31796A15C00AC3C19 /* OZLProjectInfoViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2B62D0E21796A15C00AC3C19 /* OZLProjectInfoViewController.storyboard */; }; 2B62D0E81796A8D800AC3C19 /* OZLIssueFilterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B62D0E71796A8D800AC3C19 /* OZLIssueFilterViewController.m */; }; 2B6F382F1797A00A00D06F51 /* MLTableAlertBackground.png in Resources */ = {isa = PBXBuildFile; fileRef = 2B6F38251797A00A00D06F51 /* MLTableAlertBackground.png */; }; 2B6F38301797A00A00D06F51 /* MLTableAlertBackground@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2B6F38261797A00A00D06F51 /* MLTableAlertBackground@2x.png */; }; @@ -23,7 +23,7 @@ 2B6F38391797BEBA00D06F51 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2B6F38381797BEBA00D06F51 /* QuartzCore.framework */; }; 2B8A11E217963CE500906D34 /* OZLIssueDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B8A11E117963CE500906D34 /* OZLIssueDetailViewController.m */; }; 2B9968AB1794F71B0086F115 /* OZLModelIssueCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B9968AA1794F71B0086F115 /* OZLModelIssueCategory.m */; }; - 2B9968AF1794FC0A0086F115 /* OZLProjectCreateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B9968AD1794FC0A0086F115 /* OZLProjectCreateViewController.m */; }; + 2B9968AF1794FC0A0086F115 /* OZLProjectInfoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B9968AD1794FC0A0086F115 /* OZLProjectInfoViewController.m */; }; 2B9968B417951A5C0086F115 /* OZLIssueCreateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B9968B217951A5C0086F115 /* OZLIssueCreateViewController.m */; }; 2BBE440F179E500E00FD9E20 /* OZLIssueLogtimeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BBE440E179E500E00FD9E20 /* OZLIssueLogtimeViewController.m */; }; 2BBE4411179E503100FD9E20 /* OZLIssueLogtimeViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2BBE4410179E503100FD9E20 /* OZLIssueLogtimeViewController.storyboard */; }; @@ -42,8 +42,6 @@ 2BCF88101793ABA0006FC859 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCF880F1793ABA0006FC859 /* Reachability.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 2BCF88121793CB4F006FC859 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2BCF88111793CB4F006FC859 /* CFNetwork.framework */; }; 2BCF88141793CB94006FC859 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2BCF88131793CB94006FC859 /* SystemConfiguration.framework */; }; - 2BCF88181793E353006FC859 /* OZLProjectDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCF88161793E353006FC859 /* OZLProjectDetailViewController.m */; }; - 2BCF88191793E353006FC859 /* OZLProjectDetailViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2BCF88171793E353006FC859 /* OZLProjectDetailViewController.xib */; }; 2BCF881E1793F3C8006FC859 /* OZLModelIssue.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCF881D1793F3C8006FC859 /* OZLModelIssue.m */; }; 2BCF88211793F478006FC859 /* OZLModelTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCF88201793F478006FC859 /* OZLModelTracker.m */; }; 2BCF88271793F4AA006FC859 /* OZLModelIssueStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCF88261793F4AA006FC859 /* OZLModelIssueStatus.m */; }; @@ -96,7 +94,7 @@ /* Begin PBXFileReference section */ 2B62D0DE1796498800AC3C19 /* OZLIssueCreateViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = OZLIssueCreateViewController.storyboard; path = ViewControllers/OZLIssueCreateViewController.storyboard; sourceTree = ""; }; 2B62D0E0179649A800AC3C19 /* OZLIssueDetailViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = OZLIssueDetailViewController.storyboard; path = ViewControllers/OZLIssueDetailViewController.storyboard; sourceTree = ""; }; - 2B62D0E21796A15C00AC3C19 /* OZLProjectCreateViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = OZLProjectCreateViewController.storyboard; path = ViewControllers/OZLProjectCreateViewController.storyboard; sourceTree = ""; }; + 2B62D0E21796A15C00AC3C19 /* OZLProjectInfoViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = OZLProjectInfoViewController.storyboard; path = ViewControllers/OZLProjectInfoViewController.storyboard; sourceTree = ""; }; 2B62D0E61796A8D800AC3C19 /* OZLIssueFilterViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLIssueFilterViewController.h; path = ViewControllers/OZLIssueFilterViewController.h; sourceTree = ""; }; 2B62D0E71796A8D800AC3C19 /* OZLIssueFilterViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLIssueFilterViewController.m; path = ViewControllers/OZLIssueFilterViewController.m; sourceTree = ""; }; 2B6F38251797A00A00D06F51 /* MLTableAlertBackground.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = MLTableAlertBackground.png; sourceTree = ""; }; @@ -114,8 +112,8 @@ 2B8A11E117963CE500906D34 /* OZLIssueDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLIssueDetailViewController.m; path = ViewControllers/OZLIssueDetailViewController.m; sourceTree = ""; }; 2B9968A91794F71B0086F115 /* OZLModelIssueCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLModelIssueCategory.h; path = Models/OZLModelIssueCategory.h; sourceTree = ""; }; 2B9968AA1794F71B0086F115 /* OZLModelIssueCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLModelIssueCategory.m; path = Models/OZLModelIssueCategory.m; sourceTree = ""; }; - 2B9968AC1794FC0A0086F115 /* OZLProjectCreateViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLProjectCreateViewController.h; path = ViewControllers/OZLProjectCreateViewController.h; sourceTree = ""; }; - 2B9968AD1794FC0A0086F115 /* OZLProjectCreateViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLProjectCreateViewController.m; path = ViewControllers/OZLProjectCreateViewController.m; sourceTree = ""; }; + 2B9968AC1794FC0A0086F115 /* OZLProjectInfoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLProjectInfoViewController.h; path = ViewControllers/OZLProjectInfoViewController.h; sourceTree = ""; }; + 2B9968AD1794FC0A0086F115 /* OZLProjectInfoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLProjectInfoViewController.m; path = ViewControllers/OZLProjectInfoViewController.m; sourceTree = ""; }; 2B9968B117951A5C0086F115 /* OZLIssueCreateViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLIssueCreateViewController.h; path = ViewControllers/OZLIssueCreateViewController.h; sourceTree = ""; }; 2B9968B217951A5C0086F115 /* OZLIssueCreateViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLIssueCreateViewController.m; path = ViewControllers/OZLIssueCreateViewController.m; sourceTree = ""; }; 2BBE440D179E500E00FD9E20 /* OZLIssueLogtimeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLIssueLogtimeViewController.h; path = ViewControllers/OZLIssueLogtimeViewController.h; sourceTree = ""; }; @@ -146,9 +144,6 @@ 2BCF880F1793ABA0006FC859 /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Reachability.m; sourceTree = ""; }; 2BCF88111793CB4F006FC859 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; 2BCF88131793CB94006FC859 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; - 2BCF88151793E352006FC859 /* OZLProjectDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLProjectDetailViewController.h; path = ViewControllers/OZLProjectDetailViewController.h; sourceTree = ""; }; - 2BCF88161793E353006FC859 /* OZLProjectDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLProjectDetailViewController.m; path = ViewControllers/OZLProjectDetailViewController.m; sourceTree = ""; }; - 2BCF88171793E353006FC859 /* OZLProjectDetailViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = OZLProjectDetailViewController.xib; path = ViewControllers/OZLProjectDetailViewController.xib; sourceTree = ""; }; 2BCF881C1793F3C8006FC859 /* OZLModelIssue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLModelIssue.h; path = Models/OZLModelIssue.h; sourceTree = ""; }; 2BCF881D1793F3C8006FC859 /* OZLModelIssue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLModelIssue.m; path = Models/OZLModelIssue.m; sourceTree = ""; }; 2BCF881F1793F478006FC859 /* OZLModelTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLModelTracker.h; path = Models/OZLModelTracker.h; sourceTree = ""; }; @@ -321,12 +316,9 @@ D5DB80A31792F4DE0081662A /* OZLProjectListViewController.h */, D5DB80A41792F4DE0081662A /* OZLProjectListViewController.m */, D5DB80A51792F4DE0081662A /* OZLProjectListViewController.xib */, - 2BCF88151793E352006FC859 /* OZLProjectDetailViewController.h */, - 2BCF88161793E353006FC859 /* OZLProjectDetailViewController.m */, - 2BCF88171793E353006FC859 /* OZLProjectDetailViewController.xib */, - 2B9968AC1794FC0A0086F115 /* OZLProjectCreateViewController.h */, - 2B9968AD1794FC0A0086F115 /* OZLProjectCreateViewController.m */, - 2B62D0E21796A15C00AC3C19 /* OZLProjectCreateViewController.storyboard */, + 2B9968AC1794FC0A0086F115 /* OZLProjectInfoViewController.h */, + 2B9968AD1794FC0A0086F115 /* OZLProjectInfoViewController.m */, + 2B62D0E21796A15C00AC3C19 /* OZLProjectInfoViewController.storyboard */, ); name = Project; sourceTree = ""; @@ -628,10 +620,9 @@ D5DB80A71792F4DE0081662A /* OZLProjectListViewController.xib in Resources */, D5DB80AD1792F6980081662A /* OZLProjectViewController.xib in Resources */, D5DB80B61793016B0081662A /* OZLAccountViewController.xib in Resources */, - 2BCF88191793E353006FC859 /* OZLProjectDetailViewController.xib in Resources */, 2B62D0DF1796498800AC3C19 /* OZLIssueCreateViewController.storyboard in Resources */, 2B62D0E1179649A800AC3C19 /* OZLIssueDetailViewController.storyboard in Resources */, - 2B62D0E31796A15C00AC3C19 /* OZLProjectCreateViewController.storyboard in Resources */, + 2B62D0E31796A15C00AC3C19 /* OZLProjectInfoViewController.storyboard in Resources */, 2B6F382F1797A00A00D06F51 /* MLTableAlertBackground.png in Resources */, 2B6F38301797A00A00D06F51 /* MLTableAlertBackground@2x.png in Resources */, 2B6F38311797A00A00D06F51 /* MLTableAlertButton.png in Resources */, @@ -699,14 +690,13 @@ D5DB80C217931C8B0081662A /* OZLModelProject.m in Sources */, 2BCF880C1793A26A006FC859 /* MBProgressHUD.m in Sources */, 2BCF88101793ABA0006FC859 /* Reachability.m in Sources */, - 2BCF88181793E353006FC859 /* OZLProjectDetailViewController.m in Sources */, 2BCF881E1793F3C8006FC859 /* OZLModelIssue.m in Sources */, 2BCF88211793F478006FC859 /* OZLModelTracker.m in Sources */, 2BCF88271793F4AA006FC859 /* OZLModelIssueStatus.m in Sources */, 2BCF882A1793F4C9006FC859 /* OZLModelIssuePriority.m in Sources */, 2BCF88301793F5CE006FC859 /* OZLModelUser.m in Sources */, 2B9968AB1794F71B0086F115 /* OZLModelIssueCategory.m in Sources */, - 2B9968AF1794FC0A0086F115 /* OZLProjectCreateViewController.m in Sources */, + 2B9968AF1794FC0A0086F115 /* OZLProjectInfoViewController.m in Sources */, 2B9968B417951A5C0086F115 /* OZLIssueCreateViewController.m in Sources */, 2BCCA0541795312E00FA8B1A /* OZLConstants.m in Sources */, 2B8A11E217963CE500906D34 /* OZLIssueDetailViewController.m in Sources */, diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.h b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.h index a16a228..0b4d3ed 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.h +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.h @@ -30,6 +30,13 @@ #import "OZLModelIssue.h" #import "OZLModelProject.h" +typedef enum { + OZLIssueInfoViewModeCreate, + OZLIssueInfoViewModeDisplay, + OZLIssueInfoViewModeEdit +} OZLIssueInfoViewMode; + + @interface OZLIssueCreateViewController : UITableViewController - (IBAction)onCancel:(id)sender; - (IBAction)onSave:(id)sender; diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.h b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.h deleted file mode 100644 index 83bbf2c..0000000 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.h +++ /dev/null @@ -1,43 +0,0 @@ -// -// OZLProjectDetailViewController.h -// RedmineMobile -// -// Created by lizhijie on 7/15/13. - -// This code is distributed under the terms and conditions of the MIT license. - -// Copyright (c) 2013 Zhijie Lee(onezeros.lee@gmail.com) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import "OZLModelProject.h" - -@interface OZLProjectDetailViewController : UIViewController - -@property(nonatomic, strong) OZLModelProject* projectData; - -@property (weak, nonatomic) IBOutlet UILabel *IDLabel; -@property (weak, nonatomic) IBOutlet UILabel *nameLabel; -@property (weak, nonatomic) IBOutlet UILabel *parentIDlabel; -@property (weak, nonatomic) IBOutlet UILabel *createTimeLabel; -@property (weak, nonatomic) IBOutlet UILabel *updateTimeLabel; -@property (weak, nonatomic) IBOutlet UITextView *descriptionTextview; - -@end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.m deleted file mode 100644 index cbfdd7a..0000000 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.m +++ /dev/null @@ -1,80 +0,0 @@ -// -// OZLProjectDetailViewController.m -// RedmineMobile -// -// Created by lizhijie on 7/15/13. - -// This code is distributed under the terms and conditions of the MIT license. - -// Copyright (c) 2013 Zhijie Lee(onezeros.lee@gmail.com) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "OZLProjectDetailViewController.h" - -@interface OZLProjectDetailViewController () { - -} - -@end - -@implementation OZLProjectDetailViewController - -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil -{ - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - // Custom initialization - } - return self; -} - -- (void)viewDidLoad -{ - [super viewDidLoad]; - [_IDLabel setText:[NSString stringWithFormat:@"%d",_projectData.index]]; - [_nameLabel setText:_projectData.name]; - if (_projectData.parentId < 0) { - [_parentIDlabel setText:@"--"]; - }else { - [_parentIDlabel setText:[NSString stringWithFormat:@"%d",_projectData.parentId]]; - } - [_createTimeLabel setText:_projectData.createdOn]; - [_updateTimeLabel setText:_projectData.updatedOn]; - - [_descriptionTextview setEditable:NO]; - [_descriptionTextview setText:_projectData.description]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -- (void)viewDidUnload { - [self setIDLabel:nil]; - [self setNameLabel:nil]; - [self setParentIDlabel:nil]; - [self setCreateTimeLabel:nil]; - [self setUpdateTimeLabel:nil]; - [self setDescriptionTextview:nil]; - [super viewDidUnload]; -} -@end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.xib b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.xib deleted file mode 100644 index e6aa4d7..0000000 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.xib +++ /dev/null @@ -1,583 +0,0 @@ - - - - 1552 - 11G63 - 3084 - 1138.51 - 569.00 - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 2083 - - - IBProxyObject - IBUILabel - IBUITextView - IBUIView - - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - PluginDependencyRecalculationVersion - - - - - IBFilesOwner - IBCocoaTouchFramework - - - IBFirstResponder - IBCocoaTouchFramework - - - - 274 - - - - 292 - {{20, 20}, {106, 21}} - - - - _NS:9 - NO - YES - 7 - NO - IBCocoaTouchFramework - ID: - - 1 - MCAwIDAAA - darkTextColor - - - 0 - - 1 - 17 - - - Helvetica - 17 - 16 - - NO - - - - 292 - {{20, 49}, {106, 21}} - - - - _NS:9 - NO - YES - 7 - NO - IBCocoaTouchFramework - Name: - - - 0 - - - NO - - - - 292 - {{20, 107}, {106, 21}} - - - - _NS:9 - NO - YES - 7 - NO - IBCocoaTouchFramework - Created On: - - - 0 - - - NO - - - - 292 - {{20, 136}, {106, 21}} - - - - _NS:9 - NO - YES - 7 - NO - IBCocoaTouchFramework - Updated On: - - - 0 - - - NO - - - - 292 - {{20, 165}, {106, 21}} - - - - _NS:9 - NO - YES - 7 - NO - IBCocoaTouchFramework - Description: - - - 0 - - - NO - - - - 292 - {{20, 78}, {106, 21}} - - - - _NS:9 - NO - YES - 7 - NO - IBCocoaTouchFramework - Parent ID: - - - 0 - - - NO - - - - 306 - {{20, 194}, {280, 290}} - - - - _NS:9 - - 1 - MSAxIDEAA - - YES - YES - IBCocoaTouchFramework - Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. - - 2 - IBCocoaTouchFramework - - - 1 - 14 - - - Helvetica - 14 - 16 - - - - - 292 - {{134, 20}, {166, 21}} - - - - _NS:9 - NO - YES - 7 - NO - IBCocoaTouchFramework - ID: - - - 0 - - - NO - - - - 292 - {{134, 49}, {166, 21}} - - - - _NS:9 - NO - YES - 7 - NO - IBCocoaTouchFramework - ID: - - - 0 - - - NO - - - - 292 - {{134, 78}, {166, 21}} - - - - _NS:9 - NO - YES - 7 - NO - IBCocoaTouchFramework - ID: - - - 0 - - - NO - - - - 292 - {{134, 107}, {166, 21}} - - - - _NS:9 - NO - YES - 7 - NO - IBCocoaTouchFramework - ID: - - - 0 - - - NO - - - - 292 - {{134, 136}, {166, 21}} - - - - _NS:9 - NO - YES - 7 - NO - IBCocoaTouchFramework - ID: - - - 0 - - - NO - - - {{0, 64}, {320, 504}} - - - - - 3 - MQA - - 2 - - - - - NO - - - IBUIScreenMetrics - - YES - - - - - - {320, 568} - {568, 320} - - - IBCocoaTouchFramework - Retina 4 Full Screen - 2 - - IBCocoaTouchFramework - - - - - - - view - - - - 3 - - - - IDLabel - - - - 18 - - - - nameLabel - - - - 19 - - - - parentIDlabel - - - - 20 - - - - createTimeLabel - - - - 21 - - - - updateTimeLabel - - - - 22 - - - - descriptionTextview - - - - 23 - - - - - - 0 - - - - - - 1 - - - - - - - - - - - - - - - - - - - -1 - - - File's Owner - - - -2 - - - - - 6 - - - - - 7 - - - - - 8 - - - - - 9 - - - - - 10 - - - - - 11 - - - - - 12 - - - - - 13 - - - - - 14 - - - - - 15 - - - - - 16 - - - - - 17 - - - - - - - OZLProjectDetailViewController - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - UIResponder - 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 - 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 - - - - - - 23 - - - - - OZLProjectDetailViewController - UIViewController - - UILabel - UILabel - UITextView - UILabel - UILabel - UILabel - - - - IDLabel - UILabel - - - createTimeLabel - UILabel - - - descriptionTextview - UITextView - - - nameLabel - UILabel - - - parentIDlabel - UILabel - - - updateTimeLabel - UILabel - - - - IBProjectSource - ./Classes/OZLProjectDetailViewController.h - - - - - 0 - IBCocoaTouchFramework - YES - 3 - 2083 - - diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectCreateViewController.h b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectInfoViewController.h similarity index 84% rename from RedmineMobile/RedmineMobile/ViewControllers/OZLProjectCreateViewController.h rename to RedmineMobile/RedmineMobile/ViewControllers/OZLProjectInfoViewController.h index 39e8b14..4a46332 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectCreateViewController.h +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectInfoViewController.h @@ -1,5 +1,5 @@ // -// OZLProjectCreateViewController.h +// OZLProjectInfoViewController.h // RedmineMobile // // Created by lizhijie on 7/16/13. @@ -29,7 +29,14 @@ #import #import "OZLModelProject.h" -@interface OZLProjectCreateViewController : UITableViewController +typedef enum { + OZLProjectInfoViewModeCreate, + OZLProjectInfoViewModeDisplay, + OZLProjectInfoViewModeEdit +} OZLProjectInfoViewMode; + + +@interface OZLProjectInfoViewController : UITableViewController - (IBAction)onCancel:(id)sender; - (IBAction)onSave:(id)sender; @property (weak, nonatomic) IBOutlet UITextField *name; @@ -40,4 +47,7 @@ @property (nonatomic,strong) OZLModelProject* parentProject; @property (nonatomic,strong) NSArray* projectList; +@property (nonatomic, strong) OZLModelProject* projectData; +@property (nonatomic) int viewMode; + @end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectCreateViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectInfoViewController.m similarity index 85% rename from RedmineMobile/RedmineMobile/ViewControllers/OZLProjectCreateViewController.m rename to RedmineMobile/RedmineMobile/ViewControllers/OZLProjectInfoViewController.m index cda5122..c4b2a72 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectCreateViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectInfoViewController.m @@ -1,5 +1,5 @@ // -// OZLProjectCreateViewController.m +// OZLProjectInfoViewController.m // RedmineMobile // // Created by lizhijie on 7/16/13. @@ -26,19 +26,19 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#import "OZLProjectCreateViewController.h" +#import "OZLProjectInfoViewController.h" #import "MBProgressHUD.h" #import "OZLNetwork.h" #import "MLTableAlert.h" -@interface OZLProjectCreateViewController () { +@interface OZLProjectInfoViewController () { MBProgressHUD * _HUD; } @end -@implementation OZLProjectCreateViewController +@implementation OZLProjectInfoViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { @@ -53,15 +53,45 @@ { [super viewDidLoad]; + + _HUD = [[MBProgressHUD alloc] initWithView:self.view]; + [self.view addSubview:_HUD]; + _HUD.labelText = @"Loading..."; + + if (_viewMode == OZLProjectInfoViewModeCreate) { + [self prepareViewForCreate]; + }else if(_viewMode == OZLProjectInfoViewModeDisplay) { + [self prepareViewForDisplay]; + }else if(_viewMode == OZLProjectInfoViewModeEdit) { + + } +} + +-(void)prepareViewForDisplay +{ + self.navigationItem.title = @"Project Details"; + + _name.userInteractionEnabled = NO; + _identifier.userInteractionEnabled = NO; + _homepageUrl.userInteractionEnabled = NO; + _description.userInteractionEnabled = NO; + + _name.text = _projectData.name; + _identifier.text = _projectData.identifier; + _homepageUrl.text = _projectData.homepage; + _description.text = _projectData.description; +} + +-(void)prepareViewForCreate +{ + UIBarButtonItem* cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(onCancel:)]; [self.navigationItem setLeftBarButtonItem:cancelBtn]; UIBarButtonItem* saveBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(onSave:)]; [self.navigationItem setRightBarButtonItem:saveBtn]; + self.navigationItem.title = @"New Project"; - _HUD = [[MBProgressHUD alloc] initWithView:self.view]; - [self.view addSubview:_HUD]; - _HUD.labelText = @"Loading..."; } - (void)didReceiveMemoryWarning @@ -126,6 +156,9 @@ [super viewDidUnload]; } +#pragma mark tableview datasource + +#pragma mark tableview delegate -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section ==0 && indexPath.row == 4) {//parent project diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectCreateViewController.storyboard b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectInfoViewController.storyboard similarity index 92% rename from RedmineMobile/RedmineMobile/ViewControllers/OZLProjectCreateViewController.storyboard rename to RedmineMobile/RedmineMobile/ViewControllers/OZLProjectInfoViewController.storyboard index cdfb4ff..3749179 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectCreateViewController.storyboard +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectInfoViewController.storyboard @@ -4,11 +4,11 @@ - + - - + + @@ -170,22 +170,6 @@ - - - - - - - - - - - - - - - - diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.m index 5710843..faf0a37 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.m @@ -30,7 +30,7 @@ #import "PPRevealSideViewController.h" #import "OZLProjectViewController.h" #import "OZLAccountViewController.h" -#import "OZLProjectCreateViewController.h" +#import "OZLProjectInfoViewController.h" #import "OZLNetwork.h" #import "OZLModelProject.h" #import "MBProgressHUD.h" @@ -137,11 +137,10 @@ } - (IBAction)createProject:(id)sender { - //OZLProjectCreateViewController* creator = [[OZLProjectCreateViewController alloc] initWithNibName:@"OZLProjectCreateViewController" bundle:nil]; - //[self.navigationController presentModalViewController:creator animated:YES]; - UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLProjectCreateViewController" bundle:nil]; - OZLProjectCreateViewController* creator = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLProjectCreateViewController"]; + UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLProjectInfoViewController" bundle:nil]; + OZLProjectInfoViewController* creator = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLProjectInfoViewController"]; [creator setProjectList:_projectList]; + [creator setViewMode:OZLProjectInfoViewModeCreate]; [self.navigationController pushViewController:creator animated:YES]; } diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m index afef5c5..b259fce 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m @@ -31,7 +31,7 @@ #import "OZLProjectListViewController.h" #import "OZLNetwork.h" #import "MBProgressHUD.h" -#import "OZLProjectDetailViewController.h" +#import "OZLProjectInfoViewController.h" #import "OZLIssueDetailViewController.h" #import "OZLIssueCreateViewController.h" #import "OZLIssueFilterViewController.h" @@ -371,10 +371,10 @@ } - (IBAction)onShowInfo:(id)sender { -// UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"OZLProjectDetailViewController" bundle:nil]; -// OZLProjectDetailViewController* detail = [storyboard instantiateViewControllerWithIdentifier:@"OZLProjectDetailViewController"]; - OZLProjectDetailViewController* detail = [[OZLProjectDetailViewController alloc] initWithNibName:@"OZLProjectDetailViewController" bundle:nil]; + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"OZLProjectInfoViewController" bundle:nil]; + OZLProjectInfoViewController* detail = [storyboard instantiateViewControllerWithIdentifier:@"OZLProjectInfoViewController"]; [detail setProjectData:_projectData]; + [detail setViewMode:OZLProjectInfoViewModeDisplay]; [self.navigationController pushViewController:detail animated:YES]; } From 8e5c0ec534f8f884e66094f90f52b0dcdd119ea8 Mon Sep 17 00:00:00 2001 From: zhijie Date: Wed, 24 Jul 2013 17:16:12 +0800 Subject: [PATCH 9/9] refactor issue create and update functionality --- .../RedmineMobile.xcodeproj/project.pbxproj | 20 ++++++------- ...=> OZLIssueCreateOrUpdateViewController.h} | 9 +++--- ...=> OZLIssueCreateOrUpdateViewController.m} | 29 +++++++++---------- ...ueCreateOrUpdateViewController.storyboard} | 23 +++++++++++++-- .../OZLIssueDetailViewController.m | 12 ++++---- .../OZLProjectInfoViewController.h | 2 +- .../OZLProjectViewController.m | 9 +++--- 7 files changed, 61 insertions(+), 43 deletions(-) rename RedmineMobile/RedmineMobile/ViewControllers/{OZLIssueCreateViewController.h => OZLIssueCreateOrUpdateViewController.h} (90%) rename RedmineMobile/RedmineMobile/ViewControllers/{OZLIssueCreateViewController.m => OZLIssueCreateOrUpdateViewController.m} (95%) rename RedmineMobile/RedmineMobile/ViewControllers/{OZLIssueCreateViewController.storyboard => OZLIssueCreateOrUpdateViewController.storyboard} (95%) diff --git a/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj b/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj index 812e107..85c6b20 100644 --- a/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj +++ b/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj @@ -7,7 +7,7 @@ objects = { /* Begin PBXBuildFile section */ - 2B62D0DF1796498800AC3C19 /* OZLIssueCreateViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2B62D0DE1796498800AC3C19 /* OZLIssueCreateViewController.storyboard */; }; + 2B62D0DF1796498800AC3C19 /* OZLIssueCreateOrUpdateViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2B62D0DE1796498800AC3C19 /* OZLIssueCreateOrUpdateViewController.storyboard */; }; 2B62D0E1179649A800AC3C19 /* OZLIssueDetailViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2B62D0E0179649A800AC3C19 /* OZLIssueDetailViewController.storyboard */; }; 2B62D0E31796A15C00AC3C19 /* OZLProjectInfoViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2B62D0E21796A15C00AC3C19 /* OZLProjectInfoViewController.storyboard */; }; 2B62D0E81796A8D800AC3C19 /* OZLIssueFilterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B62D0E71796A8D800AC3C19 /* OZLIssueFilterViewController.m */; }; @@ -24,7 +24,7 @@ 2B8A11E217963CE500906D34 /* OZLIssueDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B8A11E117963CE500906D34 /* OZLIssueDetailViewController.m */; }; 2B9968AB1794F71B0086F115 /* OZLModelIssueCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B9968AA1794F71B0086F115 /* OZLModelIssueCategory.m */; }; 2B9968AF1794FC0A0086F115 /* OZLProjectInfoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B9968AD1794FC0A0086F115 /* OZLProjectInfoViewController.m */; }; - 2B9968B417951A5C0086F115 /* OZLIssueCreateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B9968B217951A5C0086F115 /* OZLIssueCreateViewController.m */; }; + 2B9968B417951A5C0086F115 /* OZLIssueCreateOrUpdateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B9968B217951A5C0086F115 /* OZLIssueCreateOrUpdateViewController.m */; }; 2BBE440F179E500E00FD9E20 /* OZLIssueLogtimeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BBE440E179E500E00FD9E20 /* OZLIssueLogtimeViewController.m */; }; 2BBE4411179E503100FD9E20 /* OZLIssueLogtimeViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2BBE4410179E503100FD9E20 /* OZLIssueLogtimeViewController.storyboard */; }; 2BBE4414179E586B00FD9E20 /* OZLModelTimeEntryActivity.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BBE4413179E586B00FD9E20 /* OZLModelTimeEntryActivity.m */; }; @@ -92,7 +92,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 2B62D0DE1796498800AC3C19 /* OZLIssueCreateViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = OZLIssueCreateViewController.storyboard; path = ViewControllers/OZLIssueCreateViewController.storyboard; sourceTree = ""; }; + 2B62D0DE1796498800AC3C19 /* OZLIssueCreateOrUpdateViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = OZLIssueCreateOrUpdateViewController.storyboard; path = ViewControllers/OZLIssueCreateOrUpdateViewController.storyboard; sourceTree = ""; }; 2B62D0E0179649A800AC3C19 /* OZLIssueDetailViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = OZLIssueDetailViewController.storyboard; path = ViewControllers/OZLIssueDetailViewController.storyboard; sourceTree = ""; }; 2B62D0E21796A15C00AC3C19 /* OZLProjectInfoViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = OZLProjectInfoViewController.storyboard; path = ViewControllers/OZLProjectInfoViewController.storyboard; sourceTree = ""; }; 2B62D0E61796A8D800AC3C19 /* OZLIssueFilterViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLIssueFilterViewController.h; path = ViewControllers/OZLIssueFilterViewController.h; sourceTree = ""; }; @@ -114,8 +114,8 @@ 2B9968AA1794F71B0086F115 /* OZLModelIssueCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLModelIssueCategory.m; path = Models/OZLModelIssueCategory.m; sourceTree = ""; }; 2B9968AC1794FC0A0086F115 /* OZLProjectInfoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLProjectInfoViewController.h; path = ViewControllers/OZLProjectInfoViewController.h; sourceTree = ""; }; 2B9968AD1794FC0A0086F115 /* OZLProjectInfoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLProjectInfoViewController.m; path = ViewControllers/OZLProjectInfoViewController.m; sourceTree = ""; }; - 2B9968B117951A5C0086F115 /* OZLIssueCreateViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLIssueCreateViewController.h; path = ViewControllers/OZLIssueCreateViewController.h; sourceTree = ""; }; - 2B9968B217951A5C0086F115 /* OZLIssueCreateViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLIssueCreateViewController.m; path = ViewControllers/OZLIssueCreateViewController.m; sourceTree = ""; }; + 2B9968B117951A5C0086F115 /* OZLIssueCreateOrUpdateViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLIssueCreateOrUpdateViewController.h; path = ViewControllers/OZLIssueCreateOrUpdateViewController.h; sourceTree = ""; }; + 2B9968B217951A5C0086F115 /* OZLIssueCreateOrUpdateViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLIssueCreateOrUpdateViewController.m; path = ViewControllers/OZLIssueCreateOrUpdateViewController.m; sourceTree = ""; }; 2BBE440D179E500E00FD9E20 /* OZLIssueLogtimeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLIssueLogtimeViewController.h; path = ViewControllers/OZLIssueLogtimeViewController.h; sourceTree = ""; }; 2BBE440E179E500E00FD9E20 /* OZLIssueLogtimeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLIssueLogtimeViewController.m; path = ViewControllers/OZLIssueLogtimeViewController.m; sourceTree = ""; }; 2BBE4410179E503100FD9E20 /* OZLIssueLogtimeViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = OZLIssueLogtimeViewController.storyboard; path = ViewControllers/OZLIssueLogtimeViewController.storyboard; sourceTree = ""; }; @@ -329,9 +329,9 @@ D5DB80A91792F6980081662A /* OZLProjectViewController.h */, D5DB80AA1792F6980081662A /* OZLProjectViewController.m */, D5DB80AB1792F6980081662A /* OZLProjectViewController.xib */, - 2B9968B117951A5C0086F115 /* OZLIssueCreateViewController.h */, - 2B9968B217951A5C0086F115 /* OZLIssueCreateViewController.m */, - 2B62D0DE1796498800AC3C19 /* OZLIssueCreateViewController.storyboard */, + 2B9968B117951A5C0086F115 /* OZLIssueCreateOrUpdateViewController.h */, + 2B9968B217951A5C0086F115 /* OZLIssueCreateOrUpdateViewController.m */, + 2B62D0DE1796498800AC3C19 /* OZLIssueCreateOrUpdateViewController.storyboard */, 2B8A11E017963CE500906D34 /* OZLIssueDetailViewController.h */, 2B8A11E117963CE500906D34 /* OZLIssueDetailViewController.m */, 2B62D0E0179649A800AC3C19 /* OZLIssueDetailViewController.storyboard */, @@ -620,7 +620,7 @@ D5DB80A71792F4DE0081662A /* OZLProjectListViewController.xib in Resources */, D5DB80AD1792F6980081662A /* OZLProjectViewController.xib in Resources */, D5DB80B61793016B0081662A /* OZLAccountViewController.xib in Resources */, - 2B62D0DF1796498800AC3C19 /* OZLIssueCreateViewController.storyboard in Resources */, + 2B62D0DF1796498800AC3C19 /* OZLIssueCreateOrUpdateViewController.storyboard in Resources */, 2B62D0E1179649A800AC3C19 /* OZLIssueDetailViewController.storyboard in Resources */, 2B62D0E31796A15C00AC3C19 /* OZLProjectInfoViewController.storyboard in Resources */, 2B6F382F1797A00A00D06F51 /* MLTableAlertBackground.png in Resources */, @@ -697,7 +697,7 @@ 2BCF88301793F5CE006FC859 /* OZLModelUser.m in Sources */, 2B9968AB1794F71B0086F115 /* OZLModelIssueCategory.m in Sources */, 2B9968AF1794FC0A0086F115 /* OZLProjectInfoViewController.m in Sources */, - 2B9968B417951A5C0086F115 /* OZLIssueCreateViewController.m in Sources */, + 2B9968B417951A5C0086F115 /* OZLIssueCreateOrUpdateViewController.m in Sources */, 2BCCA0541795312E00FA8B1A /* OZLConstants.m in Sources */, 2B8A11E217963CE500906D34 /* OZLIssueDetailViewController.m in Sources */, 2B62D0E81796A8D800AC3C19 /* OZLIssueFilterViewController.m in Sources */, diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.h b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateOrUpdateViewController.h similarity index 90% rename from RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.h rename to RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateOrUpdateViewController.h index 0b4d3ed..27ca01c 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.h +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateOrUpdateViewController.h @@ -1,5 +1,5 @@ // -// OZLIssueCreateViewController.h +// OZLIssueCreateOrUpdateViewController.h // RedmineMobile // // Created by lizhijie on 7/16/13. @@ -32,12 +32,11 @@ typedef enum { OZLIssueInfoViewModeCreate, - OZLIssueInfoViewModeDisplay, +// OZLIssueInfoViewModeDisplay, OZLIssueInfoViewModeEdit } OZLIssueInfoViewMode; - -@interface OZLIssueCreateViewController : UITableViewController +@interface OZLIssueCreateOrUpdateViewController : UITableViewController - (IBAction)onCancel:(id)sender; - (IBAction)onSave:(id)sender; @@ -63,7 +62,7 @@ typedef enum { @property(nonatomic,strong) OZLModelProject* parentProject; @property(nonatomic,strong) OZLModelIssue* parentIssue; @property(nonatomic, strong) OZLModelIssue* issueData;// used for update issue -@property(nonatomic) int isUpdatingIssue; +@property(nonatomic) OZLIssueInfoViewMode viewMode; //@property(nonatomic,strong) NSArray* issueList; diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateOrUpdateViewController.m similarity index 95% rename from RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m rename to RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateOrUpdateViewController.m index a7183ed..50bf131 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateOrUpdateViewController.m @@ -1,5 +1,5 @@ // -// OZLIssueCreateViewController.m +// OZLIssueCreateOrUpdateViewController.m // RedmineMobile // // Created by lizhijie on 7/16/13. @@ -26,7 +26,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#import "OZLIssueCreateViewController.h" +#import "OZLIssueCreateOrUpdateViewController.h" #import "OZLNetwork.h" #import "MBProgressHUD.h" #import "OZLModelIssuePriority.h" @@ -36,7 +36,7 @@ #import "MLTableAlert.h" #import "OZLSingleton.h" -@interface OZLIssueCreateViewController () { +@interface OZLIssueCreateOrUpdateViewController () { NSDate* _currentStartDate; NSDate* _currentDueDate; @@ -47,7 +47,7 @@ @end -@implementation OZLIssueCreateViewController +@implementation OZLIssueCreateOrUpdateViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { @@ -123,7 +123,7 @@ -(void)initializeViewValues { - if (_isUpdatingIssue) { // initial values for ui elements + if (_viewMode == OZLIssueInfoViewModeEdit) { // initial values for ui elements _subjectTextField.text = _issueData.subject; if (_issueData.tracker) { _trackerLabel.text = _issueData.tracker.name; @@ -146,8 +146,7 @@ _estimatedHoursLabel.text = [NSString stringWithFormat:@"%f",_issueData.estimatedHours]; _doneProgressLabel.text = [NSString stringWithFormat:@"%d %%",(int)_issueData.doneRatio]; - - }else { + }else if(_viewMode == OZLIssueInfoViewModeCreate){ _issueData = [[OZLModelIssue alloc] init]; } @@ -201,9 +200,9 @@ }else if(_parentProject){ _issueData.projectId = _parentProject.index; } - if (_isUpdatingIssue) { + if (_viewMode == OZLIssueInfoViewModeEdit) { _issueData.notes = _descriptionTextview.text; - }else { + }else if(_viewMode == OZLIssueInfoViewModeCreate) { _issueData.description = _descriptionTextview.text; } _issueData.startDate = _startDateLabel.text; @@ -214,7 +213,7 @@ _HUD.mode = MBProgressHUDModeIndeterminate; - if (_isUpdatingIssue) { + if (_viewMode == OZLIssueInfoViewModeEdit) { _HUD.labelText = @"Updating Issue ..."; [_HUD show:YES]; [OZLNetwork updateIssue:_issueData withParams:nil andBlock:^(BOOL success, NSError *error){ @@ -232,7 +231,7 @@ [self.navigationController popViewControllerAnimated:YES]; } }]; - }else { + }else if(_viewMode == OZLIssueInfoViewModeCreate){ _HUD.labelText = @"Creating New Issue ..."; [_HUD show:YES]; [OZLNetwork createIssue:_issueData withParams:nil andBlock:^(BOOL success, NSError *error){ @@ -373,9 +372,9 @@ { if (section == 0) { NSString* tip ; - if (_isUpdatingIssue) { + if (_viewMode == OZLIssueInfoViewModeEdit) { tip = [NSString stringWithFormat:@"Update issue #%d",_issueData.index]; - }else { + }else if(_viewMode == OZLIssueInfoViewModeCreate){ if (_parentIssue) { tip = [NSString stringWithFormat:@"Add sub issue to #%d",_parentIssue.index]; }else { @@ -384,9 +383,9 @@ } return tip; }else if(section == 3) { - if (_isUpdatingIssue) { + if (_viewMode == OZLIssueInfoViewModeEdit) { return @"Notes"; - }else { + }else if(_viewMode == OZLIssueInfoViewModeCreate){ return @"Description"; } } diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.storyboard b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateOrUpdateViewController.storyboard similarity index 95% rename from RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.storyboard rename to RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateOrUpdateViewController.storyboard index 2216f3e..1369d60 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.storyboard +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateOrUpdateViewController.storyboard @@ -4,10 +4,10 @@ - + - + @@ -289,6 +289,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m index b0c1780..a9c3a96 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m @@ -30,7 +30,7 @@ #import "OZLIssueHistoryViewController.h" #import "OZLIssueLogtimeViewController.h" #import "OZLSingleton.h" -#import "OZLIssueCreateViewController.h" +#import "OZLIssueCreateOrUpdateViewController.h" @interface OZLIssueDetailViewController () @@ -93,8 +93,8 @@ [self.navigationController pushViewController:history animated:YES]; }break; case 1:{// add sub task - UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueCreateViewController" bundle:nil]; - OZLIssueCreateViewController* creator = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueCreateViewController"]; + UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueCreateOrUpdateViewController" bundle:nil]; + OZLIssueCreateOrUpdateViewController* creator = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueCreateOrUpdateViewController"]; [creator setParentIssue:_issueData]; [self.navigationController pushViewController:creator animated:YES]; }break; @@ -105,10 +105,10 @@ [self.navigationController pushViewController:creator animated:YES]; }break; case 3:{ // update - UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueCreateViewController" bundle:nil]; - OZLIssueCreateViewController* creator = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueCreateViewController"]; + UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueCreateOrUpdateViewController" bundle:nil]; + OZLIssueCreateOrUpdateViewController* creator = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueCreateOrUpdateViewController"]; [creator setIssueData:_issueData]; - [creator setIsUpdatingIssue:YES]; + [creator setViewMode:OZLIssueInfoViewModeEdit]; [self.navigationController pushViewController:creator animated:YES]; }break; default: diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectInfoViewController.h b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectInfoViewController.h index 4a46332..78bd745 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectInfoViewController.h +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectInfoViewController.h @@ -48,6 +48,6 @@ typedef enum { @property (nonatomic,strong) NSArray* projectList; @property (nonatomic, strong) OZLModelProject* projectData; -@property (nonatomic) int viewMode; +@property (nonatomic) OZLProjectInfoViewMode viewMode; @end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m index b259fce..5ec0c45 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m @@ -33,7 +33,7 @@ #import "MBProgressHUD.h" #import "OZLProjectInfoViewController.h" #import "OZLIssueDetailViewController.h" -#import "OZLIssueCreateViewController.h" +#import "OZLIssueCreateOrUpdateViewController.h" #import "OZLIssueFilterViewController.h" #import "OZLSingleton.h" @@ -357,10 +357,11 @@ } - (IBAction)onNewIssue:(id)sender { - //OZLIssueCreateViewController* creator = [[OZLIssueCreateViewController alloc] initWithNibName:@"OZLIssueCreateViewController" bundle:nil]; - UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueCreateViewController" bundle:nil]; - OZLIssueCreateViewController* creator = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueCreateViewController"]; + //OZLIssueCreateOrUpdateViewController* creator = [[OZLIssueCreateOrUpdateViewController alloc] initWithNibName:@"OZLIssueCreateOrUpdateViewController" bundle:nil]; + UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueCreateOrUpdateViewController" bundle:nil]; + OZLIssueCreateOrUpdateViewController* creator = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueCreateOrUpdateViewController"]; [creator setParentProject:_projectData]; + [creator setViewMode:OZLIssueInfoViewModeCreate]; //[self.navigationController presentModalViewController:creator animated:YES]; [self.navigationController pushViewController:creator animated:YES]; }