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

[whimsy] 02/02: more cleanup and use of computed properties

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

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

commit a4ff0d2e30d4aee9a2d391b90aee326e713e828a
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Thu Sep 7 22:04:15 2017 -0400

    more cleanup and use of computed properties
---
 www/roster/views/ppmc/committers.js.rb | 30 +++++++-----------
 www/roster/views/ppmc/members.js.rb    | 40 +++--------------------
 www/roster/views/ppmc/mentors.js.rb    | 58 +++-------------------------------
 3 files changed, 22 insertions(+), 106 deletions(-)

diff --git a/www/roster/views/ppmc/committers.js.rb b/www/roster/views/ppmc/committers.js.rb
index 18811ef..95001c6 100644
--- a/www/roster/views/ppmc/committers.js.rb
+++ b/www/roster/views/ppmc/committers.js.rb
@@ -21,7 +21,7 @@ class PPMCCommitters < Vue
         end
 
         _tbody do
-          @committers.each do |person|
+          committers.each do |person|
             next if @@ppmc.owners.include? person.id
             _PPMCCommitter auth: @@auth, person: person, ppmc: @@ppmc
             pending << person.id if person.status == :pending
@@ -53,22 +53,16 @@ class PPMCCommitters < Vue
   end
 
   # compute list of committers
-  def created()
-    committers = []
+  def committers
+    result = []
     
     @@ppmc.committers.each do |id|
       person = @@ppmc.roster[id]
       person.id = id
-      committers << person
+      result << person
     end
 
-    @committers = committers.sort_by {|person| person.name}
-  end
-
-  # add a person to the displayed list of committers
-  def add(person)
-    person.status = 'pending'
-    @committers << person
+    result.sort_by {|person| person.name}
   end
 end
 
@@ -97,13 +91,13 @@ class PPMCCommitter < Vue
 
       if @@person.selected
         _td data_ids: @@person.id do 
-	  if @@auth.ipmc and not @@person.icommit
-	    _button.btn.btn_primary 'Add as an incubator committer',
-	      data_action: 'add icommit',
-	      data_target: '#confirm', data_toggle: 'modal',
-	      data_confirmation: "Add #{@@person.name} as a commiter " +
-		"for the incubator PPMC?"
-	  end
+          if @@auth.ipmc and not @@person.icommit
+            _button.btn.btn_primary 'Add as an incubator committer',
+              data_action: 'add icommit',
+              data_target: '#confirm', data_toggle: 'modal',
+              data_confirmation: "Add #{@@person.name} as a commiter " +
+                "for the incubator PPMC?"
+          end
         end
       elsif not @@person.icommit
         _span.issue 'not listed as an incubator committer'
diff --git a/www/roster/views/ppmc/members.js.rb b/www/roster/views/ppmc/members.js.rb
index b18e3a1..7142d2b 100644
--- a/www/roster/views/ppmc/members.js.rb
+++ b/www/roster/views/ppmc/members.js.rb
@@ -4,8 +4,6 @@
 
 class PPMCMembers < Vue
   def render
-    pending = [] 
-
     _h2.ppmc! 'PPMC'
     _table.table.table_hover do
       _thead do
@@ -18,53 +16,25 @@ class PPMCMembers < Vue
       end
 
       _tbody do
-        @roster.each do |person|
+        roster.each do |person|
           next if @@ppmc.mentors.include? person.id
           _PPMCMember auth: @@auth, person: person, ppmc: @@ppmc
-          pending << person.id if person.status == :pending
-        end
-
-        if pending.length > 1
-          _tr do
-            _td colspan: 2
-            _td data_ids: pending.join(',') do
-
-              # produce a list of ids to be added
-              if pending.length == 2
-                list = "#{pending[0]} and #{pending[1]}"
-              else
-                list = pending[0..-2].join(', ') + ", and " +  pending[-1]
-              end
-
-              _button.btn.btn_success 'Add all to the PPMC',
-                data_action: 'add ppmc committer',
-                data_target: '#confirm', data_toggle: 'modal',
-                data_confirmation: "Add #{list} to the " +
-                  "#{@@ppmc.display_name} PPMC?"
-            end
-          end
         end
       end
     end
   end
 
   # compute roster
-  def created()
-    roster = []
+  def roster
+    result = []
     
     @@ppmc.owners.each do |id|
       person = @@ppmc.roster[id]
       person.id = id
-      roster << person
+      result << person
     end
 
-    @roster = roster.sort_by {|person| person.name}
-  end
-
-  # add a person to the displayed list of PMC members
-  def add(person)
-    person.status = :pending
-    @roster << person
+    result.sort_by {|person| person.name}
   end
 end
 
diff --git a/www/roster/views/ppmc/mentors.js.rb b/www/roster/views/ppmc/mentors.js.rb
index 6164100..9bcabe4 100644
--- a/www/roster/views/ppmc/mentors.js.rb
+++ b/www/roster/views/ppmc/mentors.js.rb
@@ -8,8 +8,6 @@ class PPMCMentors < Vue
   end
 
   def render
-    pending = [] 
-
     _h2.mentors! 'Mentors'
     _table.table.table_hover do
       _thead do
@@ -22,70 +20,24 @@ class PPMCMentors < Vue
       end
 
       _tbody do
-        @roster.each do |person|
+        roster.each do |person|
           _PPMCMentor auth: @@auth, person: person, ppmc: @@ppmc
-          pending << person.id if person.status == :pending
-        end
-
-        if pending.length > 1
-          _tr do
-            _td colspan: 2
-            _td data_ids: pending.join(',') do
-
-              # produce a list of ids to be added
-              if pending.length == 2
-                list = "#{pending[0]} and #{pending[1]}"
-              else
-                list = pending[0..-2].join(', ') + ", and " +  pending[-1]
-              end
-
-              _button.btn.btn_success 'Add all as mentors',
-                data_action: 'add ppmc committer mentor',
-                data_target: '#confirm', data_toggle: 'modal',
-                data_confirmation: "Add #{list} to the " +
-                  "#{@@ppmc.display_name} PPMC?"
-            end
-          end
         end
       end
     end
   end
 
   # compute roster
-  def created()
-    roster = []
+  def roster
+    result = []
     
     @@ppmc.mentors.each do |id|
       person = @@ppmc.roster[id]
       person.id = id
-      roster << person
+      result << person
     end
 
-    @roster = roster.sort_by {|person| person.name}
-  end
-
-  # fetch IPMC list
-  def mounted()
-    return unless @@auth and @@auth.ipmc
-    Polyfill.require(%w(Promise fetch)) do
-      fetch('committee/incubator.json', credentials: 'include').then {|response|
-        if response.status == 200
-          response.json().then do |json|
-            @ipmc = json.roster.keys()
-          end
-        else
-          console.log "IPMC #{response.status} #{response.statusText}"
-        end
-      }.catch {|error|
-        console.log "IPMC #{errror}"
-      }
-    end
-  end
-
-  # add a person to the displayed list of PMC members
-  def add(person)
-    person.status = :pending
-    @roster << person
+    result.sort_by {|person| person.name}
   end
 end
 

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