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 77bbd9e77c5a833cf304591689c954d43e8ca591 Author: Shane Curcuru <[email protected]> AuthorDate: Thu May 2 08:55:35 2019 -0400 Select multiple attr must be either present or not at all --- lib/whimsy/asf/forms.rb | 8 ++++++- www/members/mentor-format.rb | 53 +++++++++++++++++++++++++++++++++++++++++++ www/members/mentor-update.cgi | 25 +++++++++++++++----- 3 files changed, 79 insertions(+), 7 deletions(-) diff --git a/lib/whimsy/asf/forms.rb b/lib/whimsy/asf/forms.rb index 5e54c3b..e5f8a8d 100644 --- a/lib/whimsy/asf/forms.rb +++ b/lib/whimsy/asf/forms.rb @@ -87,7 +87,13 @@ class Wunderbar::HtmlMarkup _label.control_label.col_sm_3 label, for: "#{name}" _div.col_sm_9 do _div.input_group do - _select.form_control name: "#{name}", id: "#{name}", aria_describedby: "#{aria_describedby}", required: required, readonly: readonly do + args = { + name: "#{name}", id: "#{name}", aria_describedby: "#{aria_describedby}", required: required, readonly: readonly + } + if multiple + args['multiple'] = 'true' + end + _select.form_control args do if ''.eql?(value) if ''.eql?(placeholder) _option '', value: '', selected: 'selected' diff --git a/www/members/mentor-format.rb b/www/members/mentor-format.rb index 29eee37..924a8ec 100644 --- a/www/members/mentor-format.rb +++ b/www/members/mentor-format.rb @@ -11,6 +11,59 @@ class MentorFormat ERRORS = 'errors' TIMEZONE = 'timezone' TZ = TZInfo::Timezone.all_country_zone_identifiers + PREFERS_TYPES = [ + 'email', + 'phone', + 'Slack', + 'irc', + 'Hangouts', + 'Facebook', + 'Skype', + 'other (text chat)', + 'other (video chat)' + ] + LANGUAGES = [ # Wikipedia top list by total speakers, plus EU + 'Arabic', + 'Bengali', + 'Bulgarian', + 'Chinese', + 'Croatian', + 'Czech', + 'Danish', + 'Dutch', + 'English', + 'Estonian', + 'Finnish', + 'French', + 'German', + 'Greek', + 'Hindi', + 'Hungarian', + 'Indonesean', + 'Irish', + 'Italian', + 'Japanese', + 'Korean', + 'Latvian', + 'Lithuanian', + 'Maltese', + 'Marathi', + 'Polish', + 'Portugese', + 'Punjabi', + 'Romanian', + 'Russian', + 'Slovak', + 'Slovene', + 'Spanish', + 'Swahili', + 'Swedish', + 'Tamil', + 'Telugu', + 'Thai', + 'Turkish', + 'Vietnamese' + ] # Read mapping of labels to fields def self.get_uimap(path) diff --git a/www/members/mentor-update.cgi b/www/members/mentor-update.cgi index af80e33..51b76c2 100755 --- a/www/members/mentor-update.cgi +++ b/www/members/mentor-update.cgi @@ -45,8 +45,20 @@ def emit_form(apacheid, mdata, button_help, uimap) helptext: uimap[field][1] ) emit_mentor_input('availability', mdata, uimap, 'glyphicon-hourglass') - emit_mentor_input('prefers', mdata, uimap, 'glyphicon-ok-sign') - emit_mentor_input('languages', mdata, uimap, 'glyphicon-globe') + field = 'prefers' + _whimsy_forms_select(label: uimap[field][0], name: field, multiple: true, + value: (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] : ''), + options: MentorFormat::LANGUAGES, + icon: 'glyphicon-globe', iconlabel: 'globe', + helptext: uimap[field][1] + ) _div.form_group do _label.col_sm_offset_3.col_sm_9.strong.text_left 'What You Could Help Mentees With' @@ -201,18 +213,19 @@ _html do # Display data to the user, depending if we're GET (existing mentor record or just blank data) or POST (show SVN checkin results) if _.post? - submission = { # TODO make this a loop over uimap.keys; TODO check if we want any other fields + submission = { "timezone" => "#{@timezone}", "availability" => "#{@availability}", "contact" => "#{@contact}", - "prefers" => "#{@prefers}", "available" => "#{@available}", "mentoring" => "#{@mentoring}", "experience" => "#{@experience}", - "languages" => "#{@languages}", "pronouns" => "#{@pronouns}", "aboutme" => "#{@aboutme}", - "homepage" => "#{@homepage}" + "homepage" => "#{@homepage}", + # Multiple select fields + "prefers" => _.params['prefers'], + "languages" => _.params['languages'] } if @notavailable submission['notavailable'] = "#{@notavailable}"
