Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a9e4ed0

Browse files
任务 - 关联资源
1 parent 3b45f33 commit a9e4ed0

24 files changed

+394
-21
lines changed

‎Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 66 additions & 0 deletions
Large diffs are not rendered by default.

‎Coding_iOS/Controllers/EditTaskViewController.m

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#import "WebViewController.h"
2323
#import "ProjectToChooseListViewController.h"
2424
#import "EditLabelViewController.h"
25+
#import "TaskResourceReferenceViewController.h"
2526

2627
@interface EditTaskViewController ()<TTTAttributedLabelDelegate>
2728
@property (strong, nonatomic) UITableView *myTableView;
@@ -164,7 +165,7 @@ - (void)queryToRefreshActivityList{
164165
[[Coding_NetAPIManager sharedManager] request_ActivityListOfTask:_myCopyTask andBlock:^(id data, NSError *error) {
165166
if (data) {
166167
weakSelf.myCopyTask.activityList = data;
167-
[weakSelf.myTableView reloadSections:[NSIndexSetindexSetWithIndex:2] withRowAnimation:UITableViewRowAnimationAutomatic];
168+
[weakSelf.myTableView reloadData];
168169
};
169170
}];
170171
}
@@ -182,13 +183,23 @@ - (void)queryToRefreshTaskDetail{
182183
[weakSelf configTitle];
183184

184185
[weakSelf.myTableView reloadData];
186+
[weakSelf queryToRefreshResourceReference];
185187
[weakSelf queryToRefreshActivityList];
186188
}else if ([[[error.userInfo objectForKey:@"msg"] allKeys] containsObject:@"task_not_exist"]){
187189
[self.navigationItem setRightBarButtonItem:nil animated:YES];
188190
}
189191
}];
190192
}
191193

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+
}
192203
#pragma mark Mine M
193204
- (void)doneBtnClicked{
194205
if (_myCopyTask.isRequesting) {
@@ -281,7 +292,7 @@ - (void)deleteComment:(TaskComment *)comment{
281292
}
282293
#pragma mark Table M
283294
- (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;
285296
}
286297
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
287298
NSInteger row = 0;
@@ -290,6 +301,8 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
290301
}else if (section == 1){
291302
TaskHandleType handleType = self.myCopyTask.handleType;
292303
row = handleType == TaskHandleTypeEdit? 5: handleType == TaskHandleTypeAddWithProject? 4: 5;
304+
}else if (section == 2 && _myTask.resourceReference.itemList.count > 0){
305+
row = 1;
293306
}else{
294307
row = self.myCopyTask.activityList.count;
295308
}
@@ -361,6 +374,12 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
361374
cell.backgroundColor = kColorTableBG;
362375
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:60];
363376
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;
364383
}else{
365384
ProjectActivity *curActivity = [self.myCopyTask.activityList objectAtIndex:indexPath.row];
366385
if ([curActivity.target_type isEqualToString:@"TaskComment"]) {
@@ -376,7 +395,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
376395
cell.contentLabel.delegate = self;
377396
[cell configTop:(indexPath.row == 0) andBottom:(indexPath.row == _myCopyTask.activityList.count - 1)];
378397
cell.backgroundColor = kColorTableBG;
379-
// [tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:60];
380398
return cell;
381399
}else{
382400
TaskActivityCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TaskActivityCell forIndexPath:indexPath];
@@ -398,6 +416,8 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
398416
}
399417
}else if (indexPath.section == 1){
400418
cellHeight = [LeftImage_LRTextCell cellHeight];
419+
}else if (indexPath.section == 2 && _myTask.resourceReference.itemList.count > 0){
420+
cellHeight = [LeftImage_LRTextCell cellHeight];
401421
}else if (self.myCopyTask.activityList.count > indexPath.row){
402422
ProjectActivity *curActivity = [self.myCopyTask.activityList objectAtIndex:indexPath.row];
403423
if ([curActivity.target_type isEqualToString:@"TaskComment"]) {
@@ -413,8 +433,6 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
413433
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
414434
if (section == 0) {
415435
return 0.5;
416-
}else if (section == 3){
417-
return 0.5;
418436
}else{
419437
return 20.0;
420438
}
@@ -427,28 +445,13 @@ - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSIntege
427445
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
428446
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 1)];
429447
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-
}
438448
return headerView;
439449
}
440450

441451
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
442452
[tableView deselectRowAtIndexPath:indexPath animated:YES];
443453
ESWeakSelf;
444454
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-
// }
452455
}else if (indexPath.section == 1){
453456
LeftImage_LRTextCellType cellType = _myCopyTask.handleType == TaskHandleTypeAddWithoutProject? indexPath.row : indexPath.row +1;
454457
if (cellType == LeftImage_LRTextCellTypeTaskProject) {
@@ -522,6 +525,10 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
522525
vc.curTask = _myCopyTask;
523526
[self.navigationController pushViewController:vc animated:YES];
524527
}
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];
525532
}else {
526533
ProjectActivity *curActivity = [self.myCopyTask.activityList objectAtIndex:indexPath.row];
527534
if ([curActivity.target_type isEqualToString:@"TaskComment"]) {
@@ -549,6 +556,7 @@ - (void)goToDescriptionVC{
549556
_self.taskChangedBlock();
550557
}
551558
[_self.myTableView reloadData];
559+
[_self queryToRefreshResourceReference];
552560
};
553561
[self.navigationController pushViewController:vc animated:YES];
554562
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// TaskResourceReferenceViewController.h
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 16/2/23.
6+
// Copyright © 2016年 Coding. All rights reserved.
7+
//
8+
9+
#import "BaseViewController.h"
10+
#import "Task.h"
11+
12+
@interface TaskResourceReferenceViewController : BaseViewController
13+
@property (strong, nonatomic) Task *curTask;
14+
@end
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
//
2+
// TaskResourceReferenceViewController.m
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 16/2/23.
6+
// Copyright © 2016年 Coding. All rights reserved.
7+
//
8+
9+
#import "TaskResourceReferenceViewController.h"
10+
#import "TaskResourceReferenceCell.h"
11+
#import "Coding_NetAPIManager.h"
12+
13+
@interface TaskResourceReferenceViewController ()<UITableViewDataSource, UITableViewDelegate>
14+
@property (nonatomic, strong) UITableView *myTableView;
15+
16+
@end
17+
18+
@implementation TaskResourceReferenceViewController
19+
20+
- (void)viewDidLoad {
21+
[super viewDidLoad];
22+
// Do any additional setup after loading the view.
23+
// 添加myTableView
24+
_myTableView = ({
25+
UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
26+
tableView.backgroundColor = [UIColor clearColor];
27+
tableView.dataSource = self;
28+
tableView.delegate = self;
29+
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
30+
[tableView registerClass:[TaskResourceReferenceCell class] forCellReuseIdentifier:kCellIdentifier_TaskResourceReferenceCell];
31+
[self.view addSubview:tableView];
32+
[tableView mas_makeConstraints:^(MASConstraintMaker *make) {
33+
make.edges.equalTo(self.view);
34+
}];
35+
tableView;
36+
});
37+
38+
}
39+
40+
#pragma mark Table M
41+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
42+
return _curTask.resourceReference.itemList.count;
43+
}
44+
45+
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
46+
TaskResourceReferenceCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TaskResourceReferenceCell forIndexPath:indexPath];
47+
cell.item = _curTask.resourceReference.itemList[indexPath.row];
48+
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:45];
49+
return cell;
50+
}
51+
52+
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
53+
[tableView deselectRowAtIndexPath:indexPath animated:YES];
54+
ResourceReferenceItem *item = _curTask.resourceReference.itemList[indexPath.row];
55+
[self goToItem:item];
56+
}
57+
58+
#pragma mark Table M - Edit
59+
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
60+
return YES;
61+
}
62+
63+
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
64+
if (editingStyle == UITableViewCellEditingStyleDelete) {
65+
ResourceReferenceItem *item = _curTask.resourceReference.itemList[indexPath.row];
66+
67+
__weak typeof(self) weakSelf = self;
68+
UIActionSheet *actionSheet = [UIActionSheet bk_actionSheetCustomWithTitle:[NSString stringWithFormat:@"确定取消关联:%@", item.title] buttonTitles:nil destructiveTitle:@"确定" cancelTitle:@"取消" andDidDismissBlock:^(UIActionSheet *sheet, NSInteger index) {
69+
if (index == 0) {
70+
[weakSelf deleteItem:item];
71+
}
72+
}];
73+
[actionSheet showInView:self.view];
74+
}
75+
}
76+
77+
#pragma mark - Actiom
78+
- (void)deleteItem:(ResourceReferenceItem *)item{
79+
__weak typeof(self) weakSelf = self;
80+
[[Coding_NetAPIManager sharedManager] request_DeleteResourceReference:item.code ofTask:_curTask andBlock:^(id data, NSError *error) {
81+
if (data) {
82+
[weakSelf.curTask.resourceReference.itemList removeObject:item];
83+
[weakSelf.myTableView reloadData];
84+
}
85+
}];
86+
}
87+
88+
- (void)goToItem:(ResourceReferenceItem *)item{
89+
UIViewController *vc = [BaseViewController analyseVCFromLinkStr:item.link];
90+
if (vc) {
91+
[self.navigationController pushViewController:vc animated:YES];
92+
}else{
93+
[NSObject showHudTipStr:@"暂时不支持查看该资源"];
94+
}
95+
}
96+
@end
1.19 KB
Loading[フレーム]
1.9 KB
Loading[フレーム]
1005 Bytes
Loading[フレーム]
1.52 KB
Loading[フレーム]
428 Bytes
Loading[フレーム]
605 Bytes
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /