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/07/30 00:01:58 UTC

[whimsy] branch master updated: move to an add dialog

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


The following commit(s) were added to refs/heads/master by this push:
     new 5b9fcf9  move to an add dialog
5b9fcf9 is described below

commit 5b9fcf9667cfa091eb7e5f1d39e20c137c0ea4fa
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Sat Jul 29 20:01:42 2017 -0400

    move to an add dialog
---
 www/roster/views/app.js.rb             |   1 +
 www/roster/views/ppmc/add.js.rb        | 134 +++++++++++++++++++++++++++++++++
 www/roster/views/ppmc/committers.js.rb |  21 ------
 www/roster/views/ppmc/main.js.rb       |  14 ++--
 www/roster/views/ppmc/members.js.rb    |  25 ------
 www/roster/views/ppmc/mentors.js.rb    |  22 ------
 6 files changed, 140 insertions(+), 77 deletions(-)

diff --git a/www/roster/views/app.js.rb b/www/roster/views/app.js.rb
index b173a15..c75a77b 100644
--- a/www/roster/views/app.js.rb
+++ b/www/roster/views/app.js.rb
@@ -24,6 +24,7 @@ require_relative 'ppmc/mentors'
 require_relative 'ppmc/members'
 require_relative 'ppmc/committers'
 require_relative 'ppmc/roster'
+require_relative 'ppmc/add'
 require_relative 'ppmc/graduate'
 
 require_relative 'committerSearch'
diff --git a/www/roster/views/ppmc/add.js.rb b/www/roster/views/ppmc/add.js.rb
new file mode 100644
index 0000000..1146345
--- /dev/null
+++ b/www/roster/views/ppmc/add.js.rb
@@ -0,0 +1,134 @@
+#
+# Add People to a project
+#
+
+class PPMCAdd < React
+  def initialize
+    @people = []
+  end
+
+  def render
+    _div.modal.fade.ppmcadd! tabindex: -1 do
+      _div.modal_dialog do
+        _div.modal_content do
+          _div.modal_header.bg_info do
+            _button.close 'x', data_dismiss: 'modal'
+            _h4.modal_title 'Add People to the ' + @@ppmc.display_name +
+	      ' Podling'
+          end
+
+          _div.modal_body do
+            _div.container_fluid do
+
+	      unless @people.empty?
+                _table.table do
+                  _thead do
+                    _tr do
+	              _th 'id'
+	              _th 'name'
+	              _th 'email'
+	            end
+                  end
+                  _tbody do
+                    @people.each do |person|
+	              _tr do
+	                _td person.id
+	                _td person.name
+	                _td person.mail[0]
+	              end
+	            end
+                  end
+                end
+	      end
+
+              _CommitterSearch add: self.add,
+	        exclude: @@ppmc.roster.keys().
+		  concat(@people.map {|person| person.id})
+            end
+          end
+
+          _div.modal_footer do
+            _span.status 'Processing request...' if @disabled
+
+            _button.btn.btn_default 'Cancel', data_dismiss: 'modal',
+              disabled: @disabled
+
+	    plural = (@people.length > 1 ? 's' : '')
+
+            if @@auth.ppmc
+              _button.btn.btn_primary "Add as committer#{plural}", 
+	        data_action: 'add committer',
+	        onClick: self.post, disabled: (@people.empty?)
+
+              _button.btn.btn_primary 'Add to PPMC', onClick: self.post,
+	        data_action: 'add ppmc committer', disabled: (@people.empty?)
+            end
+
+            if @@auth.ipmc
+              action = 'add mentor'
+              action += ' ppmc committer' if @@auth.ppmc
+
+              _button.btn.btn_primary "Add as mentor#{plural}", 
+	        data_action: action, onClick: self.post,
+                 disabled: (@people.empty?)
+            end
+          end
+        end
+      end
+    end
+  end
+
+  def componentDidMount()
+    jQuery('#pmcadd').on('show.bs.modal') do |event|
+      button = event.relatedTarget
+      setTimeout(500) { jQuery('#pmcadd input').focus() }
+    end
+  end
+
+  def add(person)
+    @people << person
+    self.forceUpdate()
+    jQuery('#pmcadd input').focus()
+  end
+
+  def post(event)
+    button = event.currentTarget
+
+    # parse action extracted from the button
+    targets = button.dataset.action.split(' ')
+    action = targets.shift()
+
+    # construct arguments to fetch
+    args = {
+      method: 'post',
+      credentials: 'include',
+      headers: {'Content-Type' => 'application/json'},
+      body: {
+        project: @@ppmc.id, 
+        ids: @people.map {|person| person.id}.join(' '), 
+        action: action, 
+        targets: targets
+      }.inspect
+    }
+
+    @disabled = true
+    Polyfill.require(%w(Promise fetch)) do
+      fetch("actions/committee", args).then {|response|
+        content_type = response.headers.get('content-type') || ''
+        if response.status == 200 and content_type.include? 'json'
+          response.json().then do |json|
+            @@update.call(json)
+          end
+        else
+          alert "#{response.status} #{response.statusText}"
+        end
+        jQuery('#pmcadd').modal(:hide)
+        @disabled = false
+      }.catch {|error|
+        alert error
+        jQuery('#pmcadd').modal(:hide)
+        @disabled = false
+      }
+    end
+  end
+end
diff --git a/www/roster/views/ppmc/committers.js.rb b/www/roster/views/ppmc/committers.js.rb
index 4a56429..a3648a9 100644
--- a/www/roster/views/ppmc/committers.js.rb
+++ b/www/roster/views/ppmc/committers.js.rb
@@ -47,19 +47,6 @@ class PPMCCommitters < React
               end
             end
           end
