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 2018/04/03 19:29:59 UTC
[whimsy] branch master updated: change chair support
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 7fd73da change chair support
7fd73da is described below
commit 7fd73da199147765adc74a3b4200e77165814136
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Tue Apr 3 15:29:36 2018 -0400
change chair support
---
www/board/agenda/routes.rb | 5 +
www/board/agenda/templates/change-chair.erb | 24 ++++
www/board/agenda/views/actions/post-data.json.rb | 77 ++++++++++++
www/board/agenda/views/buttons/post.js.rb | 144 ++++++++++++++++++-----
4 files changed, 222 insertions(+), 28 deletions(-)
diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb
index 89996af..8445ff3 100755
--- a/www/board/agenda/routes.rb
+++ b/www/board/agenda/routes.rb
@@ -227,6 +227,11 @@ get %r{/(\d\d\d\d-\d\d-\d\d)} do |date|
redirect to("/#{date}/")
end
+# post item support
+get '/json/post-data' do
+ _json :"actions/post-data"
+end
+
# feedback responses
get '/json/responses' do
_json :"actions/responses"
diff --git a/www/board/agenda/templates/change-chair.erb b/www/board/agenda/templates/change-chair.erb
new file mode 100644
index 0000000..0bafdcf
--- /dev/null
+++ b/www/board/agenda/templates/change-chair.erb
@@ -0,0 +1,24 @@
+WHEREAS, the Board of Directors heretofore appointed
+<%= @outgoing_chair.public_name %>
+(<%= @outgoing_chair.id %>) to the office of Vice President, Apache
+<%= @committee.display_name %>, and
+
+WHEREAS, the Board of Directors is in receipt of the resignation of
+<%= @outgoing_chair.public_name %> from the office of Vice President, Apache
+<%= @committee.display_name %>, and
+
+WHEREAS, the Project Management Committee of the Apache
+<%= @committee.display_name %> project
+has chosen by vote to recommend <%= @incoming_chair.public_name %>
+(<%= @incoming_chair.id %>) as the successor to the post;
+
+NOW, THEREFORE, BE IT RESOLVED, that <%= @outgoing_chair.public_name %> is
+relieved and discharged from the duties and responsibilities of the office of
+Vice President, Apache <%= @committee.display_name %>, and
+
+BE IT FURTHER RESOLVED, that <%= @incoming_chair.public_name %> be and hereby is
+appointed to the office of Vice President, Apache
+<%= @committee.display_name %>, to serve in accordance with and subject to the
+direction of the Board of Directors and the Bylaws of the Foundation until
+death, resignation, retirement, removal or disqualification, or until a
+successor is appointed.
diff --git a/www/board/agenda/views/actions/post-data.json.rb b/www/board/agenda/views/actions/post-data.json.rb
new file mode 100644
index 0000000..5a26826
--- /dev/null
+++ b/www/board/agenda/views/actions/post-data.json.rb
@@ -0,0 +1,77 @@
+#
+# Helpers for building agenda items to be posted:
+# committee-list: list all of the committees
+# committee-members: list chair and members of a committee
+# change-chair: produce a draft change chair resolution
+#
+
+# debugging support: enable script to be run from the command line
+if $0 == __FILE__
+ $LOAD_PATH.unshift File.realpath(File.expand_path('../'*6 + 'lib', __FILE__))
+ Dir.chdir File.expand_path('../..', __dir__)
+ require './helpers/string'
+ require 'whimsy/asf'
+ require 'ostruct'
+ require 'pp'
+ $SAFE = 1
+
+ ARGV.each do |arg|
+ name, value = arg.split('=', 2)
+ next unless name =~ /^\w+$/ and value
+ instance_variable_set "@#{name}", value
+ end
+
+ binding.local_variable_set :env, OpenStruct.new(user: ENV['user'])
+end
+
+ASF::Committee.load_committee_info
+
+output = case @request
+when 'committee-list'
+ id = env.user
+
+ committees = {chair: [], member: [], rest: []}
+
+ ASF::Committee.pmcs.sort_by {|pmc| pmc.id}.each do |pmc|
+ if pmc.chairs.any? {|chair| chair[:id] == id}
+ committees[:chair] << pmc.id
+ elsif pmc.info.include? 'rubys'
+ committees[:member] << pmc.id
+ else
+ committees[:rest] << pmc.id
+ end
+ end
+
+ committees[:chair] + committees[:member] + committees[:rest] + [@request]
+
+when 'committee-members'
+ committee = ASF::Committee.find(@pmc)
+ return unless committee
+ chair = committee.chairs.first
+ return unless chair
+ roster = committee.roster
+ roster.delete(chair[:id])
+
+ roster = roster.map {|id, info| {id: id}.merge(info)}
+
+ {chair: chair, members: roster}
+
+when 'change-chair'
+ @committee = ASF::Committee[@pmc]
+ return unless @committee
+ @outgoing_chair = ASF::Person[@committee.chairs.first[:id]]
+ @incoming_chair = ASF::Person[@chair]
+ return unless @outgoing_chair and @incoming_chair
+
+ template = File.read('templates/change-chair.erb')
+ draft = template.gsub /<%=\s*(.*?)\s*%>/ do
+ var, method = $1.split('.')
+ instance_variable_get(var).send(method)
+ end
+
+ {draft: draft.reflow(0, 71)}
+end
+
+puts output if $0 == __FILE__
+
+output
diff --git a/www/board/agenda/views/buttons/post.js.rb b/www/board/agenda/views/buttons/post.js.rb
index 4c6f937..3c224ea 100644
--- a/www/board/agenda/views/buttons/post.js.rb
+++ b/www/board/agenda/views/buttons/post.js.rb
@@ -23,11 +23,6 @@ class Post < Vue
}
end
- def selectItem(event)
- @button = event.target.textContent
- retitle()
- end
-
def render
_ModalDialog.wide_form.post_report_form! color: 'commented' do
if @button == 'add item'
@@ -35,7 +30,8 @@ class Post < Vue
_ul.new_item_type do
_li do
- _button.btn.btn_primary 'Change Chair', disabled: true
+ _button.btn.btn_primary 'Change Chair', onClick: selectItem
+ _span '- change chair for an existing PMC'
end
_li do
@@ -57,7 +53,41 @@ class Post < Vue
end
_button.btn_default 'Cancel', data_dismiss: 'modal'
+
+ elsif @button == 'Change Chair'
+ _h4 'Change Chair Resolution'
+
+ _div.form_group do
+ _label 'PMC', for: 'change-chair-pmc'
+ _select.form_control.change_chair_pmc!(
+ onChange: ->(event) {chair_pmc_change(event.target.value)}
+ ) do
+ @pmcs.each {|pmc| _option pmc}
+ end
+ end
+
+ _div.form_group do
+ _label 'Outgoing Chair', for: 'outgoing-chair'
+ _input.form_control.outgoing_chair! value: @outgoing_chair,
+ disabled: true
+ end
+
+ _div.form_group do
+ _label 'Incoming Chair', for: 'incoming-chair'
+ _select.form_control.incoming_chair! do
+ @pmc_members.each do |person|
+ _option person.name, value: person.id,
+ selected: person.id == User.id
+ end
+ end
+ end
+
+ _button.btn_default 'Cancel', data_dismiss: 'modal', disabled: @disabled
+ _button.btn_primary 'Draft', disabled: @disabled,
+ onClick: draft_chair_change_resolution
+
else
+
_h4 @header
#input field: title
@@ -98,6 +128,17 @@ class Post < Vue
end
end
+ # add item menu support
+ def selectItem(event)
+ @button = event.target.textContent
+
+ if @button == 'Change Chair'
+ initialize_chair_change()
+ end
+
+ retitle()
+ end
+
# autofocus on report/resolution title/text
def mounted()
jQuery('#post-report-form').on 'show.bs.modal' do
@@ -298,6 +339,40 @@ class Post < Vue
end
end
+ # when save button is pushed, post comment and dismiss modal when complete
+ def submit(event)
+ @edited = false
+
+ if @header == 'Add Resolution'
+ data = {
+ agenda: Agenda.file,
+ attach: '7?',
+ title: @title,
+ report: @report
+ }
+ else
+ data = {
+ agenda: Agenda.file,
+ attach: @@item.attach,
+ digest: @digest,
+ message: @message,
+ report: @report
+ }
+ end
+
+ @disabled = true
+ post 'post', data do |response|
+ jQuery('#post-report-form').modal(:hide)
+ document.body.classList.remove('modal-open')
+ @disabled = false
+ Agenda.load response.agenda, response.digest
+ end
+ end
+
+ #########################################################################
+ # Treasurer #
+ #########################################################################
+
# upload contents of spreadsheet in base64; append extracted table to report
def upload_spreadsheet(event)
@disabled = true
@@ -322,33 +397,46 @@ class Post < Vue
reader.readAsArrayBuffer(document.getElementById('upload').files[0])
end
- # when save button is pushed, post comment and dismiss modal when complete
- def submit(event)
- @edited = false
+ #########################################################################
+ # Change Project Chair #
+ #########################################################################
- if @header == 'Add Resolution'
- data = {
- agenda: Agenda.file,
- attach: '7?',
- title: @title,
- report: @report
- }
- else
- data = {
- agenda: Agenda.file,
- attach: @@item.attach,
- digest: @digest,
- message: @message,
- report: @report
- }
+ def initialize_chair_change()
+ @disabled = true
+ @pmcs = []
+ chair_pmc_change(nil)
+ post 'post-data', request: 'committee-list' do |response|
+ @pmcs = response
+ chair_pmc_change(@pmcs.first)
end
+ end
+ def chair_pmc_change(pmc)
@disabled = true
- post 'post', data do |response|
- jQuery('#post-report-form').modal(:hide)
- document.body.classList.remove('modal-open')
+ @outgoing_chair = nil
+ @pmc_members = []
+ return unless pmc
+ post 'post-data', request: 'committee-members', pmc: pmc do |response|
+ @outgoing_chair = response.chair.name
+ @pmc_members = response.members
@disabled = false
- Agenda.load response.agenda, response.digest
end
end
+
+ def draft_chair_change_resolution()
+ @disabled = true
+ options = {
+ request: 'change-chair',
+ pmc: document.getElementById('change-chair-pmc').value,
+ chair: document.getElementById('incoming-chair').value
+ }
+
+ post 'post-data', options do |response|
+ @button = @header = 'Add Resolution'
+ @title = response.title
+ @report = response.draft
+ @disabled = false
+ end
+ end
+
end
--
To stop receiving notification emails like this one, please contact
rubys@apache.org.