Browse Source

scoring complete!

master
Aaron Parecki 7 years ago
parent
commit
eb01181852
No known key found for this signature in database GPG Key ID: 276C2817346D6056
4 changed files with 130 additions and 25 deletions
  1. +22
    -0
      app/Http/Controllers/DashboardController.php
  2. +55
    -12
      public/js/app.js
  3. +51
    -11
      resources/assets/js/components/Scorecard.vue
  4. +2
    -2
      resources/assets/js/components/TweetQueue.vue

+ 22
- 0
app/Http/Controllers/DashboardController.php View File

@ -84,6 +84,28 @@ class DashboardController extends Controller
return response()->json(['result'=>'ok']); 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() { public function load_dropdowns() {
$documents = DB::table('m7_documents')->orderBy('id')->get(); $documents = DB::table('m7_documents')->orderBy('id')->get();
$transit_centers = DB::table('transit_centers')->orderBy('name')->get(); $transit_centers = DB::table('transit_centers')->orderBy('name')->get();

+ 55
- 12
public/js/app.js View File

@ -46602,7 +46602,7 @@ module.exports = {
this.tweet = {}; this.tweet = {};
this.show = false; this.show = false;
}, },
rejectTweet: function rejectTweet() {
completedTweet: function completedTweet() {
this.tweet = {}; this.tweet = {};
this.show = false; this.show = false;
} }
@ -46662,7 +46662,7 @@ module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c
_vm.show = $event _vm.show = $event
}, },
"dismiss": _vm.dismissTweet, "dismiss": _vm.dismissTweet,
"reject": _vm.rejectTweet
"complete": _vm.completedTweet
} }
})], 1)])]) })], 1)])])
},staticRenderFns: []} },staticRenderFns: []}
@ -46815,6 +46815,9 @@ module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c
attrs: { attrs: {
"type": "button", "type": "button",
"disabled": _vm.isAcceptDisabled "disabled": _vm.isAcceptDisabled
},
on: {
"click": _vm.scoreTweet
} }
}, [_vm._v("Accept")]), _vm._v(" "), _c('button', { }, [_vm._v("Accept")]), _vm._v(" "), _c('button', {
staticClass: "btn btn-danger", staticClass: "btn btn-danger",
@ -47240,9 +47243,9 @@ module.exports = {
centers: [], centers: [],
lines: [], lines: [],
replyText: '', replyText: '',
selectedDocument: false,
selectedTransitCenter: false,
selectedTransitLine: false,
selectedDocument: null,
selectedTransitCenter: null,
selectedTransitLine: null,
selectedNonTrimetLine: '', selectedNonTrimetLine: '',
selectedPhotoHasAnotherTeam: false, selectedPhotoHasAnotherTeam: false,
selectedM5Singing: false, selectedM5Singing: false,
@ -47255,9 +47258,9 @@ module.exports = {
if (this.show) { if (this.show) {
switch (this.tweet.mission_id) { switch (this.tweet.mission_id) {
case 1: case 1:
return this.selectedTransitLine == false && this.selectedNonTrimetLine == '';
return this.selectedTransitLine == null && this.selectedNonTrimetLine == '';
case 2: case 2:
return this.selectedTransitCenter == false;
return this.selectedTransitCenter == null;
case 3: case 3:
case 4: case 4:
case 6: case 6:
@ -47266,7 +47269,7 @@ module.exports = {
case 5: case 5:
return this.selectedM5Singing == false && this.selectedM5Tipping == false; return this.selectedM5Singing == false && this.selectedM5Tipping == false;
case 7: case 7:
return this.selectedDocument == false;
return this.selectedDocument == null;
default: default:
return true; return true;
} }
@ -47280,11 +47283,13 @@ module.exports = {
}, },
methods: { methods: {
clearState: function clearState() { clearState: function clearState() {
this.selectedDocument = false;
this.selectedTransitCenter = false;
this.selectedTransitLine = false;
this.selectedDocument = null;
this.selectedTransitCenter = null;
this.selectedTransitLine = null;
this.selectedNonTrimetLine = ''; this.selectedNonTrimetLine = '';
this.selectedPhotoHasAnotherTeam = false; this.selectedPhotoHasAnotherTeam = false;
this.selectedM5Singing = false;
this.selectedM5Tipping = false;
this.replyText = ''; this.replyText = '';
}, },
dismiss: function dismiss() { dismiss: function dismiss() {
@ -47296,7 +47301,45 @@ module.exports = {
tweet_id: this.tweet.tweet_id tweet_id: this.tweet.tweet_id
}, function () { }, function () {
this.clearState(); 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)); }.bind(this));
} }
}, },

+ 51
- 11
resources/assets/js/components/Scorecard.vue View File

@ -38,7 +38,7 @@
</div> </div>
<div class="tweet-actions"> <div class="tweet-actions">
<button type="button" class="btn btn-success" :disabled="isAcceptDisabled">Accept</button>
<button type="button" class="btn btn-success" v-on:click="scoreTweet" :disabled="isAcceptDisabled">Accept</button>
<button type="button" class="btn btn-danger" v-on:click="rejectTweet">Reject</button> <button type="button" class="btn btn-danger" v-on:click="rejectTweet">Reject</button>
</div> </div>
@ -168,9 +168,9 @@ module.exports = {
centers: [], centers: [],
lines: [], lines: [],
replyText: '', replyText: '',
selectedDocument: false,
selectedTransitCenter: false,
selectedTransitLine: false,
selectedDocument: null,
selectedTransitCenter: null,
selectedTransitLine: null,
selectedNonTrimetLine: '', selectedNonTrimetLine: '',
selectedPhotoHasAnotherTeam: false, selectedPhotoHasAnotherTeam: false,
selectedM5Singing: false, selectedM5Singing: false,
@ -182,9 +182,9 @@ module.exports = {
if(this.show) { if(this.show) {
switch(this.tweet.mission_id) { switch(this.tweet.mission_id) {
case 1: case 1:
return this.selectedTransitLine == false && this.selectedNonTrimetLine == '';
return this.selectedTransitLine == null && this.selectedNonTrimetLine == '';
case 2: case 2:
return this.selectedTransitCenter == false;
return this.selectedTransitCenter == null;
case 3: case 3:
case 4: case 4:
case 6: case 6:
@ -193,7 +193,7 @@ module.exports = {
case 5: case 5:
return this.selectedM5Singing == false && this.selectedM5Tipping == false; return this.selectedM5Singing == false && this.selectedM5Tipping == false;
case 7: case 7:
return this.selectedDocument == false;
return this.selectedDocument == null;
default: default:
return true; return true;
} }
@ -207,11 +207,13 @@ module.exports = {
}, },
methods: { methods: {
clearState() { clearState() {
this.selectedDocument = false;
this.selectedTransitCenter = false;
this.selectedTransitLine = false;
this.selectedDocument = null;
this.selectedTransitCenter = null;
this.selectedTransitLine = null;
this.selectedNonTrimetLine = ''; this.selectedNonTrimetLine = '';
this.selectedPhotoHasAnotherTeam = false; this.selectedPhotoHasAnotherTeam = false;
this.selectedM5Singing = false;
this.selectedM5Tipping = false;
this.replyText = ''; this.replyText = '';
}, },
dismiss() { dismiss() {
@ -223,7 +225,45 @@ module.exports = {
tweet_id: this.tweet.tweet_id tweet_id: this.tweet.tweet_id
}, function() { }, function() {
this.clearState(); 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)); }.bind(this));
} }
}, },

+ 2
- 2
resources/assets/js/components/TweetQueue.vue View File

@ -18,7 +18,7 @@
</div> </div>
</div> </div>
<div class="col-xs-8 col-md-8"> <div class="col-xs-8 col-md-8">
<scorecard :show.sync="show" :tweet="tweet" v-on:dismiss="dismissTweet" v-on:reject="rejectTweet"></scorecard>
<scorecard :show.sync="show" :tweet="tweet" v-on:dismiss="dismissTweet" v-on:complete="completedTweet"></scorecard>
</div> </div>
</div> </div>
</div> </div>
@ -119,7 +119,7 @@ module.exports = {
this.tweet = {}; this.tweet = {};
this.show = false; this.show = false;
}, },
rejectTweet() {
completedTweet() {
this.tweet = {}; this.tweet = {};
this.show = false; this.show = false;
} }

Loading…
Cancel
Save