diff options
Diffstat (limited to 'extensions/MozProjectReview')
3 files changed, 303 insertions, 235 deletions
diff --git a/extensions/MozProjectReview/Extension.pm b/extensions/MozProjectReview/Extension.pm index 0f5c2b735..a7c632f46 100644 --- a/extensions/MozProjectReview/Extension.pm +++ b/extensions/MozProjectReview/Extension.pm @@ -41,6 +41,13 @@ sub post_bug_after_creation { my ($do_sec_review, $do_legal, $do_finance, $do_privacy_vendor, $do_data_safety, $do_privacy_tech, $do_privacy_policy); + # Logic section which dictates which bugs are created. This should be + # similar to the logic used in extensions/MozProjectReview/web/js/moz_project_review.js + + if ($params->{new_or_change} eq 'New') { + $do_legal = 1; + } + if ($params->{mozilla_data} eq 'Yes') { $do_legal = 1; $do_privacy_policy = 1; @@ -54,15 +61,15 @@ sub post_bug_after_creation { $do_data_safety = 1; } - if ($params->{new_or_change} eq 'New') { - $do_legal = 1; - } - if ($params->{separate_party} eq 'Yes') { if ($params->{relationship_type} ne 'Hardware Purchase') { $do_legal = 1; } + if ($params->{relationship_type} eq 'Hardware Purchase') { + $do_finance = 1; + } + if ($params->{data_access} eq 'Yes') { $do_privacy_policy = 1; $do_legal = 1; @@ -106,11 +113,8 @@ sub post_bug_after_creation { } if ($do_legal) { - my $component; - if ($params->{new_or_change} eq 'New') { - $component = 'General'; - } - elsif ($params->{new_or_change} eq 'Existing') { + my $component = 'General'; + if ($params->{new_or_change} eq 'Existing') { $component = $params->{mozilla_project}; } diff --git a/extensions/MozProjectReview/template/en/default/bug/create/create-moz-project-review.html.tmpl b/extensions/MozProjectReview/template/en/default/bug/create/create-moz-project-review.html.tmpl index 251f26c6d..19fc8ae55 100644 --- a/extensions/MozProjectReview/template/en/default/bug/create/create-moz-project-review.html.tmpl +++ b/extensions/MozProjectReview/template/en/default/bug/create/create-moz-project-review.html.tmpl @@ -110,8 +110,7 @@ <span class="field_label required">Key Initiative:</span> <span class="field_data"> <div class="field_description">Which key initiative does this support?</div> - <select name="key_initiative" id="key_initiative" - onchange="MPR.toggleVisibleById(this,'Other','key_initiative_other_row');"> + <select name="key_initiative" id="key_initiative"> <option value="">Select One</option> <option value="Firefox Desktop">Firefox Desktop</option> <option value="Firefox Mobile">Firefox Mobile</option> @@ -173,11 +172,10 @@ <div id="mozilla_data_row" class="field_row"> <span class="field_label required">Mozilla Data:</span> <span class="field_data"> - <div class="field_description">Does this product/service/project access, interact with, or store Mozilla + <div class="field_description">Does this product/service/project access, interact with, or store Mozilla (customer, contributor, user, employee) data? Example of such data includes email addresses, first and last name, addresses, phone numbers, credit card data.)</div> - <select name="mozilla_data" id="mozilla_data" - onchange="MPR.toggleSpecialSections();"> + <select name="mozilla_data" id="mozilla_data"> <option value="">Select One</option> <option value="Yes">Yes</option> <option value="No">No</option> @@ -188,10 +186,9 @@ <div id="new_or_change_row" class="field_row"> <span class="field_label required">New or Change:</span> <span class="field_data"> - <div class="field_description">Is this a NEW product, service, project, feature, or functionality, + <div class="field_description">Is this a NEW product, service, project, feature, or functionality, a change to an EXISTING one, or neither?</div> - <select name="new_or_change" id="new_or_change" - onchange="MPR.toggleVisibleById(this,'Existing','mozilla_project_row');"> + <select name="new_or_change" id="new_or_change"> <option value="">Select One</option> <option value="New">New</option> <option value="Existing">Existing</option> @@ -233,17 +230,7 @@ source licenses, renewals, additional services or goods, and any other agreements. </div> - <select name="separate_party" id="separate_party" - onchange="MPR.toggleVisibleById(this,'Yes','initial_separate_party_questions'); - if (this.value == 'No') { - Dom.addClass('finance_questions','bz_default_hidden'); - if (Dom.get('mozilla_data').value != 'Yes') - Dom.addClass('legal_questions', 'bz_default_hidden'); - } - else { - Dom.removeClass('legal_questions', 'bz_default_hidden'); - MPR.toggleVisibleById('relationship_type','Hardware Purchase','finance_questions'); - }"> + <select name="separate_party" id="separate_party"> <option value="">Select One</option> <option value="Yes">Yes</option> <option value="No">No</option> @@ -256,14 +243,7 @@ <span class="field_label required">Type of Relationship:</span> <span class="field_data"> <div class="field_description">What type of relationship?</div> - <select name="relationship_type" id="relationship_type" - onchange="MPR.toggleVisibleById(this, 'Vendor/Services', 'legal_sow_questions'); - MPR.toggleVisibleById(this, 'Vendor/Services', 'legal_vendor_services_where_row'); - MPR.toggleVisibleById(this, 'Hardware Purchase', 'finance_questions'); - if (this.value == 'Hardware Purchase' && Dom.get('mozilla_data').value != 'Yes') - Dom.addClass('legal_questions', 'bz_default_hidden'); - else if (Dom.get('separate_party').value == 'Yes') - Dom.removeClass('legal_questions', 'bz_default_hidden');"> + <select name="relationship_type" id="relationship_type"> <option value="">Select One</option> <option value="Vendor/Services">Vendor/Services</option> <option value="Distribution/Bundling">Distribution/Bundling</option> @@ -280,8 +260,7 @@ <span class="field_data"> <div class="field_description">Will the other party have access to Mozilla (customer, contributor, user, employee) data? (If this is for an NDA, choose no)</div> - <select name="data_access" id="data_access" - onchange="MPR.toggleSpecialSections();"> + <select name="data_access" id="data_access"> <option value="">Select One</option> <option value="Yes">Yes</option> <option value="No">No</option> @@ -302,10 +281,7 @@ <span class="field_data"> <div class="field_description">What is the anticipated cost of the vendor relationship? (Entire Contract Cost, not monthly cost)</div> - <select name="vendor_cost" id="vendor_cost" - onchange="MPR.toggleVisibleById(this,'> $25,000','finance_questions'); - MPR.toggleVisibleById(this,'<= $25,000','po_needed_row'); - if (Dom.get('po_needed').value == 'Yes') Dom.removeClass('finance_questions','bz_default_hidden');"> + <select name="vendor_cost" id="vendor_cost"> <option value="">Select One</option> <option value="N/A">N/A</option> <option value="<= $25,000"><= $25,000</option> @@ -317,8 +293,7 @@ <div id="po_needed_row" class="field_row bz_default_hidden"> <span class="field_label required">PO Needed?:</span> <span class="field_data"> - <select name="po_needed" id="po_needed" - onchange="MPR.toggleVisibleById(this,'Yes','finance_questions');"> + <select name="po_needed" id="po_needed"> <option value="">Select One</option> <option value="Yes">Yes</option> <option value="No">No</option> @@ -389,8 +364,7 @@ <span class="field_label">Privacy Policy:</span> <span class="field_data"> <div class="field_description">Do you currently have a privacy policy for your project / site / product?</div> - <select name="privacy_policy_project" id="privacy_policy_project" - onchange="MPR.toggleVisibleById(this,'Yes','privacy_policy_project_link_row');"> + <select name="privacy_policy_project" id="privacy_policy_project"> <option value="">Select One</option> <option value="Yes">Yes</option> <option value="No">No</option> @@ -410,8 +384,7 @@ <span class="field_label">User Data:</span> <span class="field_data"> <div class="field_description">Does your product/service/project collect, use or maintain any user data?</div> - <select name="privacy_policy_user_data" id="privacy_policy_user_data" - onchange="MPR.toggleVisibleById(this,'Yes','privacy_policy_project_user_data_bug_row');"> + <select name="privacy_policy_user_data" id="privacy_policy_user_data"> <option value="">Select One</option> <option value="Yes">Yes</option> <option value="No">No</option> @@ -444,8 +417,7 @@ <span class="field_label">Privacy Policy:</span> <span class="field_data"> <div class="field_description">Will the vendor have access to Mozilla (customer, contributor, user, employee) data?</div> - <select name="privacy_policy_vendor_user_data" id="privacy_policy_vendor_user_data" - onchange="MPR.toggleVisibleById(this,'Yes','privacy_policy_vendor_extra');"> + <select name="privacy_policy_vendor_user_data" id="privacy_policy_vendor_user_data"> <option value="">Select One</option> <option value="Yes">Yes</option> <option value="No">No</option> @@ -720,8 +692,7 @@ <div id="finance_purchase_inbudget_row" class="field_row"> <span class="field_label required">Is this line item in budget?:</span> <span class="field_data"> - <select name="finance_purchase_inbudget" id="finance_purchase_inbudget" - onchange="MPR.toggleVisibleById(this, 'No', 'finance_purchase_notinbudget_why_row');"> + <select name="finance_purchase_inbudget" id="finance_purchase_inbudget"> <option value="">Select One</option> <option value="Yes">Yes</option> <option value="No">No</option> @@ -792,8 +763,7 @@ <span class="field_label">User Data:</span> <span class="field_data"> <div class="field_description">Does your project collect data from users?</div> - <select name="data_safety_user_data" id="data_safety_user_data" - onchange="MPR.toggleVisibleById(this,'Yes','data_safety_extra_questions');"> + <select name="data_safety_user_data" id="data_safety_user_data"> <option value="">Select One</option> <option value="Yes">Yes</option> <option value="No">No</option> @@ -856,8 +826,7 @@ <span class="field_label">Data Retention:</span> <span class="field_data"> <div class="field_description">Will your project / team members need to retain user data?</div> - <select name="data_safety_retention" id="data_safety_retention" - onchange="MPR.toggleVisibleById(this,'Yes','data_safety_retention_length_row');"> + <select name="data_safety_retention" id="data_safety_retention"> <option value="">Select One</option> <option value="Yes">Yes</option> <option value="No">No</option> @@ -877,8 +846,7 @@ <span class="field_label">Separate Party:</span> <span class="field_data"> <div class="field_description">Will any user data be shared or accessed by third party partners, customers or providers?</div> - <select name="data_safety_separate_party" id="data_safety_separate_party" - onchange="MPR.toggleVisibleById(this,'Yes','data_safety_separate_party_data_row');"> + <select name="data_safety_separate_party" id="data_safety_separate_party"> <option value="">Select One</option> <option value="Yes">Yes</option> <option value="No">No</option> @@ -916,9 +884,7 @@ <span class="field_label">Community Visibility and Input:</span> <span class="field_data"> <div class="field_description">Has your proposal been shared publicly, including requirements for Mozilla to collect and host user data?</div> - <select name="data_safety_community_visibility" id="data_safety_community_visibility" - onchange="MPR.toggleVisibleById(this,'Yes','data_safety_communication_channels_row'); - MPR.toggleVisibleById(this,'No','data_safety_communication_plan_row');"> + <select name="data_safety_community_visibility" id="data_safety_community_visibility"> <option value="">Select One</option> <option value="Yes">Yes</option> <option value="No">No</option> diff --git a/extensions/MozProjectReview/web/js/moz_project_review.js b/extensions/MozProjectReview/web/js/moz_project_review.js index 4c5a5314e..dca67f2ae 100644 --- a/extensions/MozProjectReview/web/js/moz_project_review.js +++ b/extensions/MozProjectReview/web/js/moz_project_review.js @@ -3,207 +3,305 @@ * 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. + * defined by the Mozilla Public License, v. 2.0. */ -YAHOO.namespace('MozProjectReview'); - -var MPR = YAHOO.MozProjectReview; var Dom = YAHOO.util.Dom; var Event = YAHOO.util.Event; -MPR.required_fields = { - "initial_questions": { - "short_desc": "Please enter a value for project or feature name in the initial questions section", - "cc": "Please enter a value for points of contact in the initial questions section", - "urgency": "Please enter a value for urgency in the initial questions section", - "key_initiative": "Please select a value for key initiative in the initial questions section", - "project_status": "Please select a value for project status in the initial questions section", - "mozilla_data": "Please select a value for mozilla data in the initial questions section", - "new_or_change": "Please select a value for new or change to existing project in the initial questions section", - "separate_party": "Please select a value for separate party in the initial questions section" - }, - "finance_questions": { - "finance_purchase_vendor": "Please enter a value for vendor in the finance questions section", - "finance_purchase_what": "Please enter a value for what in the finance questions section", - "finance_purchase_why": "Please enter a value for why in the finance questions section", - "finance_purchase_risk": "Please enter a value for risk in the finance questions section", - "finance_purchase_alternative": "Please enter a value for alternative in the finance questions section", - "finance_purchase_inbudget": "Please enter a value for in budget in the finance questions section", - "finance_purchase_urgency": "Please select a value for urgency in the finance questions section", - "finance_purchase_cost": "Please enter a value for total cost in the finance questions section" +var MPR = { + required_fields: { + "initial_questions": { + "short_desc": "Please enter a value for project or feature name in the initial questions section", + "cc": "Please enter a value for points of contact in the initial questions section", + "urgency": "Please enter a value for urgency in the initial questions section", + "key_initiative": "Please select a value for key initiative in the initial questions section", + "project_status": "Please select a value for project status in the initial questions section", + "mozilla_data": "Please select a value for mozilla data in the initial questions section", + "new_or_change": "Please select a value for new or change to existing project in the initial questions section", + "separate_party": "Please select a value for separate party in the initial questions section" + }, + "finance_questions": { + "finance_purchase_vendor": "Please enter a value for vendor in the finance questions section", + "finance_purchase_what": "Please enter a value for what in the finance questions section", + "finance_purchase_why": "Please enter a value for why in the finance questions section", + "finance_purchase_risk": "Please enter a value for risk in the finance questions section", + "finance_purchase_alternative": "Please enter a value for alternative in the finance questions section", + "finance_purchase_inbudget": "Please enter a value for in budget in the finance questions section", + "finance_purchase_urgency": "Please select a value for urgency in the finance questions section", + "finance_purchase_cost": "Please enter a value for total cost in the finance questions section" + }, + "legal_questions": { + "legal_priority": "Please select a priority for the legal questions section", + "legal_help_from_legal": "Please describe the help needed from the Legal department" + }, + "legal_sow_questions": { + "legal_sow_vendor_name": "Please enter a value for SOW legal vendor name", + "legal_sow_vendor_address": "Please enter a value for SOW vendor address", + "legal_sow_vendor_email": "Please enter a value for SOW vendor email for notices", + "legal_sow_vendor_mozcontact": "Please enter a value for SOW Mozilla contact", + "legal_sow_vendor_contact": "Please enter a value for SOW vendor contact and email address", + "legal_sow_vendor_services": "Please enter a value for SOW vendor services description", + "legal_sow_vendor_deliverables": "Please enter a value for SOW vendor deliverables description", + "legal_sow_start_date": "Please enter a value for SOW vendor start date", + "legal_sow_end_date": "Please enter a value for SOW vendor end date", + "legal_sow_vendor_payment": "Please enter a value for SOW vendor payment amount", + "legal_sow_vendor_payment_basis": "Please enter a value for SOW vendor payment basis", + "legal_sow_vendor_payment_schedule": "Please enter a value for SOW vendor payment schedule", + "legal_sow_vendor_total_max": "Please enter a value for SOW vendor maximum total to be paid", + "legal_sow_vendor_product_line": "Please enter a value for SOW vendor product line" + } }, - "legal_questions": { - "legal_priority": "Please select a priority for the legal questions section", - "legal_help_from_legal": "Please describe the help needed from the Legal department", + + select_inputs: [ + 'urgency', + 'key_initiative', + 'project_status', + 'mozilla_data', + 'new_or_change', + 'mozilla_project', + 'separate_party', + 'relationship_type', + 'data_access', + 'vendor_cost', + 'po_needed', + 'sec_affects_products', + 'privacy_policy_project', + 'privacy_policy_user_data', + 'privacy_policy_vendor_user_data', + 'privacy_policy_vendor_questionnaire', + 'legal_priority', + 'legal_sow_vendor_product_line', + 'legal_vendor_services_where', + 'finance_purchase_inbudget', + 'finance_purchase_urgency', + 'data_safety_user_data', + 'data_safety_retention', + 'data_safety_separate_party', + 'data_safety_community_visibility' + ], + + init: function () { + // Bind the updateSections function to each of the inputs desired + for (var i = 0, l = this.select_inputs.length; i < l; i++) { + Event.on(this.select_inputs[i], 'change', MPR.updateSections); + } + MPR.updateSections(); }, - "legal_sow_questions": { - "legal_sow_vendor_name": "Please enter a value for SOW legal vendor name", - "legal_sow_vendor_address": "Please enter a value for SOW vendor address", - "legal_sow_vendor_email": "Please enter a value for SOW vendor email for notices", - "legal_sow_vendor_mozcontact": "Please enter a value for SOW Mozilla contact", - "legal_sow_vendor_contact": "Please enter a value for SOW vendor contact and email address", - "legal_sow_vendor_services": "Please enter a value for SOW vendor services description", - "legal_sow_vendor_deliverables": "Please enter a value for SOW vendor deliverables description", - "legal_sow_start_date": "Please enter a value for SOW vendor start date", - "legal_sow_end_date": "Please enter a value for SOW vendor end date", - "legal_sow_vendor_payment": "Please enter a value for SOW vendor payment amount", - "legal_sow_vendor_payment_basis": "Please enter a value for SOW vendor payment basis", - "legal_sow_vendor_payment_schedule": "Please enter a value for SOW vendor payment schedule", - "legal_sow_vendor_total_max": "Please enter a value for SOW vendor maximum total to be paid", - "legal_sow_vendor_product_line": "Please enter a value for SOW vendor product line", - } -}; -MPR.toggleSpecialSections = function () { - var mozilla_data_select = Dom.get('mozilla_data'); - var data_access_select = Dom.get('data_access'); - var vendor_cost_select = Dom.get('vendor_cost'); + updateSections: function () { + // Sections that will be hidden/shown based on the input values + // Start out as all false except for initial questions which is always visible + var page_sections = { + initial_questions: true, + key_initiative_other_row: false, + initial_separate_party_questions: false, + finance_questions: false, + finance_purchase_notinbudget_why_row: false, + po_needed_row: false, + legal_questions: false, + legal_sow_questions: false, + legal_vendor_single_country: false, + legal_vendor_services_where_row: false, + sec_review_questions: false, + privacy_policy_project_questions: false, + privacy_policy_vendor_questions: false, + data_safety_questions: false, + data_safety_extra_questions: false, + mozilla_project_row: false, + privacy_policy_project_link_row: false, + privacy_policy_project_user_data_bug_row: false, + privacy_policy_vendor_extra: false, + data_safety_extra_questions: false, + data_safety_retention_length_row: false, + data_safety_separate_party_data_row: false, + data_safety_communication_channels_row: false, + data_safety_communication_plan_row: false, + }; - if (mozilla_data_select.value == 'Yes') { - Dom.removeClass('legal_questions', 'bz_default_hidden'); - Dom.removeClass('privacy_policy_project_questions', 'bz_default_hidden'); - Dom.removeClass('data_safety_questions', 'bz_default_hidden'); - Dom.removeClass('sec_review_questions', 'bz_default_hidden'); - } - else { - if (Dom.get('separate_party').value != 'Yes') - Dom.addClass('legal_questions', 'bz_default_hidden'); - Dom.addClass('privacy_policy_project_questions', 'bz_default_hidden'); - Dom.addClass('data_safety_questions', 'bz_default_hidden'); - Dom.addClass('sec_review_questions', 'bz_default_hidden'); - } + if (Dom.get('key_initiative').value == 'Other') { + page_sections.key_initiative_other_row = true; + } - if (Dom.get('separate_party').value == 'Yes' - && Dom.get('relationship_type').value == 'Vendor/Services') - { - Dom.removeClass('legal_sow_section', 'bz_default_hidden'); - } + if (Dom.get('new_or_change').value == 'Existing') { + page_sections.mozilla_project_row = true; + } - if (data_access_select.value == 'Yes' || mozilla_data_select.value == 'Yes') { - Dom.removeClass('sec_review_questions', 'bz_default_hidden'); - } - else { - Dom.addClass('sec_review_questions', 'bz_default_hidden'); - } + if (Dom.get('new_or_change').value == 'New') + page_sections.legal_questions = true; - if (data_access_select.value == 'Yes') { - Dom.removeClass('privacy_policy_vendor_questions', 'bz_default_hidden'); - } - else { - Dom.addClass('privacy_policy_vendor_questions', 'bz_default_hidden'); - } + if (Dom.get('mozilla_data').value == 'Yes') { + page_sections.legal_questions = true; + page_sections.privacy_policy_project_questions = true; + page_sections.data_safety_questions = true; + page_sections.sec_review_questions = true; + } - if (vendor_cost_select.value == '> $25,000') { - Dom.removeClass('finance_questions', 'bz_default_hidden'); - } - else { - Dom.addClass('finance_questions', 'bz_default_hidden'); - } -} + if (Dom.get('separate_party').value == 'Yes') { + page_sections.initial_separate_party_questions = true; -MPR.toggleVisibleById = function () { - var args = Array.prototype.slice.call(arguments); - var select = args.shift(); - var value = args.shift(); - var ids = args; + if (Dom.get('relationship_type').value + && Dom.get('relationship_type').value != 'Hardware Purchase') + { + page_sections.legal_questions = true; + } - if (typeof select == 'string') { - select = Dom.get(select); - } + if (Dom.get('relationship_type').value == 'Vendor/Services' + || Dom.get('relationship_type').value == 'Distribution/Bundling') + { + page_sections.legal_sow_questions = true; + page_sections.legal_vendor_services_where_row = true; + } + + if (Dom.get('relationship_type').value == 'Hardware Purchase') { + page_sections.finance_questions = true; + } + + if (Dom.get('data_access').value == 'Yes') { + page_sections.legal_questions = true; + page_sections.sec_review_questions = true; + page_sections.privacy_policy_vendor_questions = true; + } + + if (Dom.get('vendor_cost').value == '<= $25,000') { + page_sections.po_needed_row = true; + } + + if (Dom.get('po_needed').value == 'Yes') { + page_sections.finance_questions = true; + } - for (var i = 0; i < ids.length; i++) { - if (select.value == value) { - Dom.removeClass(ids[i], 'bz_default_hidden'); + if (Dom.get('vendor_cost').value == '> $25,000') { + page_sections.finance_questions = true; + } } - else { - Dom.addClass(ids[i], 'bz_default_hidden'); + + if (Dom.get('legal_vendor_services_where').value == 'A single country') { + page_sections.legal_vendor_single_country = true; } - } -} - -MPR.validateAndSubmit = function () { - var alert_text = ''; - var section = ''; - for (section in MPR.required_fields) { - if (!Dom.hasClass(section, 'bz_default_hidden')) { - var field = ''; - for (field in MPR.required_fields[section]) { - if (!MPR.isFilledOut(field)) { - alert_text += MPR.required_fields[section][field] + "\n"; + + if (Dom.get('finance_purchase_inbudget').value == 'No') { + page_sections.finance_purchase_notinbudget_why_row = true; + } + + if (Dom.get('privacy_policy_project').value == 'Yes') { + page_sections.privacy_policy_project_link_row = true; + } + + if (Dom.get('privacy_policy_user_data').value == 'Yes') { + page_sections.privacy_policy_project_user_data_bug_row = true; + } + + if (Dom.get('privacy_policy_vendor_user_data').value == 'Yes') { + page_sections.privacy_policy_vendor_extra = true; + } + + if (Dom.get('data_safety_user_data').value == 'Yes') { + page_sections.data_safety_extra_questions = true; + } + + if (Dom.get('data_safety_retention').value == 'Yes') { + page_sections.data_safety_retention_length_row = true; + } + + if (Dom.get('data_safety_separate_party').value == 'Yes') { + page_sections.data_safety_separate_party_data_row = true; + } + + if (Dom.get('data_safety_community_visibility').value == 'Yes') { + page_sections.data_safety_communication_channels_row = true; + } + + if (Dom.get('data_safety_community_visibility').value == 'No') { + page_sections.data_safety_communication_plan_row = true; + } + + // Toggle the individual page_sections + for (section in page_sections) { + MPR.toggleShowSection(section, page_sections[section]); + } + }, + + toggleShowSection: function (section, show) { + if (show) { + Dom.removeClass(section, 'bz_default_hidden'); + } + else { + Dom.addClass(section ,'bz_default_hidden'); + } + }, + + validateAndSubmit: function () { + var alert_text = ''; + var section = ''; + for (section in this.required_fields) { + if (!Dom.hasClass(section, 'bz_default_hidden')) { + var field = ''; + for (field in MPR.required_fields[section]) { + if (!MPR.isFilledOut(field)) { + alert_text += this.required_fields[section][field] + "\n"; + } } } } - } + + // Special case checks + if (Dom.get('relationship_type').value == 'Vendor/Services' + && Dom.get('legal_vendor_services_where').value == '') + { + alert_text += "Please select a value for vendor services where\n"; + } - if (Dom.get('relationship_type').value == 'Vendor/Services' - && Dom.get('legal_vendor_services_where').value == '') - { - alert_text += "Please select a value for vendor services where\n"; - } + if (Dom.get('relationship_type').value == 'Vendor/Services' + && Dom.get('legal_vendor_services_where').value == 'A single country' + && Dom.get('legal_vendor_single_country').value == '') + { + alert_text += "Please select a value for vendor services where single country\n"; + } - if (Dom.get('relationship_type').value == 'Vendor/Services' - && Dom.get('legal_vendor_services_where').value == 'A single country' - && Dom.get('legal_vendor_single_country').value == '') - { - alert_text += "Please select a value for vendor services where single country\n"; - } + if (Dom.get('key_initiative').value == 'Other') { + if (!MPR.isFilledOut('key_initiative_other')) { + alert_text += "Please enter a value for key initiative in the initial questions section\n"; + } + } - if (Dom.get('key_initiative').value == 'Other') { - if (!MPR.isFilledOut('key_initiative_other')) - alert_text += "Please enter a value for key initiative in the initial questions section\n"; - } + if (Dom.get('separate_party').value == 'Yes') { + if (!MPR.isFilledOut('relationship_type')) { + alert_text += "Please select a value for type of relationship\n"; + } + if (!MPR.isFilledOut('data_access')) { + alert_text += "Please select a value for data access\n"; + } + if (!MPR.isFilledOut('vendor_cost')) { + alert_text += "Please select a value for vendor cost\n"; + } + } - if (Dom.get('separate_party').value == 'Yes') { - if (!MPR.isFilledOut('relationship_type')) alert_text += "Please select a value for type of relationship\n"; - if (!MPR.isFilledOut('data_access')) alert_text += "Please select a value for data access\n"; - if (!MPR.isFilledOut('vendor_cost')) alert_text += "Please select a value for vendor cost\n"; - } + if (Dom.get('finance_purchase_inbudget').value == 'No') { + if (!MPR.isFilledOut('finance_purchase_notinbudget_why')) { + alert_text += "Please include additional description for the out of budget line item\n"; + } + } - if (Dom.get('finance_purchase_inbudget').value == 'No') { - if (!MPR.isFilledOut('finance_purchase_notinbudget_why')) - alert_text += "Please include additional description for the out of budget line item\n"; - } + if (Dom.get('vendor_cost').value == '<= $25,000' + && Dom.get('po_needed').value == '') + { + alert_text += "Please select whether a PO is needed or not\n"; + } - if (Dom.get('vendor_cost').value == '<= $25,000' - && Dom.get('po_needed').value == '') - { - alert_text += "Please select whether a PO is needed or not\n"; - } + if (alert_text) { + alert(alert_text); + return false; + } - if (alert_text) { - alert(alert_text); - return false; + return true; + }, + + //Takes a DOM element id and makes sure that it is filled out + isFilledOut: function (elem_id) { + var str = Dom.get(elem_id).value; + return str.length > 0 ? true : false; } +}; - return true; -} - -YAHOO.util.Event.onDOMReady(function() { - MPR.toggleSpecialSections(); - MPR.toggleVisibleById('new_or_change', 'Existing', 'mozilla_project_row'); - MPR.toggleVisibleById('separate_party', 'Yes', 'initial_separate_party_questions'); - MPR.toggleVisibleById('relationship_type', 'Vendor/Services', 'legal_sow_section'); - MPR.toggleVisibleById('vendor_cost', '> $25,000', 'finance_questions'); - MPR.toggleVisibleById('privacy_policy_project', 'Yes', 'privacy_policy_project_link_row'); - MPR.toggleVisibleById('privacy_policy_user_data', 'Yes', 'privacy_policy_project_user_data_bug_row'); - MPR.toggleVisibleById('privacy_policy_vendor_user_data', 'Yes', 'privacy_policy_vendor_extra'); - MPR.toggleVisibleById('data_safety_user_data', 'Yes', 'data_safety_extra_questions'); - MPR.toggleVisibleById('data_safety_retention', 'Yes', 'data_safety_retention_length_row'); - MPR.toggleVisibleById('data_safety_separate_party', 'Yes', 'data_safety_separate_party_data_row'); - MPR.toggleVisibleById('data_safety_community_visibility', 'Yes', 'data_safety_communication_channels_row'); - MPR.toggleVisibleById('data_safety_community_visibility', 'No', 'data_safety_communication_plan_row'); -}); - -//Takes a DOM element id and makes sure that it is filled out -MPR.isFilledOut = function (elem_id) { - var str = Dom.get(elem_id).value; - return str.length > 0 ? true : false; -} - -Event.addListener('legal_vendor_services_where', 'change', function(e) { - if (this.value == 'A single country') - Dom.removeClass('legal_vendor_single_country', 'bz_default_hidden'); - else - Dom.addClass('legal_vendor_single_country', 'bz_default_hidden'); -}); +Event.onDOMReady(MPR.init()); |