You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

248 lines
7.7 KiB

  1. <template>
  2. <div class="panel panel-default scorecard" v-if="show">
  3. <div class="panel-heading">
  4. <div class="team">
  5. <span class="team-icon" :style="'background-color: #'+tweet.team_color"></span>
  6. <span class="team-name">{{ tweet.team_name }}</span>
  7. </div>
  8. <h2>{{ tweet.mission }}</h2>
  9. <button type="button" class="close" v-on:click="dismiss"><span>&times;</span></button>
  10. </div>
  11. <div class="panel-body">
  12. <div class="row">
  13. <div class="col-md-8">
  14. <div class="profile">
  15. <img :src="tweet.player_photo" :style="'border-color: #'+tweet.team_color">
  16. <span><a :href="'https://twitter.com/'+tweet.player_username">@{{ tweet.player_username }}</a></span>
  17. </div>
  18. <div class="tweet">
  19. <div class="text">{{ tweet.text }}</div>
  20. <div v-if="tweet.photos">
  21. <div :class="'multi-photo photos-'+tweet.photos.length" v-if="tweet.photos">
  22. <div v-for="img in tweet.photos" class="photo" :style="'background-image:url('+img+')'" :data-featherlight="img">
  23. <img :src="img">
  24. </div>
  25. </div>
  26. <div class="multi-photo-clear"></div>
  27. </div>
  28. </div>
  29. <div class="tweet-reply">
  30. <textarea class="form-control" rows="2" v-model="replyText" style="margin-bottom: 4px;"></textarea>
  31. <button type="submit" class="btn btn-primary" :disabled="isTweetReplyDisabled">Reply</button>
  32. <div class="clear"></div>
  33. </div>
  34. <div class="tweet-actions">
  35. <button type="button" class="btn btn-success" :disabled="isAcceptDisabled">Accept</button>
  36. <button type="button" class="btn btn-danger" v-on:click="rejectTweet">Reject</button>
  37. </div>
  38. </div>
  39. <div class="col-md-4">
  40. <!-- MISSION 1 -->
  41. <template v-if="tweet.mission_id == 1">
  42. <p class="instructions">
  43. The photo must show the sign with the transit line
  44. </p>
  45. <div class="form-group">
  46. <select class="form-control" v-model="selectedTransitLine">
  47. <option value=""></option>
  48. <option v-for="line in lines" :value="line.id">{{ line.name }}</option>
  49. </select>
  50. </div>
  51. <div class="form-group">
  52. <input type="text" v-model="selectedNonTrimetLine" placeholder="Non-Trimet Line" class="form-control">
  53. </div>
  54. </template>
  55. <!-- MISSION 2 -->
  56. <template v-if="tweet.mission_id == 2">
  57. <p class="instructions">
  58. <ul>
  59. <li>Photo must show the sign with the transit center</li>
  60. <li>Bonus points if another team and their pennant are visible!</li>
  61. </ul>
  62. </p>
  63. <div class="form-group">
  64. <select class="form-control" v-model="selectedTransitCenter">
  65. <option value=""></option>
  66. <option v-for="stop in centers" :value="stop.id">{{ stop.name }}</option>
  67. </select>
  68. </div>
  69. <div class="form-group">
  70. <div class="checkbox">
  71. <label>
  72. <input type="checkbox" v-model="selectedPhotoHasAnotherTeam">
  73. Another team is in the photo
  74. </label>
  75. </div>
  76. </div>
  77. </template>
  78. <!-- MISSION 3 -->
  79. <template v-if="tweet.mission_id == 3">
  80. <p class="instructions">
  81. <ul>
  82. <li>Make sure this photo is on the tram or at the top tram station</li>
  83. <li>Reject if it shows the rooftop with the code!</li>
  84. </ul>
  85. </p>
  86. </template>
  87. <!-- MISSION 4 -->
  88. <template v-if="tweet.mission_id == 4">
  89. <p class="instructions">
  90. <ul>
  91. <li>The photo must include the radio</li>
  92. <li>Reject if it shows the decoded message</li>
  93. </ul>
  94. </p>
  95. </template>
  96. <!-- MISSION 5 -->
  97. <template v-if="tweet.mission_id == 5">
  98. <p class="instructions">
  99. Accept a photo of either a team member singing, or a photo of tipping the bus driver
  100. </p>
  101. <div class="form-group">
  102. <label>
  103. <input type="checkbox" v-model="selectedM5Singing">
  104. Singing
  105. </label>
  106. <label>
  107. <input type="checkbox" v-model="selectedM5Tipping">
  108. Tipping the driver
  109. </label>
  110. </div>
  111. </template>
  112. <!-- MISSION 6 -->
  113. <template v-if="tweet.mission_id == 6">
  114. <p class="instructions">
  115. The photo must show all team members with their completed visas
  116. </p>
  117. </template>
  118. <!-- MISSION 7 -->
  119. <template v-if="tweet.mission_id == 7">
  120. <p class="instructions">
  121. Accept a photo that completes one of the below documents:
  122. </p>
  123. <div class="form-group">
  124. <div v-for="doc in documents" class="radio">
  125. <label>
  126. <input type="radio" name="selectedDocument" v-model="selectedDocument" :value="doc.id">
  127. {{ doc.description }}
  128. </label>
  129. </div>
  130. </div>
  131. </template>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136. </template>
  137. <script>
  138. module.exports = {
  139. props: ['show', 'tweet'],
  140. data () {
  141. return {
  142. documents: [],
  143. centers: [],
  144. lines: [],
  145. replyText: '',
  146. selectedDocument: false,
  147. selectedTransitCenter: false,
  148. selectedTransitLine: false,
  149. selectedNonTrimetLine: '',
  150. selectedPhotoHasAnotherTeam: false,
  151. selectedM5Singing: false,
  152. selectedM5Tipping: false
  153. }
  154. },
  155. computed: {
  156. isAcceptDisabled() {
  157. if(this.show) {
  158. switch(this.tweet.mission_id) {
  159. case 1:
  160. return this.selectedTransitLine == false && this.selectedNonTrimetLine == '';
  161. case 2:
  162. return this.selectedTransitCenter == false;
  163. case 3:
  164. case 4:
  165. case 6:
  166. // Nothing to check
  167. return false;
  168. case 5:
  169. return this.selectedM5Singing == false && this.selectedM5Tipping == false;
  170. case 7:
  171. return this.selectedDocument == false;
  172. default:
  173. return true;
  174. }
  175. } else {
  176. return true;
  177. }
  178. },
  179. isTweetReplyDisabled() {
  180. return this.replyText == '';
  181. }
  182. },
  183. methods: {
  184. clearState() {
  185. this.selectedDocument = false;
  186. this.selectedTransitCenter = false;
  187. this.selectedTransitLine = false;
  188. this.selectedNonTrimetLine = '';
  189. this.selectedPhotoHasAnotherTeam = false;
  190. this.replyText = '';
  191. },
  192. dismiss() {
  193. this.clearState();
  194. this.$emit('dismiss');
  195. },
  196. rejectTweet() {
  197. $.post("/dashboard/reject-tweet", {
  198. tweet_id: this.tweet.tweet_id
  199. }, function() {
  200. this.clearState();
  201. this.$emit('reject');
  202. }.bind(this));
  203. }
  204. },
  205. watch: {
  206. // https://vuejs.org/v2/guide/computed.html#Watchers
  207. show: function(val) {
  208. if(val) {
  209. // https://vuejs.org/v2/guide/reactivity.html#Async-Update-Queue
  210. Vue.nextTick(function() {
  211. $(".multi-photo .photo").featherlight();
  212. }.bind(this));
  213. }
  214. }
  215. },
  216. created() {
  217. $.get("/dashboard/dropdowns", function(response){
  218. this.centers = response.transit_centers;
  219. this.lines = response.transit_lines;
  220. this.documents = response.documents;
  221. }.bind(this));
  222. }
  223. }
  224. </script>