issue list sort function done, but filter is not finished yet

filter is not finished because some parameters of Remine REST are not
clear
This commit is contained in:
zhijie 2013-07-19 15:53:29 +08:00
parent 059a1aad12
commit 3b7bc1644e
7 changed files with 173 additions and 67 deletions

View File

@ -38,6 +38,11 @@
@property(nonatomic,strong) NSString* redmineUserName;
@property(nonatomic,strong) NSString* redminePassword;
// issue list option
@property(nonatomic) int issueListFilterType;
@property(nonatomic) int issueListSortType;
@property(nonatomic) int issueListSortAscending;
//app status
@property(nonatomic) int lastProjectID;// last viewed project id

View File

@ -37,6 +37,11 @@ NSString* USER_DEFUALTS_LAST_PROJECT_ID = @"USER_DEFUALTS_LAST_PROJECT_ID";
NSString* USER_DEFUALTS_REDMINE_USER_NAME = @"USER_DEFUALTS_REDMINE_USER_NAME";
NSString* USER_DEFUALTS_REDMINE_PASSWORD = @"USER_DEFUALTS_REDMINE_PASSWORD";
//issue list option
NSString* USER_DEFAULTS_ISSUE_LIST_ASCEND = @"USER_DEFUALTS_ISSUE_LIST_ASCEND";// ascend or descend
NSString* USER_DEFAULTS_ISSUE_LIST_FILTER = @"USER_DEFAULTS_ISSUE_LIST_FILTER";
NSString* USER_DEFAULTS_ISSUE_LIST_SORT = @"USER_DEFAULTS_ISSUE_LIST_SORT";
static OZLSingleton* sharedInstance = nil;
+(OZLSingleton*) sharedInstance
{
@ -50,6 +55,9 @@ static OZLSingleton* sharedInstance = nil;
[NSNumber numberWithInt:-1],USER_DEFUALTS_LAST_PROJECT_ID,
@"",USER_DEFUALTS_REDMINE_USER_NAME,
@"",USER_DEFUALTS_REDMINE_PASSWORD,
[NSNumber numberWithInt:0],USER_DEFAULTS_ISSUE_LIST_FILTER,
[NSNumber numberWithInt:0],USER_DEFAULTS_ISSUE_LIST_SORT,
[NSNumber numberWithInt:0],USER_DEFAULTS_ISSUE_LIST_ASCEND,
nil];
[defaults registerDefaults:dic];
}
@ -116,4 +124,40 @@ static OZLSingleton* sharedInstance = nil;
[userdefaults setObject:redminePassword forKey:USER_DEFUALTS_REDMINE_PASSWORD];
[userdefaults synchronize];
}
-(int)issueListFilterType
{
NSUserDefaults* userdefaults = [NSUserDefaults standardUserDefaults];
return [[userdefaults objectForKey:USER_DEFAULTS_ISSUE_LIST_FILTER] intValue];
}
-(void)setIssueListFilterType:(int)issueListFilterType
{
NSUserDefaults* userdefaults = [NSUserDefaults standardUserDefaults];
[userdefaults setObject:[NSNumber numberWithInt:issueListFilterType] forKey:USER_DEFAULTS_ISSUE_LIST_FILTER];
[userdefaults synchronize];
}
-(int)issueListSortAscending
{
NSUserDefaults* userdefaults = [NSUserDefaults standardUserDefaults];
return [[userdefaults objectForKey:USER_DEFAULTS_ISSUE_LIST_ASCEND] intValue];
}
-(void)setIssueListSortAscending:(int)issueListSortAscending
{
NSUserDefaults* userdefaults = [NSUserDefaults standardUserDefaults];
[userdefaults setObject:[NSNumber numberWithInt:issueListSortAscending] forKey:USER_DEFAULTS_ISSUE_LIST_ASCEND];
[userdefaults synchronize];
}
-(int)issueListSortType
{
NSUserDefaults* userdefaults = [NSUserDefaults standardUserDefaults];
return [[userdefaults objectForKey:USER_DEFAULTS_ISSUE_LIST_SORT] intValue];
}
-(void)setIssueListSortType:(int)issueListSortType
{
NSUserDefaults* userdefaults = [NSUserDefaults standardUserDefaults];
[userdefaults setObject:[NSNumber numberWithInt:issueListSortType] forKey:USER_DEFAULTS_ISSUE_LIST_SORT];
[userdefaults synchronize];
}
@end

View File

@ -34,6 +34,12 @@
- (IBAction)onCancel:(id)sender;
- (IBAction)onSave:(id)sender;
@property (weak, nonatomic) NSArray* trackerList;
@property (weak, nonatomic) NSArray* priorityList;
@property (weak, nonatomic) NSArray* statusList;
@property (weak, nonatomic) NSArray* userList;
// neccessory
@property (weak, nonatomic) IBOutlet UITextField *subjectTextField;
@property (weak, nonatomic) IBOutlet UILabel *trackerLabel;

View File

