Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <template lang="html">
  2.   <div v-if="coaster" @click="makeDetail()" class="coaster">
  3.     <slot name="titleBar"></slot>
  4.     <div class="card is-fullwidth">
  5.  
  6.       <header class="card-header">
  7.         <p class="card-header-title">
  8.           <img class="shift-icon" v-bind:src="loadSvg(coaster.shiftType)" alt="">
  9.           <span class="date">{{mediumDateString}}</span>
  10.           <span class="time"><i class="fa" :class="timeIcon"></i></span>
  11.         </p>
  12.  
  13.         <a v-if="isDetailView" @click.stop="closeDetailView" class="card-header-icon">
  14.           <i class="fa fa-close"></i>
  15.         </a>
  16.       </header>
  17.  
  18.       <div class="card-content">
  19.  
  20.         <div v-if="options">
  21.           <div v-if="options.showPickedUp" class="posted-by media">
  22.             <div class="media-left">
  23.               <figure class="posted-by-user">
  24.                 <img v-if="pickingUpUser.photoURL" :src="pickingUpUser.photoURL" alt="">
  25.                 <span v-if="!pickingUpUser.photoURL" class="icon is-large">
  26.                   <i class="fa fa-user"></i>
  27.                 </span>
  28.               </figure>
  29.             </div>
  30.  
  31.             <div class="media-content">
  32.               <ul>
  33.                 <li v-if="pickingUpUser"><strong>{{pickingUpUser.name}}</strong></li>
  34.                 <li>{{longDateString}}</li>
  35.                 <li><strong>{{coaster.time + ' ' + coaster.shiftType}}</strong></li>
  36.               </ul>
  37.               <span class="desktop-comments">{{ coaster.comment }}</span>
  38.             </div>
  39.           </div>
  40.  
  41.         </div>
  42.  
  43.  
  44.  
  45.         <div class="media">
  46.           <div class="media-left">
  47.             <figure class="posted-by-user">
  48.               <img v-if="coaster.postedBy.photoURL" :src="coaster.postedBy.photoURL" alt="">
  49.               <span v-if="!coaster.postedBy.photoURL" class="icon is-large">
  50.                 <i class="fa fa-user"></i>
  51.               </span>
  52.             </figure>
  53.           </div>
  54.  
  55.           <div class="media-content">
  56.             <ul>
  57.               <li v-show="!options.showPickedUp">{{longDateString}}</li>
  58.               <li v-show="!options.showPickedUp"><strong>{{coaster.time + ' ' + coaster.shiftType}}</strong></li>
  59.               <li>for <strong>{{coaster.postedBy.displayName}}</strong></li>
  60.               <li><small>{{datePosted}}</small></li>
  61.             </ul>
  62.             <span class="desktop-comments">{{ coaster.comment }}</span>
  63.           </div>
  64.         </div>
  65.  
  66.         <div class="content">
  67.  
  68.           <span class="mobile-comments">{{ coaster.comment }}</span>
  69.  
  70.  
  71.           <slot name="buttons"></slot>
  72.  
  73.  
  74.           <div v-if="isDetailView" class="details">
  75.             <textarea v-if="isCommenting" class="textarea"></textarea>
  76.           </div>
  77.         </div>
  78.       </div>
  79.  
  80.     </div>
  81.   </div>
  82. </template>
  83.  
  84. <script>
  85. import router from '../../router'
  86. import moment from 'moment'
  87. import mixins from '../../mixins'
  88. import * as myButton from '../widgets/Button.vue'
  89.  
  90.  
  91. export default {
  92.   components: {
  93.     myButton
  94.   },
  95.   mixins: [mixins],
  96.   data () {
  97.     return {
  98.       localComment: '',
  99.       isCommenting: false
  100.     }
  101.   },
  102.   props: ['coaster', 'options'],
  103.  
  104.   computed: {
  105.     pickingUpUser () {
  106.       if (!this.coaster.coasterHistory) return
  107.       let history = this.coaster.coasterHistory
  108.       let firstPickUp;
  109.       for(var name in history) {
  110.           console.log(name);
  111.           firstPickUp = history[name];
  112.       }
  113.       console.log(firstPickUp);
  114.       return firstPickUp.pickedUpBy
  115.     },
  116.  
  117.     longDateString () {
  118.       // if (!this.coaster) return
  119.       return moment(this.coaster.date).format('dddd, MMM Do')
  120.     },
  121.  
  122.     mediumDateString () {
  123.       // if (!this.coaster) return
  124.       return moment(this.coaster.date).format('ddd, MMM Do')
  125.     },
  126.  
  127.     datePosted () {
  128.       // if (!this.coaster) return
  129.       return moment(this.coaster.posted).fromNow()
  130.     },
  131.  
  132.     timeIcon () {
  133.       // if (!this.coaster) return
  134.       return (this.coaster.time === 'PM') ? 'fa-moon-o' : 'fa-sun-o'
  135.     },
  136.  
  137.     isDetailView () {
  138.       return this.$store.state.route.name === 'detail'
  139.     }
  140.  
  141.   },
  142.   methods: {
  143.  
  144.     makeDetail (coaster) {
  145.       if (!this.coaster || this.isDetailView) return
  146.       router.push({ name: 'detail', params: { id: this.coaster.key }})
  147.     },
  148.     closeDetailView () {
  149.       router.push({ path: '/'})
  150.     },
  151.  
  152.     startCommenting () {
  153.       this.isCommenting = true;
  154.     },
  155.     cancelComment () {
  156.       this.isCommenting = false;
  157.     },
  158.     getTitle:  function (coaster) {
  159.       if (coaster) {
  160.         return moment(coaster.date).format('dddd, MMM Do') + ' | ' + coaster.time + ' | ' + coaster.shiftType
  161.       }
  162.     },
  163.  
  164.   }
  165. }
  166. </script>
  167.  
  168. <style lang="scss" rel="stylesheet/scss">
  169. @import '../../../node_modules/bulma/sass/utilities/mixins.sass';
  170.  
  171. .coaster {
  172.   &:hover {
  173.     cursor: pointer;
  174.   }
  175.   .card-header {
  176.     .card-header-title {
  177.       align-items: center;
  178.       justify-content: space-between;
  179.     }
  180.     img.shift-icon {
  181.       width: 8vw;
  182.       max-height: 50px;
  183.     }
  184.     @include tablet {
  185.       .date {
  186.         font-size: 1.8em;
  187.       }
  188.       .time {
  189.         line-height: 1em;
  190.         .fa {
  191.           font-size: 2.8em;
  192.         }
  193.       }
  194.     }
  195.   }
  196.   .media-left {
  197.     text-align: center;
  198.     .fa-user {
  199.       vertical-align: middle;
  200.       line-height: inherit;
  201.     }
  202.     .posted-by-user {
  203.       img {
  204.         width: 74px;
  205.         height: 74px;
  206.         object-fit: cover;
  207.       }
  208.       .icon {
  209.         width: 74px;
  210.         height: 74px;
  211.         line-height: 74px;
  212.         vertical-align: bottom;
  213.         border: 1px solid grey;
  214.         border-radius: 3px;
  215.       }
  216.       @include tablet {
  217.         img {
  218.           width: 100px;
  219.           height: 100px;
  220.         }
  221.         .icon {
  222.           width: 100px;
  223.         }
  224.  
  225.       }
  226.     }
  227.   }
  228.   .desktop-comments {
  229.     display: none;
  230.     @include desktop {
  231.       display: inline;
  232.     };
  233.   }
  234.   .mobile-comments {
  235.     display: inline;
  236.     @include desktop {
  237.       display: none;
  238.     };
  239.   }
  240.  
  241.  
  242. }
  243.  
  244.  
  245. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement