# HG changeset patch # User Alexandre Segura # Date 1488214214 -3600 # Node ID 0a4743126d74d52bc241c35a224fa7aff1315bc2 # Parent e5286c7506b5955a71056d1e9298c892f187e540 Implement replying to comments. diff -r e5286c7506b5 -r 0a4743126d74 src/iconolab/serializers.py --- a/src/iconolab/serializers.py Mon Feb 27 17:47:22 2017 +0100 +++ b/src/iconolab/serializers.py Mon Feb 27 17:50:14 2017 +0100 @@ -25,6 +25,7 @@ class IconolabCommentSerializer(serializers.ModelSerializer): + allow_thread = serializers.BooleanField() class Meta: model = IconolabComment fields = '__all__' diff -r e5286c7506b5 -r 0a4743126d74 src/iconolab/settings/dev.py.tmpl --- a/src/iconolab/settings/dev.py.tmpl Mon Feb 27 17:47:22 2017 +0100 +++ b/src/iconolab/settings/dev.py.tmpl Mon Feb 27 17:50:14 2017 +0100 @@ -83,7 +83,7 @@ COMMENTS_APP = "django_comments_xtd" COMMENTS_XTD_MODEL = "iconolab.models.IconolabComment" COMMENTS_XTD_FORM_CLASS = 'iconolab.forms.comments.IconolabCommentForm' -COMMENTS_XTD_MAX_THREAD_LEVEL = 100 +COMMENTS_XTD_MAX_THREAD_LEVEL = 1 COMMENTS_PER_PAGE_DEFAULT = 10 SITE_ID = 1 diff -r e5286c7506b5 -r 0a4743126d74 src/iconolab/templates/iconolab/detail_image.html --- a/src/iconolab/templates/iconolab/detail_image.html Mon Feb 27 17:47:22 2017 +0100 +++ b/src/iconolab/templates/iconolab/detail_image.html Mon Feb 27 17:50:14 2017 +0100 @@ -60,15 +60,15 @@ action="{% url 'annotation_edit' collection_name image_guid ':annotation_guid' %}"> {% csrf_token %} - -
-
-
- -
- -
+ +
+ + +
@@ -84,6 +84,15 @@ var getCommentFormURL = "{% url 'get_comment_form' ':annotation_guid' %}" var isAuthenticated = {% if user.is_authenticated %}true{% else %}false{% endif %}; + Vue.component('comment-form', { + template: '
', + data: function() { + return { + replyTo: 0 + } + } + }); + var vm = new Vue({ el: '.annotation-navigator', data: function() { @@ -110,12 +119,17 @@ $.get(getCommentFormURL.replace(':annotation_guid', annotation), { next: currentPath + '#' + annotation }) .then(function(form) { + Vue.component('comment-form', function (resolve, reject) { + resolve({ + props: ['reply-to'], + template: form, + }); + }); + $('.list-group a[data-annotation-id]').removeClass('active'); $el.addClass('active'); - if (isAuthenticated) { - $('#form-comment form').replaceWith(form).show(); - } + $('.annotation-comment-list').show(); vm.annotation = annotations[revision]; @@ -156,10 +170,7 @@ vm.annotation = null; - $('#form-comment form') - .hide() - .find('textarea, [type="submit"]') - .attr('disabled', true); + $('.annotation-comment-list').hide(); location.hash = ''; }); @@ -181,7 +192,7 @@ } } } - window.addEventListener('hashchange', function() { router(false) }); + window.addEventListener('hashchange', function() { router(true) }); window.addEventListener('load', function() { router(true) }); diff -r e5286c7506b5 -r 0a4743126d74 src/iconolab/templates/partials/comment_form.html --- a/src/iconolab/templates/partials/comment_form.html Mon Feb 27 17:47:22 2017 +0100 +++ b/src/iconolab/templates/partials/comment_form.html Mon Feb 27 17:50:14 2017 +0100 @@ -8,21 +8,15 @@ {{ comment_form.security_hash }} - + -
- {% if comment_form.comment.errors %} - - {% endif %} +
- + + diff -r e5286c7506b5 -r 0a4743126d74 src_js/iconolab-bundle/src/components/editor/Comment.vue --- a/src_js/iconolab-bundle/src/components/editor/Comment.vue Mon Feb 27 17:47:22 2017 +0100 +++ b/src_js/iconolab-bundle/src/components/editor/Comment.vue Mon Feb 27 17:50:14 2017 +0100 @@ -1,9 +1,16 @@ @@ -12,15 +19,26 @@ import showdown from 'showdown' - const converter = new showdown.Converter() + const converter = new showdown.Converter({ + simpleLineBreaks: true + }) export default { + components: ['comment-form'], props: [ + 'id', + 'level', 'comment', 'username', 'email', - 'date' + 'date', + 'allowThread' ], + data() { + return { + showForm: false + } + }, computed: { dateFormatted: function () { @@ -46,11 +64,15 @@ padding: 5px 0; border-bottom: 1px solid #ccc; } +.comment-author { + float: left; + margin-right: 4px; +} +.comment-date { + +} .comment-footer { margin-top: 5px; color: #ccc; } -.comment-date { - float: right; -} diff -r e5286c7506b5 -r 0a4743126d74 src_js/iconolab-bundle/src/components/editor/CommentList.vue --- a/src_js/iconolab-bundle/src/components/editor/CommentList.vue Mon Feb 27 17:47:22 2017 +0100 +++ b/src_js/iconolab-bundle/src/components/editor/CommentList.vue Mon Feb 27 17:50:14 2017 +0100 @@ -1,12 +1,14 @@ @@ -43,6 +45,10 @@