Commits

Anonymous committed fb1fa7c

Option to hide/show 100% completed statistics on every table.

Actually this includes full support for a more generic show/hide
mechanism which we could use for more actions. The only limitation
is the use of an input:checked element (ie no <span>s).

  • Participants
  • Parent commits 763bc6a

Comments (0)

Files changed (17)

docs/releases/0.7.txt

 - Replaced django-evolution with South
 - Added buildout support
 - Added zebra style to the stats tables
+- Added option to filter out completed files in a statistics table.
 
 
 Translations

transifex/site_media/css/base.css

   padding-bottom: 1em;
 }
 
-div.obj_bigdetails div.editlinks { float: right; clear: right; }
-div.obj_bigdetails div.editlinks p { float: right; clear: right; margin: 0; }
+div.editlinks { float: right; clear: right; }
+div.editlinks p { float: right; clear: right; margin: 0; }
 div.deletelink { text-align: center; margin-bottom: 1em; }
 div.deletelink a:hover {
   color: #833;

transifex/site_media/css/icons.css

 .i16.compress { background-image: url('../images/icons/compress.png'); }
 .i16.delete { background-image: url('../images/icons/cross.png'); }
 .i16.delete_circle { background-image: url('../images/icons/cancel.png'); }
+.i16.drink { background-image: url('../images/icons/drink.png'); }
 .i16.edit { background-image: url('../images/icons/pencil.png'); }
 .i16.edit_file { background-image: url('../images/icons/page_white_edit.png'); }
 .i16.cache { background-image: url('../images/icons/lorry.png'); }

transifex/site_media/images/icons/drink.png

Added
New image

transifex/site_media/js/tablesorted.js

+
+function toggle_entries(entries_status){
+    /*
+    Toggle entries of the online translation form filtering the rows by the
+    status of each entry.
+    */
+    $('.'+entries_status).each(function(){
+        if($("input[name='show_"+entries_status+"']").is(':checked')){
+            $(this).removeClass('hidden_field');
+        } else {
+            $(this).addClass('hidden_field');
+        }
+    })
+};
+
 $(document).ready(function(){
 
     // ordering for Release stats table

transifex/templates/languages/language_release.html

     form.submit_form { display: none; }
     form.submit_form fieldset { border: 2px dotted #ddd; }
   </style>
+
+  <script type="text/javascript">
+  $(function(){
+    {% include "translations/stats_table_filter_header.html" %}
+  });
+  </script>
 {% endblock %}
 
 {% block body_class %}{{ block.super }} language_release{% endblock %}
 
 <h3>{% trans "Project/Component statistics" %} </h3>
 
+{% include "translations/stats_table_filter_box.html" %}
+
 {% lang_stats_table pofile_list %}
 
 {% url language_release_download slug=language.code collection_slug=release.collection.slug release_slug=release.slug filetype="zip" as zip_download_url %}

transifex/templates/projects/component_detail.html

 {% load txpermissions %}
 
 {% block extra_head %}
+  <script type="text/javascript" src="{{ MEDIA_URL }}js/file_submit.js"></script>
+  <script type="text/javascript" src="{{ MEDIA_URL }}js/watch_toggle.js"></script>
+  <script type="text/javascript" src="{{ MEDIA_URL }}js/tablesorted.js"></script>
+  <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.qtip-1.0.0-rc2.min.js"></script>
+
   <script type="text/javascript">
   var calcstats = {{ component.should_calculate|lower }};
 
         tooltip('#note', submission_note);
 
     {% endif %}
+
+    {% include "translations/stats_table_filter_header.html" %}
+
   });
 
 
   </script>
-  <script type="text/javascript" src="{{ MEDIA_URL }}js/file_submit.js"></script>
-  <script type="text/javascript" src="{{ MEDIA_URL }}js/watch_toggle.js"></script>
-  <script type="text/javascript" src="{{ MEDIA_URL }}js/tablesorted.js"></script>
-  <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.qtip-1.0.0-rc2.min.js"></script>
   <link media="screen" href="{{ MEDIA_URL }}css/tablesorter.css" type="text/css" rel="stylesheet" />
   <style type="text/css">
     form.submit_form { display: none; }
 {% endif %} 
 
 </table>
+
+{% include "translations/stats_table_filter_box.html" %}
+
 {% with component.trans.get_stats as stats %} 
 {% comp_stats_table stats component.should_calculate %}
 

transifex/templates/translations/stats_table_filter_box.html

+{% load i18n %}
+<div class="editlinks">
+  <form>
+  <fieldset>
+    <table>
+      <tr>
+        <td class="i16 drink">{% trans "Show completed" %}</td>
+        <td><input id="show_complete" type="checkbox" checked="checked" name="show_complete" /></td>
+      </tr>
+    </table>
+  </fieldset>
+  </form>
+</div>

transifex/templates/translations/stats_table_filter_header.html

+    // Actions to show/hide completed statistics on table
+    $("input[name='show_complete']").change(function(){
+          toggle_entries('complete');
+    })

transifex/templates/txcollections/release_detail.html

   <link rel="alternate" type="application/rss+xml" title="RSS" href="{% url release_languages_feed collection_slug=release.collection.slug release_slug=release.slug %}" />
   <script type="text/javascript" src="{{ MEDIA_URL }}js/tablesorted.js"></script>  
   <link media="screen" href="{{ MEDIA_URL }}css/tablesorter.css" type="text/css" rel="stylesheet" />
+
+  <script type="text/javascript">
+  $(function(){
+    {% include "translations/stats_table_filter_header.html" %}
+  });
+  </script>
 {% endblock %}
 
 {% block breadcrumb %}{{ block.super }} &raquo; {{ release.name }}{% endblock %}
 <div id="projects" class="projects">
 
 <h3>{% trans "Translation statistics" %}</h3>
+
+{% include "translations/stats_table_filter_box.html" %}
+
 {% release_stats_table pofile_list collection release %}
 
 {% if not pofile_list %}

transifex/translations/templates/comp_lang_stats_table.html

    </thead>
    <tbody>
    {% for stat in stats %} 
-      <tr>
+      <tr class="{% number_range stat.trans_perc %}">
         <td class="left name" id="{{stat.filename}}">
               <span class="stat_message">{{stat.filename}}</span>
           {% if stat.error %}

transifex/translations/templates/comp_stats_table.html

    </thead>
    <tbody>
    {% for stat in stats %} 
-      <tr>
+      <tr class="{% number_range stat.trans_perc %}">
         <td class="left name" id="{{stat.language_code}}" name="{{stat.language_code}}">
           {% if stat.language %}
               <a href="{{stat.language.get_absolute_url}}" title="{% trans "See statistics for this language" %}">{{stat.language.name}}</a> <span class="stat_message" >({{stat.language.code}})</span>

transifex/translations/templates/lang_stats_table.html

    {% for stat in stats %}
     {% get_permission "project_perm.submit_file" for request.user and stat.object.project as "can_submit_file" %}
     {% get_permission "project_perm.maintain" for request.user and stat.object.project as "is_maintainer" %}
-      <tr>
+      <tr class="{% number_range stat.trans_perc %}">
         <td class="left name" id="{{stat.object.full_name}}">
           <a href="{{stat.object.project.get_absolute_url}}" title="{% trans "Go to this project page" %}">{{stat.object.project.name}}</a> 
           <span class="stat_message" > &raquo; <a href="{{stat.object.get_absolute_url}}#{{stat.language.code}}" title="{% trans "Go to this component page" %}">{{stat.object.name}}</a></span>

transifex/translations/templates/number_range.html

+{% if range %}{{ range }}{% endif %}

transifex/translations/templates/project_stats_table.html

    </thead>
    <tbody>        
    {% for language, comp in stats.items %}
-    <tr>
+    <tr class="{% number_range stat.trans_perc %}">
       <td class="left name" id="{{language.code}}">{{ language.name }} ({{language.code}})</td>    
       {% for name, stat in comp.items %}
         {% with 140 as barwidth %}

transifex/translations/templates/release_stats_table.html

    </thead>
    <tbody>
    {% for stat in stats %} 
-      <tr>
+      <tr class="{% number_range stat.trans_perc %}">
         <td class="left name" id="{{stat.language.code}}">
           {% if stat.language %}
               <a href="{% url language_release stat.language.code collection.slug release.slug %}" title="{% trans "See the detailed statistics for this language" %}">{{stat.language.name}}</a> <span class="stat_message" >({{stat.language.code}})</span>

transifex/translations/templatetags/statistics.py

     """
 
     context['sources'] = sources
-    return context
+    return context
+
+@register.inclusion_tag("number_range.html")
+def number_range(number):
+    """Return a number to group completion stats based on their number.
+    
+    Depending on the categories defined, different classes will be returned.
+    For example, with the following constant, this will return
+    'lt50' for numbers less than 50 and gt50 for numbers between 50-100.
+    In the case of multiple matches, the first match is returned.
+    
+    RANGES = {'lt50': (0, 49),
+              'gt50': (50, 100)}
+    """
+
+    RANGES = {'incomplete': (0, 99),
+              'complete': (100, 100)}
+    for (r, w) in RANGES.items():
+        if w[0] <= number <= w[1]:
+            return {'range': r }