src_js/iconolab-bundle/src/components/editor/CommentList.vue
author Alexandre Segura <mex.zktk@gmail.com>
Thu, 23 Feb 2017 11:52:20 +0100
changeset 356 a45f7dac4789
parent 351 2d5557c01f95
child 396 0a4743126d74
permissions -rw-r--r--
Change wordings, align text.

<template>
    <div v-show="annotation">
        <label class="small text-muted">Commentaires</label>
        <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:comment="comment.comment"
            v-bind:username="comment.user_name"
            v-bind:date="comment.submit_date"></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>
.alert {
    padding: 10px;
    font-size: 12px;
}
</style>