You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by cu...@apache.org on 2017/04/14 13:38:30 UTC

[whimsy] branch master updated: Add style and sorting

This is an automated email from the ASF dual-hosted git repository.

curcuru pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git

The following commit(s) were added to refs/heads/master by this push:
       new  5365573   Add style and sorting
5365573 is described below

commit 53655737224bd79789d760483d724942bad6cb0a
Author: Shane Curcuru <as...@shanecurcuru.org>
AuthorDate: Fri Apr 14 09:38:26 2017 -0400

    Add style and sorting
---
 www/members/non-participants.cgi | 143 +++++++++++++++++++++------------------
 1 file changed, 77 insertions(+), 66 deletions(-)

diff --git a/www/members/non-participants.cgi b/www/members/non-participants.cgi
index b1507f1..5caea55 100755
--- a/www/members/non-participants.cgi
+++ b/www/members/non-participants.cgi
@@ -5,6 +5,7 @@ require 'whimsy/asf'
 require 'wunderbar/bootstrap'
 require 'date'
 require 'json'
+require 'wunderbar/jquery/stupidtable'
 
 # separator / is added when link is generated
 ROSTER = "https://whimsy.apache.org/roster/committer"
@@ -15,7 +16,7 @@ attendance = JSON.parse(IO.read("#{MEETINGS}/attendance.json"))
 
 # extract and format dates
 dates = attendance['dates'].sort.
-  map {|date| Date.parse(date).strftime('%Y-%b')}
+map {|date| Date.parse(date).strftime('%Y-%b')}
 
 # compute mappings of names to ids
 members = ASF::Member.list
@@ -30,92 +31,102 @@ matrix = attendance['matrix'].map do |name, meetings|
   data = meetings.sort.reverse.map(&:last)
   first = data.length
   missed = (data.index {|datum| datum != '-'} || data.length)
- 
+  
   [id, name, first, missed]
 end
 
 # produce HTML
 _html do
-  _style %{
-    table {margin: 16px}
-    .count {margin-left: 24px}
-    li {margin: 16px 0}
-  }
-
-  # common banner
-  _a href: 'https://whimsy.apache.org/' do
-    _img title: "ASF Logo", alt: "ASF Logo",
-      src: "https://www.apache.org/img/asf_logo.png"
-  end
-
-  _h1 'Non-participating active members'
-
-  @meetingsMissed = (@meetingsMissed || 3).to_i
-
-  # selection
-  _form_ do
-    _span "List of members that have not participated, starting with the "
-    _select name: 'meetingsMissed', onChange: 'this.form.submit()' do
-      dates.reverse.each_with_index do |name, i|
-        _option name, value: i+1, selected: (i+1 == @meetingsMissed)
+  _body? do
+    _whimsy_header 'Active Members not participating in meetings'
+    _whimsy_content do
+      
+    @meetingsMissed = (@meetingsMissed || 3).to_i
+      
+    _div.row do
+      _div.col_md_6 do
+        _div.panel.panel_primary do
+          _div.panel_heading {_h3.panel_title 'Select Date'}
+          _div.panel_body do
+            _form_ do
+              _span "List of members that have not participated, starting with the "
+              _select name: 'meetingsMissed', onChange: 'this.form.submit()' do
+                dates.reverse.each_with_index do |name, i|
+                  _option name, value: i+1, selected: (i+1 == @meetingsMissed)
+                end
+              end
+              _span "meeting.  Active members does not include emeritus or deceased members."
+            end
+          end
+        end
       end
-    end
-    _span "meeting."
-  end
-
-  count = 0
-  _table.table.table_hover do
-    _thead do
-      _tr do
-        _th 'Name'
-        _th 'Membership start date'
-        _th 'Last participated'
+      _div.col_md_6 do
+        _div.panel.panel_primary do
+          _div.panel_heading {_h3.panel_title 'Definitions'}
+          _div.panel_body do
+            _ 'Participating is defined by doing at least one of the following:'
+            _ul do
+              _li 'Attending a members meeting'
+              _li 'Voting in an election'
+              _li 'Assigning a proxy'
+            end
+          end
+        end
       end
     end
-
-    matrix.each do |id, name, first, missed|
-      next unless id
     
-      if missed >= @meetingsMissed
-        _tr_ do
-          _td! {_a nameMap[id], href: "#{ROSTER}/#{id}"}
-          _td dates[-first-1] || dates.first
-          if missed >= first
-            _td {_em 'never'}
-          else
-            _td dates[-missed-1]
+    count = 0
+    _table.table.table_hover do
+      _thead do
+        _tr do
+          _th 'Name', data_sort: 'string'
+          _th 'Membership start date', data_sort: 'string'
+          _th 'Last participated', data_sort: 'string'
+        end
+      end
+      
+      matrix.each do |id, name, first, missed|
+        next unless id
+        
+        if missed >= @meetingsMissed
+          _tr_ do
+            _td! {_a nameMap[id], href: "#{ROSTER}/#{id}"}
+            _td dates[-first-1] || dates.first
+            if missed >= first
+              _td {_em 'never'}
+            else
+              _td dates[-missed-1]
+            end
           end
+          count += 1
         end
-        count += 1
       end
     end
-  end
-
-  _div.count "Count: #{count}"
-
-  _h3 'Definitions'
-
-  _ul do
-    _li 'Active members are members that are neither emeritus nor deceased.'
-    _li do
-      _ 'Participating is defined by doing at least one of the following:'
-      _ul do
-        _li 'Attending a members meeting'
-        _li 'Voting in an election'
-        _li 'Assigning a proxy'
-      end
+    
+    _div.count "Count: #{count} members inactive for #{@meetingsMissed} meetings."
+    
+    _script %{
+      var table = $(".table").stupidtable();
+      table.on("aftertablesort", function (event, data) {
+        var th = $(this).find("th");
+        th.find(".arrow").remove();
+        var dir = $.fn.stupidtable.dir;
+        var arrow = data.direction === dir.ASC ? "&uarr;" : "&darr;";
+        th.eq(data.column).append('<span class="arrow">' + arrow +'</span>');
+        });
+      }
     end
   end
 end
-
+  
 _json do
   meetingsMissed = (@meetingsMissed || 3).to_i
-
+  
   inactive = matrix.select do |id, name, first, missed|
     id and missed >= meetingsMissed
   end
-
+  
   Hash[inactive.map {|id, name, first, missed| 
     [id, {name: name, missed: missed, status: 'no response yet'}]
-  }]
+    }]
 end

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].