whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Ruby <ru...@apache.org>
Subject [whimsy.git] [1/1] Commit 6daeafa: select on search => add to list
Date Sun, 14 Feb 2016 15:57:06 GMT
Commit 6daeafa1e6214a681b13c7fd97c12e5fbb573426:
    select on search => add to list


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

------------------------------------------------------------
www/roster/views/committee.js.rb                             | ++++++++ ---
www/roster/views/committerSearch.js.rb                       | +++++++++ --
------------------------------------------------------------
186 changes: 143 additions, 43 deletions.
------------------------------------------------------------


diff --git a/www/roster/views/committee.js.rb b/www/roster/views/committee.js.rb
index 4cb1b87..524e25e 100644
--- a/www/roster/views/committee.js.rb
+++ b/www/roster/views/committee.js.rb
@@ -15,14 +15,17 @@ def render
 
     _p @@committee.description
 
-    _div.alert.alert_success 'Double click on a row to edit' if auth
+    if auth
+      _div.alert.alert_success 'Double click on a row to edit.  ' +
+        "Double click on \u2795 to add."
+    end
 
     # main content
     _PMCMembers auth: @@auth, committee: @@committee
     _PMCCommitters auth: @@auth, committee: @@committee
 
-    # hidden form
-    _PMCConfirm if @@auth
+    # hidden orm
+    _PMCConfirm if auth
   end
 end
 
@@ -32,6 +35,7 @@ def render
 
 class PMCMembers < React
   def initialize
+    @roster = {}
     @state = :closed
   end
 
@@ -46,18 +50,15 @@ def render
         end
       end
 
-      roster = @@committee.roster
-
-      for id in roster
-        person = roster[id]
-        person.id = id
-
-        _PMCMember auth: @@auth, person: person, committee: @@committee
-      end
+      _tbody do
+        @roster.each do |person|
+          _PMCMember auth: @@auth, person: person, committee: @@committee
+        end
 
-      if @@auth
-        _tr onDoubleClick: self.select do
-          _td((@state == :open ? '' : '+'), colspan: 4)
+        if @@auth
+          _tr onDoubleClick: self.select do
+            _td((@state == :open ? '' : "\u2795"), colspan: 4)
+          end
         end
       end
     end
@@ -69,13 +70,34 @@ def render
    end
   end
 
-  def select
+  # update props on initial load
+  def componentWillMount()
+    self.componentWillReceiveProps()
+  end
+
+  # compute roster
+  def componentWillReceiveProps()
+    @roster = []
+    
+    for id in @@committee.roster
+      person = @@committee.roster[id]
+      person.id = id
+      @roster << person
+    end
+  end
+
+  # open search box
+  def select()
     return unless @@auth
     window.getSelection().removeAllRanges()
     @state = ( @state == :open ? :closed : :open )
   end
 
+  # add a person to the displayed list of PMC members
   def add(person)
+    person.date = 'pending'
+    @roster << person
+    @state = :closed
   end
 end
 
@@ -97,17 +119,16 @@ def render
           end
         end
 
-        committers = @@committee.committers
-
-        for id in committers
-          next if @@committee.roster[id]
-          _PMCCommitter auth: @@auth, person: {id: id, name: committers[id]},
-            committee: @@committee
-        end
+        _tbody do
+          @committers.each do |person|
+            next if @@committee.roster[person.id]
+            _PMCCommitter auth: @@auth, person: person, committee: @@committee
+          end
 
-        if @@auth
-          _tr onDoubleClick: self.select do
-            _td((@state == :open ? '' : '+'), colspan: 4)
+          if @@auth
+            _tr onDoubleClick: self.select do
+              _td((@state == :open ? '' : '+'), colspan: 4)
+            end
           end
         end
       end
@@ -120,13 +141,32 @@ def render
     end
   end
 
-  def select
+  # update props on initial load
+  def componentWillMount()
+    self.componentWillReceiveProps()
+  end
+
+  # compute list of committers
+  def componentWillReceiveProps()
+    @committers = []
+    
+    for id in @@committee.committers
+      @committers << {id: id, name: @@committee.committers[id]}
+    end
+  end
+
+  # open search box
+  def select()
     return unless @@auth
     window.getSelection().removeAllRanges()
     @state = ( @state == :open ? :closed : :open )
   end
 
+  # add a person to the displayed list of committers
   def add(person)
+    person.date = 'pending'
+    @committers << person
+    @state = :closed
   end
 end
 
@@ -147,10 +187,22 @@ def render
 
       if @state == :open
         _td do 
