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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     1
<template>
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 351
diff changeset
     2
    <div v-show="annotation" class="wrapper">
328
c23659daa42d Show alert when there are no comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 326
diff changeset
     3
        <div v-show="comments.length === 0" class="alert alert-info">Pas de commentaire pour le moment.</div>
326
b962ae792616 Make CommentList more isolated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
     4
        <comment
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     5
            v-for="comment in comments"
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 351
diff changeset
     6
            v-bind:id="comment.id"
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 351
diff changeset
     7
            v-bind:level="comment.level"
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     8
            v-bind:comment="comment.comment"
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     9
            v-bind:username="comment.user_name"
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 351
diff changeset
    10
            v-bind:date="comment.submit_date"
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 351
diff changeset
    11
            v-bind:allowThread="comment.allow_thread"></comment>
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    12
    </div>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    13
</template>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    14
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    15
<script>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    16
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    17
    import Comment from './Comment.vue'
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    18
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    19
    export default {
326
b962ae792616 Make CommentList more isolated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    20
        props: ['annotation', 'fetch'],
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    21
        components: {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    22
            Comment
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    23
        },
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    24
        data() {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    25
            return {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    26
                'comments': []
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    27
            }
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    28
        },
326
b962ae792616 Make CommentList more isolated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    29
        computed: {
b962ae792616 Make CommentList more isolated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    30
            commentsURL: function() {
b962ae792616 Make CommentList more isolated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    31
                return this.fetch.replace(':annotation_guid', this.annotation.annotation_guid);
b962ae792616 Make CommentList more isolated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    32
            }
b962ae792616 Make CommentList more isolated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    33
        },
b962ae792616 Make CommentList more isolated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    34
        watch: {
b962ae792616 Make CommentList more isolated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    35
            annotation: function(annotation) {
b962ae792616 Make CommentList more isolated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    36
                if (annotation) {
b962ae792616 Make CommentList more isolated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    37
                    $.getJSON(this.commentsURL).then((comments) => this.comments = comments);
b962ae792616 Make CommentList more isolated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    38
                } else {
b962ae792616 Make CommentList more isolated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    39
                    this.comments = [];
b962ae792616 Make CommentList more isolated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    40
                }
b962ae792616 Make CommentList more isolated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    41
            }
b962ae792616 Make CommentList more isolated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    42
        }
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    43
    }
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    44
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    45
</script>
328
c23659daa42d Show alert when there are no comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 326
diff changeset
    46
c23659daa42d Show alert when there are no comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 326
diff changeset
    47
<style scoped>
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 351
diff changeset
    48
.wrapper {
410
a6db5e626850 sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents: 396
diff changeset
    49
    /* max-height: 200px; */
a6db5e626850 sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents: 396
diff changeset
    50
    height: auto;
a6db5e626850 sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents: 396
diff changeset
    51
    overflow-y: auto;
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 351
diff changeset
    52
}
328
c23659daa42d Show alert when there are no comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 326
diff changeset
    53
.alert {
c23659daa42d Show alert when there are no comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 326
diff changeset
    54
    padding: 10px;
c23659daa42d Show alert when there are no comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 326
diff changeset
    55
    font-size: 12px;
c23659daa42d Show alert when there are no comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 326
diff changeset
    56
}
c23659daa42d Show alert when there are no comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 326
diff changeset
    57
</style>