Skip to content

Commit 1b46271

Browse files
committed
项目内冒泡的删除权限 & 修改功能
1 parent 3d1c7c1 commit 1b46271

11 files changed

+79
-43
lines changed

Coding_iOS/.DS_Store

2 KB
Binary file not shown.

Coding_iOS/Controllers/ProjectTweetSendViewController.h

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
@interface ProjectTweetSendViewController : BaseViewController
1414
@property (strong, nonatomic) Project *curPro;
15+
@property (strong, nonatomic) Tweet *curTweet;//有的话,就是编辑。。没有的话,就是添加
1516
@property (copy, nonatomic) void(^sentBlock)(Tweet *tweet);
1617

1718
@end

Coding_iOS/Controllers/ProjectTweetSendViewController.m

+29-13
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ - (void)loadEditView{
109109
_editView.textContainerInset = UIEdgeInsetsMake(15, kPaddingLeftWidth - 5, 8, kPaddingLeftWidth - 5);
110110
_editView.placeholder = @"任务描述";
111111

112-
_editView.text = nil;
112+
_editView.text = _curTweet.raw;
113113
[self.view addSubview:_editView];
114114
[_editView mas_makeConstraints:^(MASConstraintMaker *make) {
115115
make.edges.equalTo(self.view);
@@ -170,19 +170,35 @@ - (void)previewLoadMDData{
170170
#pragma mark nav_btn
171171

172172
- (void)sendBtnClicked{
173-
[NSObject showHUDQueryStr:@"正在发布..."];
174-
@weakify(self);
175-
[[Coding_NetAPIManager sharedManager] request_Tweet_DoProjectTweet_WithPro:self.curPro.id content:self.editView.text andBlock:^(id data, NSError *error) {
176-
[NSObject hideHUDQuery];
177-
if (data) {
178-
[NSObject showHudTipStr:@"发布成功"];
179-
@strongify(self);
180-
if (self.sentBlock) {
181-
self.sentBlock(data);
173+
if (_curTweet && _curTweet.isProjectTweet) {
174+
[NSObject showHUDQueryStr:@"正在修改..."];
175+
@weakify(self);
176+
[[Coding_NetAPIManager sharedManager] request_Tweet_EditProjectTweet:self.curTweet content:self.editView.text andBlock:^(id data, NSError *error) {
177+
[NSObject hideHUDQuery];
178+
if (data) {
179+
[NSObject showHudTipStr:@"修改成功"];
180+
@strongify(self);
181+
if (self.sentBlock) {
182+
self.sentBlock(data);
183+
}
184+
[self.navigationController popViewControllerAnimated:YES];
182185
}
183-
[self.navigationController popViewControllerAnimated:YES];
184-
}
185-
}];
186+
}];
187+
}else{
188+
[NSObject showHUDQueryStr:@"正在发布..."];
189+
@weakify(self);
190+
[[Coding_NetAPIManager sharedManager] request_Tweet_DoProjectTweet_WithPro:self.curPro.id content:self.editView.text andBlock:^(id data, NSError *error) {
191+
[NSObject hideHUDQuery];
192+
if (data) {
193+
[NSObject showHudTipStr:@"发布成功"];
194+
@strongify(self);
195+
if (self.sentBlock) {
196+
self.sentBlock(data);
197+
}
198+
[self.navigationController popViewControllerAnimated:YES];
199+
}
200+
}];
201+
}
186202
}
187203

188204
#pragma mark UIWebViewDelegate

Coding_iOS/Controllers/TweetDetailViewController.m

+21-26
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#import "ReportIllegalViewController.h"
2222
#import "TweetSendLocationDetailViewController.h"
2323
#import "CodingShareView.h"
24+
#import "ProjectTweetSendViewController.h"
2425

2526
@interface TweetDetailViewController ()
2627
@property (nonatomic, strong) UITableView *myTableView;
@@ -86,16 +87,7 @@ - (void)viewDidLoad
8687
self.myTableView.contentInset = contentInsets;
8788
self.myTableView.scrollIndicatorInsets = contentInsets;
8889

89-
if (!_curTweet.content
90-
|| (_curTweet.likes.integerValue > 0 && _curTweet.like_users.count == 0)) {
91-
[self refreshTweet];
92-
}else{
93-
_myMsgInputView.commentOfId = _curTweet.id;
94-
95-
if (_curTweet.comments.integerValue > _curTweet.comment_list.count) {
96-
[self refreshComments];//加载等多评论
97-
}
98-
}
90+
[self refreshTweet];
9991
}
10092

10193
- (void)viewWillDisappear:(BOOL)animated{
@@ -124,21 +116,19 @@ - (void)didReceiveMemoryWarning
124116

125117
- (void)rightNavBtnClicked{
126118
if (self.curTweet.id && [self.curTweet.id isKindOfClass:[NSNumber class]]) {
127-
[_myMsgInputView isAndResignFirstResponder];
128-
129-
// if (_curTweet.project_id != nil) {
130-
// [NSObject showHudTipStr:@"项目内冒泡,不能分享"];
131-
// return;
132-
// }
133-
[CodingShareView showShareViewWithObj:_curTweet];
134-
135-
// @weakify(self);
136-
// [[UIActionSheet bk_actionSheetCustomWithTitle:nil buttonTitles:@[@"举报"] destructiveTitle:nil cancelTitle:@"取消" andDidDismissBlock:^(UIActionSheet *sheet, NSInteger index) {
137-
// if (index == 0) {
138-
// @strongify(self);
139-
// [self goToReport];
140-
// }
141-
// }] showInView:self.view];
119+
if (_curTweet.isProjectTweet) {
120+
ProjectTweetSendViewController *vc = [ProjectTweetSendViewController new];
121+
vc.curPro = _curProject;
122+
vc.curTweet = _curTweet;
123+
__weak typeof(self) weakSelf = self;
124+
vc.sentBlock = ^(Tweet *tweet){
125+
[weakSelf refreshTweet];
126+
};
127+
[self.navigationController pushViewController:vc animated:YES];
128+
}else{
129+
[_myMsgInputView isAndResignFirstResponder];
130+
[CodingShareView showShareViewWithObj:_curTweet];
131+
}
142132
}
143133
}
144134

@@ -176,7 +166,7 @@ - (void)messageInputView:(UIMessageInputView *)inputView heightToBottomChenged:(
176166
#pragma mark refresh
177167
- (void)refreshTweet{
178168
__weak typeof(self) weakSelf = self;
179-
if (_curTweet.project && !_curTweet.project_id) {
169+
if (_curTweet.isProjectTweet && !_curTweet.project.current_user_role_id) {
180170
[[Coding_NetAPIManager sharedManager] request_ProjectDetail_WithObj:_curTweet.project andBlock:^(id data, NSError *error) {
181171
if (data) {
182172
weakSelf.curTweet.project = data;
@@ -201,6 +191,11 @@ - (void)refreshTweet{
201191
weakSelf.myMsgInputView.toUser = nil;
202192
[weakSelf.myTableView reloadData];
203193
[weakSelf refreshComments];
194+
if (weakSelf.curTweet.isProjectTweet &&
195+
(weakSelf.curTweet.project.current_user_role_id.integerValue >= 90 ||
196+
[Login isLoginUserGlobalKey:weakSelf.curTweet.owner.global_key])) {
197+
[self.navigationItem setRightBarButtonItem:[UIBarButtonItem itemWithBtnTitle:@"编辑" target:self action:@selector(rightNavBtnClicked)] animated:YES];
198+
}
204199
}else{
205200
[weakSelf.refreshControl endRefreshing];
206201
}

Coding_iOS/Controllers/UserOrProjectTweetsViewController.m

+4
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ - (void)viewDidLoad
9090
[_myTableView addInfiniteScrollingWithActionHandler:^{
9191
[weakSelf refreshMore];
9292
}];
93+
}
94+
95+
- (void)viewWillAppear:(BOOL)animated{
96+
[super viewWillAppear:animated];
9397
[self refresh];
9498
}
9599

Coding_iOS/Models/Tweet.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@class TweetImage;
1717

1818
@interface Tweet : NSObject
19-
@property (readwrite, nonatomic, strong) NSString *content, *device, *location, *coord, *address;
19+
@property (readwrite, nonatomic, strong) NSString *content, *device, *location, *coord, *address, *raw;
2020
@property (readwrite, nonatomic, strong) NSNumber *liked, *rewarded, *activity_id, *id, *comments, *likes, *rewards;
2121
@property (readwrite, nonatomic, strong) NSDate *created_at, *sort_time;
2222
@property (readwrite, nonatomic, strong) User *owner;

Coding_iOS/Models/Tweets.m

+3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ - (NSDictionary *)toParams{
9090
}
9191

9292
- (void)configWithTweets:(NSArray *)responseA{
93+
if (self.curPro) {
94+
[responseA setValue:self.curPro forKey:@"project"];
95+
}
9396
if (responseA && [responseA count] > 0) {
9497
self.canLoadMore = (_tweetType != TweetTypePublicHot);
9598
Tweet *lastTweet = [responseA lastObject];

Coding_iOS/Util/Manager/Coding_NetAPIManager.h

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ typedef NS_ENUM(NSInteger, PurposeType) {
237237
- (void)request_Tweet_DoComment_WithObj:(Tweet *)tweet andBlock:(void (^)(id data, NSError *error))block;
238238
- (void)request_Tweet_DoTweet_WithObj:(Tweet *)tweet andBlock:(void (^)(id data, NSError *error))block;
239239
- (void)request_Tweet_DoProjectTweet_WithPro:(NSNumber *)pro_id content:(NSString *)content andBlock:(void (^)(id data, NSError *error))block;
240+
- (void)request_Tweet_EditProjectTweet:(Tweet *)tweet content:(NSString *)content andBlock:(void (^)(id data, NSError *error))block;
240241
- (void)request_Tweet_Likers_WithObj:(Tweet *)tweet andBlock:(void (^)(id data, NSError *error))block;
241242
- (void)request_Tweet_LikesAndRewards_WithObj:(Tweet *)tweet andBlock:(void (^)(id data, NSError *error))block;
242243
- (void)request_Tweet_Comments_WithObj:(Tweet *)tweet andBlock:(void (^)(id data, NSError *error))block;

Coding_iOS/Util/Manager/Coding_NetAPIManager.m

+17-1
Original file line numberDiff line numberDiff line change
@@ -2456,6 +2456,22 @@ - (void)request_Tweet_DoProjectTweet_WithPro:(NSNumber *)pro_id content:(NSStrin
24562456
}];
24572457
}
24582458

2459+
- (void)request_Tweet_EditProjectTweet:(Tweet *)tweet content:(NSString *)content andBlock:(void (^)(id data, NSError *error))block{
2460+
NSString *path = [NSString stringWithFormat:@"api/project/%@/tweet/%@", tweet.project_id, tweet.id];
2461+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:path withParams:@{@"raw": content} withMethodType:Put andBlock:^(id data, NSError *error) {
2462+
if (data) {
2463+
[MobClick event:kUmeng_Event_Request_ActionOfServer label:@"冒泡_修改_项目内冒泡"];
2464+
2465+
id resultData = [data valueForKeyPath:@"data"];
2466+
Tweet *result = [NSObject objectOfClass:@"Tweet" fromJSON:resultData];
2467+
block(result, nil);
2468+
}else{
2469+
[NSObject showStatusBarError:error];
2470+
block(nil, error);
2471+
}
2472+
}];
2473+
}
2474+
24592475
- (void)request_Tweet_Likers_WithObj:(Tweet *)tweet andBlock:(void (^)(id data, NSError *error))block{
24602476
tweet.isLoading = YES;
24612477
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:[tweet toLikersPath] withParams:[tweet toLikersParams] withMethodType:Get andBlock:^(id data, NSError *error) {
@@ -2530,7 +2546,7 @@ - (void)request_TweetComment_Delete_WithTweet:(Tweet *)tweet andComment:(Comment
25302546
}
25312547

25322548
- (void)request_Tweet_Detail_WithObj:(Tweet *)tweet andBlock:(void (^)(id data, NSError *error))block{
2533-
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:[tweet toDetailPath] withParams:nil withMethodType:Get andBlock:^(id data, NSError *error) {
2549+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:[tweet toDetailPath] withParams:@{@"withRaw": @YES} withMethodType:Get andBlock:^(id data, NSError *error) {
25342550
if (data) {
25352551
[MobClick event:kUmeng_Event_Request_Get label:@"冒泡_详情"];
25362552

Coding_iOS/Views/Cell/TweetCell.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ - (void)setTweet:(Tweet *)tweet needTopView:(BOOL)needTopView{
228228
self.likeBtn.hidden = self.rewardBtn.hidden = [_tweet isProjectTweet];
229229

230230
_like_reward_users = [_tweet like_reward_users];
231-
BOOL isMineTweet = [_tweet.owner.global_key isEqualToString:[Login curLoginUser].global_key];
231+
BOOL isMineTweet = [_tweet.owner.global_key isEqualToString:[Login curLoginUser].global_key] || tweet.project.current_user_role_id.integerValue >= 90;
232232

233233
self.topView.hidden = !_needTopView;
234234
//owner头像

Coding_iOS/Views/Cell/TweetDetailCell.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ - (void)setTweet:(Tweet *)tweet{
240240
[self.rewardBtn setTitle:_tweet.rewards.stringValue forState:UIControlStateNormal];
241241
[self.commentBtn setTitle:_tweet.comments.stringValue forState:UIControlStateNormal];
242242

243-
BOOL isMineTweet = [_tweet.owner.global_key isEqualToString:[Login curLoginUser].global_key];
243+
BOOL isMineTweet = [_tweet.owner.global_key isEqualToString:[Login curLoginUser].global_key] || tweet.project.current_user_role_id.integerValue >= 90;
244244
if (isMineTweet) {
245245
[self.deleteBtn setY:curBottomY];
246246
self.deleteBtn.hidden = NO;

0 commit comments

Comments
 (0)