diff --git a/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj b/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj index beb0a2a..8619513 100644 --- a/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj +++ b/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj @@ -13,6 +13,11 @@ 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 /* OZLModelStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCF88261793F4AA006FC859 /* OZLModelStatus.m */; }; + 2BCF882A1793F4C9006FC859 /* OZLModelPriority.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCF88291793F4C9006FC859 /* OZLModelPriority.m */; }; + 2BCF88301793F5CE006FC859 /* OZLModelUser.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCF882F1793F5CE006FC859 /* OZLModelUser.m */; }; D5DB805A1792F2BF0081662A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5DB80591792F2BF0081662A /* UIKit.framework */; }; D5DB805C1792F2BF0081662A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5DB805B1792F2BF0081662A /* Foundation.framework */; }; D5DB805E1792F2BF0081662A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5DB805D1792F2BF0081662A /* CoreGraphics.framework */; }; @@ -57,6 +62,16 @@ 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 = ""; }; + 2BCF88201793F478006FC859 /* OZLModelTracker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLModelTracker.m; path = Models/OZLModelTracker.m; sourceTree = ""; }; + 2BCF88251793F4AA006FC859 /* OZLModelStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLModelStatus.h; path = Models/OZLModelStatus.h; sourceTree = ""; }; + 2BCF88261793F4AA006FC859 /* OZLModelStatus.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLModelStatus.m; path = Models/OZLModelStatus.m; sourceTree = ""; }; + 2BCF88281793F4C9006FC859 /* OZLModelPriority.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLModelPriority.h; path = Models/OZLModelPriority.h; sourceTree = ""; }; + 2BCF88291793F4C9006FC859 /* OZLModelPriority.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLModelPriority.m; path = Models/OZLModelPriority.m; sourceTree = ""; }; + 2BCF882E1793F5CE006FC859 /* OZLModelUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLModelUser.h; path = Models/OZLModelUser.h; sourceTree = ""; }; + 2BCF882F1793F5CE006FC859 /* OZLModelUser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLModelUser.m; path = Models/OZLModelUser.m; sourceTree = ""; }; D5DB80561792F2BF0081662A /* RedmineMobile.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RedmineMobile.app; sourceTree = BUILT_PRODUCTS_DIR; }; D5DB80591792F2BF0081662A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; D5DB805B1792F2BF0081662A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -150,6 +165,29 @@ path = Reachability; sourceTree = ""; }; + 2BCF881A1793EF9F006FC859 /* Project */ = { + isa = PBXGroup; + children = ( + D5DB80A31792F4DE0081662A /* OZLProjectListViewController.h */, + D5DB80A41792F4DE0081662A /* OZLProjectListViewController.m */, + D5DB80A51792F4DE0081662A /* OZLProjectListViewController.xib */, + D5DB80A91792F6980081662A /* OZLProjectViewController.h */, + D5DB80AA1792F6980081662A /* OZLProjectViewController.m */, + D5DB80AB1792F6980081662A /* OZLProjectViewController.xib */, + 2BCF88151793E352006FC859 /* OZLProjectDetailViewController.h */, + 2BCF88161793E353006FC859 /* OZLProjectDetailViewController.m */, + 2BCF88171793E353006FC859 /* OZLProjectDetailViewController.xib */, + ); + name = Project; + sourceTree = ""; + }; + 2BCF881B1793EFB7006FC859 /* Issue */ = { + isa = PBXGroup; + children = ( + ); + name = Issue; + sourceTree = ""; + }; D5DB804D1792F2BF0081662A = { isa = PBXGroup; children = ( @@ -278,18 +316,11 @@ D5DB80A81792F4E40081662A /* ViewControllers */ = { isa = PBXGroup; children = ( - D5DB80A31792F4DE0081662A /* OZLProjectListViewController.h */, - D5DB80A41792F4DE0081662A /* OZLProjectListViewController.m */, - D5DB80A51792F4DE0081662A /* OZLProjectListViewController.xib */, - D5DB80A91792F6980081662A /* OZLProjectViewController.h */, - D5DB80AA1792F6980081662A /* OZLProjectViewController.m */, - D5DB80AB1792F6980081662A /* OZLProjectViewController.xib */, + 2BCF881B1793EFB7006FC859 /* Issue */, + 2BCF881A1793EF9F006FC859 /* Project */, D5DB80B21793016B0081662A /* OZLAccountViewController.h */, D5DB80B31793016B0081662A /* OZLAccountViewController.m */, D5DB80B41793016B0081662A /* OZLAccountViewController.xib */, - 2BCF88151793E352006FC859 /* OZLProjectDetailViewController.h */, - 2BCF88161793E353006FC859 /* OZLProjectDetailViewController.m */, - 2BCF88171793E353006FC859 /* OZLProjectDetailViewController.xib */, ); name = ViewControllers; sourceTree = ""; @@ -310,8 +341,18 @@ D5DB80BF17931C580081662A /* Models */ = { isa = PBXGroup; children = ( + 2BCF88251793F4AA006FC859 /* OZLModelStatus.h */, + 2BCF88261793F4AA006FC859 /* OZLModelStatus.m */, D5DB80C017931C8B0081662A /* OZLModelProject.h */, D5DB80C117931C8B0081662A /* OZLModelProject.m */, + 2BCF881C1793F3C8006FC859 /* OZLModelIssue.h */, + 2BCF881D1793F3C8006FC859 /* OZLModelIssue.m */, + 2BCF881F1793F478006FC859 /* OZLModelTracker.h */, + 2BCF88201793F478006FC859 /* OZLModelTracker.m */, + 2BCF88281793F4C9006FC859 /* OZLModelPriority.h */, + 2BCF88291793F4C9006FC859 /* OZLModelPriority.m */, + 2BCF882E1793F5CE006FC859 /* OZLModelUser.h */, + 2BCF882F1793F5CE006FC859 /* OZLModelUser.m */, ); name = Models; sourceTree = ""; @@ -411,6 +452,11 @@ 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 /* OZLModelStatus.m in Sources */, + 2BCF882A1793F4C9006FC859 /* OZLModelPriority.m in Sources */, + 2BCF88301793F5CE006FC859 /* OZLModelUser.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelIssue.h b/RedmineMobile/RedmineMobile/Models/OZLModelIssue.h new file mode 100644 index 0000000..371020d --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelIssue.h @@ -0,0 +1,34 @@ +// +// OZLModelIssue.h +// RedmineMobile +// +// Created by lizhijie on 7/15/13. +// Copyright (c) 2013 Lee Zhijie. All rights reserved. +// + +#import +#import "OZLModelTracker.h" +#import "OZLModelStatus.h" +#import "OZLModelUser.h" +#import "OZLModelPriority.h" + +@interface OZLModelIssue : NSObject + +@property(nonatomic) int index; +@property(nonatomic) int projectId; +@property(nonatomic) int parentIssueId; +@property(nonatomic,strong) OZLModelTracker* tracker; +@property(nonatomic,strong) OZLModelUser* author; +@property(nonatomic,strong) OZLModelUser* assignedTo; +@property(nonatomic,strong) OZLModelPriority* priority; +@property(nonatomic,strong) NSString* subject; +@property(nonatomic,strong) NSString* description; +@property(nonatomic,strong) NSString* startDate; +@property(nonatomic,strong) NSString* dueDate; +@property(nonatomic,strong) NSString* createdOn; +@property(nonatomic,strong) NSString* updatedOn; +@property(nonatomic) float doneRatio; + +-(id)initWithDictionary:(NSDictionary*)dic; + +@end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelIssue.m b/RedmineMobile/RedmineMobile/Models/OZLModelIssue.m new file mode 100644 index 0000000..74a9284 --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelIssue.m @@ -0,0 +1,68 @@ +// +// OZLModelIssue.m +// RedmineMobile +// +// Created by lizhijie on 7/15/13. +// Copyright (c) 2013 Lee Zhijie. All rights reserved. +// + +#import "OZLModelIssue.h" + +@implementation OZLModelIssue + +-(id)initWithDictionary:(NSDictionary*)dic +{ + self = [super init]; + if (!self) { + return nil; + } + +// @property(nonatomic) int index; +// @property(nonatomic) int projectId; +// @property(nonatomic) int parentIssueId; +// @property(nonatomic,strong) OZLModelTracker* tracker; +// @property(nonatomic,strong) OZLModelUser* author; +// @property(nonatomic,strong) OZLModelUser* assignedTo; +// @property(nonatomic,strong) OZLModelPriority* priority; +// @property(nonatomic,strong) NSString* subject; +// @property(nonatomic,strong) NSString* description; +// @property(nonatomic,strong) NSString* startDate; +// @property(nonatomic,strong) NSString* dueDate; +// @property(nonatomic,strong) NSString* createdOn; +// @property(nonatomic,strong) NSString* updatedOn; +// @property(nonatomic) float doneRatio; + _index = [[dic objectForKey:@"id"] intValue]; + _projectId = [[[dic objectForKey:@"project"] objectForKey:@"id"] intValue]; + id parent = [dic objectForKey:@"parent"]; + if (parent != nil) { + _parentIssueId = [[parent objectForKey:@"id"] intValue]; + }else { + _parentIssueId = -1; + } + id tracker = [dic objectForKey:@"tracker"]; + if (tracker != nil) { + _tracker = [[OZLModelTracker alloc] initWithDictionary:tracker]; + } + id author = [dic objectForKey:@"author"]; + if (author != nil) { + _author = [[OZLModelUser alloc] initWithDictionary:author]; + } + id assignedTo = [dic objectForKey:@"assigned_to"]; + if (assignedTo != nil) { + _assignedTo = [[OZLModelUser alloc] initWithDictionary:assignedTo]; + } + id priority = [dic objectForKey:@"priority"]; + if (priority != nil) { + _priority = [[OZLModelPriority alloc] initWithDictionary:priority]; + } + _subject = [dic objectForKey:@"subject"]; + _description = [dic objectForKey:@"description"]; + _startDate = [dic objectForKey:@"start_date"]; + _dueDate = [dic objectForKey:@"due_date"]; + _createdOn = [dic objectForKey:@"created_on"]; + _updatedOn = [dic objectForKey:@"updated_on"]; + _doneRatio = [[dic objectForKey:@"done_ratio"] floatValue]; + return self; +} + +@end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelPriority.h b/RedmineMobile/RedmineMobile/Models/OZLModelPriority.h new file mode 100644 index 0000000..2cb49ae --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelPriority.h @@ -0,0 +1,18 @@ +// +// OZLModelPriority.h +// RedmineMobile +// +// Created by lizhijie on 7/15/13. +// Copyright (c) 2013 Lee Zhijie. All rights reserved. +// + +#import + +@interface OZLModelPriority : NSObject + +@property(nonatomic) int index; +@property(nonatomic, strong) NSString* name; + +-(id)initWithDictionary:(NSDictionary*)dic; + +@end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelPriority.m b/RedmineMobile/RedmineMobile/Models/OZLModelPriority.m new file mode 100644 index 0000000..1be7ceb --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelPriority.m @@ -0,0 +1,26 @@ +// +// OZLModelPriority.m +// RedmineMobile +// +// Created by lizhijie on 7/15/13. +// Copyright (c) 2013 Lee Zhijie. All rights reserved. +// + +#import "OZLModelPriority.h" + +@implementation OZLModelPriority + +-(id)initWithDictionary:(NSDictionary*)dic +{ + self = [super init]; + if (!self) { + return nil; + } + + _index = [[dic objectForKey:@"id"] intValue]; + _name = [dic objectForKey:@"name"]; + + return self; +} + +@end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelProject.h b/RedmineMobile/RedmineMobile/Models/OZLModelProject.h index a6f2e79..5879d9e 100644 --- a/RedmineMobile/RedmineMobile/Models/OZLModelProject.h +++ b/RedmineMobile/RedmineMobile/Models/OZLModelProject.h @@ -38,4 +38,5 @@ @property(nonatomic,strong) NSString* updatedOn; -(id)initWithDictionary:(NSDictionary*)dic; + @end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelStatus.h b/RedmineMobile/RedmineMobile/Models/OZLModelStatus.h new file mode 100644 index 0000000..843e15e --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelStatus.h @@ -0,0 +1,18 @@ +// +// OZLModelStatus.h +// RedmineMobile +// +// Created by lizhijie on 7/15/13. +// Copyright (c) 2013 Lee Zhijie. All rights reserved. +// + +#import + +@interface OZLModelStatus : NSObject + +@property(nonatomic) int index; +@property(nonatomic, strong) NSString* name; + +-(id)initWithDictionary:(NSDictionary*)dic; + +@end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelStatus.m b/RedmineMobile/RedmineMobile/Models/OZLModelStatus.m new file mode 100644 index 0000000..e61bb57 --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelStatus.m @@ -0,0 +1,25 @@ +// +// OZLModelStatus.m +// RedmineMobile +// +// Created by lizhijie on 7/15/13. +// Copyright (c) 2013 Lee Zhijie. All rights reserved. +// + +#import "OZLModelStatus.h" + +@implementation OZLModelStatus + +-(id)initWithDictionary:(NSDictionary*)dic +{ + self = [super init]; + if (!self) { + return nil; + } + + _index = [[dic objectForKey:@"id"] intValue]; + _name = [dic objectForKey:@"name"]; + return self; +} + +@end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelTracker.h b/RedmineMobile/RedmineMobile/Models/OZLModelTracker.h new file mode 100644 index 0000000..f0b67d6 --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelTracker.h @@ -0,0 +1,18 @@ +// +// OZLModelTracker.h +// RedmineMobile +// +// Created by lizhijie on 7/15/13. +// Copyright (c) 2013 Lee Zhijie. All rights reserved. +// + +#import + +@interface OZLModelTracker : NSObject + +@property(nonatomic) int index; +@property(nonatomic, strong) NSString* name; + +-(id)initWithDictionary:(NSDictionary*)dic; + +@end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelTracker.m b/RedmineMobile/RedmineMobile/Models/OZLModelTracker.m new file mode 100644 index 0000000..0b027a0 --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelTracker.m @@ -0,0 +1,25 @@ +// +// OZLModelTracker.m +// RedmineMobile +// +// Created by lizhijie on 7/15/13. +// Copyright (c) 2013 Lee Zhijie. All rights reserved. +// + +#import "OZLModelTracker.h" + +@implementation OZLModelTracker + +-(id)initWithDictionary:(NSDictionary*)dic +{ + self = [super init]; + if (!self) { + return nil; + } + + _index = [[dic objectForKey:@"id"] intValue]; + _name = [dic objectForKey:@"name"]; + + return self; +} +@end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelUser.h b/RedmineMobile/RedmineMobile/Models/OZLModelUser.h new file mode 100644 index 0000000..a2ea548 --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelUser.h @@ -0,0 +1,18 @@ +// +// OZLModelUser.h +// RedmineMobile +// +// Created by lizhijie on 7/15/13. +// Copyright (c) 2013 Lee Zhijie. All rights reserved. +// + +#import + +@interface OZLModelUser : NSObject + +@property(nonatomic) int index; +@property(nonatomic, strong) NSString* name; + +-(id)initWithDictionary:(NSDictionary*)dic; + +@end diff --git a/RedmineMobile/RedmineMobile/Models/OZLModelUser.m b/RedmineMobile/RedmineMobile/Models/OZLModelUser.m new file mode 100644 index 0000000..ea313b6 --- /dev/null +++ b/RedmineMobile/RedmineMobile/Models/OZLModelUser.m @@ -0,0 +1,26 @@ +// +// OZLModelUser.m +// RedmineMobile +// +// Created by lizhijie on 7/15/13. +// Copyright (c) 2013 Lee Zhijie. All rights reserved. +// + +#import "OZLModelUser.h" + +@implementation OZLModelUser + +-(id)initWithDictionary:(NSDictionary*)dic +{ + self = [super init]; + if (!self) { + return nil; + } + + _index = [[dic objectForKey:@"id"] intValue]; + _name = [dic objectForKey:@"name"]; + + return self; +} + +@end diff --git a/RedmineMobile/RedmineMobile/Utils/OZLNetwork.h b/RedmineMobile/RedmineMobile/Utils/OZLNetwork.h index b99d624..476b8af 100644 --- a/RedmineMobile/RedmineMobile/Utils/OZLNetwork.h +++ b/RedmineMobile/RedmineMobile/Utils/OZLNetwork.h @@ -28,6 +28,11 @@ #import #import "OZLModelProject.h" +#import "OZLModelIssue.h" +#import "OZLModelPriority.h" +#import "OZLModelStatus.h" +#import "OZLModelTracker.h" +#import "OZLModelUser.h" @interface OZLNetwork : NSObject @@ -35,4 +40,8 @@ +(void)getProjectListWithParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block; +(void)getDetailForProject:(int)projectid withParams:(NSDictionary*)params andBlock:(void (^)(OZLModelProject *result, NSError *error))block; +// issue ++(void)getIssueListForProject:(int)projectid withParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block; ++(void)getDetailFoIssue:(int)issueid withParams:(NSDictionary*)params andBlock:(void (^)(OZLModelIssue *result, NSError *error))block; + @end diff --git a/RedmineMobile/RedmineMobile/Utils/OZLNetwork.m b/RedmineMobile/RedmineMobile/Utils/OZLNetwork.m index 40f39ce..0e9d552 100644 --- a/RedmineMobile/RedmineMobile/Utils/OZLNetwork.m +++ b/RedmineMobile/RedmineMobile/Utils/OZLNetwork.m @@ -30,7 +30,6 @@ #import "OZLNetworkBase.h" #import "AFHTTPRequestOperation.h" #import "JSONKit.h" -#import "OZLModelProject.h" @implementation OZLNetwork @@ -86,4 +85,58 @@ }]; } ++(void)getIssueListForProject:(int)projectid withParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block +{ + NSString* path = [NSString stringWithFormat:@"/issues.json"]; + NSMutableDictionary* dic = [[NSMutableDictionary alloc] initWithDictionary:params]; + [dic setObject:[NSNumber numberWithInt:projectid] forKey:@"project_id"]; + + [[OZLNetworkBase sharedClient] getPath:path parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject) { + + if (block) { + NSLog(@"the repsonse:%@",responseObject); + + NSMutableArray* issues = [[NSMutableArray alloc] init]; + + NSArray* issuesDic = [responseObject objectForKey:@"issues"]; + for (NSDictionary* p in issuesDic) { + [issues addObject:[[OZLModelIssue alloc] initWithDictionary:p]]; + } + block(issues,nil); + } + + + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + + if (block) { + block([NSArray array], error); + } + + }]; +} + ++(void)getDetailFoIssue:(int)issueid withParams:(NSDictionary*)params andBlock:(void (^)(OZLModelIssue *result, NSError *error))block +{ + NSString* path = [NSString stringWithFormat:@"/issues/%d.json",issueid]; + [[OZLNetworkBase sharedClient] getPath:path parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + + if (block) { + NSLog(@"the repsonse:%@",responseObject); + + NSDictionary* projectDic = [responseObject objectForKey:@"issue"]; + OZLModelIssue* issue = [[OZLModelIssue alloc] initWithDictionary:projectDic]; + + block(issue,nil); + } + + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + + + if (block) { + block([NSArray array], error); + } + + }]; +} + @end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.m index d00ba53..9429daf 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.m @@ -61,6 +61,10 @@ _HUD = [[MBProgressHUD alloc] initWithView:self.view]; [self.view addSubview:_HUD]; _HUD.labelText = @"Refreshing..."; + + + UIBarButtonItem* accountBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:self action:@selector(showAccountView:)]; + [self.navigationItem setLeftBarButtonItem:accountBtn]; } -(void) viewWillAppear:(BOOL)animated diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.xib b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.xib index dfd642c..8f9cb11 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.xib +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.xib @@ -2,18 +2,19 @@ 1552 - 12E55 + 11G63 3084 - 1187.39 - 626.00 + 1138.51 + 569.00 com.apple.InterfaceBuilder.IBCocoaTouchPlugin 2083 IBProxyObject - IBUIButton + IBUIBarButtonItem IBUITableView + IBUIToolbar IBUIView @@ -36,48 +37,17 @@ 274 - - - 292 - {320, 44} - - - _NS:9 - NO - IBCocoaTouchFramework - 0 - 0 - 1 - Account - - 3 - MQA - - - 1 - MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA - - - 3 - MC41AA - - - 2 - 15 - - - Helvetica-Bold - 15 - 16 - - 274 - {{0, 45}, {320, 503}} + {320, 460} + _NS:9 - + + 3 + MQA + YES IBCocoaTouchFramework YES @@ -88,10 +58,30 @@ 22 22 + + + 266 + {{0, 460}, {320, 44}} + + + _NS:9 + NO + NO + IBCocoaTouchFramework + + + IBCocoaTouchFramework + 1 + + 4 + + + - {{0, 20}, {320, 548}} + {{0, 64}, {320, 504}} - + + 3 MQA @@ -100,6 +90,9 @@ + + NO + IBUIScreenMetrics @@ -138,15 +131,6 @@ 20 - - - showAccountView: - - - 7 - - 17 - @@ -160,8 +144,8 @@ 1 - + @@ -176,18 +160,25 @@ - - 4 - - - - 9 + + 21 + + + + + + + + 22 + + + @@ -196,16 +187,50 @@ 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 - 20 + 22 + + + + + OZLProjectListViewController + UIViewController + + showAccountView: + id + + + showAccountView: + + showAccountView: + id + + + + projectsTableview + UITableView + + + projectsTableview + + projectsTableview + UITableView + + + + IBProjectSource + ./Classes/OZLProjectListViewController.h + + + - 0 IBCocoaTouchFramework YES diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.h b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.h index 0e70084..06029b5 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.h +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.h @@ -30,5 +30,6 @@ #import "OZLModelProject.h" @interface OZLProjectViewController : UIViewController +@property (weak, nonatomic) IBOutlet UITableView *issuesTableview; @property (nonatomic,strong) OZLModelProject* projectData; @end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m index 46806f3..44a2ada 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m @@ -35,6 +35,8 @@ @interface OZLProjectViewController () { + NSArray* _issuesList; + float _sideviewOffset; MBProgressHUD * _HUD; } @@ -80,7 +82,14 @@ _projectData = result; [self.navigationItem setTitle:_projectData.name]; - [_HUD hide:YES]; + // load issues + [OZLNetwork getIssueListForProject:_projectData.index withParams:nil andBlock:^(NSArray *result, NSError *error) { + _issuesList = result; + + [_issuesTableview reloadData]; + [_HUD hide:YES]; + }]; + }]; } @@ -131,4 +140,93 @@ // Dispose of any resources that can be recreated. } +- (void)viewDidUnload { + [self setIssuesTableview:nil]; + [super viewDidUnload]; +} + + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + + // Return the number of sections. + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + + // Return the number of rows in the section. + return [_issuesList count]; +} + +-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath +{ + return 44; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + NSString* cellidentifier = [NSString stringWithFormat:@"issue_cell_id"]; + UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellidentifier]; + if (!cell) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellidentifier]; + } + OZLModelIssue* issue = [_issuesList objectAtIndex:indexPath.row]; + cell.textLabel.text = issue.subject; + cell.detailTextLabel.text = issue.description; + 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 +{ + +// [self showProjectView:[_issuesList objectAtIndex:indexPath.row]]; + +} + + @end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.xib b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.xib index f766380..052ced7 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.xib +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.xib @@ -37,11 +37,12 @@ 274 - + 274 {320, 460} + _NS:9 3 @@ -57,7 +58,7 @@ 22 22 - + 266 {{0, 460}, {320, 44}} @@ -67,17 +68,18 @@ NO IBCocoaTouchFramework - - Item + IBCocoaTouchFramework 1 - + + 4 {{0, 64}, {320, 504}} + 3 MQA @@ -119,6 +121,30 @@ 3 + + + issuesTableview + + + + 9 + + + + dataSource + + + + 10 + + + + delegate + + + + 11 + @@ -132,8 +158,8 @@ 1 - - + + @@ -150,20 +176,20 @@ 6 - + - + 7 - - + + 8 - + @@ -182,7 +208,7 @@ - 8 + 11 0