From 1581bb83e31e2d9f2ad6f3610c178257eb056203 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Mon, 3 Jul 2017 15:22:03 -0700 Subject: [PATCH] enable rejecting tweets --- app/Http/Controllers/DashboardController.php | 19 ++++++++++++++ public/js/app.js | 25 ++++++++++++++++--- resources/assets/js/components/Scorecard.vue | 17 ++++++++++--- resources/assets/js/components/TweetQueue.vue | 6 ++++- routes/web.php | 2 ++ 5 files changed, 62 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index ed3123d..b10ed2d 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -65,6 +65,25 @@ class DashboardController extends Controller return response()->json(['result'=>'ok']); } + public function reject_tweet(Request $request) { + $tweet = Tweet::where('id', $request->input('tweet_id'))->first(); + if($tweet) { + $tweet->processed = 1; + $tweet->m1_transit_line_id = null; + $tweet->m1_non_trimet = null; + $tweet->m2_transit_center_id = null; + $tweet->m2_with_other_team = 0; + $tweet->m3_complete = null; + $tweet->m4_complete = null; + $tweet->m5_complete = null; + $tweet->m5_tip = null; + $tweet->m6_complete = null; + $tweet->m7_document_id = null; + $tweet->save(); + } + return response()->json(['result'=>'ok']); + } + public function load_dropdowns() { $documents = DB::table('m7_documents')->orderBy('id')->get(); $transit_centers = DB::table('transit_centers')->orderBy('name')->get(); diff --git a/public/js/app.js b/public/js/app.js index 36923c7..473a48e 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -46599,6 +46599,10 @@ module.exports = { status: 'unclaimed' }, function (response) {}); + this.tweet = {}; + this.show = false; + }, + rejectTweet: function rejectTweet() { this.tweet = {}; this.show = false; } @@ -46657,7 +46661,8 @@ module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c "update:show": function($event) { _vm.show = $event }, - "dismiss": _vm.dismissTweet + "dismiss": _vm.dismissTweet, + "reject": _vm.rejectTweet } })], 1)])]) },staticRenderFns: []} @@ -46815,6 +46820,9 @@ module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c staticClass: "btn btn-danger", attrs: { "type": "button" + }, + on: { + "click": _vm.rejectTweet } }, [_vm._v("Reject")])])]), _vm._v(" "), _c('div', { staticClass: "col-md-4" @@ -47271,14 +47279,25 @@ module.exports = { } }, methods: { - dismiss: function dismiss() { - this.$emit('dismiss'); + clearState: function clearState() { this.selectedDocument = false; this.selectedTransitCenter = false; this.selectedTransitLine = false; this.selectedNonTrimetLine = ''; this.selectedPhotoHasAnotherTeam = false; this.replyText = ''; + }, + dismiss: function dismiss() { + this.clearState(); + this.$emit('dismiss'); + }, + rejectTweet: function rejectTweet() { + $.post("/dashboard/reject-tweet", { + tweet_id: this.tweet.tweet_id + }, function () { + this.clearState(); + this.$emit('reject'); + }.bind(this)); } }, watch: { diff --git a/resources/assets/js/components/Scorecard.vue b/resources/assets/js/components/Scorecard.vue index cdd2034..9245812 100644 --- a/resources/assets/js/components/Scorecard.vue +++ b/resources/assets/js/components/Scorecard.vue @@ -39,7 +39,7 @@
- +
@@ -206,14 +206,25 @@ module.exports = { } }, methods: { - dismiss() { - this.$emit('dismiss'); + clearState() { this.selectedDocument = false; this.selectedTransitCenter = false; this.selectedTransitLine = false; this.selectedNonTrimetLine = ''; this.selectedPhotoHasAnotherTeam = false; this.replyText = ''; + }, + dismiss() { + this.clearState(); + this.$emit('dismiss'); + }, + rejectTweet() { + $.post("/dashboard/reject-tweet", { + tweet_id: this.tweet.tweet_id + }, function() { + this.clearState(); + this.$emit('reject'); + }.bind(this)); } }, watch: { diff --git a/resources/assets/js/components/TweetQueue.vue b/resources/assets/js/components/TweetQueue.vue index 18a4801..8869dfc 100644 --- a/resources/assets/js/components/TweetQueue.vue +++ b/resources/assets/js/components/TweetQueue.vue @@ -18,7 +18,7 @@
- +
@@ -116,6 +116,10 @@ module.exports = { }, function(response){ }); + this.tweet = {}; + this.show = false; + }, + rejectTweet() { this.tweet = {}; this.show = false; } diff --git a/routes/web.php b/routes/web.php index 7f0c59b..6afa3bd 100644 --- a/routes/web.php +++ b/routes/web.php @@ -22,6 +22,8 @@ Route::get('/dashboard/queue', 'DashboardController@queue')->name('queue'); Route::get('/dashboard/ping', 'DashboardController@ping'); Route::get('/dashboard/dropdowns', 'DashboardController@load_dropdowns'); Route::post('/dashboard/claim-tweet', 'DashboardController@claim_tweet'); +Route::post('/dashboard/reject-tweet', 'DashboardController@reject_tweet'); +Route::post('/dashboard/score-tweet', 'DashboardController@score_tweet'); Route::get('/teams', 'TeamController@index')->name('teams'); Route::post('/teams/new', 'TeamController@create_team');