Skip to content

Commit a5cf09a

Browse files
committed
Beta Done
1 parent 29ce730 commit a5cf09a

15 files changed

Lines changed: 196 additions & 44 deletions

Coding_iOS/APIUrl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@
1818
//生产
1919
#define kNetPath_Code_Base @"https://coding.net/"
2020

21+
//村民机
22+
//#define kNetPath_Code_Base @"http://192.168.0.188:8080/"
23+
2124
#pragma mark ConfigUrl
2225
#define kNetPath_Code_Login @"api/login"

Coding_iOS/Controllers/EditTaskViewController.m

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#import "TaskDescriptionViewController.h"
2222
#import "WebViewController.h"
2323
#import "ProjectToChooseListViewController.h"
24+
#import "EditLabelViewController.h"
2425

2526
@interface EditTaskViewController ()<TTTAttributedLabelDelegate>
2627
@property (strong, nonatomic) UITableView *myTableView;
@@ -322,6 +323,13 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
322323
}
323324
[weakSelf goToDescriptionVC];
324325
};
326+
cell.addTagBlock = ^(){
327+
[weakSelf goToTagsVC];
328+
};
329+
cell.tagsChangedBlock = ^(){
330+
weakSelf.myTask.labels = [weakSelf.myCopyTask.labels mutableCopy];
331+
[weakSelf.myTableView reloadData];
332+
};
325333

326334
cell.backgroundColor = kColorTableBG;
327335
// [tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:20];
@@ -404,7 +412,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
404412

405413
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
406414
if (section == 0) {
407-
return 30.0;
415+
return 0.5;
408416
}else if (section == 3){
409417
return 0.5;
410418
}else{
@@ -449,6 +457,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
449457
ESStrongSelf;
450458
_self.myCopyTask.project = project;
451459
_self.myCopyTask.owner = nil;//更换新的执行人
460+
[_self.myCopyTask.labels removeAllObjects];
452461
[_self.myTableView reloadData];
453462
};
454463
[self.navigationController pushViewController:vc animated:YES];
@@ -527,6 +536,48 @@ - (void)goToDescriptionVC{
527536
[self.navigationController pushViewController:vc animated:YES];
528537
}
529538

539+
- (void)goToTagsVC{
540+
if (!_myCopyTask.project) {
541+
[self showHudTipStr:@"需要选定所属项目先~"];
542+
return;
543+
}
544+
EditLabelViewController *vc = [[EditLabelViewController alloc] init];
545+
vc.curProject = self.myCopyTask.project;
546+
vc.orignalTags = self.myCopyTask.labels;
547+
@weakify(self);
548+
vc.tagsChangedBlock = ^(EditLabelViewController *vc, NSMutableArray *selectedTags){
549+
@strongify(self);
550+
[self tagsHasChanged:selectedTags fromVC:vc];
551+
};
552+
[self.navigationController pushViewController:vc animated:YES];
553+
}
554+
555+
- (void)tagsHasChanged:(NSMutableArray *)selectedTags fromVC:(EditLabelViewController *)vc{
556+
if ([ProjectTag tags:self.myCopyTask.labels isEqualTo:selectedTags]) {
557+
[vc.navigationController popViewControllerAnimated:YES];
558+
}else{
559+
if (self.myCopyTask.handleType > TaskHandleTypeEdit) {
560+
self.myCopyTask.labels = selectedTags;
561+
self.myTask.labels = [self.myCopyTask.labels mutableCopy];
562+
[self.myTableView reloadData];
563+
[vc.navigationController popViewControllerAnimated:YES];
564+
}else{
565+
vc.navigationItem.rightBarButtonItem.enabled = NO;
566+
@weakify(self);
567+
[[Coding_NetAPIManager sharedManager] request_EditTask:_myCopyTask withTags:selectedTags andBlock:^(id data, NSError *error) {
568+
@strongify(self);
569+
vc.navigationItem.rightBarButtonItem.enabled = YES;
570+
if (data) {
571+
self.myCopyTask.labels = selectedTags;
572+
self.myTask.labels = [self.myCopyTask.labels mutableCopy];
573+
[self.myTableView reloadData];
574+
[vc.navigationController popViewControllerAnimated:YES];
575+
}
576+
}];
577+
}
578+
}
579+
}
580+
530581
- (void)doCommentToComment:(TaskComment *)toComment sender:(id)sender{
531582
if ([self.myMsgInputView isAndResignFirstResponder]) {
532583
return ;

Coding_iOS/Controllers/EditTopicViewController.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ - (void)loadLabelView
134134
}
135135
__weak typeof(self) weakSelf = self;
136136
_tagsView.deleteTagBlock = ^(ProjectTag *curTag){
137-
[weakSelf.curProTopic.mdLabels removeObject:curTag];
137+
curTag = [ProjectTag tags:weakSelf.curProTopic.mdLabels hasTag:curTag];
138+
if (curTag) {
139+
[weakSelf.curProTopic.mdLabels removeObject:curTag];
140+
}
138141
[weakSelf loadEditView];
139142
weakSelf.navigationItem.rightBarButtonItem.enabled = YES;
140143
};

Coding_iOS/Controllers/TopicDetailViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ - (void)tagsHasChanged:(NSMutableArray *)selectedTags fromVC:(EditLabelViewContr
151151
@weakify(self);
152152
[[Coding_NetAPIManager sharedManager] request_ModifyProjectTpoicLabel:self.curTopic andBlock:^(id data, NSError *error) {
153153
@strongify(self);
154-
vc.navigationItem.rightBarButtonItem.enabled = NO;
154+
vc.navigationItem.rightBarButtonItem.enabled = YES;
155155
if (data) {
156156
self.curTopic.labels = [self.curTopic.mdLabels mutableCopy];
157157
[self.myTableView reloadData];
158-
[self.navigationController popViewControllerAnimated:YES];
158+
[vc.navigationController popViewControllerAnimated:YES];
159159
}
160160
}];
161161
}

Coding_iOS/Models/ProjectTag.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,20 @@ - (NSString *)color{
2929
}
3030
return _color;
3131
}
32+
33+
- (NSString *)name{
34+
if (_name.length <= 0) {
35+
_name = @"...";
36+
}
37+
return _name;
38+
}
39+
3240
+ (instancetype)tagWithName:(NSString *)name{
3341
ProjectTag *tag = [[self alloc] init];
3442
tag.name = name;
3543
return tag;
3644
}
45+
3746
+ (BOOL)tags:(NSArray *)aTags isEqualTo:(NSArray *)bTags{
3847
BOOL isSame = YES;
3948
if (aTags.count != bTags.count ||

Coding_iOS/Models/Task.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import "Projects.h"
1212
#import "Login.h"
1313
#import "TaskComment.h"
14+
#import "ProjectTag.h"
1415

1516
@class Project;
1617
@class Task_Description;
@@ -28,7 +29,8 @@ typedef NS_ENUM(NSInteger, TaskHandleType) {
2829
@property (readonly, nonatomic, strong) NSDate *deadline_date;
2930
@property (readwrite, nonatomic, strong) Project *project;
3031
@property (readwrite, nonatomic, strong) NSNumber *id, *status, *owner_id, *priority, *comments, *has_description;
31-
@property (readwrite, nonatomic, strong) NSMutableArray *activityList;
32+
@property (readwrite, nonatomic, strong) NSDictionary *propertyArrayMap;
33+
@property (readwrite, nonatomic, strong) NSMutableArray *activityList, *labels;
3234
@property (nonatomic, assign) TaskHandleType handleType;
3335
@property (nonatomic, assign) BOOL isRequesting, isRequestingDetail, isRequestingCommentList, needRefreshDetail;
3436
@property (readwrite, nonatomic, strong) NSString *nextCommentStr;

Coding_iOS/Models/Task.m

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ - (instancetype)init
1414
{
1515
self = [super init];
1616
if (self) {
17+
_propertyArrayMap = [NSDictionary dictionaryWithObjectsAndKeys:
18+
@"ProjectTag", @"labels", nil];
19+
1720
_handleType = TaskHandleTypeEdit;
1821
_isRequesting = _isRequestingDetail = _isRequestingCommentList = NO;
1922
_needRefreshDetail = NO;
@@ -77,6 +80,7 @@ - (BOOL)isSameToTask:(Task *)task{
7780
&& self.priority.intValue == task.priority.intValue
7881
&& self.status.intValue == task.status.intValue
7982
&& ((!self.deadline && !task.deadline) || [self.deadline isEqualToString:task.deadline])
83+
&& [ProjectTag tags:self.labels isEqualTo:task.labels]
8084
);
8185
}
8286
- (void)copyDataFrom:(Task *)task{
@@ -102,6 +106,7 @@ - (void)copyDataFrom:(Task *)task{
102106

103107
self.has_description = task.has_description;
104108
self.task_description = task.task_description;
109+
self.labels = [task.labels mutableCopy];
105110
}
106111

107112
//任务状态
@@ -157,14 +162,22 @@ - (NSString *)toAddTaskPath{
157162
return [NSString stringWithFormat:@"api%@/task", self.backend_project_path];
158163
}
159164
- (NSDictionary *)toAddTaskParams{
160-
NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithDictionary:@{@"content" : [self.content aliasedString],
161-
@"owner_id" : self.owner.id,
162-
@"priority" : self.priority}];
165+
NSMutableDictionary *params = [@{@"content" : [self.content aliasedString],
166+
@"owner_id" : self.owner.id,
167+
@"priority" : self.priority} mutableCopy];
168+
163169
if (self.deadline.length >= 10) {
164-
[params setObject:self.deadline forKey:@"deadline"];
170+
params[@"deadline"] = self.deadline;
165171
}
166172
if (self.task_description.markdown.length > 0) {
167-
[params setObject:[self.task_description.markdown aliasedString] forKey:@"description"];
173+
params[@"description"] = [self.task_description.markdown aliasedString];
174+
}
175+
if (self.labels.count > 0) {
176+
NSMutableArray *labels = [NSMutableArray new];
177+
for (ProjectTag *curL in self.labels) {
178+
[labels addObject:curL.id.stringValue];
179+
}
180+
params[@"labels"] = labels;
168181
}
169182
return params;
170183
}

Coding_iOS/Util/Manager/Coding_NetAPIManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ typedef NS_ENUM(NSUInteger, VerifyType){
108108
- (void)request_DeleteTask:(Task *)task andBlock:(void (^)(id data, NSError *error))block;
109109
- (void)request_EditTask:(Task *)task oldTask:(Task *)oldTask andBlock:(void (^)(id data, NSError *error))block;
110110
- (void)request_EditTask:(Task *)task withDescriptionStr:(NSString *)descriptionStr andBlock:(void (^)(id data, NSError *error))block;
111+
- (void)request_EditTask:(Task *)task withTags:(NSMutableArray *)selectedTags andBlock:(void (^)(id data, NSError *error))block;
111112
- (void)request_ChangeTaskStatus:(Task *)task andBlock:(void (^)(id data, NSError *error))block;
112113
- (void)request_TaskDetail:(Task *)task andBlock:(void (^)(id data, NSError *error))block;
113114
- (void)request_CommentListOfTask:(Task *)task andBlock:(void (^)(id data, NSError *error))block;

Coding_iOS/Util/Manager/Coding_NetAPIManager.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,11 @@ - (void)request_EditTask:(Task *)task withDescriptionStr:(NSString *)description
879879

880880
}
881881

882+
- (void)request_EditTask:(Task *)task withTags:(NSMutableArray *)selectedTags andBlock:(void (^)(id data, NSError *error))block{
883+
[MobClick event:kUmeng_Event_Request label:@"更新任务标签"];
884+
block(selectedTags, nil);
885+
}
886+
882887
- (void)request_ChangeTaskStatus:(Task *)task andBlock:(void (^)(id data, NSError *error))block{
883888
[MobClick event:kUmeng_Event_Request label:@"编辑任务状态"];
884889
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:[task toEditTaskStatusPath] withParams:[task toChangeStatusParams] withMethodType:Put andBlock:^(id data, NSError *error) {
@@ -1004,16 +1009,14 @@ - (void)request_ProjectTopic_WithObj:(ProjectTopic *)proTopic andBlock:(void (^)
10041009
//markdown详情
10051010
id resultData = [data valueForKeyPath:@"data"];
10061011
ProjectTopic *resultT = [NSObject objectOfClass:@"ProjectTopic" fromJSON:resultData];
1007-
1012+
resultT.mdLabels = [resultT.labels mutableCopy];
10081013
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:[proTopic toTopicPath] withParams:@{@"type": [NSNumber numberWithInteger:1]} withMethodType:Get andBlock:^(id dataMD, NSError *errorMD) {
1014+
proTopic.isTopicLoading = NO;
10091015
if (dataMD) {
10101016
resultT.mdTitle = [[dataMD valueForKey:@"data"] valueForKey:@"title"];
10111017
resultT.mdContent = [[dataMD valueForKey:@"data"] valueForKey:@"content"];
1012-
id labels = [[dataMD valueForKey:@"data"] valueForKey:@"labels"];
1013-
resultT.mdLabels = [NSObject arrayFromJSON:labels ofObjects:@"ProjectTag"];
10141018
block(resultT, nil);
10151019
}else{
1016-
proTopic.isTopicLoading = NO;
10171020
block(nil, errorMD);
10181021
}
10191022
}];

Coding_iOS/Views/Cell/TaskContentCell.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
@property (nonatomic,copy) void(^textViewBecomeFirstResponderBlock)();
1818
@property (nonatomic,copy) void(^deleteBtnClickedBlock)(Task *);
1919
@property (nonatomic,copy) void(^descriptionBtnClickedBlock)(Task *);
20+
@property (nonatomic, copy) void (^addTagBlock)();
21+
@property (nonatomic, copy) void (^tagsChangedBlock)();
2022

2123
+ (CGFloat)cellHeightWithObj:(id)obj;
2224
@end

0 commit comments

Comments
 (0)