src/catedit/templates/social/changeset.html
author durandn
Tue, 07 Apr 2015 20:03:04 +0200
changeset 62 746d486f7c42
parent 48 353e246a8f59
child 64 78ffda1da64c
permissions -rw-r--r--
Added support for custom properties per repository + added doc in the readme for this (config.py PROPERTY_LIST entry has changed a bit)

{% extends "social/comment_thread_layout.html" %}
{% if not session["user_logged"] or not session["user_can_edit"][current_repository] %}
  {% set readonly="readonly" %}
{% else %}
  {% set readonly=False %}
{% endif %}
{% block title %}{{super()}}{% endblock title %}
{% block head %}
  {{super()}}
  <script src="{{ url_for('static', filename='js/jquery-1.11.1.min.js') }}" language="Javascript" type="text/javascript"></script>
  <script>
    $(document).ready(function(){
      $(".cat-info-div").hide();
      $(".cat-table").hide();
      {% if changes_details %}
        $(".changes-table").show()
        $(".changes-table-toggle").toggleClass("btn-info")
        $(".changes-box").toggleClass("alert-info");
      {% endif %}
      $(".before-cat-table-toggle").click(function(evt){
        $(".before-cat-table-toggle").toggleClass("btn-info")
        $(".before-box").toggleClass("alert-info");

        $(".after-cat-table-toggle").removeClass("btn-info")
        $(".after-box").removeClass("alert-info");

        $(".changes-table-toggle").removeClass("btn-info")
        $(".changes-box").removeClass("alert-info");

        $(".before-cat-table").toggle("fast", function(){
          $(".before-cat-table-toggle").children().toggleClass("glyphicon-chevron-up glyphicon-chevron-down")
        });
        $(".after-cat-table").hide("fast", function(){
          $(".after-cat-table-toggle").children().removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down");
        });
        $(".changes-table").hide(function(){
          $(".changes-table-toggle").children().removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down");
        });
      });

      $(".after-cat-table-toggle").click(function(evt){
        $(".after-cat-table-toggle").toggleClass("btn-info")
        $(".after-box").toggleClass("alert-info");

        $(".before-cat-table-toggle").removeClass("btn-info")
        $(".before-box").removeClass("alert-info");

        $(".changes-table-toggle").removeClass("btn-info")
        $(".changes-box").removeClass("alert-info");

        $(".after-cat-table").toggle("fast", function(){
          $(".after-cat-table-toggle").children().toggleClass("glyphicon-chevron-up glyphicon-chevron-down")
        });
        $(".before-cat-table").hide("fast", function(){
          $(".before-cat-table-toggle").children().removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down");
        });
        $(".changes-table").hide(function(){
          $(".changes-table-toggle").children().removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down");
        });
      });

      $(".changes-table-toggle").click(function(evt){
        $(".changes-table-toggle").toggleClass("btn-info")
        $(".changes-box").toggleClass("alert-info");

        $(".before-cat-table-toggle").removeClass("btn-info")
        $(".before-box").removeClass("alert-info");

        $(".after-cat-table-toggle").removeClass("btn-info")
        $(".after-box").removeClass("alert-info");

        $(".changes-table").slideToggle(function(){
          $(".changes-table-toggle").children().toggleClass("glyphicon-chevron-up glyphicon-chevron-down")
        });
        $(".before-cat-table").hide("fast", function(){
          $(".before-cat-table-toggle").children().removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down");
        });
        $(".after-cat-table").hide("fast", function(){
          $(".after-cat-table-toggle").children().removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down");
        });
      });

      $(".cat-info-toggle").click(function(evt){
        $("#properties_"+evt.target.id.split('_').slice(2,5).join('_')).slideToggle(function(){
          $("#info_button_"+evt.target.id.split('_').slice(2,5).join('_')).children().toggleClass("glyphicon-plus-sign");
          $("#info_button_"+evt.target.id.split('_').slice(2,5).join('_')).children().toggleClass("glyphicon-minus-sign");
        });

      });
    });
  </script>
{% endblock head%}
{% block navbar_items %}
  {{super()}}
  <li><a class="navbar-decorative">></a></li>
  <li><a href="{{ url_for('social.changesets_index', repository=current_repository)}}">Changements</a></li>
  <li><a class="navbar-decorative">></a></li>
  <li class="active"><a>Discussion</a></li>
{% endblock navbar_items %}
{% block additional_content %}
<h3><b>Changements:</b> {{comments["title"]}}</h3>
<div class="container changeset-menu">
  <div class="col-md-4 before-box alert">
    <h4><strong>Avant modifications </strong>
    <a title="Afficher/Cacher tableau" class="btn btn-default before-cat-table-toggle">
      <span class="glyphicon glyphicon-chevron-down"/>
    </a></h4>
    <p class="text-justified">
      Permet de visualiser l'état de l'ensemble de catégories {{current_repository}} avant que ne soient pris en compte
      les changements considérés.
    </p>
  </div>
  <div class="col-md-4 changes-box alert">
    <h4><strong>Résumé des modifications </strong>
    <a title="Afficher/Cacher tableau" class="btn btn-default changes-table-toggle">
      <span class="glyphicon glyphicon-chevron-down"/>
    </a></h4>
    <p class="text-justified">
      Permet de visualiser les différences entre l'ensemble de catégories {{current_repository}} avant les modifications considérées
      et le même ensemble après les modifications
    </p>
  </div>
  <div class="col-md-4 after-box alert">
    <h4><strong>Après modifications </strong>
    <a title="Afficher/Cacher tableau" class="btn btn-default after-cat-table-toggle">
      <span class="glyphicon glyphicon-chevron-down"/>
    </a></h4>
    <p class="text-justified">
      Permet de visualiser l'état de l'ensemble de catégories {{current_repository}} après prise en compte
      les changements considérés.
    </p>
  </div>
