Fix comment form.
authorAlexandre Segura <mex.zktk@gmail.com>
Mon, 20 Feb 2017 17:46:45 +0100
changeset 324 8f19067caeec
parent 323 55c024fc7c60
child 325 8f158a4c7759
Fix comment form.
src/iconolab/templates/iconolab/detail_image.html
src/iconolab/templates/partials/comment_form.html
src_js/iconolab-bundle/src/iconolab.scss
--- a/src/iconolab/templates/iconolab/detail_image.html	Mon Feb 20 17:29:55 2017 +0100
+++ b/src/iconolab/templates/iconolab/detail_image.html	Mon Feb 20 17:46:45 2017 +0100
@@ -49,12 +49,14 @@
           {% csrf_token %}
         </annotation-form>
         <comment-list ref="commentList"></comment-list>
-        <form id="form-comment">
-            <div class="form-group">
-              <textarea class="form-control input-sm" placeholder="Ajouter mon commentaire..." disabled></textarea>
-            </div>
-            <button type="submit" class="btn btn-block btn-sm btn-primary" disabled>Commenter</button>
-        </form>
+        <div id="form-comment">
+          <form>
+              <div class="form-group">
+                <textarea class="form-control input-sm" placeholder="Ajouter mon commentaire..." disabled></textarea>
+              </div>
+              <button type="submit" class="btn btn-block btn-sm btn-primary" disabled>Commenter</button>
+          </form>
+        </div>
       </div>
     </div>
   </div>
@@ -90,7 +92,7 @@
         $.getJSON('/comments/annotation/' + annotation + '/comments.json')
           .then(function(comments) {
 
-            $('#annotation-panel form:last').replaceWith(form);
+            $('#form-comment form').replaceWith(form);
 
             $('.list-group a[data-annotation-id]').removeClass('active');
             $el.addClass('active');
@@ -139,7 +141,7 @@
     vm.$refs.panel.reset();
     vm.$refs.commentList.comments = [];
 
-    $('#annotation-panel form:last').find('textarea, [type="submit"]').attr('disabled', true);
+    $('#form-comment form').find('textarea, [type="submit"]').attr('disabled', true);
 
     location.hash = '';
   });
--- a/src/iconolab/templates/partials/comment_form.html	Mon Feb 20 17:29:55 2017 +0100
+++ b/src/iconolab/templates/partials/comment_form.html	Mon Feb 20 17:46:45 2017 +0100
@@ -1,5 +1,7 @@
 <form action="{% url 'post_comment' %}" method="POST">
+
   {% csrf_token %}
+
   {{ comment_form.content_type }}
   {{ comment_form.object_pk }}
   {{ comment_form.timestamp }}
@@ -23,45 +25,4 @@
   </fieldset>
   <input class="btn btn-block btn-sm btn-primary" type="submit" name="post" class="submit-post" value="Commenter">
 
-  {% comment %}
-  {#
-  <input id="reply-to-field" type="hidden" name="reply_to" value="0"></input>
-  <input type="hidden" name="next" value="{% url 'annotation_detail' collection_name image_guid annotation_guid %}">
-  <h4> Commenter ({{user.username}}) </h4>
-  <div class="reply-to-container">
-    <label id="form-reply-to-label" class="control-label reply-to-label" for="id_{{ comment_form.comment.name }}">En réponse à : </label>
-    <div class="alert alert-info reply-to-alert">
-       <p class="reply-to-content comment-content"></p>
-       <hr class="comment-separator">
-       <div class="reply-to-subtext comment-subtext"></div>
-       <div class="reply-to-label-list comment-metacategories"></div>
-    </div>
-    <a class="btn btn-default btn-sm reply-to-cancel">Annuler et répondre sur le fil principal</a><br><br>
-  </div>
-  <fieldset class="form-group {% if comment_form.comment.errors %}has-error{% endif %}">
-    {% if comment_form.comment.errors %}
-      <div class="alert alert-danger" role="alert">
-        <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
-        <span class="sr-only">Erreur :</span>
-          {{ comment_form.comment.errors | striptags }}
-      </div>
-    {% endif %}
-    <textarea class="form-control"
-      name="{{ comment_form.comment.name }}"
-      id="id_{{ comment_form.comment.name }}" ></textarea>
-  </fieldset>
-  <fieldset class="form-group {% if comment_form.metacategories.errors %}has-error{% endif %}">
-    <div class="input-group">
-      {% for metacategory in comment_form.metacategories %}
-        <label class="checkbox-inline" for="{{metacategory.id_for_label}}">
-            {{ metacategory.tag }} {{metacategory.choice_label}}
-        </label>
-      {% endfor %}
-    </div>
-  </fieldset>
-  <p class="submit">
-    <input class="btn btn-default" type="submit" name="post" class="submit-post" value="Publier"/>
-  </p>
-  #}
-  {% endcomment %}
 </form>
--- a/src_js/iconolab-bundle/src/iconolab.scss	Mon Feb 20 17:29:55 2017 +0100
+++ b/src_js/iconolab-bundle/src/iconolab.scss	Mon Feb 20 17:46:45 2017 +0100
@@ -331,7 +331,7 @@
             > * {
                 flex: 1;
             }
-            form:last-of-type {
+            > *:last-child {
                 display: flex;
                 flex-direction: column;
                 justify-content: flex-end;