Skip to content

Commit f625744

Browse files
committed
快捷创建 项目、任务、冒泡
1 parent a818f5a commit f625744

19 files changed

Lines changed: 185 additions & 81 deletions

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
4E217F161A70EDC700F6DF88 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4E217F091A70EDC700F6DF88 /* [email protected] */; };
6969
4E217F171A70EDC700F6DF88 /* SVWebViewControllerActivity.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E217F0B1A70EDC700F6DF88 /* SVWebViewControllerActivity.m */; };
7070
4E217F1A1A71007800F6DF88 /* SVWebViewController.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4E217F1C1A71007800F6DF88 /* SVWebViewController.strings */; };
71+
4E24B2681B43D33F004D7989 /* ProjectToChooseListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E24B2671B43D33F004D7989 /* ProjectToChooseListViewController.m */; };
7172
4E2719B81AB02F31006AE214 /* NProjectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E2719B71AB02F31006AE214 /* NProjectViewController.m */; };
7273
4E2719C71AB07ED6006AE214 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4E2719C61AB07ED6006AE214 /* [email protected] */; };
7374
4E2906A21A403B7D008A5B97 /* FileDownloadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E2906A11A403B7D008A5B97 /* FileDownloadView.m */; };
@@ -831,6 +832,8 @@
831832
4E217F0B1A70EDC700F6DF88 /* SVWebViewControllerActivity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVWebViewControllerActivity.m; sourceTree = "<group>"; };
832833
4E217F1B1A71007800F6DF88 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/SVWebViewController.strings; sourceTree = "<group>"; };
833834
4E217F1D1A71007C00F6DF88 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/SVWebViewController.strings"; sourceTree = "<group>"; };
835+
4E24B2661B43D33F004D7989 /* ProjectToChooseListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProjectToChooseListViewController.h; sourceTree = "<group>"; };
836+
4E24B2671B43D33F004D7989 /* ProjectToChooseListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProjectToChooseListViewController.m; sourceTree = "<group>"; };
834837
4E2719B61AB02F31006AE214 /* NProjectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NProjectViewController.h; sourceTree = "<group>"; };
835838
4E2719B71AB02F31006AE214 /* NProjectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NProjectViewController.m; sourceTree = "<group>"; };
836839
4E2719C61AB07ED6006AE214 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
@@ -2940,6 +2943,8 @@
29402943
4E4D6A6F1B1C68F100FD2E49 /* CommitFilesViewController.m */,
29412944
4E4D6A711B1C694100FD2E49 /* FileChangeDetailViewController.h */,
29422945
4E4D6A721B1C694100FD2E49 /* FileChangeDetailViewController.m */,
2946+
4E24B2661B43D33F004D7989 /* ProjectToChooseListViewController.h */,
2947+
4E24B2671B43D33F004D7989 /* ProjectToChooseListViewController.m */,
29432948
);
29442949
path = Controllers;
29452950
sourceTree = "<group>";
@@ -4309,6 +4314,7 @@
43094314
8E97CE471A0A2DF8006F9AD7 /* AGEmojiKeyBoardView.m in Sources */,
43104315
4E53EB521AFA03990034FE1C /* RKSwipeBetweenViewControllers.m in Sources */,
43114316
8EA6D12C19E240C40076D59C /* EditTopicViewController.m in Sources */,
4317+
4E24B2681B43D33F004D7989 /* ProjectToChooseListViewController.m in Sources */,
43124318
4EA7F15B1A6D192B00A046BD /* SDWebImageCompat.m in Sources */,
43134319
8EA6D13A19E240C40076D59C /* Project_RootViewController.m in Sources */,
43144320
4ECF70401B180740000280FF /* EaseGitButtonsView.m in Sources */,

Coding_iOS/Controllers/EditTaskViewController.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,8 @@
1010
#import "Task.h"
1111
#import "UIMessageInputView.h"
1212

