whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: rough in ppmc actions UI
Date Tue, 17 Jan 2017 17:45:55 GMT
This is an automated email from the ASF dual-hosted git repository.

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

The following commit(s) were added to refs/heads/master by this push:
       new  873b6da   rough in ppmc actions UI
873b6da is described below

commit 873b6da4761a61ae54631d0a82d8648712f28e07
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Tue Jan 17 12:45:20 2017 -0500

    rough in ppmc actions UI
    
    note: Confirm dialogs are ripe for refactoring
---
 www/roster/views/app.js.rb             |  1 +
 www/roster/views/committerSearch.js.rb | 10 +++--
 www/roster/views/ppmc/confirm.js.rb    | 82 ++++++++++++++++++++++++++++++++++
 www/roster/views/ppmc/main.js.rb       |  6 +--
 www/roster/views/ppmc/members.js.rb    | 32 +++++++++----
 5 files changed, 117 insertions(+), 14 deletions(-)

diff --git a/www/roster/views/app.js.rb b/www/roster/views/app.js.rb
index 5227136..16f9275 100644
--- a/www/roster/views/app.js.rb
+++ b/www/roster/views/app.js.rb
@@ -19,6 +19,7 @@ require_relative 'person/sascore'
 
 require_relative 'ppmc/main'
 require_relative 'ppmc/members'
+require_relative 'ppmc/confirm'
 
 require_relative 'committerSearch'
 
diff --git a/www/roster/views/committerSearch.js.rb b/www/roster/views/committerSearch.js.rb
index 2ccad41..1b2813b 100644
--- a/www/roster/views/committerSearch.js.rb
+++ b/www/roster/views/committerSearch.js.rb
@@ -46,7 +46,9 @@ class CommitterSearch < React
           person.mail.any? {|mail| mail.include? part}
         }
       then
-        list << person
+        unless @@exclude and @@exclude.include? person.id
+          list << person
+        end
       end
     end
   end
@@ -71,6 +73,7 @@ class CommitterSearch < React
           _table.table.table_hover do
             _thead do
               _tr do
+                _th
                 _th 'id'
                 _th 'public name'
                 _th 'email'
@@ -79,7 +82,8 @@ class CommitterSearch < React
 
             _tbody do
               list.each do |person|
-                _tr data_id: person.id, onDoubleClick: self.select do
+                _tr do
+                  _td "\u2795", data_id: person.id, onClick: self.select
                   _td {_a person.id, href: "committer/#{person.id}"}
 
                   if person.member
@@ -94,7 +98,7 @@ class CommitterSearch < React
 
               if @@add
                 _tr.alert_success do
-                  _td 'Double click on a row to add', colspan: 3
+                  _td "Click on \u2795 to add", colspan: 3
                 end
               end
             end
diff --git a/www/roster/views/ppmc/confirm.js.rb b/www/roster/views/ppmc/confirm.js.rb
new file mode 100644
index 0000000..ebbde69
--- /dev/null
+++ b/www/roster/views/ppmc/confirm.js.rb
@@ -0,0 +1,82 @@
+#
+# Confirmation dialog
+#
+
+class PPMCConfirm < React
+  def initialize
+    @text = 'text'
+    @color = 'btn-default'
+    @button = 'OK'
+    @disabled = false
+  end
+
+  def render
+    _div.modal.fade.confirm! 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 'Confirm Request'
+          end
+
+          _div.modal_body do
+            _p @text
+          end
+
+          _div.modal_footer do
+            _span.status 'Processing request...' if @disabled
+            _button.btn.btn_default 'Cancel', data_dismiss: 'modal',
+              disabled: @disabled
+            _button.btn @button, class: @color, onClick: self.post,
+              disabled: @disabled
+          end
+        end
+      end
+    end
+  end
+
+  def componentDidMount()
+    jQuery('#confirm').on('show.bs.modal') do |event|
+      button = event.relatedTarget
+      @id = button.parentNode.dataset.id
+      @action = button.dataset.action
+      @text = button.dataset.confirmation
+      @color = button.classList[1]
+      @button = button.textContent
+    end
+  end
+
+  def post()
+    # parse action extracted from the button
+    targets = @action.split(' ')
+    action = targets.shift()
+
+    # construct arguments to fetch
+    args = {
+      method: 'post',
+      credentials: 'include',
+      headers: {'Content-Type' => 'application/json'},
+      body: {ppmc: @@ppmc, id: @id, action: action, targets: targets}.inspect
+    }
+
+    @disabled = true
+    Polyfill.require(%w(Promise fetch)) do
+      fetch('actions/ppmc', 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('#confirm').modal(:hide)
+        @disabled = false
+      }.catch {|error|
+        alert errror
+        jQuery('#confirm').modal(:hide)
+        @disabled = false
+      }
+    end
+  end
+end
diff --git a/www/roster/views/ppmc/main.js.rb b/www/roster/views/ppmc/main.js.rb
index 54af090..adb6c80 100644
--- a/www/roster/views/ppmc/main.js.rb
+++ b/www/roster/views/ppmc/main.js.rb
@@ -18,9 +18,9 @@ class PPMC < React
     # usage information for authenticated users (PMC chair, etc.)
     if auth
       _div.alert.alert_success do
