From 412b8264dd8b7832e273be8e887df2c47c46b297 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Wed, 26 Nov 2014 22:01:03 +0000 Subject: Bug 1063818: Updates to form.dev-engagement-event --- extensions/BMO/Extension.pm | 117 +++ extensions/BMO/lib/Constants.pm | 12 + .../create/comment-dev-engagement-event.txt.tmpl | 90 +- .../create/create-dev-engagement-event.html.tmpl | 906 ++++++++++----------- extensions/BMO/web/js/dev_engagement.js | 290 +++++++ extensions/BMO/web/js/form_validate.js | 15 + 6 files changed, 917 insertions(+), 513 deletions(-) create mode 100644 extensions/BMO/web/js/dev_engagement.js diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm index 700199f51..321cdb29e 100644 --- a/extensions/BMO/Extension.pm +++ b/extensions/BMO/Extension.pm @@ -1199,6 +1199,9 @@ sub post_bug_after_creation { elsif ($format eq 'mozpr') { $self->_post_mozpr_bug($args); } + elsif ($format eq 'dev-engagement-event') { + $self->_post_dev_engagement($args); + } } sub _post_employee_incident_bug { @@ -1370,6 +1373,120 @@ sub _post_mozpr_bug { $bug->update($bug->creation_ts); } +sub _post_dev_engagement { + my ($self, $args) = @_; + my $vars = $args->{vars}; + my $parent_bug = $vars->{bug}; + my $template = Bugzilla->template; + my $cgi = Bugzilla->cgi; + my $params = Bugzilla->input_params; + my $old_user = Bugzilla->user; + + my $error_mode_cache = Bugzilla->error_mode; + Bugzilla->error_mode(ERROR_MODE_DIE); + + my $discussion_bug; + eval { + # Add attachment containing tab delimited field values for + # spreadsheet import. + my @columns = qw(event start_date end_date location attendees + audience desc mozilla_attending_list); + my @attach_values; + foreach my $column(@columns) { + my $value = $params->{$column} || ""; + $value =~ s/"/""/g; + push(@attach_values, qq{"$value"}); + } + + my @requested; + foreach my $param (grep(/^request_/, keys %$params)) { + next if !$params->{$param} || $param eq 'request_other_text'; + $param =~ s/^request_//; + push(@requested, ucfirst($param)); + } + push(@attach_values, '"' . join(",", @requested) . '"'); + + my $attachment = Bugzilla::Attachment->create({ + bug => $parent_bug, + creation_ts => $parent_bug->creation_ts, + data => join("\t", @attach_values), + description => 'Spreadsheet Data', + filename => 'dev_engagement_submission.txt', + ispatch => 0, + isprivate => 0, + mimetype => 'text/plain' + }); + + # Insert comment for attachment + $parent_bug->add_comment('', { isprivate => 0, + type => CMT_ATTACHMENT_CREATED, + extra_data => $attachment->id }); + delete $parent_bug->{'attachments'}; # So the new attachment displays properly + + # File discussion bug + Bugzilla->set_user(Bugzilla::User->new({ name => 'nobody@mozilla.org' })); + my $new_user = Bugzilla->user; + + # HACK: User needs to be in the editbugs and primary bug's group to allow + # setting of dependencies. + $new_user->{'groups'} = [ + Bugzilla::Group->new({ name => 'editbugs' }), + Bugzilla::Group->new({ name => 'mozilla-employee-confidential' }) + ]; + + my $recipients = { changer => $new_user }; + $vars->{original_reporter} = $old_user; + + $discussion_bug = Bugzilla::Bug->create({ + short_desc => '[discussion] ' . $parent_bug->short_desc, + product => 'Developer Engagement', + component => 'Events Request Discussion', + keywords => ['event-discussion-needs-review'], + bug_severity => 'normal', + groups => ['mozilla-employee-confidential'], + comment => 'This is the discussion for the request ' . + 'described in bug ' . $parent_bug->id . '.', + op_sys => 'All', + rep_platform => 'All', + version => 'unspecified' + }); + + # Set the needinfo flag on the discussion bug + my @new_flags; + foreach my $type (@{ $discussion_bug->flag_types }) { + next if $type->name ne 'needinfo'; + foreach my $requestee (DEV_ENGAGE_DISCUSS_NEEDINFO()) { + my $needinfo_flag = { + type_id => $type->id, + status => '?', + requestee => $requestee, + }; + push(@new_flags, $needinfo_flag); + } + } + $discussion_bug->set_flags(\@new_flags, []) if @new_flags; + $discussion_bug->update($discussion_bug->creation_ts); + Bugzilla::BugMail::Send($discussion_bug->id, $recipients); + + # Add discussion comment to the parent bug pointing to new bug + # and dependency link + $parent_bug->set_all({ dependson => { add => [ $discussion_bug->id ] } }); + $parent_bug->add_comment('This request is being discussed in bug ' . + $discussion_bug->id); + $parent_bug->update($parent_bug->creation_ts); + # No need to send mail for parent bug + }; + my $error = $@; + + Bugzilla->set_user($old_user); + Bugzilla->error_mode($error_mode_cache); + + if ($error || !$discussion_bug) { + warn "Failed to create additional dev-engagement bug: $error" if $error; + $vars->{'message'} = 'dev_engagement_creation_failed'; + } +} + sub _add_attachment { my ($self, $args, $attachment_args) = @_; diff --git a/extensions/BMO/lib/Constants.pm b/extensions/BMO/lib/Constants.pm index 23eaae9cb..b60c8fd37 100644 --- a/extensions/BMO/lib/Constants.pm +++ b/extensions/BMO/lib/Constants.pm @@ -24,10 +24,22 @@ use strict; use base qw(Exporter); our @EXPORT = qw( REQUEST_MAX_ATTACH_LINES + DEV_ENGAGE_DISCUSS_NEEDINFO ); # Maximum attachment size in lines that will be sent with a # requested attachment flag notification. use constant REQUEST_MAX_ATTACH_LINES => 1000; +# Requestees who need a needinfo flag set for the dev engagement +# discussion bug +use constant DEV_ENGAGE_DISCUSS_NEEDINFO => qw( + afabbro@mozilla.com + dcamp@mozilla.com + jswisher@mozilla.com + rchau@mozilla.com + stormy@mozilla.com + spersing@mozilla.com +); + 1; diff --git a/extensions/BMO/template/en/default/bug/create/comment-dev-engagement-event.txt.tmpl b/extensions/BMO/template/en/default/bug/create/comment-dev-engagement-event.txt.tmpl index cb7473e22..0cfcf7887 100644 --- a/extensions/BMO/template/en/default/bug/create/comment-dev-engagement-event.txt.tmpl +++ b/extensions/BMO/template/en/default/bug/create/comment-dev-engagement-event.txt.tmpl @@ -20,8 +20,33 @@ Email Address: Role in relation to event: [%+ cgi.param('role') %] +Vouched Mozillian: +[%+ cgi.param('vouched_mozillian') %] + +[% IF cgi.param('vouched_mozillian') == 'Yes' %] +Mozillian URL: +[%+ cgi.param('mozillian_profile_url') %] +[% END %] + :: +Developer Event?: +[%+ cgi.param('developer_event') %] + +Is Mozilla Attending?: +[%+ cgi.param('mozilla_attending') %] + +[% IF cgi.param('mozilla_attending') == 'Yes' %] +Mozilla Attending List: +[%+ cgi.param('mozilla_attending_list') %] +[% END %] + +Code of Conduct?: +[%+ cgi.param('code_of_conduct') %] + +Code of Conduct URL: +[%+ cgi.param('code_of_conduct_url') %] + Event Name: [%+ cgi.param('event') %] @@ -32,6 +57,9 @@ End Date: [%+ cgi.param('end_date') %] Event Location: +[%+ cgi.param('event_location') %] + +Event Location Description: [%+ cgi.param('location') || "-" %] Venue: @@ -46,39 +74,55 @@ Expected Attendees: Event Description: [%+ cgi.param('desc') || "-" %] -Primary Audience: -[%+ cgi.param('audience') || "-" %] +:: Relevant Products: -[% "\n* Firefox OS" IF cgi.param('product-fxos') %] -[% "\n* Firefox Web Browser" IF cgi.param('product-fx') %] -[% "\n* Webmaker" IF cgi.param('product-webmaker') %] -[% "\n* Persona" IF cgi.param('product-persona') %] -[% "\n* Marketplace" IF cgi.param('product-marketplace') %] -[% "\n* Thunderbird" IF cgi.param('product-tb') %] -[% "\n* The Free and Open Web" IF cgi.param('product-fow') %] -[% "\n* Other: " _ cgi.param('product-other-text') IF cgi.param('product-other') %] +[% "\n* Firefox OS" IF cgi.param('product_fxos') %] +[% "\n* Firefox Web Browser" IF cgi.param('product_fx') %] +[% "\n* Webmaker" IF cgi.param('product_webmaker') %] +[% "\n* Persona" IF cgi.param('product_persona') %] +[% "\n* Marketplace" IF cgi.param('product_marketplace') %] +[% "\n* Thunderbird" IF cgi.param('product_tb') %] +[% "\n* The Free and Open Web" IF cgi.param('product_fow') %] +[% "\n* Developer Tools" IF cgi.param('product_devtools') %] +[% "\n* Other: " _ cgi.param('product_other_text') IF cgi.param('product_other') %] + +Option to Sponsor a Booth?: +[%+ cgi.param('sponsor_booth') %] + +Need a Speaker?: +[%+ cgi.param('speaker_needed') %] + +[% IF cgi.param('speaker_needed') == 'Yes' %] +Speaker Needed Topic: +[%+ cgi.param('speaker_needed_topic') %] +[% END %] + +Development Session?: +[%+ cgi.param('development_session') %] :: Requests: -[% "\n* Keynote Presentation" IF cgi.param('request-keynote') %] -[% "\n* Talk Presentation" IF cgi.param('request-talk') %] -[% "\n* Workshop" IF cgi.param('request-workshop') %] -[% "\n* Sponsorship" IF cgi.param('request-sponsorship') %] -[% "\n* Other: " _ cgi.param('request-other-text') IF cgi.param('request-other') %] +[% "\n* Keynote Presentation" IF cgi.param('request_keynote') %] +[% "\n* Talk Presentation" IF cgi.param('request_talk') %] +[% "\n* Workshop" IF cgi.param('request_workshop') %] +[% "\n* Sponsorship" IF cgi.param('request_sponsorship') %] +[% "\n* Other: " _ cgi.param('request_other_text') IF cgi.param('request_other') %] -Suggested sponsorship amount/level: -[%+ cgi.param('sponsorship-suggestion') || "-" %] +Mozilla Sponsored Event Before?: +[%+ cgi.param('previous_event') %] -Already Registered Mozillians: -[%+ cgi.param('mozillians') || "-" %] +[% IF cgi.param('previous_event') == 'Yes' %] +Previous Event Year: +[%+ cgi.param('previous_event_year') %] -Requesting A Specific Person: -[%+ cgi.param('specific') || "-" %] +Previous Event Name: +[%+ cgi.param('previous_event_name') %] +[% END %] -Alternative Person: -[%+ cgi.param('fallback') || "-" %] +Suggested sponsorship amount/level: +[%+ cgi.param('sponsorship_suggestion') || "-" %] Anything Else: [%+ cgi.param('else') || "-" %] diff --git a/extensions/BMO/template/en/default/bug/create/create-dev-engagement-event.html.tmpl b/extensions/BMO/template/en/default/bug/create/create-dev-engagement-event.html.tmpl index ef6737098..9665bcc27 100644 --- a/extensions/BMO/template/en/default/bug/create/create-dev-engagement-event.html.tmpl +++ b/extensions/BMO/template/en/default/bug/create/create-dev-engagement-event.html.tmpl @@ -9,164 +9,49 @@ [% PROCESS global/variables.none.tmpl %] [% inline_css = BLOCK %] - #bug_form { - max-width: 50em; - } - - #bug_form th { - text-align: left; - padding-top: 0.5em; - } - - #bug_form .section-head { - font-size: larger; - padding-top: 1em; - } - - #bug_form th:not(.section-head), #bug_form td { - padding-left: 2em; - } - - #bug_form .mandatory { - color: red; - } - - #bug_form .blurb { - font-style: italic; - } - - #bug_form .wide { - width: 40em; - } - - #bug_form input[disabled] { - background: transparent; - } -[% END %] - -[% inline_js = BLOCK %] -// -[% END %] - -[% mandatory = BLOCK %] - * +#dev_form { + width: 60%; +} +#dev_form .required:after { + content: " *"; + color: red; +} +#dev_form .field_label { + text-align: left; + font-weight: bold; +} +#dev_form .field_desc, +#dev_form .head_desc { + word-wrap: normal; +} +#dev_form .head_desc { + font-size: 1.5em; + padding-bottom: .5em; +} +#dev_form .form_section { + margin-bottom: 1em; + padding-left: 2em; +} +.yui-calcontainer { + z-index: 2; +} [% END %] [% PROCESS global/header.html.tmpl title = "Developer Events Request Form" style = inline_css style_urls = [ 'skins/standard/enter_bug.css' ] - javascript = inline_js - javascript_urls = [ 'extensions/BMO/web/js/form_validate.js', 'js/field.js', 'js/util.js' ] + javascript_urls = [ 'js/field.js', + 'js/util.js', + 'extensions/BMO/web/js/form_validate.js', + 'extensions/BMO/web/js/dev_engagement.js' ] yui = [ 'calendar' ] %]

Developer Events Request Form

-
+ @@ -175,6 +60,7 @@ + @@ -183,354 +69,394 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

- Hi! Thanks so much for asking Mozilla to participate at your event! -

-

- The Developer Events Team evaluates each request individually, based on - multiple criteria, including quarterly goals and priorities. We meet at - least biweekly, and this form is designed to gather all the information - we need to evaluate each request at these meetings. Please take a minute - to fill it out thoroughly so we can process your request as soon as - possible. -

-

- Please review our - event request guidelines for information about how we evaluate requests. -

-
- First, tell us about yourself! -
- What is your name? [% mandatory FILTER none %] -
- -
- Please provide your email address. [% mandatory FILTER none %] -
- -
- What is your role in relation to this event? [% mandatory FILTER none %] -
-
- eg. organizer, speaker/atendee (past), speaker/attendee (current), etc. -
- -
- Let's start with the basics. -
- Event Name [% mandatory FILTER none %] -
- -
- Start Date [% mandatory FILTER none %] -
- - -
-
- End Date [% mandatory FILTER none %] -
- - -
-
+

Hi! Thanks so much for asking Mozilla to participate at your event!

+

The Developer Events Team evaluates each request individually, based on + multiple criteria, including quarterly goals and priorities. We meet at + least biweekly, and this form is designed to gather all the information + we need to evaluate each request at these meetings. Please take a minute + to fill it out thoroughly so we can process your request as soon as + possible.

+

Please review our + + event request guidelines for information about how we evaluate requests.

+ +
+ First, tell us about yourself! +
+ +
+
+ What is your name? +
+ +
+ +
+
+ Please provide your email address. +
+ +
+ +
+
+ What is your role in relation to this event? +
+
+ eg. organizer, speaker/attendee (past), speaker/attendee (current), etc. +
+ +
+ +
+
+ Are you a vouched Mozillian? +
+ +
+ +
+
+ Mozillian profile URL +
+ +
+ +
+ Let's start with the basics. +
+ +
+
+ Is this a developer event? +
+ +
+ The Developer Events Team only participates in developer events. + Form submission has been disabled. +
+
+ +
+
+ Is someone from Mozilla attending? +
+ +
+ The Developer Events Team usually doesn’t sponsor an event unless someone + from Mozilla is attending. If you would like to request a speaker, there’s + an opportunity to do so later on this page. +
+
+ +
+
+ Please list the names of anyone from Mozilla who are already registered to + attend, speak, or participate in this event. +
+ +
+ +
+
+ Do you have a code of conduct? +
+ +
+ Mozilla only participates in events that have a code of conduct. + Fom submission has been disabled. +
+
+ +
+
+ Code of Conduct URL +
+ +
+ +
+
+ Event Name +
+ +
+ +
+
+ Start Date +
+ + +
+
+ +
+
+ End Date +
+ + +
+
+ +
+
Event Location -
-
- Include city, state, and country. Please write "Multiple" if this event - takes place across several locations. -
- -
+ + + + +
+
+ Event Location Description +
+
+ Include city, state, and country. +
+ +
+ +
+
Venue -
-
- What is the name of the venue where your event will be held? Enter TBD if - you don't know yet. -
- -
+ +
+ What is the name of the venue where your event will be held? Enter TBD if + you don't know yet. +
+ + + +
+
Weblink -
-
- Weblink to the event site, Eventbrite page, Lanyrd page, Meetup page, etc. -
- -
- Number of expected attendees [% mandatory FILTER none %] -
- -
- Please give a [short] description of the event. [% mandatory FILTER none %] -
-
- Include track topics, presentation topics, event format. -
- -
- Who is the primary audience for this event? [% mandatory FILTER none %] -
-
- Developers (specify coding language and platform), business development, - marketing associates, corporate executives, etc. -
- -
- Which Mozilla products/projects are most relevant to this event? [% mandatory FILTER none %] -
-
- Please select all that apply. - See mozilla.org/products - for more information about Mozilla products. -
- -
- -
- -
- -
- -
- -
- -
- - - -
- Tell us more about what you're looking for! -
- What are you requesting from Mozilla? [% mandatory FILTER none %] -
-
- Please select all that apply. -
- -
- -
- -
- -
- - - -
- If requesting sponsorship, what amount/level do you suggest? -
- -
- Please list the names of anyone from Mozilla who are already registered to - attend, speak, or participate in this event. -
- -
- Are you requesting a specific person to present or participate at this - event? If so, please list their name(s). -
- -
- If this individual is unable to attend/speak/participate in this event, is - there anyone else you would like to request? -
- -
+ +
+ Weblink to the event site, Eventbrite page, Lanyrd page, Meetup page, etc. +
+ + + +
+
+ Number of expected attendees +
+ +
+ +
+
+ Please give a [short] description of the event. +
+
+ Include track topics, presentation topics, event format. +
+ +
+ +
+ Some more detail on the event. +
+ +
+
+ Which Mozilla products/projects are most relevant to this event? +
+
+ Please select all that apply. See + + mozilla.org/products for more information about Mozilla products. +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + + +
+ +
+
+ Do you have an option to sponsor a booth? +
+ +
+ +
+
+ Do you need a speaker? +
+ +
+ +
+
+ What topic do you want someone to speak about? +
+
+ Please be specific so that we can find a great speaker for you. Examples: + Developer Tools for Firefox, the future of the Web, CSS media queries. +
+ +
+ +
+
+ Will this event include a session about developing with HTML, CSS, or + JavaScript? +
+ +
+ +
+ Tell us more about what you're looking for! +
+ +
+
+ What are you requesting from Mozilla? +
+
+ Please select all that apply. +
+ +
+ +
+ +
+ +
+ + + +
+ +
+
+ Has Mozilla sponsored this event before? +
+ +
+ +
+
+ Year +
+ +
+ Name of Event +
+ +
+ +
+
+ If requesting sponsorship, what amount/level do you suggest? +
+
+ Please include the currency. +
+ +
+ +
+
Please upload a Sponsorship Prospectus if you have one. -
- - - -
+ + + + + + +
+
Anything else that may help us review this request? -
- -
 
- -
+ + + + +
diff --git a/extensions/BMO/web/js/dev_engagement.js b/extensions/BMO/web/js/dev_engagement.js new file mode 100644 index 000000000..0bb7313b1 --- /dev/null +++ b/extensions/BMO/web/js/dev_engagement.js @@ -0,0 +1,290 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This Source Code Form is "Incompatible With Secondary Licenses", as + * defined by the Mozilla Public License, v. 2.0. */ + +var DE = { + formUpdate: function () { + var sections = { + developer_event_warning: false, + code_of_conduct_warning: false, + mozilla_attending_warning: false, + mozillian_profile_url_section: false, + mozilla_attending_list_section: false, + code_of_conduct_url_section: false, + speaker_needed_detail_section: false, + previous_event_details_section: false + }; + var commit_disabled = false; + + if (fieldValue('developer_event') == 'No') { + commit_disabled = true; + sections.developer_event_warning = true; + } + + if (fieldValue('mozilla_attending') == 'No') { + sections.mozilla_attending_warning = true; + } + else if (fieldValue('mozilla_attending') == 'Yes') { + sections.mozilla_attending_list_section = true; + } + + if (fieldValue('code_of_conduct') == 'No') { + commit_disabled = true; + sections.code_of_conduct_warning = true; + } + else if (fieldValue('code_of_conduct') == 'Yes') { + sections.code_of_conduct_url_section = true; + } + + if (fieldValue('vouched_mozillian') == 'Yes') { + sections.mozillian_profile_url_section = true; + } + + if (fieldValue('previous_event') == 'Yes') { + sections.previous_event_details_section = true; + } + + if (fieldValue('speaker_needed') == 'Yes') { + sections.speaker_needed_detail_section = true; + } + + for (section in sections) { + if (sections[section]) { + DE.removeClass(document.getElementById(section), + 'bz_default_hidden'); + } + else { + DE.addClass(document.getElementById(section), + 'bz_default_hidden'); + } + } + YAHOO.util.Dom.get('commit').disabled = commit_disabled; + }, + focusOther: function (id, other_id) { + var cb = document.getElementById(id); + var input = document.getElementById(other_id); + input.disabled = !cb.checked; + if (cb.checked) input.focus(); + }, + onSubmit: function (ev) { + var alert_text = ''; + // Required fields check + var required_text_fields = { + 'name' : 'Please enter your name.', + 'email' : 'Please enter your email address.', + 'role' : 'Please enter your role.', + 'event' : 'Please enter the event name.', + 'start_date' : 'Please enter the event start date.', + 'end_date' : 'Please enter the event end date.', + 'location' : 'Please enter a location description for the event.', + 'attendees' : 'Please enter number of expected attendees.', + 'desc' : 'Please enter a description of the event.', + }; + + var required_selects = { + 'vouched_mozillian' : 'Please select if you are a vouched mozillian.', + 'developer_event' : 'Please select if this is a developer event.', + 'mozilla_attending' : 'Please select if Mozilla is attending the event.', + 'code_of_conduct' : 'Please select if the event has a code of conduct.', + 'event_location' : 'Please a location for the event.', + 'previous_event' : 'Please select if Mozilla has sponsored this event before.', + 'development_session' : 'Please select if this event includes a development session.', + }; + + if (fieldValue('vouched_mozillian') == 'Yes') + required_text_fields['mozillian_profile_url'] + = 'Please enter your mozillian profile url.'; + if (fieldValue('mozilla_attending') == 'Yes') + required_text_fields['mozilla_attending_list'] + = 'Please enter a list of Mozilla persons attending the event.'; + if (fieldValue('code_of_conduct') == 'Yes') + required_text_fields['code_of_conduct_url'] + = 'Please enter a code of conduct url.'; + if (fieldValue('previous_event') == 'Yes') { + required_text_fields['previous_event_year'] + = 'Please select a year for the previous sponsored event.'; + required_text_fields['previous_event_name'] + = 'Please enter a name for the previous sponsored event.'; + } + + var relevant_products = [ + 'product_fxos', + 'product_fx', + 'product_webmaker', + 'product_persona', + 'product_marketplace', + 'product_tb', + 'product_fow', + 'product_devtools', + 'product_other', + ]; + var found = 0; + for (var i = 0, l = relevant_products.length; i < l; i ++) { + if (isChecked(relevant_products[i])) found = 1; + } + if (!found) + alert_text += "Please check one or more relevant products.\n"; + if (isChecked('product_other')) + required_text_fields['product_other_text'] + = 'Please enter a value for other relevant product.'; + + var request_types = [ + 'request_keynote', + 'request_talk', + 'request_workshop', + 'request_sponsorship', + 'request_other' + ]; + found = 0; + for (var i = 0, l = request_types.length; i < l; i ++) { + if (isChecked(request_types[i])) found = 1; + } + if (!found) + alert_text += "Please check one or more items being requested of Mozilla.\n"; + if (isChecked('request_other')) + required_text_fields['request_other_text'] + = 'Please enter a value for other item being requested.'; + + for (field in required_text_fields) { + if (!isFilledOut(field)) + alert_text += required_text_fields[field] + "\n"; + } + for (field in required_selects) { + if (!fieldValue(field)) + alert_text += required_selects[field] + "\n"; + } + if (alert_text != '') { + alert(alert_text); + YAHOO.util.Event.stopEvent(ev); + } + + // Whiteboard value + var wb = ''; + var location_wb_map = { + 'Africa' : 'africa', + 'Asia' : 'asia', + 'Australia' : 'australia', + 'Europe' : 'europe', + 'North America' : 'north-america', + 'Central / South America' : 'central-south-america', + 'Multiple' : 'multiple', + 'Online only' : 'online', + }; + wb += '[location:' + location_wb_map[fieldValue('event_location')] + '] '; + + var request_items = []; + if (document.getElementById('request_keynote').checked) + request_items.push('keynote'); + if (document.getElementById('request_talk').checked) + request_items.push('talk'); + if (document.getElementById('request_workshop').checked) + request_items.push('workshop'); + if (document.getElementById('request_sponsorship').checked) + request_items.push('sponsorship'); + if (document.getElementById('request_other').checked) + request_items.push('other'); + wb += '[requesting:' + request_items.join(',') + '] '; + + var product_items = []; + if (document.getElementById('product_fxos').checked) + product_items.push('firefox-os'); + if (document.getElementById('product_fx').checked) + product_items.push('firefox-web-browser'); + if (document.getElementById('product_webmaker').checked) + product_items.push('webmaker'); + if (document.getElementById('product_persona').checked) + product_items.push('persona'); + if (document.getElementById('product_marketplace').checked) + product_items.push('marketplace'); + if (document.getElementById('product_tb').checked) + product_items.push('thunderbird'); + if (document.getElementById('product_fow').checked) + product_items.push('open-web'); + if (document.getElementById('product_devtools').checked) + product_items.push('developer-tools'); + if (document.getElementById('product_other').checked) + product_items.push('other'); + wb += '[products:' + product_items.join(',') + '] '; + + if (fieldValue('developer_event') == 'Yes') + wb += '[developer-event:true] '; + var mozilla_attending = fieldValue('mozilla_attending') == 'Yes' ? 'true' : 'false'; + wb += '[mozilla-already-attending:' + mozilla_attending + '] '; + var vouched = fieldValue('vouched_mozillian') == 'Yes' ? 'true' : 'false'; + wb += '[requested-by-mozillian:' + vouched + '] '; + if (fieldValue('code_of_conduct') == 'Yes') + wb += '[code-of-conduct:true] '; + var previous_event = fieldValue('previous_event') == 'Yes' ? 'true' : 'false'; + wb += '[past-sponsorship:' + previous_event + '] '; + var needs_speaker = fieldValue('speaker_needed') == 'Yes' ? 'true' : 'false'; + wb += '[needs-speaker:' + needs_speaker + '] '; + var sponsor_booth = fieldValue('sponsor_booth') == 'Yes' ? 'true' : 'false'; + wb += '[option-to-sponsor-booth:' + sponsor_booth + '] '; + var dev_session_map = { + 'Yes' : 'true', + 'No' : 'false', + 'To be determined' : 'tbd', + }; + wb += '[open-web-session-at-event:' + + dev_session_map[fieldValue('development_session')] + '] '; + wb += '[expected-attendees:' + fieldValue('attendees') + '] '; + var prospectus = fieldValue('data') ? 'true' : 'false'; + wb += '[prospectus:' + prospectus + '] '; + document.getElementById('status_whiteboard').value = wb.replace(/ $/, ''); + + var summary = document.getElementById('event').value + ', ' + DE.long_start_date(); + var loc = document.getElementById('location').value; + if (loc) + summary = summary + ' (' + loc + ')'; + document.getElementById('short_desc').value = summary; + document.getElementById('bug_file_loc').value = document.getElementById('link').value; + document.getElementById('cf_due_date').value = document.getElementById('start_date').value; + }, + long_start_date: function () { + var ymd = document.getElementById('start_date').value.split('-'); + if (ymd.length != 3) + return ''; + var month = YAHOO.bugzilla.calendar_start_date.cfg.getProperty('MONTHS_LONG')[ymd[1] - 1]; + return month + ' ' + ymd[0]; + }, + hasClass: function (element, class_name) { + return element.className.match(new RegExp('(\\s|^)' + class_name + '(\\s|$)')); + }, + addClass: function (element, class_name) { + if (!DE.hasClass(element, class_name)) + element.className += " " + class_name; + }, + removeClass: function (element, class_name) { + if (DE.hasClass(element, class_name)) { + var reg = new RegExp('(\\s|^)' + class_name + '(\\s|$)'); + element.className = element.className.replace(reg,' '); + } + }, + init: function() { + YAHOO.util.Event.on('dev_form', 'submit', DE.onSubmit); + YAHOO.util.Event.on('product_other', 'change', function () { + DE.focusOther('product_other', 'product_other_text'); + }); + YAHOO.util.Event.on('request_other', 'change', function () { + DE.focusOther('request_other', 'request_other_text'); + }); + var select_inputs = [ + 'developer_event', + 'code_of_conduct', + 'vouched_mozillian', + 'mozilla_attending', + 'speaker_needed', + 'previous_event' + ]; + for (var i = 0, l = select_inputs.length; i < l; i++) { + YAHOO.util.Event.on(select_inputs[i], 'change', DE.formUpdate); + } + DE.formUpdate(); + createCalendar('start_date'); + createCalendar('end_date'); + } +}; +YAHOO.util.Event.onDOMReady(DE.init); diff --git a/extensions/BMO/web/js/form_validate.js b/extensions/BMO/web/js/form_validate.js index 7e9746a5c..53b16ab1c 100644 --- a/extensions/BMO/web/js/form_validate.js +++ b/extensions/BMO/web/js/form_validate.js @@ -39,3 +39,18 @@ function isOneChecked(form_nodelist) { } return false; } + +function fieldValue(elem_id) { + var el = document.getElementById(elem_id); + if (!el) { + console.error('Failed to find element: ' + elem_id); + return false; + } + if (el.type == 'text' + || el.type == 'textarea' + || el.type == 'file') + { + return el.value; + } + return el.options[el.selectedIndex].value; +} -- cgit v1.2.3-24-g4f1b