-
-          if @@auth and @@auth.ppmc
-            _tr onClick: self.select do
-              _td((@state == :open ? '' : "\u2795"), colspan: 3)
-            end
-          end
-        end
-      end
-
-      if @state == :open
-        _div.search_box do
-          _CommitterSearch add: self.add, multiple: true,
-            exclude: @committers.map {|person| person.id unless person.issue}
         end
       end
     end
@@ -83,18 +70,10 @@ class PPMCCommitters < React
     @committers = committers.sort_by {|person| person.name}
   end
 
-  # open search box
-  def select()
-    return unless @@auth and @@auth.ppmc
-    window.getSelection().removeAllRanges()
-    @state = ( @state == :open ? :closed : :open )
-  end
-
   # add a person to the displayed list of committers
   def add(person)
     person.status = 'pending'
     @committers << person
-    @state = :closed
   end
 end
 
diff --git a/www/roster/views/ppmc/main.js.rb b/www/roster/views/ppmc/main.js.rb
index f5ffe0f..4220750 100644
--- a/www/roster/views/ppmc/main.js.rb
+++ b/www/roster/views/ppmc/main.js.rb
@@ -54,11 +54,6 @@ class PPMC < React
         else
           _span 'Double click on a Mentors row to show actions.'
         end
-
-        unless @ppmc.roster.keys().empty?
-          _span "  Click on \u2795 to add."
-          _span "  Multiple people can be added with a single confirmation."
-        end
       end
     end
 
@@ -66,8 +61,8 @@ class PPMC < React
     _div.row key: 'databar' do
       _div.col_sm_6 do
         if @@auth.ipmc or @@auth.ipmc
-          _button.btn.btn_default 'Add', disabled: true,
-            data_target: '#pmcadd', data_toggle: 'modal'
+          _button.btn.btn_default 'Add',
+            data_target: '#ppmcadd', data_toggle: 'modal'
 
           mod_disabled = true
           for id in @ppmc.roster
@@ -81,7 +76,7 @@ class PPMC < React
             _button.btn.btn_default 'Modify', disabled: true
           else
             _button.btn.btn_primary 'Modify',
-              data_target: '#pmcmod', data_toggle: 'modal'
+              data_target: '#ppmcmod', data_toggle: 'modal'
           end
         elsif @ppmc.owners.empty? and (@@auth.root or @@auth.secretary)
           _button.btn.btn_primary 'Create project in LDAP', onClick: self.post,
@@ -216,9 +211,10 @@ class PPMC < React
     # Graduation resolution
     _PPMCGraduate ppmc: @ppmc, id: @@auth.id
 
-    # hidden form
+    # hidden forms
     if @@auth.ppmc or @@auth.ipmc
       _Confirm action: :ppmc, project: @ppmc.id, update: self.update
+      _PPMCAdd ppmc: @@ppmc, update: self.update, auth: @@auth
     end
   end
 
diff --git a/www/roster/views/ppmc/members.js.rb b/www/roster/views/ppmc/members.js.rb
index 79f51d1..ca699d2 100644
--- a/www/roster/views/ppmc/members.js.rb
+++ b/www/roster/views/ppmc/members.js.rb
@@ -3,10 +3,6 @@
 #
 
 class PPMCMembers < React
-  def initialize
-    @state = :closed
-  end
-
   def render
     pending = [] 
 
@@ -48,19 +44,6 @@ class PPMCMembers < React
             end
           end
         end
-
-        if @@auth and @@auth.ppmc and not @@ppmc.roster.keys().empty?
-          _tr onClick: self.select do
-            _td((@state == :open ? '' : "\u2795"), colspan: 4)
-          end
-        end
-      end
-    end
-
-    if @state == :open
-      _div.search_box do
-        _CommitterSearch add: self.add, multiple: true,
-          exclude: @roster.map {|person| person.id unless person.issue}
       end
     end
   end
@@ -83,18 +66,10 @@ class PPMCMembers < React
     @roster = roster.sort_by {|person| person.name}
   end
 
-  # open search box
-  def select()
-    return unless @@auth and @@auth.ppmc
-    window.getSelection().removeAllRanges()
-    @state = ( @state == :open ? :closed : :open )
-  end
-
   # add a person to the displayed list of PMC members
   def add(person)
     person.status = :pending
     @roster << person
-    @state = :closed
   end
 end
 
diff --git a/www/roster/views/ppmc/mentors.js.rb b/www/roster/views/ppmc/mentors.js.rb
index d073d7b..1e1ade5 100644
--- a/www/roster/views/ppmc/mentors.js.rb
+++ b/www/roster/views/ppmc/mentors.js.rb
@@ -4,7 +4,6 @@
 
 class PPMCMentors < React
   def initialize
-    @state = :closed
     @ipmc = []
   end
 
@@ -48,19 +47,6 @@ class PPMCMentors < React
             end
           end
         end
-
-        if @@auth and @@auth.ipmc and not @@ppmc.roster.keys().empty?
-          _tr onClick: self.select do
-            _td((@state == :open ? '' : "\u2795"), colspan: 4)
-          end
-        end
-      end
-    end
-
-    if @state == :open
-      _div.search_box do
-        _CommitterSearch add: self.add, include: @ipmc, multiple: true,
-          exclude: @roster.map {|person| person.id unless person.issue}
       end
     end
   end
@@ -101,18 +87,10 @@ class PPMCMentors < React
     end
   end
 
-  # open search box
-  def select()
-    return unless @@auth and @@auth.ipmc
-    window.getSelection().removeAllRanges()
-    @state = ( @state == :open ? :closed : :open )
-  end
-
   # add a person to the displayed list of PMC members
   def add(person)
     person.status = :pending
     @roster << person
-    @state = :closed
   end
 end
 

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