22
22
#import " WebViewController.h"
23
23
#import " ProjectToChooseListViewController.h"
24
24
#import " EditLabelViewController.h"
25
+ #import " TaskResourceReferenceViewController.h"
25
26
26
27
@interface EditTaskViewController ()<TTTAttributedLabelDelegate>
27
28
@property (strong , nonatomic ) UITableView *myTableView;
@@ -164,7 +165,7 @@ - (void)queryToRefreshActivityList{
164
165
[[Coding_NetAPIManager sharedManager ] request_ActivityListOfTask: _myCopyTask andBlock: ^(id data, NSError *error) {
165
166
if (data) {
166
167
weakSelf.myCopyTask .activityList = data;
167
- [weakSelf.myTableView reloadSections: [ NSIndexSet indexSetWithIndex: 2 ] withRowAnimation: UITableViewRowAnimationAutomatic ];
168
+ [weakSelf.myTableView reloadData ];
168
169
};
169
170
}];
170
171
}
@@ -182,13 +183,23 @@ - (void)queryToRefreshTaskDetail{
182
183
[weakSelf configTitle ];
183
184
184
185
[weakSelf.myTableView reloadData ];
186
+ [weakSelf queryToRefreshResourceReference ];
185
187
[weakSelf queryToRefreshActivityList ];
186
188
}else if ([[[error.userInfo objectForKey: @" msg" ] allKeys ] containsObject: @" task_not_exist" ]){
187
189
[self .navigationItem setRightBarButtonItem: nil animated: YES ];
188
190
}
189
191
}];
190
192
}
191
193
194
+ - (void )queryToRefreshResourceReference {
195
+ __weak typeof (self) weakSelf = self;
196
+ [[Coding_NetAPIManager sharedManager ] request_TaskResourceReference: _myTask andBlock: ^(id data, NSError *error) {
197
+ if (data) {
198
+ _myTask.resourceReference = data;
199
+ [weakSelf.myTableView reloadData ];
200
+ }
201
+ }];
202
+ }
192
203
#pragma mark Mine M
193
204
- (void )doneBtnClicked {
194
205
if (_myCopyTask.isRequesting ) {
@@ -281,7 +292,7 @@ - (void)deleteComment:(TaskComment *)comment{
281
292
}
282
293
#pragma mark Table M
283
294
- (NSInteger )numberOfSectionsInTableView : (UITableView *)tableView {
284
- return (self.myCopyTask .handleType > TaskHandleTypeEdit)? 2 : 3 ;
295
+ return (self.myCopyTask .handleType > TaskHandleTypeEdit)? 2 : self. myTask . resourceReference . itemList . count > 0 ? 4 : 3 ;
285
296
}
286
297
- (NSInteger )tableView : (UITableView *)tableView numberOfRowsInSection : (NSInteger )section {
287
298
NSInteger row = 0 ;
@@ -290,6 +301,8 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
290
301
}else if (section == 1 ){
291
302
TaskHandleType handleType = self.myCopyTask .handleType ;
292
303
row = handleType == TaskHandleTypeEdit? 5 : handleType == TaskHandleTypeAddWithProject? 4 : 5 ;
304
+ }else if (section == 2 && _myTask.resourceReference .itemList .count > 0 ){
305
+ row = 1 ;
293
306
}else {
294
307
row = self.myCopyTask .activityList .count ;
295
308
}
@@ -361,6 +374,12 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
361
374
cell.backgroundColor = kColorTableBG ;
362
375
[tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: 60 ];
363
376
return cell;
377
+ }else if (indexPath.section == 2 && _myTask.resourceReference .itemList .count > 0 ){
378
+ LeftImage_LRTextCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_LeftImage_LRText forIndexPath: indexPath];
379
+ [cell setObj: _myTask type: LeftImage_LRTextCellTypeTaskResourceReference];
380
+ cell.backgroundColor = kColorTableBG ;
381
+ [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: 60 ];
382
+ return cell;
364
383
}else {
365
384
ProjectActivity *curActivity = [self .myCopyTask.activityList objectAtIndex: indexPath.row];
366
385
if ([curActivity.target_type isEqualToString: @" TaskComment" ]) {
@@ -376,7 +395,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
376
395
cell.contentLabel .delegate = self;
377
396
[cell configTop: (indexPath.row == 0 ) andBottom: (indexPath.row == _myCopyTask.activityList.count - 1 )];
378
397
cell.backgroundColor = kColorTableBG ;
379
- // [tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:60];
380
398
return cell;
381
399
}else {
382
400
TaskActivityCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_TaskActivityCell forIndexPath: indexPath];
@@ -398,6 +416,8 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
398
416
}
399
417
}else if (indexPath.section == 1 ){
400
418
cellHeight = [LeftImage_LRTextCell cellHeight ];
419
+ }else if (indexPath.section == 2 && _myTask.resourceReference .itemList .count > 0 ){
420
+ cellHeight = [LeftImage_LRTextCell cellHeight ];
401
421
}else if (self.myCopyTask .activityList .count > indexPath.row ){
402
422
ProjectActivity *curActivity = [self .myCopyTask.activityList objectAtIndex: indexPath.row];
403
423
if ([curActivity.target_type isEqualToString: @" TaskComment" ]) {
@@ -413,8 +433,6 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
413
433
- (CGFloat )tableView : (UITableView *)tableView heightForHeaderInSection : (NSInteger )section {
414
434
if (section == 0 ) {
415
435
return 0.5 ;
416
- }else if (section == 3 ){
417
- return 0.5 ;
418
436
}else {
419
437
return 20.0 ;
420
438
}
@@ -427,28 +445,13 @@ - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSIntege
427
445
- (UIView *)tableView : (UITableView *)tableView viewForHeaderInSection : (NSInteger )section {
428
446
UIView *headerView = [[UIView alloc ] initWithFrame: CGRectMake (0 , 0 , kScreen_Width , 1 )];
429
447
headerView.backgroundColor = kColorTableSectionBg ;
430
- if (section == 0 ) {
431
- [headerView setHeight: 30.0 ];
432
- }else if (section == 3 ){
433
- headerView.backgroundColor = [UIColor whiteColor ];
434
- [headerView setHeight: 1.0 ];
435
- }else {
436
- [headerView setHeight: 20 ];
437
- }
438
448
return headerView;
439
449
}
440
450
441
451
- (void )tableView : (UITableView *)tableView didSelectRowAtIndexPath : (NSIndexPath *)indexPath {
442
452
[tableView deselectRowAtIndexPath: indexPath animated: YES ];
443
453
ESWeakSelf;
444
454
if (indexPath.section == 0 ) {
445
- // if (indexPath.row != 0) {
446
- // if (self.myCopyTask.has_description.boolValue && !self.myCopyTask.task_description) {
447
- // //描述内容 还没有加载成功
448
- // return ;
449
- // }
450
- // [self goToDescriptionVC];
451
- // }
452
455
}else if (indexPath.section == 1 ){
453
456
LeftImage_LRTextCellType cellType = _myCopyTask.handleType == TaskHandleTypeAddWithoutProject? indexPath.row : indexPath.row +1 ;
454
457
if (cellType == LeftImage_LRTextCellTypeTaskProject) {
@@ -522,6 +525,10 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
522
525
vc.curTask = _myCopyTask;
523
526
[self .navigationController pushViewController: vc animated: YES ];
524
527
}
528
+ }else if (indexPath.section == 2 && _myTask.resourceReference .itemList .count > 0 ){
529
+ TaskResourceReferenceViewController *vc = [TaskResourceReferenceViewController new ];
530
+ vc.curTask = _myTask;
531
+ [self .navigationController pushViewController: vc animated: YES ];
525
532
}else {
526
533
ProjectActivity *curActivity = [self .myCopyTask.activityList objectAtIndex: indexPath.row];
527
534
if ([curActivity.target_type isEqualToString: @" TaskComment" ]) {
@@ -549,6 +556,7 @@ - (void)goToDescriptionVC{
549
556
_self.taskChangedBlock ();
550
557
}
551
558
[_self.myTableView reloadData ];
559
+ [_self queryToRefreshResourceReference ];
552
560
};
553
561
[self .navigationController pushViewController: vc animated: YES ];
554
562
}
0 commit comments