src_js/iconolab-bundle/src/components/editor/Comment.vue
author Alexandre Segura <mex.zktk@gmail.com>
Mon, 27 Feb 2017 17:50:14 +0100
changeset 396 0a4743126d74
parent 391 7ab1cc12827e
child 405 6b8a1ae18e91
permissions -rw-r--r--
Implement replying to comments.
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: 391
diff changeset
     2
    <div class="comment" v-bind:style="{ marginLeft: (level * 15) + 'px' }">
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
     3
        <div class="comment-body">
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
     4
            <strong class="comment-author">{{ username }}</strong>
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
     5
            <div class="comment-content" v-html="commentFormatted"></div>
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
     6
        </div>
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     7
        <div class="comment-footer">
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
     8
            <a v-if="allowThread" href="#" v-on:click.prevent="showForm = !showForm">Répondre</a>
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     9
            <span class="comment-date">{{ dateFormatted }}</span>
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    10
            <comment-form v-bind:reply-to="id" v-if="allowThread" v-show="showForm">
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    11
                <button slot="submit" type="submit" class="btn btn-xs btn-primary">Valider</button>
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    12
                <a slot="submit" href="#" v-on:click.prevent="showForm = false" class="text-muted" style="margin-left: 5px;">Annuler</a>
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    13
            </comment-form>
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    14
        </div>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    15
    </div>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    16
</template>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    17
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    18
<script>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    19
391
7ab1cc12827e adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents: 323
diff changeset
    20
    import showdown from 'showdown'
7ab1cc12827e adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents: 323
diff changeset
    21
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    22
    const converter = new showdown.Converter({
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    23
        simpleLineBreaks: true
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    24
    })
391
7ab1cc12827e adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents: 323
diff changeset
    25
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    26
    export default {
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    27
        components: ['comment-form'],
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    28
        props: [
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    29
            'id',
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    30
            'level',
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    31
            'comment',
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    32
            'username',
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    33
            'email',
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    34
            'date',
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    35
            'allowThread'
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    36
        ],
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    37
        data() {
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    38
            return {
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    39
                showForm: false
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    40
            }
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    41
        },
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    42
        computed: {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    43
            dateFormatted: function () {
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
                var date = new Date(this.date);
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    46
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    47
                var day = date.getDate();
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    48
                var month = date.getMonth() + 1;
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    49
                var year = date.getFullYear();
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    50
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    51
                return day + '/' + month + '/' + year;
391
7ab1cc12827e adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents: 323
diff changeset
    52
            },
7ab1cc12827e adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents: 323
diff changeset
    53
            commentFormatted: function(){
7ab1cc12827e adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents: 323
diff changeset
    54
              return converter.makeHtml(this.comment);
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    55
            }
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    56
        }
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    57
    }
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    58
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    59
</script>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    60
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    61
<style scoped>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    62
.comment {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    63
    font-size: 12px;
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    64
    padding: 5px 0;
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    65
    border-bottom: 1px solid #ccc;
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    66
}
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    67
.comment-author {
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    68
    float: left;
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    69
    margin-right: 4px;
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    70
}
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    71
.comment-date {
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    72
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    73
}
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    74
.comment-footer {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    75
    margin-top: 5px;
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    76
    color: #ccc;
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    77
}
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    78
</style>