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 11:16:19 UTC
[whimsy] branch master updated: rough in mod
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 aacb4df rough in mod
aacb4df is described below
commit aacb4df64d96dc447ad17c41208e78e13636f9a8
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Sun Jul 30 07:15:58 2017 -0400
rough in mod
---
www/roster/views/app.js.rb | 1 +
www/roster/views/ppmc/main.js.rb | 1 +
www/roster/views/ppmc/mod.js.rb | 147 +++++++++++++++++++++++++++++++++++++
www/roster/views/ppmc/roster.js.rb | 2 +-
4 files changed, 150 insertions(+), 1 deletion(-)
diff --git a/www/roster/views/app.js.rb b/www/roster/views/app.js.rb
index c75a77b..c26d6f2 100644
--- a/www/roster/views/app.js.rb
+++ b/www/roster/views/app.js.rb
@@ -25,6 +25,7 @@ require_relative 'ppmc/members'
require_relative 'ppmc/committers'
require_relative 'ppmc/roster'
require_relative 'ppmc/add'
+require_relative 'ppmc/mod'
require_relative 'ppmc/graduate'
require_relative 'committerSearch'
diff --git a/www/roster/views/ppmc/main.js.rb b/www/roster/views/ppmc/main.js.rb
index 9ede51b..181582c 100644
--- a/www/roster/views/ppmc/main.js.rb
+++ b/www/roster/views/ppmc/main.js.rb
@@ -215,6 +215,7 @@ class PPMC < React
if @@auth.ppmc or @@auth.ipmc
_Confirm action: :ppmc, project: @ppmc.id, update: self.update
_PPMCAdd ppmc: @ppmc, update: self.update, auth: @@auth
+ _PPMCMod ppmc: @ppmc, update: self.update, auth: @@auth
end
end
diff --git a/www/roster/views/ppmc/mod.js.rb b/www/roster/views/ppmc/mod.js.rb
new file mode 100644
index 0000000..3c64b21
--- /dev/null
+++ b/www/roster/views/ppmc/mod.js.rb
@@ -0,0 +1,147 @@
+#
+# Add People to a project
+#
+
+class PPMCMod < React
+ def initialize
+ @people = []
+ end
+
+ def render
+ _div.modal.fade.ppmcmod! 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 "Modify People's Roles in the " +
+ @@ppmc.display_name + ' Podling'
+ end
+
+ _div.modal_body do
+ _div.container_fluid do
+ _table.table do
+ _thead do
+ _tr do
+ _th 'id'
+ _th 'name'
+ end
+ end
+ _tbody do
+ @people.each do |person|
+ _tr do
+ _td person.id
+ _td person.name
+ end
+ end
+ end
+ end
+ end
+ end
+
+ _div.modal_footer do
+ _span.status 'Processing request...' if @disabled
+
+ _button.btn.btn_default 'Cancel', data_dismiss: 'modal',
+ disabled: @disabled
+
+ if @@auth.ppmc
+ # show add to PPMC button only if every person is not on the PPMC
+ if @people.all? {|person| !@@ppmc.owners.include? person.id}
+ _button.btn.btn_primary "Add to PPMC",
+ data_action: 'add ppmc',
+ onClick: self.post, disabled: (@people.empty?)
+ end
+ end
+
+ # show add as mentor button only if every person is not a mentor
+ if @@auth.ipmc
+ if @people.all? {|person| !@@ppmc.mentors.include? person.id}
+ plural = (@people.length > 1 ? 's' : '')
+
+ action = 'add mentor'
+ if @people.any? {|person| !@@ppmc.owners.include? person.id}
+ action += ' ppmc'
+ end
+
+ _button.btn.btn_primary "Add as Mentor#{plural}",
+ data_action: action, onClick: self.post,
+ disabled: (@people.empty?)
+ end
+ end
+
+ # remove from all relevant locations
+ remove_from = ['committer']
+ if @people.any? {|person| @@ppmc.owners.include? person.id}
+ remove_from << 'ppmc'
+ end
+ if @people.any? {|person| @@ppmc.mentors.include? person.id}
+ remove_from << 'mentor'
+ end
+
+ _button.btn.btn_primary 'Remove from project', onClick: self.post,
+ data_action: "remove #{remove_from.join(' ')}"
+ end
+ end
+ end
+ end
+ end
+
+ def componentDidMount()
+ jQuery('#ppmcmod').on('show.bs.modal') do |event|
+ button = event.relatedTarget
+ setTimeout(500) { jQuery('#ppmcmod input').focus() }
+
+ selected = []
+ roster = @@ppmc.roster
+ for id in roster
+ if roster[id].selected
+ roster[id].id = id
+ selected << roster[id]
+ end
+ end
+
+ @people = selected
+ end
+ 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('#ppmcmod').modal(:hide)
+ @disabled = false
+ }.catch {|error|
+ alert error
+ jQuery('#ppmcmod').modal(:hide)
+ @disabled = false
+ }
+ end
+ end
+end
diff --git a/www/roster/views/ppmc/roster.js.rb b/www/roster/views/ppmc/roster.js.rb
index da93f8e..3cf0fb7 100644
--- a/www/roster/views/ppmc/roster.js.rb
+++ b/www/roster/views/ppmc/roster.js.rb
@@ -42,7 +42,7 @@ class PPMCRoster < React
if @@auth.ipmc or @@auth.ppmc
_td do
_input type: 'checkbox', checked: person.selected || false,
- onChange: -> {self.toggleSelect(person)}, disabled: true
+ onChange: -> {self.toggleSelect(person)}
end
end
--
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].