-          _button.btn.btn_warning 'Remove from PMC', data_target: '#confirm',
-            data_toggle: 'modal',
-            data_confirmation: "Remove #{@@person.name} from the " +
-              "#{@@committee.display_name} PMC?"
+          if @@person.date == 'pending'
+           _button.btn.btn_primary 'Add as a committer and to the PMC',
+             data_target: '#confirm', data_toggle: 'modal',
+             data_confirmation: "Add #{@@person.name} to the " +
+               "#{@@committee.display_name} PMC and grant committer access?"
+
+           _button.btn.btn_warning 'Add to PMC only', data_target: '#confirm',
+             data_toggle: 'modal',
+             data_confirmation: "Add #{@@person.name} to the " +
+               "#{@@committee.display_name} PMC?"
+          else
+            _button.btn.btn_warning 'Remove from PMC',
+              data_target: '#confirm', data_toggle: 'modal',
+              data_confirmation: "Remove #{@@person.name} from the " +
+                "#{@@committee.display_name} PMC?"
+          end
         end
       elsif @@person.id == @@committee.chair
         _td.chair 'chair'
@@ -160,7 +212,18 @@ def render
     end
   end
 
-  def select
+  # update props on initial load
+  def componentWillMount()
+    self.componentWillReceiveProps()
+  end
+
+  # automatically open pending entries
+  def componentWillReceiveProps()
+    @state = :open if @@person.date == 'pending'
+  end
+
+  # toggle display of buttons
+  def select()
     return unless @@auth
     window.getSelection().removeAllRanges()
     @state = ( @state == :open ? :closed : :open )
@@ -183,14 +246,25 @@ def render
 
       if @state == :open
         _td do
-          _button.btn.btn_warning 'Remove as Committer',
-            data_target: '#confirm', data_toggle: 'modal',
-            data_confirmation: "Remove #{@@person.name} as a Committer?"
-
-          _button.btn.btn_primary 'Add to PMC',
-            data_target: '#confirm', data_toggle: 'modal',
-            data_confirmation: "Add #{@@person.name} to the " +
-              "#{@@committee.display_name} PMC?"
+          if @@person.date == 'pending'
+             _button.btn.btn_primary 'Add as a committer only',
+               data_target: '#confirm', data_toggle: 'modal',
+               data_confirmation: "Grant #{@@person.name} committer access?"
+
+             _button.btn.btn_success 'Add as a committer and to the PMC',
+               data_target: '#confirm', data_toggle: 'modal',
+               data_confirmation: "Add #{@@person.name} to the " +
+                 "#{@@committee.display_name} PMC and grant committer access?"
+          else
+            _button.btn.btn_warning 'Remove as Committer',
+              data_target: '#confirm', data_toggle: 'modal',
+              data_confirmation: "Remove #{@@person.name} as a Committer?"
+
+            _button.btn.btn_primary 'Add to PMC',
+              data_target: '#confirm', data_toggle: 'modal',
+              data_confirmation: "Add #{@@person.name} to the " +
+                "#{@@committee.display_name} PMC?"
+          end
         end
       else
         _td ''
@@ -198,7 +272,18 @@ def render
     end
   end
 
-  def select
+  # update props on initial load
+  def componentWillMount()
+    self.componentWillReceiveProps()
+  end
+
+  # automatically open pending entries
+  def componentWillReceiveProps()
+    @state = :open if @@person.date == 'pending'
+  end
+
+  # toggle display of buttons
+  def select()
     return unless @@auth
     window.getSelection().removeAllRanges()
     @state = ( @state == :open ? :closed : :open )
diff --git a/www/roster/views/committerSearch.js.rb b/www/roster/views/committerSearch.js.rb
index bb9db6a..2ccad41 100644
--- a/www/roster/views/committerSearch.js.rb
+++ b/www/roster/views/committerSearch.js.rb
@@ -68,18 +68,18 @@ def render
         elsif list.length > 99
           _p "#{list.length} entries match"
         else
-          _table do
+          _table.table.table_hover do
             _thead do
               _tr do
                 _th 'id'
-                _th 'name'
+                _th 'public name'
                 _th 'email'
               end
             end
 
             _tbody do
               list.each do |person|
-                _tr do
+                _tr data_id: person.id, onDoubleClick: self.select do
                   _td {_a person.id, href: "committer/#{person.id}"}
 
                   if person.member
@@ -91,10 +91,25 @@ def render
                   _td person.mail.first
                 end
               end
+
+              if @@add
+                _tr.alert_success do
+                  _td 'Double click on a row to add', colspan: 3
+                end
+              end
             end
           end
+
         end
       end
     end
   end
+
+  def select(event)
+    if @@add
+      id = event.currentTarget.dataset.id
+      person = @list.find {|person| person.id == id}
+      @@add.call(person)
+    end
+  end
 end

Mime
View raw message