You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by Sam Ruby <ru...@apache.org> on 2016/02/14 00:58:44 UTC

[whimsy.git] [2/2] Commit b832d9a: rough in a UI

Commit b832d9a75bdcfac51c5fe5f055492ea8ab66c774:
    rough in a UI


Branch: refs/heads/master
Author: Sam Ruby <ru...@intertwingly.net>
Committer: Sam Ruby <ru...@intertwingly.net>
Pusher: rubys <ru...@apache.org>

------------------------------------------------------------
www/roster/main.rb                                           | + 
www/roster/models.rb                                         | + 
www/roster/public/stylesheets/app.css                        | ++ 
www/roster/views/committee.html.rb                           | + -
www/roster/views/committee.js.rb                             | ++++++++++ -
------------------------------------------------------------
175 changes: 158 additions, 17 deletions.
------------------------------------------------------------


diff --git a/www/roster/main.rb b/www/roster/main.rb
index 3a7fbd9..952d50f 100755
--- a/www/roster/main.rb
+++ b/www/roster/main.rb
@@ -49,6 +49,7 @@
 end
 
 get '/committee/:name' do |name|
+  @auth = Auth.info(env)
   @committee = Committee.serialize(name)
   _html :committee
 end
diff --git a/www/roster/models.rb b/www/roster/models.rb
index e4cd8bc..d2ba882 100644
--- a/www/roster/models.rb
+++ b/www/roster/models.rb
@@ -1,2 +1,3 @@
+require_relative 'models/auth'
 require_relative 'models/committer'
 require_relative 'models/committee'
diff --git a/www/roster/public/stylesheets/app.css b/www/roster/public/stylesheets/app.css
index 46a4840..ee2f99c 100644
--- a/www/roster/public/stylesheets/app.css
+++ b/www/roster/public/stylesheets/app.css
@@ -28,3 +28,5 @@ td:hover .hint {
 .breadcrumbs {padding: 10px 20px}
 
 label {margin-right: 8px}
+
+button.btn {margin: 0 8px}
diff --git a/www/roster/views/committee.html.rb b/www/roster/views/committee.html.rb
index a4c26c7..b65989c 100644
--- a/www/roster/views/committee.html.rb
+++ b/www/roster/views/committee.html.rb
@@ -17,6 +17,6 @@
 
   _script src: 'app.js'
   _.render '#main' do
-    _Committee committee: @committee
+    _Committee committee: @committee, auth: @auth
   end
 end
diff --git a/www/roster/views/committee.js.rb b/www/roster/views/committee.js.rb
index b7dfb9e..0dff348 100644
--- a/www/roster/views/committee.js.rb
+++ b/www/roster/views/committee.js.rb
@@ -1,5 +1,11 @@
+#
+# Show a committee
+#
+
 class Committee < React
   def render
+    auth = (@@auth.id == @@committee.chair or @@auth.secretary)
+
     _h1 do
       _a @@committee.display_name, href: @@committee.site
       _span ' '
@@ -9,41 +15,172 @@ def render
     _p @@committee.description
 
     _h2 'PMC'
-    _table do
+    _table.table.table_hover do
+      _thead do
+        _tr do
+          _th 'id'
+          _th 'public name'
+          _th 'starting date'
+        end
+      end
+
       roster = @@committee.roster
 
       for id in roster
         person = roster[id]
+        person.id = id
 
-        _tr do
-          _td {_a id, href: "committer/#{id}"}
-          _td person.name
-          _td person.date
-
-          if id == @@committee.chair
-            _td.chair 'chair'
-          end
-        end
+        _PMCMember auth: auth, person: person, chair: @@committee.chair
       end
+
+      _PMCMemberAdd if auth
     end
 
     if @@committee.committers.keys().all? {|id| @@committee.roster[id]}
       _p 'All committers are members of the PMC'
     else
       _h2 'Committers'
-      _table do
+      _table.table.table_hover do
+        _thead do
+          _tr do
+            _th 'id'
+            _th 'public name'
+          end
+        end
+
         committers = @@committee.committers
 
         for id in committers
           next if @@committee.roster[id]
-          person = committers[id]
+          _PMCCommitter auth: auth, person: {id: id, name: committers[id]}
+        end
 
-          _tr do
-            _td {_a id, href: "committer/#{id}"}
-            _td person
-          end
+        _PMCCommitterAdd if auth
+      end
+    end
+  end
+end
+
+#
+# Show a member of the PMC
+#
+
+class PMCMember < React
+  def initialize
+    @state = :closed
+  end
+
+  def render
+    _tr onDoubleClick: self.select do
+      _td {_a @@person.id, href: "committer/#{@@person.id}"}
+      _td @@person.name
+      _td @@person.date
+
+      if @state == :open
+        _td { _button.btn.btn_warning 'remove from PMC' }
+      elsif @@person.id == @@chair
+        _td.chair 'chair'
+      else
+        _td ''
+      end
+    end
+  end
+
+  def select
+    return unless @@auth
+    window.getSelection().removeAllRanges()
+    @state = ( @state == :open ? :closed : :open )
+  end
+end
+
+#
+# Add a member to the PMC
+#
+
+class PMCMemberAdd < React
+  def initialize
+    @state = :closed
+  end
+
+  def render
+    _tr onDoubleClick: self.select do
+      if @state == :open
+        _td '+'
+        _td { _input }
+        _td colspan: 2 do
+          _button.btn.btn_primary 'add as a committer and to the PMC'
+          _button.btn.btn_success 'add to PMC only'
         end
+      else
+        _td '+', colspan: 4
       end
     end
   end
+
+  def select
+    window.getSelection().removeAllRanges()
+    @state = ( @state == :open ? :closed : :open )
+  end
+end
+
+#
+# Show a committer
+#
+
+class PMCCommitter < React
+  def initialize
+    @state = :closed
+  end
+
+  def render
+    _tr onDoubleClick: self.select do
+      _td {_a @@person.id, href: "committer/#{@@person.id}"}
+      _td @@person.name
+
+      if @state == :open
+        _td do
+          _button.btn.btn_warning 'remove as committer'
+          _button.btn.btn_primary 'add to PMC'
+        end
+      else
+        _td ''
+      end
+    end
+  end
+
+  def select
+    return unless @@auth
+    window.getSelection().removeAllRanges()
+    @state = ( @state == :open ? :closed : :open )
+  end
+end
+
+#
+# Add a committer
+#
+
+class PMCCommitterAdd < React
+  def initialize
+    @state = :closed
+  end
+
+  def render
+    _tr onDoubleClick: self.select do
+      if @state == :open
+        _td '+'
+        _td { _input }
+        _td colspan: 2 do
+          _button.btn.btn_success 'add as a committer only'
+          _button.btn.btn_primary 'add as a committer and to the PMC'
+        end
+      else
+        _td '+', colspan: 4
+      end
+    end
+  end
+
+  def select
+    window.getSelection().removeAllRanges()
+    @state = ( @state == :open ? :closed : :open )
+  end
 end