1212#import " ResetLabelViewController.h"
1313#import " TPKeyboardAvoidingTableView.h"
1414#import " Coding_NetAPIManager.h"
15- #import " ProjectTopicLabel .h"
15+ #import " ProjectTag .h"
1616#import " MBProgressHUD+Add.h"
1717
1818#define kCellIdentifier_EditLabelHeadCell @" EditLabelHeadCell"
@@ -100,18 +100,19 @@ - (void)sendRequest
100100 [self .view beginLoading ];
101101
102102 __weak typeof (self) weakSelf = self;
103- [[Coding_NetAPIManager sharedManager ] request_ProjectTopicLabel_WithPath: [self toLabelPath ] andBlock: ^(id data, NSError *error) {
103+
104+ [[Coding_NetAPIManager sharedManager ] request_TagListInProject: _curProTopic.project type: ProjectTagTypeTopic andBlock: ^(id data, NSError *error) {
104105 [weakSelf.view endLoading ];
105106 if (data) {
106107 [_labels addObjectsFromArray: data];
107- for (ProjectTopicLabel *lbl in _labels) {
108- for (ProjectTopicLabel *tLbl in _curProTopic.mdLabels ) {
108+ for (ProjectTag *lbl in _labels) {
109+ for (ProjectTag *tLbl in _curProTopic.mdLabels ) {
109110 if ([lbl.id integerValue ] == [tLbl.id integerValue ]) {
110111 tLbl.name = lbl.name ;
111112 break ;
112113 }
113114 }
114- for (ProjectTopicLabel *tLbl in _tempArray) {
115+ for (ProjectTag *tLbl in _tempArray) {
115116 if ([lbl.id integerValue ] == [tLbl.id integerValue ]) {
116117 tLbl.name = lbl.name ;
117118 break ;
@@ -120,17 +121,13 @@ - (void)sendRequest
120121 }
121122 [weakSelf.myTableView reloadData ];
122123 }
123- }];
124- }
125124
126- - (NSString *)toLabelPath
127- {
128- return [NSString stringWithFormat: @" api/project/%d /topic/label?withCount=true" , _curProTopic.project_id.intValue];
125+ }];
129126}
130127
131128- (NSString *)toDelPath : (NSInteger )index
132129{
133- ProjectTopicLabel *ptLabel = [_labels objectAtIndex: index];
130+ ProjectTag *ptLabel = [_labels objectAtIndex: index];
134131 return [NSString stringWithFormat: @" api/project/%d /topic/label/%lld " , _curProTopic.project_id.intValue, ptLabel.id .longLongValue];
135132}
136133
@@ -174,20 +171,17 @@ - (void)addBtnClick:(UIButton *)sender
174171 [_mCurrentTextField resignFirstResponder ];
175172 if (_tempLabel.length > 0 ) {
176173 __weak typeof (self) weakSelf = self;
177- [[Coding_NetAPIManager sharedManager ] request_ProjectTopicLabel_Add_WithPath: [self toLabelPath ] withParams: @{@" name" : [_tempLabel aliasedString ], @" color" : @" #d8f3e4" } andBlock: ^(id data, NSError *error) {
178- if (!error) {
179- ProjectTopicLabel *ptLabel = [[ProjectTopicLabel alloc ] init ];
180- ptLabel.name = _tempLabel;
181- ptLabel.id = data;
182- ptLabel.owner_id = _curProTopic.project_id ;
183- ptLabel.color = @" #d8f3e4" ;
184- [weakSelf.labels addObject: ptLabel];
174+ ProjectTag *curTag = [ProjectTag tagWithName: _tempLabel];
175+ [[Coding_NetAPIManager sharedManager ] request_AddTag: curTag toProject: _curProTopic.project andBlock: ^(id data, NSError *error) {
176+ if (data) {
177+ curTag.id = data;
178+ [weakSelf.labels addObject: curTag];
185179 [weakSelf.myTableView reloadData ];
186180 _tempLabel = @" " ;
187181 weakSelf.mCurrentTextField .text = @" " ;
188182 [weakSelf showHudTipStr: @" 添加标签成功^^" ];
189183 sender.enabled = FALSE ;
190- }
184+ }
191185 }];
192186 }
193187}
@@ -231,13 +225,13 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
231225 return cell;
232226 }
233227
234- ProjectTopicLabel *ptLabel = _labels[indexPath.row];
228+ ProjectTag *ptLabel = _labels[indexPath.row];
235229
236230 EditLabelCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_EditLabelCell forIndexPath: indexPath];
237231 cell.nameLbl .text = ptLabel.name ;
238232
239233 BOOL selected = FALSE ;
240- for (ProjectTopicLabel *lbl in _curProTopic.mdLabels ) {
234+ for (ProjectTag *lbl in _curProTopic.mdLabels ) {
241235 if ([lbl.id integerValue ] == [ptLabel.id integerValue ]) {
242236 selected = TRUE ;
243237 break ;
@@ -279,11 +273,11 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
279273 EditLabelCell *cell = (EditLabelCell *)[tableView cellForRowAtIndexPath: indexPath];
280274 cell.selectBtn .selected = !cell.selectBtn .selected ;
281275
282- ProjectTopicLabel *lbl = _labels[indexPath.row];
276+ ProjectTag *lbl = _labels[indexPath.row];
283277
284278 if (cell.selectBtn .selected ) {
285279 BOOL add = TRUE ;
286- for (ProjectTopicLabel *tempLbl in _tempArray) {
280+ for (ProjectTag *tempLbl in _tempArray) {
287281 if ([tempLbl.id integerValue ] == [lbl.id integerValue ]) {
288282 add = FALSE ;
289283 break ;
@@ -308,7 +302,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
308302 // }
309303 }
310304 } else {
311- for (ProjectTopicLabel *tempLbl in _tempArray) {
305+ for (ProjectTag *tempLbl in _tempArray) {
312306 if ([tempLbl.id integerValue ] == [lbl.id integerValue ]) {
313307// if (_isSaveChange) {
314308// __weak typeof(self) weakSelf = self;
@@ -384,7 +378,7 @@ - (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityBut
384378 [self renameBtnClick: indexPath.row];
385379 } else {
386380 __weak typeof (self) weakSelf = self;
387- ProjectTopicLabel *ptLabel = [_labels objectAtIndex: indexPath.row];
381+ ProjectTag *ptLabel = [_labels objectAtIndex: indexPath.row];
388382 NSString *tip = [NSString stringWithFormat: @" 确定要删除标签:%@ ?" , ptLabel.name];
389383 UIActionSheet *actionSheet = [UIActionSheet bk_actionSheetCustomWithTitle: tip buttonTitles: nil destructiveTitle: @" 确认删除" cancelTitle: @" 取消" andDidDismissBlock: ^(UIActionSheet *sheet, NSInteger index) {
390384 if (index == 0 ) {
@@ -406,17 +400,17 @@ - (void)renameBtnClick:(NSInteger)index
406400- (void )deleteBtnClick : (NSInteger )index
407401{
408402 __weak typeof (self) weakSelf = self;
409- [[Coding_NetAPIManager sharedManager ] request_ProjectTopicLabel_Del_WithPath: [ self toDelPath: index] andBlock: ^(id data, NSError *error) {
410- if (!error ) {
403+ [[Coding_NetAPIManager sharedManager ] request_DeleteTag: _labels[ index] inProject: _curProTopic.project andBlock: ^(id data, NSError *error) {
404+ if (data ) {
411405 [weakSelf deleteLabel: index];
412406 }
413407 }];
414408}
415409
416410- (void )deleteLabel : (NSInteger )index
417411{
418- ProjectTopicLabel *lbl = _labels[index];
419- for (ProjectTopicLabel *tempLbl in _tempArray) {
412+ ProjectTag *lbl = _labels[index];
413+ for (ProjectTag *tempLbl in _tempArray) {
420414 if ([tempLbl.id integerValue ] == [lbl.id integerValue ]) {
421415 [_tempArray removeObject: tempLbl];
422416 self.navigationItem .rightBarButtonItem .enabled = YES ;
@@ -448,7 +442,7 @@ - (void)textFieldDidChange:(UITextField *)textField
448442 _tempLabel = [textField.text trimWhitespace ];
449443 BOOL enabled = _tempLabel.length > 0 ? TRUE : FALSE ;
450444 if (enabled) {
451- for (ProjectTopicLabel *lbl in _labels) {
445+ for (ProjectTag *lbl in _labels) {
452446 if ([lbl.name isEqualToString: _tempLabel]) {
453447 enabled = FALSE ;
454448 break ;
0 commit comments