# HG changeset patch # User Alexandre Segura # Date 1488328880 -3600 # Node ID 6b8a1ae18e91ec11fbb33320f9987138fcaf50ca # Parent 38dfe91ee69aecf8bd3b61c1f9f9e0075ae91f85 Introduce meta categories widget. diff -r 38dfe91ee69a -r 6b8a1ae18e91 src/iconolab/templates/iconolab/detail_image.html --- a/src/iconolab/templates/iconolab/detail_image.html Tue Feb 28 17:19:04 2017 +0100 +++ b/src/iconolab/templates/iconolab/detail_image.html Wed Mar 01 01:41:20 2017 +0100 @@ -66,9 +66,7 @@ fetch="{% url 'get_annotation_comments_json' ':annotation_guid' %}">
- - - +
@@ -88,7 +86,8 @@ template: '
', data: function() { return { - replyTo: 0 + replyTo: 0, + btnGroupClass: {} } } }); @@ -123,6 +122,31 @@ resolve({ props: ['reply-to'], template: form, + data: function() { + return { + active: null + } + }, + watch: { + active: function(active) { + if (active) { + setTimeout(() => $(this.$el).find('[name="comment"]').focus(), 200); + } + } + }, + computed: { + btnGroupClass: function() { + var classes = [ + { active: this.active || false } + ]; + + if (this.active) { + classes.push('btn-group-' + this.active) + } + + return classes; + } + } }); }); diff -r 38dfe91ee69a -r 6b8a1ae18e91 src/iconolab/templates/partials/comment_form.html --- a/src/iconolab/templates/partials/comment_form.html Tue Feb 28 17:19:04 2017 +0100 +++ b/src/iconolab/templates/partials/comment_form.html Wed Mar 01 01:41:20 2017 +0100 @@ -1,4 +1,4 @@ -
+ {% csrf_token %} @@ -10,13 +10,64 @@ -
+
+
+ + {% if 'request_for_contribution' in metacategories %} + + {% endif %} + {% if 'reference' in metacategories %} + + {% endif %} + + + + {% if 'agree' in metacategories %} + + {% endif %} + {% if 'disagree' in metacategories %} + + {% endif %} + +
+
+ +
- + + + Annuler + diff -r 38dfe91ee69a -r 6b8a1ae18e91 src/iconolab/views/comments.py --- a/src/iconolab/views/comments.py Tue Feb 28 17:19:04 2017 +0100 +++ b/src/iconolab/views/comments.py Wed Mar 01 01:41:20 2017 +0100 @@ -119,8 +119,23 @@ annotation = Annotation.objects.get(annotation_guid=annotation_guid) next_url = request.GET.get('next') form = django_comments.get_form()(annotation) + + metacategory_keys = { + 'Appel à contribution': 'request_for_contribution', + 'Référence': 'reference', + 'Accord': 'agree', + 'Désaccord': 'disagree' + } + metacategories = {} + + for metacategory in annotation.image.item.collection.metacategories.all(): + if metacategory.label not in metacategory_keys.keys(): + continue + metacategories[metacategory_keys[metacategory.label]] = metacategory + return render(request, 'partials/comment_form.html', { 'comment_form': form, + 'metacategories': metacategories, 'next': next_url }) diff -r 38dfe91ee69a -r 6b8a1ae18e91 src_js/iconolab-bundle/src/components/editor/Comment.vue --- a/src_js/iconolab-bundle/src/components/editor/Comment.vue Tue Feb 28 17:19:04 2017 +0100 +++ b/src_js/iconolab-bundle/src/components/editor/Comment.vue Wed Mar 01 01:41:20 2017 +0100 @@ -1,16 +1,15 @@ @@ -36,7 +35,8 @@ ], data() { return { - showForm: false + showForm: false, + hover: false } }, computed: { diff -r 38dfe91ee69a -r 6b8a1ae18e91 src_js/iconolab-bundle/src/iconolab.scss --- a/src_js/iconolab-bundle/src/iconolab.scss Tue Feb 28 17:19:04 2017 +0100 +++ b/src_js/iconolab-bundle/src/iconolab.scss Wed Mar 01 01:41:20 2017 +0100 @@ -103,6 +103,111 @@ border: 1px solid #bbb } +.comment-form { + + $color-request-for-contribution: #f5e41c; + $color-reference: #478ee0; + $color-agree: #b8e986; + $color-disagree: #ff7284; + + .btn-group-wrapper { + text-align: center; + } + + .form-group { + margin-bottom: 10px; + } + + .btn-group-metacategory { + + padding-bottom: 5px; + margin-bottom: 5px; + border-bottom: 2px solid #969696; + + &.btn-group-request-for-contribution { + border-color: $color-request-for-contribution; + } + &.btn-group-reference { + border-color: $color-reference; + } + &.btn-group-agree { + border-color: $color-agree; + } + &.btn-group-disagree { + border-color: $color-disagree; + } + + &.active { + padding-bottom: 0px; + } + + .btn { + border: none; + padding: 4px 8px; + margin: 0 2px; + border-radius: 0; + border-radius: 4px !important; + } + .btn:first-child { + margin-left: 0; + } + .btn:last-child { + margin-right: 0; + } + .btn:focus, + .btn.focus, + .btn:active:focus, + .btn:active.focus, + .btn.active:focus, + .btn.active.focus { + outline: none; + } + .btn.active { + padding: 4px 8px 8px; + border-bottom-left-radius: 0 !important; + border-bottom-right-radius: 0 !important; + } + .btn-comment { + background-color: #969696; + color: #fff; + padding-left: 20px; + padding-right: 20px; + &:hover { + background-color: darken(#969696, 10%); + } + &.active { + padding-left: 20px; + padding-right: 20px; + } + } + .btn-request-for-contribution { + background-color: $color-request-for-contribution; + &:hover { + background-color: darken($color-request-for-contribution, 10%); + } + } + .btn-reference { + background-color: $color-reference; + color: #fff; + &:hover { + background-color: darken($color-reference, 10%); + } + } + .btn-agree { + background-color: $color-agree; + &:hover { + background-color: darken($color-agree, 10%); + } + } + .btn-disagree { + background-color: $color-disagree; + &:hover { + background-color: darken($color-disagree, 10%); + } + } + } +} + .comment-reply-link{ cursor: pointer; }