Remove inline styles from feature matrix generator.
authorJonathan S. Katz <jonathan.katz@excoventures.com>
Sat, 22 Dec 2018 16:35:31 +0000 (11:35 -0500)
committerJonathan S. Katz <jonathan.katz@excoventures.com>
Sat, 22 Dec 2018 16:35:31 +0000 (11:35 -0500)
This moves the HTML code generated for the filters into the Django
template, instead of the JavaScript portion.

media/css/main.css
media/js/featurematrix.js
pgweb/featurematrix/views.py
templates/featurematrix/featurematrix.html

index 44cc4e3fe94b06ce448876e87121c73f567bb039..7b11456a53ab0b89060de8ea10bb6b7b41301ff5 100644 (file)
@@ -1222,6 +1222,9 @@ input.featurematrix_version {
 input.featurematrix_version:last-child {
     margin-right: 0;
 }
+hr#featurematrix_version_divider {
+    margin: 0;
+}
 td.fm_no {
     background-color: #ffdddd !important;
 }
index f82c4da25b8a23b1878c69c14c3dcebcba83b88f..13dd1837d254c5437efb3aee7c7880ec5db727af 100644 (file)
@@ -2,27 +2,6 @@
  * Filter feature matrix
  */
 $(document).ready(function(){
-    var eol_versions = $('#feature-matrix-filter').data('eol').split(',');
-
-    // Create form to contain filter checkboxes
-    $('#feature-matrix-filter').html('<form id="featurematrix_version_filter"><h5>Filter by version</h5></form>');
-
-    // Generate a list of versions based on table column headers
-    $('table tr:first th').not('th:nth-child(1)').each(function(){
-        var version_class = $(this).text().replace('.', '');
-
-        // Only mark a box as checked if no in the EOL list
-        var checked = (eol_versions.indexOf($(this).text()) == -1 ? 'checked="checked"' : '');
-
-        $('form#featurematrix_version_filter').append('<label for="' + version_class + '">' + $(this).text()
-                                       + '</label><input class="featurematrix_version" ' + checked + ' type="checkbox" id="toggle_' + version_class + '"/ value="' +
-          $(this).text() + '"/>&nbsp;');
-    });
-
-    // Add a checkbox to hide rows where all values are the same between
-    // displayed versions.  Default: checked.
-    $('form#featurematrix_version_filter').append('<hr style="margin: 0;" /> <label for="hide_unchanged">Hide unchanged features</label><input type="checkbox" id="hide_unchanged" />');
-
     // Show/hide column based on whether supplied checkbox is checked.
     function filter_version(checkbox)
     {
index c9da03075a5d9e50fd5754a553bd2d2ed35b2c59..bd44539037a1478d6188945ca32c785f89cf6529 100644 (file)
@@ -23,10 +23,10 @@ def root(request):
        if currentgroup:
                groups.append(currentgroup)
 
-       eol_versions = [v.tree for v in Version.objects.filter(supported=False, testing=False)]
+       versions = Version.objects.filter(tree__gte='8.1').order_by('-tree')
        return render_pgweb(request, 'about', 'featurematrix/featurematrix.html', {
                'groups': groups,
-               'eol_versions': eol_versions,
+               'versions': versions,
        })
 
 def detail(request, featureid):
index 492e78da8dcf56651376fcfdfb3e4b3faeda8a37..81711cf952f88a1409136be494cc2317c408ee43 100644 (file)
@@ -22,7 +22,16 @@ the text.
 </ul>
 
 <div class="row">
-  <div id="feature-matrix-filter" class="col-8 offset-2 border" data-eol="{{eol_versions|join:','}}"></div>
+  <div id="feature-matrix-filter" class="col-8 offset-2 border">
+    <form id="featurematrix_version_filter"><h5>Filter by version</h5>
+      {% for version in versions %}
+        <label for="{{ version.numtree|cut:"." }}">{{ version.numtree }}</label>
+        <input type="checkbox" id="toggle_{{ version.numtree|cut:"." }}" class="featurematrix_version" {% if version.supported or version.testing %}checked{% endif %} value="{{ version.numtree }}" />
+      {% endfor %}
+      <hr id="featurematrix_version_divider" />
+      <label for="hide_unchanged">Hide unchanged features</label><input type="checkbox" id="hide_unchanged" />
+    </form>
+  </div>
 </div>
 
 {% for group in groups %}