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/14 22:52:20 UTC
[whimsy] branch master updated: initial cut at a new 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 0b3af3c initial cut at a new add dialog
0b3af3c is described below
commit 0b3af3c93c2cd4abcd2a65214d833d07a24bb362
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Fri Jul 14 18:51:51 2017 -0400
initial cut at a new add dialog
---
www/roster/views/app.js.rb | 1 +
www/roster/views/committerSearch.js.rb | 3 +-
www/roster/views/pmc/add.js.rb | 123 +++++++++++++++++++++++++++++++++
www/roster/views/pmc/main.js.rb | 8 ++-
www/roster/views/pmc/roster.js.rb | 2 +-
5 files changed, 134 insertions(+), 3 deletions(-)
diff --git a/www/roster/views/app.js.rb b/www/roster/views/app.js.rb
index ca21f99..72f26f0 100644
--- a/www/roster/views/app.js.rb
+++ b/www/roster/views/app.js.rb
@@ -4,6 +4,7 @@ require_relative 'pmc/main'
require_relative 'pmc/pmc'
require_relative 'pmc/committers'
require_relative 'pmc/roster'
+require_relative 'pmc/add'
require_relative 'person'
require_relative 'person/fullname'
diff --git a/www/roster/views/committerSearch.js.rb b/www/roster/views/committerSearch.js.rb
index 7974215..7c0c17b 100644
--- a/www/roster/views/committerSearch.js.rb
+++ b/www/roster/views/committerSearch.js.rb
@@ -60,7 +60,7 @@ class CommitterSearch < React
_label.control_label.col_sm_3 'Search for', for: 'search-text'
_div.col_sm_9 do
_div.input_group do
- _input.form_control.search_text! autofocus: true, value: @search, onChange: self.change
+ _input.form_control autofocus: true, value: @search, onChange: self.change
_span.input_group_addon do
_span.glyphicon.glyphicon_user aria_label: "Committer ID or name"
end
@@ -131,6 +131,7 @@ class CommitterSearch < React
id = event.currentTarget.dataset.id
person = @list.find {|person| person.id == id}
@@add.call(person)
+ @search = ''
end
end
end
diff --git a/www/roster/views/pmc/add.js.rb b/www/roster/views/pmc/add.js.rb
new file mode 100644
index 0000000..632cedc
--- /dev/null
+++ b/www/roster/views/pmc/add.js.rb
@@ -0,0 +1,123 @@
+#
+# Add People to a project
+#
+
+class PMCAdd < React
+ def initialize
+ @people = []
+ end
+
+ def render
+ _div.modal.fade.pmcadd! 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 ' + @@committee.display_name +
+ ' Project'
+ 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: @@committee.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' : '')
+
+ _button.btn.btn_primary "Add as committer#{plural}",
+ data_action: 'add pmc info commit',
+ onClick: self.post, disabled: (@people.empty?)
+
+ _button.btn.btn_primary 'Add to PMC', onClick: self.post,
+ data_action: 'add commit', disabled: (@people.empty?)
+ 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: @@committee.id,
+ ids: @people.map {|person| person.id},
+ action: action,
+ targets: targets
+ }.inspect
+ }
+
+ @disabled = true
+ Polyfill.require(%w(Promise fetch)) do
+ fetch("actions/#{@@action}", 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/pmc/main.js.rb b/www/roster/views/pmc/main.js.rb
index a8d820f..1904091 100644
--- a/www/roster/views/pmc/main.js.rb
+++ b/www/roster/views/pmc/main.js.rb
@@ -67,6 +67,11 @@ class PMC < React
_div.row key: 'databar' do
_div.col_sm_6 do
+ if auth
+ _button.btn.btn_default 'Add',
+ data_target: '#pmcadd', data_toggle: 'modal'
+ _button.btn.btn_default 'Modify', disabled: true
+ end
end
_div.col_sm_6 do
_input.form_control type: 'search', placeholder: 'search',
@@ -174,9 +179,10 @@ class PMC < React
end
end
- # hidden form
+ # hidden forms
if auth
_Confirm action: :committee, project: @committee.id, update: self.update
+ _PMCAdd committee: @@committee, update: self.update
end
end
diff --git a/www/roster/views/pmc/roster.js.rb b/www/roster/views/pmc/roster.js.rb
index e1b6551..7291e09 100644
--- a/www/roster/views/pmc/roster.js.rb
+++ b/www/roster/views/pmc/roster.js.rb
@@ -36,7 +36,7 @@ class PMCRoster < React
_tbody do
matches.each do |person|
- _tr do
+ _tr key: "pmc_#{person.id}" do
_td do
_input type: 'checkbox', checked: person.selected || false,
onChange: -> {self.toggleSelect(person)}
--
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].