13-
14-
typedef NS_ENUM(NSInteger, TaskEditType) {
15-
TaskEditTypeAdd = 0,
16-
TaskEditTypeModify,
17-
};
18-
1913
@interface EditTaskViewController : BaseViewController<UITableViewDataSource, UITableViewDelegate, UIMessageInputViewDelegate>
2014
@property (strong, nonatomic) Task *myTask, *myCopyTask;
21-
@property (copy, nonatomic) void(^taskChangedBlock)(Task *curTask, TaskEditType type);
15+
@property (copy, nonatomic) void(^taskChangedBlock)();
2216
- (void)queryToRefreshTaskDetail;
2317
@end

Coding_iOS/Controllers/EditTaskViewController.m

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#import "ActionSheetDatePicker.h"
2121
#import "TaskDescriptionViewController.h"
2222
#import "WebViewController.h"
23+
#import "ProjectToChooseListViewController.h"
2324

2425
@interface EditTaskViewController ()<TTTAttributedLabelDelegate>
2526
@property (strong, nonatomic) UITableView *myTableView;
@@ -45,26 +46,14 @@ - (void)viewDidLoad
4546
{
4647
[super viewDidLoad];
4748
// Do any additional setup after loading the view.
48-
switch (_myTask.handleType) {
49-
case TaskHandleTypeAdd:{
50-
_myCopyTask = [Task taskWithTask:_myTask];
51-
_myCopyTask.handleType = TaskHandleTypeAdd;
52-
}
53-
break;
54-
case TaskHandleTypeEdit:{
55-
_myCopyTask = [Task taskWithTask:_myTask];
56-
57-
//评论
58-
_myMsgInputView = [UIMessageInputView messageInputViewWithType:UIMessageInputViewContentTypeTask];
59-
_myMsgInputView.isAlwaysShow = YES;
60-
_myMsgInputView.delegate = self;
61-
62-
[self queryToRefreshTaskDetail];
63-
64-
}
65-
break;
66-
default:
67-
break;
49+
_myCopyTask = [Task taskWithTask:_myTask];
50+
if (_myTask.handleType == TaskHandleTypeEdit) {
51+
//评论
52+
_myMsgInputView = [UIMessageInputView messageInputViewWithType:UIMessageInputViewContentTypeTask];
53+
_myMsgInputView.isAlwaysShow = YES;
54+
_myMsgInputView.delegate = self;
55+
56+
[self queryToRefreshTaskDetail];
6857
}
6958
[self configTitle];
7059

@@ -103,15 +92,17 @@ - (void)viewDidLoad
10392
RACObserve(self, myCopyTask.task_description.markdown)] reduce:^id (NSString *content, User *owner, NSNumber *priority, NSNumber *status, NSString *deadline){
10493
@strongify(self);
10594
BOOL enabled = ![self.myCopyTask isSameToTask:self.myTask];
106-
if (self.myCopyTask.handleType == TaskEditTypeAdd && self.myCopyTask.content.length <= 0) {
107-
enabled = NO;
95+
if (self.myCopyTask.handleType > TaskHandleTypeEdit) {
96+
enabled = ([self.myCopyTask.content trimWhitespace].length > 0 &&
97+
self.myCopyTask.project != nil &&
98+
self.myCopyTask.owner != nil);
10899
}
109100
return @(enabled);
110101
}];
111102
}
112103

