@@ -76,7 +76,7 @@ - (BOOL)isSameToTask:(Task *)task{
7676 && self.priority .intValue == task.priority .intValue
7777 && self.status .intValue == task.status .intValue
7878 && ((!self.deadline && !task.deadline ) || [self .deadline isEqualToString: task.deadline])
79- && ((!self. task_description && (!task. task_description || task. task_description . markdown . length <= 0 )) || [ self .task_description isSameTo: task.task_description]) );
79+ );
8080}
8181- (void )copyDataFrom : (Task *)task {
8282 self.id = task.id ;
@@ -100,25 +100,9 @@ - (void)copyDataFrom:(Task *)task{
100100 self.deadline = task.deadline ;
101101
102102 self.has_description = task.has_description ;
103- if (self.has_description && task.task_description ) {
104- self.task_description = [Task_Description taskDescriptionFrom: task.task_description];
105- }
103+ self.task_description = task.task_description ;
106104}
107105
108- // 内容
109- - (NSString *)toEditTaskContentPath {
110- return [NSString stringWithFormat: @" api/task/%d /content" , self .id .intValue];
111- }
112- -(NSDictionary *)toEditContentParams {
113- return @{@" content" : [self .content aliasedString ]};
114- }
115- // 执行人
116- - (NSString *)toEditTaskOwnerPath {
117- return [NSString stringWithFormat: @" api/task/%d /owner" , self .id .intValue];
118- }
119- -(NSDictionary *)toEditOwnerParams {
120- return @{@" owner_id" : self.owner_id };
121- }
122106// 任务状态
123107- (NSString *)toEditTaskStatusPath {
124108 return [NSString stringWithFormat: @" api/task/%d /status" , self .id .intValue];
@@ -131,14 +115,6 @@ -(NSDictionary *)toChangeStatusParams{
131115 return @{@" status" : status};
132116}
133117
134- // 任务优先级
135- - (NSString *)toEditTaskPriorityPath {
136- return [NSString stringWithFormat: @" api/task/%d /priority" , self .id .intValue];
137- }
138- -(NSDictionary *)toEditPriorityParams {
139- return @{@" priority" : self.priority };
140- }
141-
142118// 更新任务
143119- (NSString *)toUpdatePath {
144120 return [NSString stringWithFormat: @" api/task/%@ /update" , self .id .stringValue];
@@ -149,13 +125,6 @@ -(NSDictionary *)toUpdateParamsWithOld:(Task *)oldTask{
149125 if (self.content && ![self .content isEqualToString: oldTask.content]) {
150126 [params setObject: self .content forKey: @" content" ];
151127 }
152- // 描述
153- NSString *newMD = self.task_description .markdown ;
154-
155- if (newMD && ![newMD isEqualToString: oldTask.task_description.markdown] ) {
156- [params setObject: [newMD aliasedString ] forKey: @" description" ];
157- }
158-
159128 // 执行者
160129 if (self.owner_id && self.owner_id .integerValue != oldTask.owner_id .integerValue ) {
161130 [params setObject: self .owner_id forKey: @" owner_id" ];
@@ -178,6 +147,10 @@ -(NSDictionary *)toUpdateParamsWithOld:(Task *)oldTask{
178147 return params;
179148}
180149
150+ // 更新任务描述
151+ - (NSString *)toUpdateDescriptionPath {
152+ return [NSString stringWithFormat: @" api/task/%d /description" , self .id .intValue];
153+ }
181154// 添加新任务
182155- (NSString *)toAddTaskPath {
183156 return [NSString stringWithFormat: @" api%@ /task" , self .backend_project_path];
@@ -272,22 +245,14 @@ - (instancetype)init
272245 return self;
273246}
274247
275- + (instancetype )taskDescriptionFrom : (Task_Description *)oldDes {
276- if (!oldDes) {
277- return nil ;
278- }
279- Task_Description *des = [[Task_Description alloc ] init ];
280- des.markdown = oldDes.markdown ;
281- des.description_mine = oldDes.description_mine ;
282- return des;
283- }
284248+ (instancetype )defaultDescription {
285249 return [[Task_Description alloc ] init ];
286250}
287- - ( BOOL ) isSameTo : (Task_Description *) td {
288- if (self. markdown . length == 0 && !td) {
289- return YES ;
290- }
291- return [ self .markdown isEqualToString: td.markdown] ;
251+
252+ + ( instancetype ) descriptionWithMdStr : ( NSString *) mdStr {
253+ Task_Description *taskD = [Task_Description defaultDescription ] ;
254+ taskD. markdown = mdStr;
255+ return taskD ;
292256}
257+
293258@end
0 commit comments