</div><br>
<div class="before-cat-table cat-table">
  <table class="table table-condensed table-bordered">
    <thead>
      <tr class="active">
        <th class="col-md-2"><b>Nom</b></th>
        <th class="col-md-10" colspan="2"><b>Description</b></th>
      </tr>
    </thead>
    <tbody>
    {% if not session["user_logged"] %}
    <tr>
      <td class="col-md-12" colspan="2">
        <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
        <span class="sr-only">Attention:</span>
        Veuillez vous identifier pour visualiser les catégories
      </td>
    </tr>
    {% else %}
      {% if old_cat_list|length == 0 %}
        <tr>
          <td class="col-md-12" colspan="2">Aucune catégorie n'existait avant ces changements. {% if not readonly %}<a href="{{ url_for('categories.editor', repository=current_repository) }}">Créer une catégorie</a>{% endif %}</td>
        </tr>
      {% else %}
        {% import "macros.html" as macros %}
        {{ macros.category_table(old_cat_list, current_repository, state_list=["original"], interactive=False) }}
      {% endif %}
    {% endif %}
    </tbody>
  </table>
</div>
<div class="changes-table cat-table">
  <ul class="list-group col-md-12">
    <li class="list-group-item list-group-item-success">
      <h4>
        <b>Catégories ajoutées</b>
        <span class="badge">{{differences["additions"]|length}}</span>
      </h4>
    </li>
    {% for added_category in differences["additions"] %}
      <li class="list-group-item">
        {{ added_category }}
      </li>
    {% endfor %}
    <li class="list-group-item list-group-item-warning">
      <h4>
        <b>Catégories modifiées</b>
        <span class="badge">{{differences["modifications"]|length}}</span>
      </h4>
    </li>
    {% for modified_category in differences["modifications"] %}
      <li class="list-group-item {% if modified_category[2] == changes_details['cat_id'] %}list-group-item-warning{% endif %}">
          {{ modified_category[0] }}
          <span class="glyphicon glyphicon-chevron-right"></span>
          {{ modified_category[1] }}
          {% if modified_category[2] != changes_details["cat_id"] %}
          <a class="btn btn-default" href="{{url_for('social.changeset', repository=current_repository, changeset_id=changeset_id, details_cat_id=modified_category[2])}}">
            <span class="glyphicon glyphicon-log-in"></span>
          </a>
          {% else %}
            <br>
            <br>
            {% if changes_details["only_in_first"]|length > 0 %}
              <p class="text-danger">Propriétés présentes uniquement dans la version précédente:
              <dl class="dl-horizontal text-danger">
              {% for change in changes_details["only_in_first"] %}
                {% if change[0] == "description" %}
                  <dt>Description</dt>
                  <dd>{{ change[1] }}</dd>
                {% elif change[0] == "label" %}
                  <dt>Label</dt>
                  <dd>{{ change[1] }}</dd>
                {% else %}
                  <dt>{{ session["properties"][current_repository][change[0]]["descriptive_label_fr"] }}</dt>
                  <dd>
                  {% if session["properties"][current_repository][change[0]]["object_type"]=="uriref-category" %}
                    {% for old_cat in old_cat_list %}
                      {% if change[1] == old_cat.cat_id %}
                        {{ old_cat.cat_label }}
                      {% endif %}
                    {% endfor %}
                  {% elif session["properties"][current_repository][change[0]]["object_type"]=="uriref-link" %}
                    <a href="{{ change[1] }}">{{ change[1] }}</a>
                  {% else %}
                    {{ change[1] }}
                  {% endif %}
                  </dd>
                {% endif %}
              {% endfor %}
              </dl>
              </p>
            {% endif %}
            {% if changes_details["only_in_second"]|length > 0 %}
              <p class="text-success">Propriétés présentes uniquement dans la nouvelle version:
              <dl class="dl-horizontal text-success">
              {% for change in changes_details["only_in_second"] %}
                {% if change[0] == "description" %}
                  <dt>Description</dt>
                  <dd>{{ change[1] }}</dd>
                {% elif change[0] == "label" %}
                  <dt>Label</dt>
                  <dd>{{ change[1] }}</dd>
                {% else %}
                  <dt>{{ session["properties"][current_repository][change[0]]["descriptive_label_fr"] }}</dt>
                  <dd>
                  {% if session["properties"][current_repository][change[0]]["object_type"]=="uriref-category" %}
                    {% for new_cat in new_cat_list %}
                      {% if change[1] == new_cat.cat_id %}
                        {{ new_cat.cat_label }}
                      {% endif %}
                    {% endfor %}
                  {% elif session["properties"][current_repository][change[0]]["object_type"]=="uriref-link" %}
                    <a href="{{ change[1] }}">{{ change[1] }}</a>
                  {% else %}
                    {{ change[1] }}
                  {% endif %}
                  </dd>
                {% endif %}
              {% endfor %}
              </dl>
              </p>
            {% endif %}
          {% endif %}
      </li>
    {% endfor %}
    <li class="list-group-item list-group-item-danger">
      <h4>
        <b>Catégories supprimées</b>
        <span class="badge">{{differences["deletions"]|length}}</span>
      </h4>
    </li>
    {% for deleted_category in differences["deletions"] %}
      <li class="list-group-item">
        {{ deleted_category }}
      </li>
    {% endfor %}
