-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
197 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<template> | ||
<div class="comments"> | ||
<div class="card" v-for="(item, index) in filteredComments" :key="item.id"> | ||
<div class="comment-top"> | ||
<div class="comment-image"> | ||
<span class="image"> | ||
<img class="avatar-xs" :src="item.creator.avatar_url" alt="Generic placeholder image"> | ||
</span> | ||
</div> | ||
<div class="comment-author"> | ||
<h5 class="comment-heading">{{item.creator.name}}</h5> | ||
<span class="comment-date"><small>{{item.created_at | moment('from')}}</small></span> | ||
</div> | ||
</div> | ||
<div class="comment-body"> | ||
<span class="lead"> | ||
{{item.comment}} | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import EventBus from './event-bus' | ||
export default { | ||
props: ['autopart'], | ||
computed: { | ||
filteredComments () { | ||
var filteredComments = this.autopart.data.comments | ||
return _.reverse(filteredComments) | ||
} | ||
}, | ||
mounted () { | ||
EventBus.$on('add-comment', (comment) => { | ||
this.storeComment(comment) | ||
}) | ||
}, | ||
data () { | ||
return { | ||
form: { | ||
comment: null, | ||
autopart_id: null, | ||
} | ||
} | ||
}, | ||
methods: { | ||
storeComment (comment) { | ||
this.form.comment = comment | ||
this.form.autopart_id = this.autopart.data.id | ||
axios.post('/api/autoparts/comments/store', this.form) | ||
.then((response) => { | ||
this.$parent.autopart.data.comments.push(response.data); | ||
this.form = {} | ||
}) | ||
.catch((err) => { | ||
console.log(err) | ||
}) | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Vue from "vue"; | ||
const EventBus = new Vue(); | ||
export default EventBus; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
.comments { | ||
height: 300px; | ||
overflow: auto; | ||
.card { | ||
margin-bottom: 10px; | ||
border-bottom: 1px solid rgba(0,0,0,.05); | ||
padding: 5px 0px; | ||
.comment-top { | ||
margin-bottom: 5px; | ||
.comment-image { | ||
display: inline-block; | ||
vertical-align: top; | ||
padding: 0px 5px; | ||
.image { | ||
vertical-align: bottom; | ||
} | ||
} | ||
.image, | ||
.comment-author { | ||
display: inline-block; | ||
} | ||
.comment-author { | ||
.comment-heading { | ||
font-weight: bold; | ||
margin: 0 !important; | ||
} | ||
.comment-date { | ||
opacity: .7; | ||
} | ||
} | ||
} | ||
.comment-body { | ||
margin-left: 44px; | ||
} | ||
.comment-bottom { | ||
.comment-input { | ||
width: 80%; | ||
} | ||
button { | ||
width: 20%; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters