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 20d1a68: rough in confirmation dialogs
Date Sun, 14 Feb 2016 11:45:18 GMT
Commit 20d1a68984a18d31c8a01a4a2117a834603c8392:
    rough in confirmation dialogs


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

------------------------------------------------------------
www/roster/public/stylesheets/app.css                        | +++++ 
www/roster/views/committee.js.rb                             | +++++++++ -
------------------------------------------------------------
81 changes: 73 additions, 8 deletions.
------------------------------------------------------------


diff --git a/www/roster/public/stylesheets/app.css b/www/roster/public/stylesheets/app.css
index ee2f99c..9078a56 100644
--- a/www/roster/public/stylesheets/app.css
+++ b/www/roster/public/stylesheets/app.css
@@ -30,3 +30,8 @@ td:hover .hint {
 label {margin-right: 8px}
 
 button.btn {margin: 0 8px}
+
+.modal-header {
+  border-top-left-radius: 6px;
+  border-top-right-radius: 6px
+}
diff --git a/www/roster/views/committee.js.rb b/www/roster/views/committee.js.rb
index 0dff348..0ef1810 100644
--- a/www/roster/views/committee.js.rb
+++ b/www/roster/views/committee.js.rb
@@ -14,6 +14,8 @@ def render
 
     _p @@committee.description
 
+    _div.alert.alert_success 'Double click on a row to edit' if auth
+
     _h2 'PMC'
     _table.table.table_hover do
       _thead do
@@ -30,7 +32,7 @@ def render
         person = roster[id]
         person.id = id
 
-        _PMCMember auth: auth, person: person, chair: @@committee.chair
+        _PMCMember auth: auth, person: person, committee: @@committee
       end
 
       _PMCMemberAdd if auth
@@ -52,12 +54,15 @@ def render
 
         for id in committers
           next if @@committee.roster[id]
-          _PMCCommitter auth: auth, person: {id: id, name: committers[id]}
+          _PMCCommitter auth: auth, person: {id: id, name: committers[id]},
+            committee: @@committee
         end
 
         _PMCCommitterAdd if auth
       end
     end
+
+    _PMCConfirm if auth
   end
 end
 
@@ -77,8 +82,13 @@ def render
       _td @@person.date
 
       if @state == :open
-        _td { _button.btn.btn_warning 'remove from PMC' }
-      elsif @@person.id == @@chair
+        _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?"
+        end
+      elsif @@person.id == @@committee.chair
         _td.chair 'chair'
       else
         _td ''
@@ -108,8 +118,14 @@ def render
         _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'
+          _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 as a committer?"
+          _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?"
         end
       else
         _td '+', colspan: 4
@@ -139,8 +155,13 @@ def render
 
       if @state == :open
         _td do
-          _button.btn.btn_warning 'remove as committer'
-          _button.btn.btn_primary 'add to PMC'
+          _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
       else
         _td ''
@@ -184,3 +205,42 @@ def select
     @state = ( @state == :open ? :closed : :open )
   end
 end
+
+class PMCConfirm < React
+  def initialize
+    @text = 'text'
+    @color = 'btn-default'
+    @button = 'OK'
+  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
+            _button.btn.btn_default 'Cancel', data_dismiss:"modal"
+            _button.btn @button, data_dismiss:"modal", class: @color
+          end
+        end
+      end
+    end
+  end
+
+  def componentDidMount()
+    jQuery('#confirm').on('show.bs.modal') do |event|
+      button = event.relatedTarget
+      @text = button.dataset.confirmation
+      @color = button.classList[1]
+      @button = button.textContent
+    end
+  end
+end

Mime
View raw message