diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index b10ed2d..b7fe92d 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -84,6 +84,28 @@ class DashboardController extends Controller return response()->json(['result'=>'ok']); } + public function score_tweet(Request $request) { + $tweet = Tweet::where('id', $request->input('tweet_id'))->first(); + if($tweet) { + $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; + foreach($request->input('score_data') as $k=>$v) { + $tweet->{$k} = $v; + } + $tweet->processed = 1; + $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 473a48e..6b5daf6 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -46602,7 +46602,7 @@ module.exports = { this.tweet = {}; this.show = false; }, - rejectTweet: function rejectTweet() { + completedTweet: function completedTweet() { this.tweet = {}; this.show = false; } @@ -46662,7 +46662,7 @@ module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c _vm.show = $event }, "dismiss": _vm.dismissTweet, - "reject": _vm.rejectTweet + "complete": _vm.completedTweet } })], 1)])]) },staticRenderFns: []} @@ -46815,6 +46815,9 @@ module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c attrs: { "type": "button", "disabled": _vm.isAcceptDisabled + }, + on: { + "click": _vm.scoreTweet } }, [_vm._v("Accept")]), _vm._v(" "), _c('button', { staticClass: "btn btn-danger", @@ -47240,9 +47243,9 @@ module.exports = { centers: [], lines: [], replyText: '', - selectedDocument: false, - selectedTransitCenter: false, - selectedTransitLine: false, + selectedDocument: null, + selectedTransitCenter: null, + selectedTransitLine: null, selectedNonTrimetLine: '', selectedPhotoHasAnotherTeam: false, selectedM5Singing: false, @@ -47255,9 +47258,9 @@ module.exports = { if (this.show) { switch (this.tweet.mission_id) { case 1: - return this.selectedTransitLine == false && this.selectedNonTrimetLine == ''; + return this.selectedTransitLine == null && this.selectedNonTrimetLine == ''; case 2: - return this.selectedTransitCenter == false; + return this.selectedTransitCenter == null; case 3: case 4: case 6: @@ -47266,7 +47269,7 @@ module.exports = { case 5: return this.selectedM5Singing == false && this.selectedM5Tipping == false; case 7: - return this.selectedDocument == false; + return this.selectedDocument == null; default: return true; } @@ -47280,11 +47283,13 @@ module.exports = { }, methods: { clearState: function clearState() { - this.selectedDocument = false; - this.selectedTransitCenter = false; - this.selectedTransitLine = false; + this.selectedDocument = null; + this.selectedTransitCenter = null; + this.selectedTransitLine = null; this.selectedNonTrimetLine = ''; this.selectedPhotoHasAnotherTeam = false; + this.selectedM5Singing = false; + this.selectedM5Tipping = false; this.replyText = ''; }, dismiss: function dismiss() { @@ -47296,7 +47301,45 @@ module.exports = { tweet_id: this.tweet.tweet_id }, function () { this.clearState(); - this.$emit('reject'); + this.$emit('complete'); + }.bind(this)); + }, + scoreTweet: function scoreTweet() { + var score_data = {}; + + switch (this.tweet.mission_id) { + case 1: + score_data['m1_transit_line_id'] = this.selectedTransitLine; + score_data['m1_non_trimet'] = this.selectedNonTrimetLine; + break; + case 2: + score_data['m2_transit_center_id'] = this.selectedTransitCenter; + score_data['m2_with_other_team'] = this.selectedPhotoHasAnotherTeam ? 1 : 0; + break; + case 3: + score_data['m3_complete'] = true ? 1 : 0; + break; + case 4: + score_data['m4_complete'] = true ? 1 : 0; + break; + case 5: + score_data['m5_complete'] = this.selectedM5Singing ? 1 : 0; + score_data['m5_tip'] = this.selectedM5Tipping ? 1 : 0; + break; + case 6: + score_data['m6_complete'] = true ? 1 : 0; + break; + case 7: + score_data['m7_document_id'] = this.selectedDocument; + break; + } + + $.post("/dashboard/score-tweet", { + tweet_id: this.tweet.tweet_id, + score_data: score_data + }, function () { + this.clearState(); + this.$emit('complete'); }.bind(this)); } }, diff --git a/resources/assets/js/components/Scorecard.vue b/resources/assets/js/components/Scorecard.vue index 9245812..e040694 100644 --- a/resources/assets/js/components/Scorecard.vue +++ b/resources/assets/js/components/Scorecard.vue @@ -38,7 +38,7 @@
- +
@@ -168,9 +168,9 @@ module.exports = { centers: [], lines: [], replyText: '', - selectedDocument: false, - selectedTransitCenter: false, - selectedTransitLine: false, + selectedDocument: null, + selectedTransitCenter: null, + selectedTransitLine: null, selectedNonTrimetLine: '', selectedPhotoHasAnotherTeam: false, selectedM5Singing: false, @@ -182,9 +182,9 @@ module.exports = { if(this.show) { switch(this.tweet.mission_id) { case 1: - return this.selectedTransitLine == false && this.selectedNonTrimetLine == ''; + return this.selectedTransitLine == null && this.selectedNonTrimetLine == ''; case 2: - return this.selectedTransitCenter == false; + return this.selectedTransitCenter == null; case 3: case 4: case 6: @@ -193,7 +193,7 @@ module.exports = { case 5: return this.selectedM5Singing == false && this.selectedM5Tipping == false; case 7: - return this.selectedDocument == false; + return this.selectedDocument == null; default: return true; } @@ -207,11 +207,13 @@ module.exports = { }, methods: { clearState() { - this.selectedDocument = false; - this.selectedTransitCenter = false; - this.selectedTransitLine = false; + this.selectedDocument = null; + this.selectedTransitCenter = null; + this.selectedTransitLine = null; this.selectedNonTrimetLine = ''; this.selectedPhotoHasAnotherTeam = false; + this.selectedM5Singing = false; + this.selectedM5Tipping = false; this.replyText = ''; }, dismiss() { @@ -223,7 +225,45 @@ module.exports = { tweet_id: this.tweet.tweet_id }, function() { this.clearState(); - this.$emit('reject'); + this.$emit('complete'); + }.bind(this)); + }, + scoreTweet() { + var score_data = {}; + + switch(this.tweet.mission_id) { + case 1: + score_data['m1_transit_line_id'] = this.selectedTransitLine; + score_data['m1_non_trimet'] = this.selectedNonTrimetLine; + break; + case 2: + score_data['m2_transit_center_id'] = this.selectedTransitCenter; + score_data['m2_with_other_team'] = this.selectedPhotoHasAnotherTeam ? 1 : 0; + break; + case 3: + score_data['m3_complete'] = true ? 1 : 0; + break; + case 4: + score_data['m4_complete'] = true ? 1 : 0; + break; + case 5: + score_data['m5_complete'] = this.selectedM5Singing ? 1 : 0; + score_data['m5_tip'] = this.selectedM5Tipping ? 1 : 0; + break; + case 6: + score_data['m6_complete'] = true ? 1 : 0; + break; + case 7: + score_data['m7_document_id'] = this.selectedDocument; + break; + } + + $.post("/dashboard/score-tweet", { + tweet_id: this.tweet.tweet_id, + score_data: score_data + }, function(){ + this.clearState(); + this.$emit('complete'); }.bind(this)); } }, diff --git a/resources/assets/js/components/TweetQueue.vue b/resources/assets/js/components/TweetQueue.vue index 8869dfc..3e58634 100644 --- a/resources/assets/js/components/TweetQueue.vue +++ b/resources/assets/js/components/TweetQueue.vue @@ -18,7 +18,7 @@
- +
@@ -119,7 +119,7 @@ module.exports = { this.tweet = {}; this.show = false; }, - rejectTweet() { + completedTweet() { this.tweet = {}; this.show = false; }