src_js/iconolab-bundle/src/components/editor/CommentList.vue
author duong tam kien <tk@deveha.com>
Wed, 01 Mar 2017 17:18:53 +0100
changeset 410 a6db5e626850
parent 396 0a4743126d74
child 423 729e51dd282e
permissions -rw-r--r--
sizes up panels and get closer to the mockup

<template>
    <div v-show="annotation" class="wrapper">
        <div v-show="comments.length === 0" class="alert alert-info">Pas de commentaire pour le moment.</div>
        <comment
            v-for="comment in comments"
            v-bind:id="comment.id"
            v-bind:level="comment.level"
            v-bind:comment="comment.comment"
            v-bind:username="comment.user_name"
            v-bind:date="comment.submit_date"
            v-bind:allowThread="comment.allow_thread"></comment>
    </div>
</template>

<script>

    import Comment from './Comment.vue'

    export default {
        props: ['annotation', 'fetch'],
        components: {
            Comment
        },
        data() {
            return {
                'comments': []
            }
        },
        computed: {
            commentsURL: function() {
                return this.fetch.replace(':annotation_guid', this.annotation.annotation_guid);
            }
        },
        watch: {
            annotation: function(annotation) {
                if (annotation) {
                    $.getJSON(this.commentsURL).then((comments) => this.comments = comments);
                } else {
                    this.comments = [];
                }
            }
        }
    }

</script>

<style scoped>
.wrapper {
    /* max-height: 200px; */
    height: auto;
    overflow-y: auto;
}
.alert {
    padding: 10px;
    font-size: 12px;
}
</style>