Skip to content

Commit a9e4ed0

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

24 files changed

+394
-21
lines changed

Coding_iOS.xcodeproj/project.pbxproj

+66
Large diffs are not rendered by default.

Coding_iOS/Controllers/EditTaskViewController.m

+28-20
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:[NSIndexSet indexSetWithIndex: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
}
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
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
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

Coding_iOS/Models/ResourceReference.h

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// ResourceReference.h
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 16/2/23.
6+
// Copyright © 2016年 Coding. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@interface ResourceReference : NSObject
12+
@property (strong, nonatomic) NSMutableArray *Task, *MergeRequestBean, *ProjectTopic, *ProjectFile, *itemList;
13+
@property (readwrite, nonatomic, strong) NSDictionary *propertyArrayMap;
14+
15+
@end
16+
17+
@interface ResourceReferenceItem : NSObject
18+
@property (strong, nonatomic) NSString *target_type, *title, *link;
19+
@property (strong, nonatomic) NSNumber *code, *target_id;
20+
@end

Coding_iOS/Models/ResourceReference.m

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// ResourceReference.m
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 16/2/23.
6+
// Copyright © 2016年 Coding. All rights reserved.
7+
//
8+
9+
#import "ResourceReference.h"
10+
11+
@implementation ResourceReference
12+
- (instancetype)init
13+
{
14+
self = [super init];
15+
if (self) {
16+
_propertyArrayMap = @{@"Task": @"ResourceReferenceItem",
17+
@"MergeRequestBean": @"ResourceReferenceItem",
18+
@"ProjectTopic": @"ResourceReferenceItem",
19+
@"ProjectFile": @"ResourceReferenceItem",
20+
};
21+
22+
}
23+
return self;
24+
}
25+
- (NSMutableArray *)itemList{
26+
if (!_itemList) {
27+
_itemList = [NSMutableArray new];
28+
[_itemList addObjectsFromArray:_Task];
29+
[_itemList addObjectsFromArray:_ProjectTopic];
30+
[_itemList addObjectsFromArray:_ProjectFile];
31+
[_itemList addObjectsFromArray:_MergeRequestBean];
32+
}
33+
return _itemList;
34+
}
35+
@end
36+
37+
@implementation ResourceReferenceItem
38+
39+
@end

Coding_iOS/Models/Task.h

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#import "Login.h"
1313
#import "TaskComment.h"
1414
#import "ProjectTag.h"
15+
#import "ResourceReference.h"
1516

1617
@class Project;
1718
@class Task_Description;
@@ -35,6 +36,7 @@ typedef NS_ENUM(NSInteger, TaskHandleType) {
3536
@property (nonatomic, assign) BOOL isRequesting, isRequestingDetail, isRequestingCommentList, needRefreshDetail;
3637
@property (readwrite, nonatomic, strong) NSString *nextCommentStr;
3738
@property (strong, nonatomic) Task_Description *task_description;
39+
@property (strong, nonatomic) ResourceReference *resourceReference;
3840

3941
+ (Task *)taskWithProject:(Project *)project andUser:(User *)user;
4042
+ (Task *)taskWithBackend_project_path:(NSString *)backend_project_path andId:(NSString *)taskId;
@@ -65,6 +67,8 @@ typedef NS_ENUM(NSInteger, TaskHandleType) {
6567
- (NSString *)toTaskDetailPath;
6668
//任务描述
6769
- (NSString *)toDescriptionPath;
70+
//任务关联资源
71+
- (NSString *)toResourceReferencePath;
6872
//任务关注者列表
6973
- (NSString *)toWatchersPath;
7074
//评论任务

Coding_iOS/Models/Task.m

+4-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ - (NSString *)toTaskDetailPath{
227227
- (NSString *)toDescriptionPath{
228228
return [NSString stringWithFormat:@"api/task/%@/description", self.id.stringValue];
229229
}
230-
230+
//任务关联资源
231+
- (NSString *)toResourceReferencePath{
232+
return [NSString stringWithFormat:@"api%@/resource_reference/%ld", self.backend_project_path, (long)self.number.integerValue];
233+
}
231234
//任务关注者列表
232235
- (NSString *)toWatchersPath{
233236
return [NSString stringWithFormat:@"api%@/task/%@/watchers", self.backend_project_path, self.id.stringValue];

Coding_iOS/Util/Manager/Coding_NetAPIManager.h

+2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ typedef NS_ENUM(NSInteger, PurposeType) {
146146
- (void)request_EditTask:(Task *)task withTags:(NSMutableArray *)selectedTags andBlock:(void (^)(id data, NSError *error))block;
147147
- (void)request_ChangeTaskStatus:(Task *)task andBlock:(void (^)(id data, NSError *error))block;
148148
- (void)request_TaskDetail:(Task *)task andBlock:(void (^)(id data, NSError *error))block;
149+
- (void)request_TaskResourceReference:(Task *)task andBlock:(void (^)(id data, NSError *error))block;
150+
- (void)request_DeleteResourceReference:(NSNumber *)iid ofTask:(Task *)task andBlock:(void (^)(id data, NSError *error))block;
149151
- (void)request_ActivityListOfTask:(Task *)task andBlock:(void (^)(id data, NSError *error))block;
150152
- (void)request_DoCommentToTask:(Task *)task andBlock:(void (^)(id data, NSError *error))block;
151153
- (void)request_DeleteComment:(TaskComment *)comment ofTask:(Task *)task andBlock:(void (^)(id data, NSError *error))block;

0 commit comments

Comments
 (0)