113104
- (void)configTitle{
114-
if (_myTask.handleType == TaskEditTypeAdd) {
105+
if (_myTask.handleType > TaskHandleTypeEdit) {
115106
self.title = @"创建任务";
116107
}else{
117108
self.title = _myTask.project.name;
@@ -202,7 +193,7 @@ - (void)doneBtnClicked{
202193
if (_myCopyTask.isRequesting) {
203194
return;
204195
}
205-
if (_myCopyTask.handleType == TaskHandleTypeAdd) {
196+
if (_myCopyTask.handleType > TaskHandleTypeEdit) {
206197
if (!_myCopyTask.content || _myCopyTask.content.length <= 0) {
207198
return;
208199
}
@@ -211,7 +202,7 @@ - (void)doneBtnClicked{
211202
_myCopyTask.isRequesting = NO;
212203
if (data) {
213204
if (_taskChangedBlock) {
214-
_taskChangedBlock(_myTask, TaskEditTypeAdd);
205+
_taskChangedBlock();
215206
}
216207
[self.navigationController popViewControllerAnimated:YES];
217208
}
@@ -227,7 +218,7 @@ - (void)doneBtnClicked{
227218
_myTask.owner = _myCopyTask.owner;
228219
_myTask.status = _myCopyTask.status;
229220
if (_taskChangedBlock) {
230-
_taskChangedBlock(_myTask, TaskEditTypeModify);
221+
_taskChangedBlock();
231222
}
232223
[self.navigationController popViewControllerAnimated:YES];
233224
}else{
@@ -247,7 +238,7 @@ - (void)deleteTask:(Task *)toDelete{
247238
toDelete.isRequesting = NO;
248239
if (data) {
249240
if (_taskChangedBlock) {
250-
_taskChangedBlock(_myTask, TaskEditTypeAdd);
241+
_taskChangedBlock();
251242
}
252243
[self.navigationController popViewControllerAnimated:YES];
253244
}
@@ -289,14 +280,15 @@ - (void)deleteComment:(TaskComment *)comment{
289280
}
290281
#pragma mark Table M
291282
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
292-
return (self.myCopyTask.handleType == TaskEditTypeAdd)? 2: 3;
283+
return (self.myCopyTask.handleType > TaskHandleTypeEdit)? 2: 3;
293284
}
294285
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
295286
NSInteger row = 0;
296287
if (section == 0) {
297288
row = 2;
298289
}else if (section == 1){
299-
row = (self.myCopyTask.handleType == TaskHandleTypeAdd)? 3: 4;
290+
TaskHandleType handleType = self.myCopyTask.handleType;
291+
row = handleType == TaskHandleTypeEdit? 4: handleType == TaskHandleTypeAddWithProject? 3: 4;
300292
}else{
301293
row = self.myCopyTask.activityList.count;
302294
}
@@ -337,7 +329,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
337329
}else{
338330
TaskDescriptionCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TaskDescriptionCell forIndexPath:indexPath];
339331
NSString *titleStr;
340-
if (_myCopyTask.handleType == TaskEditTypeAdd) {
332+
if (_myCopyTask.handleType > TaskHandleTypeEdit) {
341333
titleStr = @"添加描述";
342334
}else{
343335
titleStr = _myCopyTask.has_description.boolValue? @"查看描述": @"补充描述";
@@ -356,7 +348,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
356348
}
357349
}else if (indexPath.section == 1){
358350
LeftImage_LRTextCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_LeftImage_LRText forIndexPath:indexPath];
359-
[cell setObj:_myCopyTask type:indexPath.row];
351+
LeftImage_LRTextCellType cellType = _myCopyTask.handleType == TaskHandleTypeAddWithoutProject? indexPath.row : indexPath.row +1;
352+
[cell setObj:_myCopyTask type:cellType];
360353
cell.backgroundColor = kColorTableBG;
361354
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:60];
362355
return cell;
@@ -449,23 +442,39 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
449442
// [self goToDescriptionVC];
450443
// }
451444
}else if (indexPath.section == 1){
452-
if (indexPath.row == LeftImage_LRTextCellTypeTaskOwner) {
445+
LeftImage_LRTextCellType cellType = _myCopyTask.handleType == TaskHandleTypeAddWithoutProject? indexPath.row : indexPath.row +1;
446+
if (cellType == LeftImage_LRTextCellTypeTaskProject) {
447+
ProjectToChooseListViewController *vc = [[ProjectToChooseListViewController alloc] init];
448+
vc.projectChoosedBlock = ^(Project *project){
449+
ESStrongSelf;
450+
_self.myCopyTask.project = project;
451+
_self.myCopyTask.owner = nil;//更换新的执行人
452+
[_self.myTableView reloadData];
453+
};
454+
[self.navigationController pushViewController:vc animated:YES];
455+
456+
NSLog(@"haimeizuo");
457+
}else if (cellType == LeftImage_LRTextCellTypeTaskOwner) {
458+
if (_myCopyTask.project == nil) {
459+
[self showHudTipStr:@"需要选定所属项目先~"];
460+
return;
461+
}
453462
ProjectMemberListViewController *vc = [[ProjectMemberListViewController alloc] init];
454463
[vc setFrame:self.view.bounds project:_myCopyTask.project type:ProMemTypeTaskOwner refreshBlock:nil selectBlock:^(ProjectMember *member) {
455464
ESStrongSelf;
456465
_self.myCopyTask.owner = member.user;//更换新的执行人
457466
[_self.myTableView reloadData];
458467
} cellBtnBlock:nil];
459468
[self.navigationController pushViewController:vc animated:YES];
460-
}else if (indexPath.row == LeftImage_LRTextCellTypeTaskPriority){
469+
}else if (cellType == LeftImage_LRTextCellTypeTaskPriority){
461470
ValueListViewController *vc = [[ValueListViewController alloc] init];
462471
[vc setTitle:@"优先级" valueList:kTaskPrioritiesDisplay defaultSelectIndex:_myCopyTask.priority.intValue type:ValueListTypeTaskPriority selectBlock:^(NSInteger index) {
463472
ESStrongSelf;
464473
_self.myCopyTask.priority = [NSNumber numberWithInteger:index];//更换新的任务优先级
465474
[_self.myTableView reloadData];
466475
}];
467476
[self.navigationController pushViewController:vc animated:YES];
468-
}else if (indexPath.row == LeftImage_LRTextCellTypeTaskDeadline){
477+
}else if (cellType == LeftImage_LRTextCellTypeTaskDeadline){
469478
NSDate *curDate = _myCopyTask.deadline_date? _myCopyTask.deadline_date : [NSDate date];
470479
ESStrongSelf;
471480
ActionSheetDatePicker *picker = [[ActionSheetDatePicker alloc] initWithTitle:nil datePickerMode:UIDatePickerModeDate selectedDate:curDate doneBlock:^(ActionSheetDatePicker *picker, NSDate *selectedDate, id origin) {
@@ -483,7 +492,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
483492
NSForegroundColorAttributeName: [UIColor colorWithHexString:@"0x666666"]} forState:UIControlStateNormal];
484493
[picker setCancelButton:barButton];
485494
[picker showActionSheetPicker];
486-
}else if (indexPath.row == LeftImage_LRTextCellTypeTaskStatus){
495+
}else if (cellType == LeftImage_LRTextCellTypeTaskStatus){
487496
ValueListViewController *vc = [[ValueListViewController alloc] init];
488497
[vc setTitle:@"阶段" valueList:@[@"未完成", @"已完成"] defaultSelectIndex:_myCopyTask.status.intValue-1 type:ValueListTypeTaskStatus selectBlock:^(NSInteger index) {
489498
ESStrongSelf;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// ProjectToChooseListViewController.h
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/7/1.
6+
// Copyright (c) 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import "BaseViewController.h"
10+
#import "Project.h"
11+
12+
@interface ProjectToChooseListViewController : BaseViewController
13+
@property (copy, nonatomic) void(^projectChoosedBlock)(Project *project);
14+
@end
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// ProjectToChooseListViewController.m
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/7/1.
6+
// Copyright (c) 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import "ProjectToChooseListViewController.h"
10+
#import "ProjectListView.h"
11+
12+
@interface ProjectToChooseListViewController ()
13+
@property (strong, nonatomic) Projects *curPros;
14+
@end
15+
16+
@implementation ProjectToChooseListViewController
17+
18+
- (void)viewDidLoad {
19+
[super viewDidLoad];
20+
// Do any additional setup after loading the view.
21+
self.title = @"所属项目";
22+
self.curPros = [Projects projectsWithType:ProjectsTypeToChoose andUser:nil];
23+
24+
__weak typeof(self) weakSelf = self;
25+
ProjectListView *listView = [[ProjectListView alloc] initWithFrame:self.view.bounds projects:self.curPros block:^(Project *project) {
26+
if (weakSelf.projectChoosedBlock) {
27+
weakSelf.projectChoosedBlock(project);
28+
}
29+
[weakSelf.navigationController popViewControllerAnimated:YES];
30+
} tabBarHeight:0];
31+
[self.view addSubview:listView];
32+
[listView mas_makeConstraints:^(MASConstraintMaker *make) {
33+
make.edges.equalTo(self.view);
34+
}];
35+
}
36+
37+
- (void)didReceiveMemoryWarning {
38+
[super didReceiveMemoryWarning];
39+
// Dispose of any resources that can be recreated.
40+
}
41+
42+
@end

Coding_iOS/Controllers/ProjectViewController.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ - (void)refreshWithNewIndex:(NSInteger)newIndex{
230230
[[ProjectTasksView alloc] initWithFrame:self.view.bounds project:_myProject block:^(ProjectTaskListView *taskListView, Task *task) {
231231
EditTaskViewController *vc = [[EditTaskViewController alloc] init];
232232
vc.myTask = task;
233-
vc.taskChangedBlock = ^(Task *curTask, TaskEditType type){
233+
vc.taskChangedBlock = ^(){
234234
[taskListView refreshToQueryData];
235235
};
236236
[weakSelf.navigationController pushViewController:vc animated:YES];
@@ -499,7 +499,8 @@ - (void)navRightBtnClicked{
499499
}
500500
ProjectTasksView *tasksView = (ProjectTasksView *)curView;
501501
EditTaskViewController *vc = [[EditTaskViewController alloc] init];
502-
vc.myTask = [Task taskWithProject:self.myProject andUser:tasksView.selectedMember.user];
502+
User *user = tasksView.selectedMember.user? tasksView.selectedMember.user : [Login curLoginUser];
503+
vc.myTask = [Task taskWithProject:self.myProject andUser:user];
503504
[self.navigationController pushViewController:vc animated:YES];
504505
}
505506
break;

Coding_iOS/Controllers/RootControllers/BaseViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ + (UIViewController *)analyseVCFromLinkStr:(NSString *)linkStr analyseMethod:(An
243243
EditTaskViewController *vc = [[EditTaskViewController alloc] init];
244244
vc.myTask = [Task taskWithBackend_project_path:[NSString stringWithFormat:@"/user/%@/project/%@", user_global_key, project_name] andId:taskId];
245245
@weakify(vc);
246-
vc.taskChangedBlock = ^(Task *curTask, TaskEditType type){
246+
vc.taskChangedBlock = ^(){
247247
@strongify(vc);
248248
[vc dismissViewControllerAnimated:YES completion:nil];
249249
};

Coding_iOS/Controllers/RootControllers/MyTask_RootViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index
153153
listView = [[ProjectTaskListView alloc] initWithFrame:carousel.bounds tasks:curTasks block:^(ProjectTaskListView *taskListView, Task *task) {
154154
EditTaskViewController *vc = [[EditTaskViewController alloc] init];
155155
vc.myTask = task;
156-
vc.taskChangedBlock = ^(Task *curTask, TaskEditType type){
156+
vc.taskChangedBlock = ^(){
157157
[taskListView refreshToQueryData];
158158
};
159159
[weakSelf.navigationController pushViewController:vc animated:YES];

0 commit comments

Comments
 (0)