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/09/08 02:04:28 UTC
[whimsy] branch master updated (2e2fab3 -> a4ff0d2)
This is an automated email from the ASF dual-hosted git repository.
rubys pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git.
from 2e2fab3 look for name in parens too for podlingnamesearch
new bc3479f refactor using mixins
new a4ff0d2 more cleanup and use of computed properties
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
www/roster/views/app.js.rb | 3 +
www/roster/views/mixins/add.js.rb | 60 ++++++++++++++++
www/roster/views/mixins/mod.js.rb | 65 +++++++++++++++++
www/roster/views/pmc/add.js.rb | 102 +++++++-------------------
www/roster/views/pmc/main.js.rb | 4 +-
www/roster/views/pmc/mod.js.rb | 111 +++++++----------------------
www/roster/views/ppmc/add.js.rb | 103 +++++++--------------------
www/roster/views/ppmc/committers.js.rb | 30 ++++----
www/roster/views/ppmc/main.js.rb | 4 +-
www/roster/views/ppmc/members.js.rb | 40 ++---------
www/roster/views/ppmc/mentors.js.rb | 58 ++-------------
www/roster/views/ppmc/mod.js.rb | 126 +++++++++------------------------
12 files changed, 267 insertions(+), 439 deletions(-)
create mode 100644 www/roster/views/mixins/add.js.rb
create mode 100644 www/roster/views/mixins/mod.js.rb
--
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].
[whimsy] 01/02: refactor using mixins
Posted by ru...@apache.org.
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
commit bc3479f328f3d86de41caded89076660663e1351
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Thu Sep 7 20:57:06 2017 -0400
refactor using mixins
---
www/roster/views/app.js.rb | 3 +
www/roster/views/mixins/add.js.rb | 60 ++++++++++++++++++
www/roster/views/mixins/mod.js.rb | 65 ++++++++++++++++++++
www/roster/views/pmc/add.js.rb | 102 ++++++++----------------------
www/roster/views/pmc/main.js.rb | 4 +-
www/roster/views/pmc/mod.js.rb | 111 ++++++++-------------------------
www/roster/views/ppmc/add.js.rb | 103 ++++++++-----------------------
www/roster/views/ppmc/main.js.rb | 4 +-
www/roster/views/ppmc/mod.js.rb | 126 +++++++++++---------------------------
9 files changed, 245 insertions(+), 333 deletions(-)
diff --git a/www/roster/views/app.js.rb b/www/roster/views/app.js.rb
index 0ec24a8..dd9a79f 100644
--- a/www/roster/views/app.js.rb
+++ b/www/roster/views/app.js.rb
@@ -1,6 +1,9 @@
require_relative 'vue-config'
require_relative 'polyfill'
+require_relative 'mixins/add'
+require_relative 'mixins/mod'
+
require_relative 'pmc/main'
require_relative 'pmc/pmc'
require_relative 'pmc/committers'
diff --git a/www/roster/views/mixins/add.js.rb b/www/roster/views/mixins/add.js.rb
new file mode 100644
index 0000000..50c4ae0
--- /dev/null
+++ b/www/roster/views/mixins/add.js.rb
@@ -0,0 +1,60 @@
+#
+# Add People to a PMC or podling
+#
+
+class ProjectAdd < Vue::Mixin
+ def mounted()
+ jQuery("##{$options.add_tag}").on('show.bs.modal') do |event|
+ button = event.relatedTarget
+ setTimeout(500) { jQuery("##{$options.add_tag} input").focus() }
+ end
+ end
+
+ def add(person)
+ @people << person
+ Vue.forceUpdate()
+ jQuery("##{$options.add_tag} 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: @@project.id,
+ ids: @people.map {|person| person.id}.join(','),
+ action: action,
+ targets: targets
+ }.inspect
+ }
+
+ @disabled = true
+ Polyfill.require(%w(Promise fetch)) do
+ fetch($options.add_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|
+ Vue.emit :update, json
+ end
+ else
+ alert "#{response.status} #{response.statusText}"
+ end
+
+ jQuery("##{$options.add_tag}").modal(:hide)
+ @disabled = false
+ }.catch {|error|
+ alert error
+ jQuery("##{$options.add_tag}").modal(:hide)
+ @disabled = false
+ }
+ end
+ end
+end
diff --git a/www/roster/views/mixins/mod.js.rb b/www/roster/views/mixins/mod.js.rb
new file mode 100644
index 0000000..9a2992f
--- /dev/null
+++ b/www/roster/views/mixins/mod.js.rb
@@ -0,0 +1,65 @@
+#
+# Modify People's role in a project
+#
+
+class ProjectMod < Vue::Mixin
+ def mounted()
+ jQuery("##{$options.mod_tag}").on('show.bs.modal') do |event|
+ button = event.relatedTarget
+ setTimeout(500) { jQuery("##{$options.mod_tag} input").focus() }
+
+ selected = []
+ roster = @@project.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: @@project.id,
+ ids: @people.map {|person| person.id}.join(','),
+ action: action,
+ targets: targets
+ }.inspect
+ }
+
+ @disabled = true
+ Polyfill.require(%w(Promise fetch)) do
+ fetch($options.add_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|
+ Vue.emit :update, json
+ end
+ else
+ alert "#{response.status} #{response.statusText}"
+ end
+
+ jQuery("##{$options.mod_tag}").modal(:hide)
+ @disabled = false
+ }.catch {|error|
+ alert error
+ jQuery("##{$options.mod_tag}").modal(:hide)
+ @disabled = false
+ }
+ end
+ end
+end
diff --git a/www/roster/views/pmc/add.js.rb b/www/roster/views/pmc/add.js.rb
index 0b77efa..c0f4cef 100644
--- a/www/roster/views/pmc/add.js.rb
+++ b/www/roster/views/pmc/add.js.rb
@@ -1,49 +1,52 @@
#
-# Add People to a project
+# Add People to a PMC
#
class PMCAdd < Vue
+ mixin ProjectAdd
+ options add_tag: "pmcadd", add_action: 'actions/committee'
+
def initialize
@people = []
end
def render
- _div.modal.fade.pmcadd! tabindex: -1 do
+ _div.modal.fade id: $options.add_tag, 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'
+ _h4.modal_title 'Add People to the ' + @@project.display_name +
+ ' Project'
end
_div.modal_body do
_div.container_fluid do
- unless @people.empty?
+ unless @people.empty?
_table.table do
_thead do
_tr do
- _th 'id'
- _th 'name'
- _th 'email'
- end
+ _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
+ _tr do
+ _td person.id
+ _td person.name
+ _td person.mail[0]
+ end
+ end
end
end
- end
+ end
_CommitterSearch add: self.add,
- exclude: @@committee.roster.keys().
- concat(@people.map {|person| person.id})
+ exclude: @@project.roster.keys().
+ concat(@people.map {|person| person.id})
end
end
@@ -53,72 +56,17 @@ class PMCAdd < Vue
_button.btn.btn_default 'Cancel', data_dismiss: 'modal',
disabled: @disabled
- plural = (@people.length > 1 ? 's' : '')
+ plural = (@people.length > 1 ? 's' : '')
_button.btn.btn_primary "Add as committer#{plural}",
- data_action: 'add commit',
- onClick: self.post, disabled: (@people.empty?)
+ data_action: 'add commit',
+ onClick: self.post, disabled: (@people.empty?)
_button.btn.btn_primary 'Add to PMC', onClick: self.post,
- data_action: 'add pmc info commit', disabled: (@people.empty?)
+ data_action: 'add pmc info commit', disabled: (@people.empty?)
end
end
end
end
end
-
- def mounted()
- jQuery('#pmcadd').on('show.bs.modal') do |event|
- button = event.relatedTarget
- setTimeout(500) { jQuery('#pmcadd input').focus() }
- end
- end
-
- def add(person)
- @people << person
- Vue.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}.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|
- Vue.emit :update, 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 4024136..ce8c271 100644
--- a/www/roster/views/pmc/main.js.rb
+++ b/www/roster/views/pmc/main.js.rb
@@ -189,8 +189,8 @@ class PMC < Vue
# hidden forms
if auth
_Confirm action: :committee, project: @committee.id, update: self.update
- _PMCAdd committee: @@committee, onUpdate: self.update
- _PMCMod committee: @@committee, onUpdate: self.update
+ _PMCAdd project: @@committee, onUpdate: self.update
+ _PMCMod project: @@committee, onUpdate: self.update
end
end
diff --git a/www/roster/views/pmc/mod.js.rb b/www/roster/views/pmc/mod.js.rb
index e6152df..f28b4ae 100644
--- a/www/roster/views/pmc/mod.js.rb
+++ b/www/roster/views/pmc/mod.js.rb
@@ -1,8 +1,11 @@
#
-# Add People to a project
+# Modify People's role in a project
#
class PMCMod < Vue
+ mixin ProjectMod
+ options mod_tag: "pmcmod", mod_action: 'actions/committee'
+
def initialize
@people = []
end
@@ -14,27 +17,27 @@ class PMCMod < Vue
_div.modal_header.bg_info do
_button.close 'x', data_dismiss: 'modal'
_h4.modal_title "Modify People's Roles in the " +
- @@committee.display_name + ' Project'
+ @@project.display_name + ' Project'
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
+ _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
@@ -45,86 +48,26 @@ class PMCMod < Vue
disabled: @disabled
# show add to PMC button only if every person is not on the PMC
- if @people.all? {|person| !@@committee.members.include? person.id}
+ if @people.all? {|person| !@@project.members.include? person.id}
_button.btn.btn_primary "Add to PMC",
- data_action: 'add pmc info',
- onClick: self.post, disabled: (@people.empty?)
+ data_action: 'add pmc info',
+ onClick: self.post, disabled: (@people.empty?)
end
# remove from all relevant locations
remove_from = ['commit']
- if @people.any? {|person| @@committee.members.include? person.id}
+ if @people.any? {|person| @@project.members.include? person.id}
remove_from << 'info'
end
- if @people.any? {|person| @@committee.ldap.include? person.id}
+ if @people.any? {|person| @@project.ldap.include? person.id}
remove_from << 'pmc'
end
_button.btn.btn_primary 'Remove from project', onClick: self.post,
- data_action: "remove #{remove_from.join(' ')}"
+ data_action: "remove #{remove_from.join(' ')}"
end
end
end
end
end
-
- def mounted()
- jQuery('#pmcmod').on('show.bs.modal') do |event|
- button = event.relatedTarget
- setTimeout(500) { jQuery('#pmcmod input').focus() }
-
- selected = []
- roster = @@committee.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: @@committee.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|
- Vue.emit :update, json
- end
- else
- alert "#{response.status} #{response.statusText}"
- end
-
- jQuery('#pmcmod').modal(:hide)
- @disabled = false
- }.catch {|error|
- alert error
- jQuery('#pmcmod').modal(:hide)
- @disabled = false
- }
- end
- end
end
diff --git a/www/roster/views/ppmc/add.js.rb b/www/roster/views/ppmc/add.js.rb
index d65cd26..6f2eb9c 100644
--- a/www/roster/views/ppmc/add.js.rb
+++ b/www/roster/views/ppmc/add.js.rb
@@ -1,49 +1,52 @@
#
-# Add People to a project
+# Add People to a PPMC
#
class PPMCAdd < Vue
+ mixin ProjectAdd
+ options add_tag: "ppmcadd", add_action: 'actions/ppmc'
+
def initialize
@people = []
end
def render
- _div.modal.fade.ppmcadd! tabindex: -1 do
+ _div.modal.fade id: $options.add_tag, 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 ' + @@ppmc.display_name +
- ' Podling'
+ _h4.modal_title 'Add People to the ' + @@project.display_name +
+ ' Podling'
end
_div.modal_body do
_div.container_fluid do
- unless @people.empty?
+ unless @people.empty?
_table.table do
_thead do
_tr do
- _th 'id'
- _th 'name'
- _th 'email'
- end
+ _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
+ _tr do
+ _td person.id
+ _td person.name
+ _td person.mail[0]
+ end
+ end
end
end
- end
+ end
_CommitterSearch add: self.add,
- exclude: @@ppmc.roster.keys().
- concat(@people.map {|person| person.id})
+ exclude: @@project.roster.keys().
+ concat(@people.map {|person| person.id})
end
end
@@ -53,15 +56,15 @@ class PPMCAdd < Vue
_button.btn.btn_default 'Cancel', data_dismiss: 'modal',
disabled: @disabled
- plural = (@people.length > 1 ? 's' : '')
+ plural = (@people.length > 1 ? 's' : '')
if @@auth.ppmc
_button.btn.btn_primary "Add as committer#{plural}",
- data_action: 'add committer',
- onClick: self.post, disabled: (@people.empty?)
+ data_action: 'add committer',
+ onClick: self.post, disabled: (@people.empty?)
_button.btn.btn_primary 'Add to PPMC', onClick: self.post,
- data_action: 'add ppmc committer', disabled: (@people.empty?)
+ data_action: 'add ppmc committer', disabled: (@people.empty?)
end
if @@auth.ipmc
@@ -69,7 +72,7 @@ class PPMCAdd < Vue
action += ' ppmc committer' if @@auth.ppmc
_button.btn.btn_primary "Add as mentor#{plural}",
- data_action: action, onClick: self.post,
+ data_action: action, onClick: self.post,
disabled: (@people.empty?)
end
end
@@ -77,58 +80,4 @@ class PPMCAdd < Vue
end
end
end
-
- def mounted()
- jQuery('#ppmcadd').on('show.bs.modal') do |event|
- button = event.relatedTarget
- setTimeout(500) { jQuery('#ppmcadd input').focus() }
- end
- end
-
- def add(person)
- @people << person
- self.forceUpdate()
- jQuery('#ppmcadd 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: @@ppmc.id,
- ids: @people.map {|person| person.id}.join(','),
- 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('#ppmcadd').modal(:hide)
- @disabled = false
- }.catch {|error|
- alert error
- jQuery('#ppmcadd').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 ce1a37e..4cdc4a9 100644
--- a/www/roster/views/ppmc/main.js.rb
+++ b/www/roster/views/ppmc/main.js.rb
@@ -201,8 +201,8 @@ class PPMC < Vue
# hidden forms
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
+ _PPMCAdd project: @ppmc, onUpdate: self.update, auth: @@auth
+ _PPMCMod project: @ppmc, onUpdate: self.update, auth: @@auth
end
end
diff --git a/www/roster/views/ppmc/mod.js.rb b/www/roster/views/ppmc/mod.js.rb
index eb42ac3..219ff46 100644
--- a/www/roster/views/ppmc/mod.js.rb
+++ b/www/roster/views/ppmc/mod.js.rb
@@ -1,40 +1,43 @@
#
-# Add People to a project
+# Modify People's role in a podling
#
class PPMCMod < Vue
+ mixin ProjectMod
+ options mod_tag: "ppmcmod", mod_action: 'actions/ppmc'
+
def initialize
@people = []
end
def render
- _div.modal.fade.ppmcmod! tabindex: -1 do
+ _div.modal.fade id: $options.mod_tag, 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'
+ @@project.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
+ _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
@@ -45,103 +48,44 @@ class PPMCMod < Vue
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
+ # show add to PPMC button only if every person is not on the PPMC
+ if @people.all? {|person| !@@project.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}
+ if @people.all? {|person| !@@project.mentors.include? person.id}
plural = (@people.length > 1 ? 's' : '')
action = 'add mentor'
- if @people.any? {|person| !@@ppmc.owners.include? person.id}
- action += ' ppmc'
+ if @people.any? {|person| !@@project.owners.include? person.id}
+ action += ' ppmc'
end
_button.btn.btn_primary "Add as Mentor#{plural}",
- data_action: action, onClick: self.post,
+ 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}
+ if @people.any? {|person| @@project.owners.include? person.id}
remove_from << 'ppmc'
end
- if @people.any? {|person| @@ppmc.mentors.include? person.id}
+ if @people.any? {|person| @@project.mentors.include? person.id}
remove_from << 'mentor'
end
_button.btn.btn_primary 'Remove from project', onClick: self.post,
- data_action: "remove #{remove_from.join(' ')}"
+ data_action: "remove #{remove_from.join(' ')}"
end
end
end
end
end
-
- def mounted()
- 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/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('#ppmcmod').modal(:hide)
- @disabled = false
- }.catch {|error|
- alert error
- jQuery('#ppmcmod').modal(:hide)
- @disabled = false
- }
- end
- end
end
--
To stop receiving notification emails like this one, please contact
"commits@whimsical.apache.org" <co...@whimsical.apache.org>.
[whimsy] 02/02: more cleanup and use of computed properties
Posted by ru...@apache.org.
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
commit a4ff0d2e30d4aee9a2d391b90aee326e713e828a
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Thu Sep 7 22:04:15 2017 -0400
more cleanup and use of computed properties
---
www/roster/views/ppmc/committers.js.rb | 30 +++++++-----------
www/roster/views/ppmc/members.js.rb | 40 +++--------------------
www/roster/views/ppmc/mentors.js.rb | 58 +++-------------------------------
3 files changed, 22 insertions(+), 106 deletions(-)
diff --git a/www/roster/views/ppmc/committers.js.rb b/www/roster/views/ppmc/committers.js.rb
index 18811ef..95001c6 100644
--- a/www/roster/views/ppmc/committers.js.rb
+++ b/www/roster/views/ppmc/committers.js.rb
@@ -21,7 +21,7 @@ class PPMCCommitters < Vue
end
_tbody do
- @committers.each do |person|
+ committers.each do |person|
next if @@ppmc.owners.include? person.id
_PPMCCommitter auth: @@auth, person: person, ppmc: @@ppmc
pending << person.id if person.status == :pending
@@ -53,22 +53,16 @@ class PPMCCommitters < Vue
end
# compute list of committers
- def created()
- committers = []
+ def committers
+ result = []
@@ppmc.committers.each do |id|
person = @@ppmc.roster[id]
person.id = id
- committers << person
+ result << person
end
- @committers = committers.sort_by {|person| person.name}
- end
-
- # add a person to the displayed list of committers
- def add(person)
- person.status = 'pending'
- @committers << person
+ result.sort_by {|person| person.name}
end
end
@@ -97,13 +91,13 @@ class PPMCCommitter < Vue
if @@person.selected
_td data_ids: @@person.id do
- if @@auth.ipmc and not @@person.icommit
- _button.btn.btn_primary 'Add as an incubator committer',
- data_action: 'add icommit',
- data_target: '#confirm', data_toggle: 'modal',
- data_confirmation: "Add #{@@person.name} as a commiter " +
- "for the incubator PPMC?"
- end
+ if @@auth.ipmc and not @@person.icommit
+ _button.btn.btn_primary 'Add as an incubator committer',
+ data_action: 'add icommit',
+ data_target: '#confirm', data_toggle: 'modal',
+ data_confirmation: "Add #{@@person.name} as a commiter " +
+ "for the incubator PPMC?"
+ end
end
elsif not @@person.icommit
_span.issue 'not listed as an incubator committer'
diff --git a/www/roster/views/ppmc/members.js.rb b/www/roster/views/ppmc/members.js.rb
index b18e3a1..7142d2b 100644
--- a/www/roster/views/ppmc/members.js.rb
+++ b/www/roster/views/ppmc/members.js.rb
@@ -4,8 +4,6 @@
class PPMCMembers < Vue
def render
- pending = []
-
_h2.ppmc! 'PPMC'
_table.table.table_hover do
_thead do
@@ -18,53 +16,25 @@ class PPMCMembers < Vue
end
_tbody do
- @roster.each do |person|
+ roster.each do |person|
next if @@ppmc.mentors.include? person.id
_PPMCMember auth: @@auth, person: person, ppmc: @@ppmc
- pending << person.id if person.status == :pending
- end
-
- if pending.length > 1
- _tr do
- _td colspan: 2
- _td data_ids: pending.join(',') do
-
- # produce a list of ids to be added
- if pending.length == 2
- list = "#{pending[0]} and #{pending[1]}"
- else
- list = pending[0..-2].join(', ') + ", and " + pending[-1]
- end
-
- _button.btn.btn_success 'Add all to the PPMC',
- data_action: 'add ppmc committer',
- data_target: '#confirm', data_toggle: 'modal',
- data_confirmation: "Add #{list} to the " +
- "#{@@ppmc.display_name} PPMC?"
- end
- end
end
end
end
end
# compute roster
- def created()
- roster = []
+ def roster
+ result = []
@@ppmc.owners.each do |id|
person = @@ppmc.roster[id]
person.id = id
- roster << person
+ result << person
end
- @roster = roster.sort_by {|person| person.name}
- end
-
- # add a person to the displayed list of PMC members
- def add(person)
- person.status = :pending
- @roster << person
+ result.sort_by {|person| person.name}
end
end
diff --git a/www/roster/views/ppmc/mentors.js.rb b/www/roster/views/ppmc/mentors.js.rb
index 6164100..9bcabe4 100644
--- a/www/roster/views/ppmc/mentors.js.rb
+++ b/www/roster/views/ppmc/mentors.js.rb
@@ -8,8 +8,6 @@ class PPMCMentors < Vue
end
def render
- pending = []
-
_h2.mentors! 'Mentors'
_table.table.table_hover do
_thead do
@@ -22,70 +20,24 @@ class PPMCMentors < Vue
end
_tbody do
- @roster.each do |person|
+ roster.each do |person|
_PPMCMentor auth: @@auth, person: person, ppmc: @@ppmc
- pending << person.id if person.status == :pending
- end
-
- if pending.length > 1
- _tr do
- _td colspan: 2
- _td data_ids: pending.join(',') do
-
- # produce a list of ids to be added
- if pending.length == 2
- list = "#{pending[0]} and #{pending[1]}"
- else
- list = pending[0..-2].join(', ') + ", and " + pending[-1]
- end
-
- _button.btn.btn_success 'Add all as mentors',
- data_action: 'add ppmc committer mentor',
- data_target: '#confirm', data_toggle: 'modal',
- data_confirmation: "Add #{list} to the " +
- "#{@@ppmc.display_name} PPMC?"
- end
- end
end
end
end
end
# compute roster
- def created()
- roster = []
+ def roster
+ result = []
@@ppmc.mentors.each do |id|
person = @@ppmc.roster[id]
person.id = id
- roster << person
+ result << person
end
- @roster = roster.sort_by {|person| person.name}
- end
-
- # fetch IPMC list
- def mounted()
- return unless @@auth and @@auth.ipmc
- Polyfill.require(%w(Promise fetch)) do
- fetch('committee/incubator.json', credentials: 'include').then {|response|
- if response.status == 200
- response.json().then do |json|
- @ipmc = json.roster.keys()
- end
- else
- console.log "IPMC #{response.status} #{response.statusText}"
- end
- }.catch {|error|
- console.log "IPMC #{errror}"
- }
- end
- end
-
- # add a person to the displayed list of PMC members
- def add(person)
- person.status = :pending
- @roster << person
+ result.sort_by {|person| person.name}
end
end
--
To stop receiving notification emails like this one, please contact
"commits@whimsical.apache.org" <co...@whimsical.apache.org>.