@ -36,10 +36,6 @@
#import "MLTableAlert.h"
@interface OZLIssueCreateViewController () {
NSArray* _trackerList;
NSArray* _priorityList;
NSArray* _statusList;
NSArray* _userList;
OZLModelTracker* _currentTracker;
OZLModelIssuePriority* _currentPriority;
@ -82,7 +78,6 @@
[self.view addSubview:_HUD];
_HUD.labelText = @"Loading...";
[self loadIssueRelatedData];
}
-(void) setupInputviews
@ -123,61 +118,6 @@
_doneProgressLabel.delegate = self;
}
-(void)loadIssueRelatedData
{
static int doneCount = 0;
[_HUD show:YES];
[OZLNetwork getTrackerListWithParams:nil andBlock:^(NSArray *result, NSError *error) {
if (!error) {
_trackerList = result;
}else {
NSLog(@"get tracker list error : %@",error.description);
}
doneCount ++;
if (doneCount == 4) {
[_HUD hide:YES];
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 == 4) {
[_HUD hide:YES];
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 == 4) {
[_HUD hide:YES];
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 == 4) {
[_HUD hide:YES];
doneCount = 0;
}
}];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];

View File

@ -27,6 +27,7 @@
// THE SOFTWARE.
#import "OZLIssueFilterViewController.h"
#import "OZLSingleton.h"
@interface OZLIssueFilterViewController () {
NSArray* _cellArray;
@ -62,9 +63,10 @@
@[@"Ascending", @"Descending"]];
_headerArray = @[@"Filter by", @"Sort by", @""];
_checkedCell[0] = 0;
_checkedCell[1] = 0;
_checkedCell[2] = 0;
OZLSingleton* singleton =[OZLSingleton sharedInstance];
_checkedCell[0] = [singleton issueListFilterType];
_checkedCell[1] = [singleton issueListSortType];
_checkedCell[2] = [singleton issueListSortAscending];
}
-(void) onCancel:(id)sender
@ -74,7 +76,14 @@
-(void) onSave:(id) sender
{
OZLSingleton* singleton =[OZLSingleton sharedInstance];
[singleton setIssueListFilterType:_checkedCell[0]];
[singleton setIssueListSortType:_checkedCell[1]];
[singleton setIssueListSortAscending:_checkedCell[2]];
[self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning
@ -123,6 +132,7 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
_checkedCell[indexPath.section] = indexPath.row;
[self.tableView reloadData];
}

View File

@ -35,4 +35,10 @@
- (IBAction)onNewIssue:(id)sender;
- (IBAction)onSortSetting:(id)sender;
@property (weak, nonatomic) NSArray* trackerList;
@property (weak, nonatomic) NSArray* priorityList;
@property (weak, nonatomic) NSArray* statusList;
@property (weak, nonatomic) NSArray* userList;
@end

View File

@ -43,6 +43,8 @@
float _sideviewOffset;
MBProgressHUD * _HUD;
NSMutableDictionary* _issueListOption;
}
@end
@ -71,7 +73,7 @@
_HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:_HUD];
_HUD.labelText = @"Loading...";
[[OZLSingleton sharedInstance] setLastProjectID:_projectData.index];
}
@ -87,6 +89,38 @@
return;
}
[_HUD show:YES];
if (_issueListOption == nil) {
[self loadIssueRelatedData];
}else {
[self loadProjectDetail];
}
}
-(void)loadProjectDetail
{
// TODO: issue filter not working yet
// prepare parameters
OZLSingleton* singleton = [OZLSingleton sharedInstance];
// meaning of these values is defined in OZLIssueFilterViewController
int filterType = [singleton issueListFilterType];
int sortType = [singleton issueListSortType];
int scendingType = [singleton issueListSortAscending];
if (filterType == 0) {// assigned to me
// TODO:
}else if(filterType == 1) {// open
[_issueListOption setObject:@"open" forKey:@"status_id"];
}else if(filterType == 2) {// reported by me
// TODO:
}
NSArray* sortCol = @[@"id",@"tracker",@"status",@"priority",@"category",@"assigned_to_id",@"fixed_version",@"start_date",@"due_date",@"estimated_hours",@"done_ratio",@"updated_on"];
NSString* sortstring = [NSString stringWithFormat:@"%@%@",[sortCol objectAtIndex:sortType],(scendingType == 0 ? @"" : @":desc")];
[_issueListOption setObject:sortstring forKey:@"sort"];
[OZLNetwork getDetailForProject:_projectData.index withParams:nil andBlock:^(OZLModelProject *result, NSError *error) {
if (error) {
NSLog(@"error getDetailForProject: %@",error.description);
@ -94,9 +128,9 @@
}else {
_projectData = result;
[self.navigationItem setTitle:_projectData.name];
// load issues
[OZLNetwork getIssueListForProject:_projectData.index withParams:nil andBlock:^(NSArray *result, NSError *error) {
[OZLNetwork getIssueListForProject:_projectData.index withParams:_issueListOption andBlock:^(NSArray *result, NSError *error) {
if (error) {
NSLog(@"error getIssueListForProject: %@",error.description);
}else {
@ -110,6 +144,63 @@
}];
}
-(void)loadIssueRelatedData
{
_issueListOption = [[NSMutableDictionary alloc] init];
static int doneCount = 0;
[OZLNetwork getTrackerListWithParams:nil andBlock:^(NSArray *result, NSError *error) {
if (!error) {
_trackerList = result;
}else {
NSLog(@"get tracker list error : %@",error.description);
}
doneCount ++;
if (doneCount == 4) {
[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 == 4) {
[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 == 4) {
[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 == 4) {
[self loadProjectDetail];
doneCount = 0;
}
}];
}
- (void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
// [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(preloadLeft) object:nil];
@ -257,6 +348,10 @@
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];
}