</ul>
</div>
<div class="after-cat-table cat-table">
  <table class="table table-condensed table-bordered">
    <thead>
      <tr class="active">
        <th class="col-md-2"><b>Nom</b></th>
        <th class="col-md-10" colspan="2"><b>Description</b></th>
      </tr>
    </thead>
    <tbody>
    {% if not session["user_logged"] %}
    <tr>
      <td class="col-md-12" colspan="2">
        <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
        <span class="sr-only">Attention:</span>
        Veuillez vous identifier pour visualiser les catégories
      </td>
    </tr>
    {% else %}
      {% if new_cat_list|length == 0 %}
        <tr>
          <td class="col-md-12" colspan="2">Aucune catégorie n'existe suite à ces changements. {% if not readonly %}<a href="{{ url_for('categories.editor', repository=current_repository) }}">Créer une catégorie</a>{% endif %}</td>
        </tr>
      {% else %}
        {% import "macros.html" as macros %}
        {{ macros.category_table(new_cat_list, current_repository, state_list=["modified"], interactive=False, with_colors=False) }}
      {% endif %}
    {% endif %}
    </tbody>
  </table>
</div>
{% endblock additional_content %}
{% block back_link %}{{ url_for('social.changesets_index', repository=current_repository)}}{% endblock back_link %}
{% block comment_posting_target %}{{url_for("social.changeset", changeset_id=changeset_id, repository=current_repository)}}{% endblock %}
{% block page_content %}
  {{super()}}
{% endblock page_content %}