-        _span 'Double click on a row to edit.'
+        _span 'Double click on a row to show actions.'
         unless @ppmc.roster.keys().empty?
-          _span "  Double click on \u2795 to add."
+          _span "  Click on \u2795 to add."
         end
       end
     end
@@ -52,7 +52,7 @@ class PPMC < React
     end
 
     # hidden form
-    # _PPMCConfirm pmc: @ppmc.id, update: self.update if auth
+    _PPMCConfirm pmc: @ppmc.id, update: self.update if auth
   end
 
   # capture ppmc on initial load
diff --git a/www/roster/views/ppmc/members.js.rb b/www/roster/views/ppmc/members.js.rb
index 7bc3e18..13b7c9e 100644
--- a/www/roster/views/ppmc/members.js.rb
+++ b/www/roster/views/ppmc/members.js.rb
@@ -25,7 +25,7 @@ class PPMCMembers < React
         end
 
         if @@auth and not @@ppmc.roster.keys().empty?
-          _tr onDoubleClick: self.select do
+          _tr onClick: self.select do
             _td((@state == :open ? '' : "\u2795"), colspan: 4)
           end
         end
@@ -34,7 +34,7 @@ class PPMCMembers < React
 
    if @state == :open
      _div.search_box do
-       _CommitterSearch add: self.add
+       _CommitterSearch add: self.add, exclude: @roster.map {|person| person.id}
      end
    end
   end
@@ -66,7 +66,7 @@ class PPMCMembers < React
 
   # add a person to the displayed list of PMC members
   def add(person)
-    person.date = 'pending'
+    person.status = 'pending'
     @roster << person
     @state = :closed
   end
@@ -92,10 +92,26 @@ class PPMCMember < React
         _td @@person.name
       end
         
-      if @@ppmc.mentors.include? @@person.id
-        _td.chair 'mentor'
-      else
-        _td
+      _td do
+        if @state == :open
+          if @@person.status == 'pending'
+            _button.btn.btn_primary 'Add to the PPMC',
+              data_action: 'add',
+              data_target: '#confirm', data_toggle: 'modal',
+              data_confirmation: "Add #{@@person.name} to the " +
+                "#{@@ppmc.display_name} PPMC?"
+          else
+            _button.btn.btn_warning 'Remove from the PPMC',
+              data_action: 'remove',
+              data_target: '#confirm', data_toggle: 'modal',
+              data_confirmation: "Remove #{@@person.name} from the " +
+                "#{@@ppmc.display_name} PPMC?"
+          end
+        elsif @@person.status == 'pending'
+          _span'pending'
+        elsif @@ppmc.mentors.include? @@person.id
+          _span.chair 'mentor'
+        end
       end
     end
   end
@@ -108,7 +124,7 @@ class PPMCMember < React
   # automatically open pending entries
   def componentWillReceiveProps(newprops)
     @state = :closed if @ppmc and newprops.ppmc.id != @ppmc.id
-    @state = :open if @@person.date == 'pending'
+    @state = :open if @@person.status == 'pending'
   end
 
   # toggle display of buttons

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

Mime
View raw message