You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by cu...@apache.org on 2019/05/02 18:35:36 UTC
[whimsy] branch master updated (80d5db8 -> 5cab7ee)
This is an automated email from the ASF dual-hosted git repository.
curcuru pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git.
from 80d5db8 Revert "Revert "Select multiple attr must be either present or not at all""
new 40dbcde Properly display multiselect options; properly do textarea
new 5cab7ee Enable checkin and update field display types
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:
lib/whimsy/asf/forms.rb | 68 ++++++++++++++++++++++++++-----------------
www/members/mentor-update.cgi | 20 +++++++------
2 files changed, 53 insertions(+), 35 deletions(-)
[whimsy] 01/02: Properly display multiselect options;
properly do textarea
Posted by cu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
curcuru pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
commit 40dbcded89d86ffa27d6dd755904103214529239
Author: Shane Curcuru <as...@shanecurcuru.org>
AuthorDate: Thu May 2 14:34:54 2019 -0400
Properly display multiselect options; properly do textarea
---
lib/whimsy/asf/forms.rb | 68 ++++++++++++++++++++++++++++++-------------------
1 file changed, 42 insertions(+), 26 deletions(-)
diff --git a/lib/whimsy/asf/forms.rb b/lib/whimsy/asf/forms.rb
index e5f8a8d..eaa3209 100644
--- a/lib/whimsy/asf/forms.rb
+++ b/lib/whimsy/asf/forms.rb
@@ -37,21 +37,25 @@ class Wunderbar::HtmlMarkup
helptext: nil
)
return unless name
- tagname = 'input'
- tagname = 'textarea' if rows
aria_describedby = "#{name}_help" if helptext
_div.form_group do
_label.control_label.col_sm_3 label, for: "#{name}"
_div.col_sm_9 do
_div.input_group do
- if pattern
- _.tag! tagname, class: 'form-control', name: "#{name}", id: "#{name}",
- type: "#{type}", pattern: "#{pattern}", placeholder: "#{placeholder}", value: value,
+ args = {
+ class: 'form-control', name: "#{name}", id: "#{name}",
+ type: "#{type}", placeholder: "#{placeholder}",
aria_describedby: "#{aria_describedby}", required: required, readonly: readonly
+ }
+ if rows
+ args[:rows] = rows
+ _textarea! args do
+ _! value
+ end
else
- _.tag! tagname, class: 'form-control', name: "#{name}", id: "#{name}",
- type: "#{type}", placeholder: "#{placeholder}", value: value,
- aria_describedby: "#{aria_describedby}", required: required, readonly: readonly
+ args[:value] = value
+ args[:pattern] = "#{pattern}" if pattern
+ _input args
end
_whimsy_forms_iconlink(icon: icon, iconlabel: iconlabel, iconlink: iconlink)
end
@@ -65,23 +69,26 @@ class Wunderbar::HtmlMarkup
end
# Display an optionlist control within a form
- # @param name required string ID of control's label
+ # @param name required string ID of control's label
+ # @param options required ['value'] or {"value" => 'Label for value'} of all selectable values
+ # @param values required 'value' or ['value'] or {"value" => 'Label for value'} of all selected values
+ # @param placeholder Currently displayed text if passed (not selectable)
def _whimsy_forms_select(
name: nil,
- label: 'Enter string',
- value: '', # Currently selected value
- valuelabel: '', # Currently selected valuelabel
- options: nil, # ['value'] or {"value" => 'Label for value'} of all selectable values
- multiple: false, # Not currently supported
+ label: 'Select value(s)',
+ values: nil,
+ options: nil,
+ multiple: false,
required: false,
readonly: false,
icon: nil,
iconlabel: nil,
iconlink: nil,
- placeholder: nil, # Currently displayed text if value is blank (not selectable)
+ placeholder: nil,
helptext: nil
)
return unless name
+ return unless values
aria_describedby = "#{name}_help" if helptext
_div.form_group do
_label.control_label.col_sm_3 label, for: "#{name}"
@@ -94,22 +101,31 @@ class Wunderbar::HtmlMarkup
args['multiple'] = 'true'
end
_select.form_control args do
- if ''.eql?(value)
- if ''.eql?(placeholder)
- _option '', value: '', selected: 'selected'
- else
- _option "#{placeholder}", value: '', selected: 'selected', disabled: 'disabled', hidden: 'hidden'
- end
+ if ''.eql?(placeholder)
+ _option '', value: '', selected: 'selected'
else
- _option ''.eql?(valuelabel) ? "#{value}" : "#{valuelabel}", value: "#{value}", selected: 'selected'
+ _option "#{placeholder}", value: '', selected: 'selected', disabled: 'disabled', hidden: 'hidden'
+ end
+ # Construct selectable list from values (first) then options
+ if values.kind_of?(Array)
+ values.each do |val|
+ _option val, value: val, selected: true
+ end
+ elsif values.kind_of?(Hash)
+ values.each do |val, disp|
+ _option disp, value: val, selected: true
+ end
+ elsif values # Fallback for simple case of single string value
+ _option "#{values}", value: "#{values}", selected: true
+ values = [values] # Ensure supports .include? for options loop below
end
if options.kind_of?(Array)
- options.each do |opt|
- _option opt, value: opt
+ options.each do |val|
+ _option val, value: val unless values.include?(val)
end
- else
+ elsif options.kind_of?(Hash)
options.each do |val, disp|
- _option disp, value: val
+ _option disp, value: val unless values.include?(val)
end
end
end
[whimsy] 02/02: Enable checkin and update field display types
Posted by cu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
curcuru pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
commit 5cab7ee9f68566e7e0116d7b924b3103db9ef252
Author: Shane Curcuru <as...@shanecurcuru.org>
AuthorDate: Thu May 2 14:35:28 2019 -0400
Enable checkin and update field display types
---
www/members/mentor-update.cgi | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/www/members/mentor-update.cgi b/www/members/mentor-update.cgi
index 51b76c2..b0de5f5 100755
--- a/www/members/mentor-update.cgi
+++ b/www/members/mentor-update.cgi
@@ -39,7 +39,7 @@ def emit_form(apacheid, mdata, button_help, uimap)
emit_mentor_input('contact', mdata, uimap, 'glyphicon-bullhorn', req: true)
field = 'timezone'
_whimsy_forms_select(label: uimap[field][0], name: field,
- value: (mdata[field] ? mdata[field] : ''),
+ values: (mdata[field] ? mdata[field] : ''),
options: MentorFormat::TZ.sort,
icon: 'glyphicon-time', iconlabel: 'clock',
helptext: uimap[field][1]
@@ -47,14 +47,14 @@ def emit_form(apacheid, mdata, button_help, uimap)
emit_mentor_input('availability', mdata, uimap, 'glyphicon-hourglass')
field = 'prefers'
_whimsy_forms_select(label: uimap[field][0], name: field, multiple: true,
- value: (mdata[field] ? mdata[field] : ''),
+ values: (mdata[field] ? mdata[field] : ''),
options: MentorFormat::PREFERS_TYPES,
icon: 'glyphicon-ok-sign', iconlabel: 'ok-sign',
helptext: uimap[field][1]
)
field = 'languages'
_whimsy_forms_select(label: uimap[field][0], name: field, multiple: true,
- value: (mdata[field] ? mdata[field] : ''),
+ values: (mdata[field] ? mdata[field] : ''),
options: MentorFormat::LANGUAGES,
icon: 'glyphicon-globe', iconlabel: 'globe',
helptext: uimap[field][1]
@@ -72,7 +72,11 @@ def emit_form(apacheid, mdata, button_help, uimap)
end
emit_mentor_input('homepage', mdata, uimap, 'glyphicon-console')
emit_mentor_input('pronouns', mdata, uimap, 'glyphicon-user')
- emit_mentor_input('aboutme', mdata, uimap, 'glyphicon-info-sign')
+ field = 'aboutme'
+ _whimsy_forms_input(label: uimap[field][0], name: field, rows: 3,
+ icon: 'glyphicon-info-sign', value: (mdata[field] ? mdata[field] : ''),
+ helptext: uimap[field][1]
+ )
_div.form_group do
_label.col_sm_offset_3.col_sm_9.strong.text_left 'Temporarily Opt Out From Any NEW Mentees'
@@ -128,15 +132,13 @@ def send_form(formdata: {})
if File.exist? fn
File.write(fn, mentor_update + "\n")
_.system ['svn', 'st']
- message = "#{$USER} updating mentoring data"
+ message = "Updating my mentoring data (whimsy)"
else
File.write(fn, mentor_update + "\n")
_.system ['svn', 'add', fn]
- message = "#{$USER} += New member mentoring volunteer"
+ message = "#{$USER} += mentoring volunteer (whimsy)"
end
-# rc = _.system ['svn', 'commit', fn, '--message', message, svnopts, credentials]
- _p "SYSTEM: #{['svn', 'commit', fn, '--message', message, svnopts, credentials]}"
- _p "DEBUG: still debugging this script, so the final commit is commented out -sc"
+ rc = _.system ['svn', 'commit', fn, '--message', message, svnopts, credentials]
end
end