update issue functionality done
This commit is contained in:
parent
d58b8f73ed
commit
0c5986735b
|
@ -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
|
||||
|
|
|
@ -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 @"";
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@
|
|||
</view>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" textLabel="O9o-aN-GPb" rowHeight="44" style="IBUITableViewCellStyleDefault" id="tiZ-Xc-Edh">
|
||||
<rect key="frame" x="0.0" y="363" width="320" height="45"/>
|
||||
<rect key="frame" x="0.0" y="363" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="10" y="0.0" width="280" height="43"/>
|
||||
|
@ -198,6 +198,24 @@
|
|||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" textLabel="Bwr-O8-sLJ" rowHeight="44" style="IBUITableViewCellStyleDefault" id="UBR-Vr-trT">
|
||||
<rect key="frame" x="0.0" y="407" width="320" height="45"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="10" y="0.0" width="280" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Update" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Bwr-O8-sLJ">
|
||||
<rect key="frame" x="10" y="0.0" width="260" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
</sections>
|
||||
|
@ -224,22 +242,6 @@
|
|||
<point key="canvasLocation" x="-99" y="-142"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<classes>
|
||||
<class className="OZLIssueDetailViewController" superclassName="UITableViewController">
|
||||
<source key="sourceIdentifier" type="project" relativePath="./Classes/OZLIssueDetailViewController.h"/>
|
||||
<relationships>
|
||||
<relationship kind="outlet" name="assignedTo" candidateClass="UILabel"/>
|
||||
<relationship kind="outlet" name="author" candidateClass="UILabel"/>
|
||||
<relationship kind="outlet" name="description" candidateClass="UILabel"/>
|
||||
<relationship kind="outlet" name="dueTime" candidateClass="UILabel"/>
|
||||
<relationship kind="outlet" name="priority" candidateClass="UILabel"/>
|
||||
<relationship kind="outlet" name="progressbar" candidateClass="UIProgressView"/>
|
||||
<relationship kind="outlet" name="startTime" candidateClass="UILabel"/>
|
||||
<relationship kind="outlet" name="status" candidateClass="UILabel"/>
|
||||
<relationship kind="outlet" name="subject" candidateClass="UILabel"/>
|
||||
</relationships>
|
||||
</class>
|
||||
</classes>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar"/>
|
||||
<simulatedOrientationMetrics key="orientation"/>
|
||||
|
|
Loading…
Reference in New Issue