summaryrefslogtreecommitdiffstats
path: root/extensions/MozProjectReview/web/js/moz_project_review.js
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/MozProjectReview/web/js/moz_project_review.js')
-rw-r--r--extensions/MozProjectReview/web/js/moz_project_review.js424
1 files changed, 230 insertions, 194 deletions
diff --git a/extensions/MozProjectReview/web/js/moz_project_review.js b/extensions/MozProjectReview/web/js/moz_project_review.js
index e2a198e2a..3d1caf528 100644
--- a/extensions/MozProjectReview/web/js/moz_project_review.js
+++ b/extensions/MozProjectReview/web/js/moz_project_review.js
@@ -6,230 +6,229 @@
* defined by the Mozilla Public License, v. 2.0.
*/
-var Dom = YAHOO.util.Dom;
-var Event = YAHOO.util.Event;
-
-var MPR = {
- required_fields: {
+$(function() {
+ 'use strict';
+ var 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",
- "key_initiative": "Please select a value for key initiative in the initial questions section",
- "release_date": "Please enter a value for release date 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",
- "separate_party": "Please select a value for separate party in the initial questions section"
+ "comment": "Please enter a value for description in the initial questions section.",
+ "key_initiative": "Please select a value for key initiative in the initial questions section.",
+ "contract_type": "Please select a value for contract type in the initial questions section.",
+ "mozilla_data": "Please select a value for mozilla data in the initial questions section.",
+ "vendor_cost": "Please select a value for vendor cost in the initial questions section.",
+ "timeframe": "Please select a value for timeframe in the initial questions section.",
+ "contract_priority": "Please select a value for priority in the initial questions section.",
+ "internal_org": "Please select a value for the internal organization 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"
+ "key_initiative_other": {
+ "key_initiative_other": "Please enter a value for other key initiative in the initial questions section."
+ },
+ "mozilla_data_explain_row": {
+ "mozilla_data_explain": "Please enter a value for mozilla data access explanation in the initial questions section."
+ },
+ "contract_type_other": {
+ "contract_type_other": "Please enter a value for other contract type in the initial questions section."
+ },
+ "contract_specific_questions": {
+ "other_party": "Please enter a value for vendor name in the contract specific questions.",
+ "vendor_services_where": "Please enter a value for the where the services will be provided in the contract specific questions.",
+ },
+ "independent_contractor_questions": {
+ "independent_contractor_prev_work": "Please select a value for previous work in the independent contractor section.",
+ "independent_contractor_incorporated": "Please select a value for incorporated in the independent contractor section.",
+ "independent_contractor_staff_agency": "Please select a value for staffing agency in the independent contractor section.",
+ "independent_contractor_other_clients": "Please select a value for other clients in the independent contractor section.",
+ "independent_contractor_dupe_services": "Please select a value for in the independent contractor section.",
+ "independent_contractor_self_manage": "Please select a value for self management of time in the independent contractor section.",
+ "independent_contractor_own_equipment": "Please select a value for use of contractors own equipment in the independent contractor section.",
+ "independent_contractor_mozilla_facility": "Please select a value for use of Mozilla facility in the independent contractor section.",
+ "independent_contractor_supervising": "Please select a value for contractor supervising Mozilla employees in the independent contractor section.",
+ },
+ "independent_contractor_prev_work_bug_row": {
+ "independent_contractor_prev_work_bug": "Please enter a value for previous work bug id in the independent contractor section."
+ },
+ "independent_contractor_dupe_services_temp_row": {
+ "independent_contractor_dupe_services_temp": "Please select a value for temporarily need duplicate services in the independent contractor section."
+ },
+ "sow_details": {
+ "sow_vendor_address": "Please enter a value for SOW vendor address.",
+ "sow_vendor_email": "Please enter a value for SOW vendor email for notices.",
+ "sow_vendor_contact": "Please enter a value for SOW vendor contact and email address.",
+ "sow_vendor_services": "Please enter a value for SOW vendor services description.",
+ "sow_vendor_deliverables": "Please enter a value for SOW vendor deliverables description.",
+ "sow_start_date": "Please enter a value for SOW vendor start date.",
+ "sow_end_date": "Please enter a value for SOW vendor end date.",
+ "sow_vendor_payment": "Please enter a value for SOW vendor payment amount.",
+ "sow_vendor_payment_basis": "Please enter a value for SOW vendor payment basis.",
+ "sow_vendor_cap_expenses": "Please enter a value for SOW cap on reimbursable expenses.",
+ "sow_vendor_payment_schedule": "Please enter a value for SOW vendor payment schedule.",
+ "sow_vendor_total_max": "Please enter a value for SOW vendor maximum total to be paid.",
},
- "legal_questions": {
- "legal_priority": "Please select a value for priority in the legal questions section",
- "legal_timeframe": "Please select a value for timeframe in the legal questions section",
- "legal_help_from_legal": "Please describe the help needed from the Legal department"
+ "sow_vendor_mozilla_systems_explain_row": {
+ "sow_vendor_mozilla_systems_explain": "Please enter a value for SOW vendor explanation for use of mozilla systems."
},
- "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"
+ "sow_vendor_onsite_where_row": {
+ "sow_vendor_onsite_where": "Please enter a value for SOW vendor onsite where and when."
},
- "data_compliance_questions": {
- "data_comp_request_type": "Please select a value for the data compliance request type",
- "data_comp_area": "Please select a value for the data compliance area",
- "data_comp_desc": "Please enter a value for the data compliance description",
- "data_comp_handling_change": "Please select a value for the data compliance handling change",
- "data_comp_practice_change": "Please select a value for the data compliance practice change"
+ "finance_questions": {
+ "finance_purchase_inbudget": "Please enter a value for in budget 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.",
+ },
+ "total_cost_row": {
+ "total_cost": "Please enter a value for total cost"
}
- },
+ };
- select_inputs: [
+ var select_inputs = [
+ 'contract_type',
+ 'independent_contractor_prev_work',
+ 'independent_contractor_dupe_services',
'key_initiative',
- 'project_status',
'mozilla_data',
- 'separate_party',
- 'relationship_type',
- 'data_access',
'vendor_cost',
- 'po_needed',
- 'sec_affects_products',
- 'legal_priority',
- 'legal_sow_vendor_product_line',
- 'legal_vendor_services_where',
- 'finance_purchase_urgency'
- ],
-
- init: function () {
+ 'sow_vendor_mozilla_systems',
+ 'sow_vendor_onsite'
+ ];
+
+ function init() {
// 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);
+ for (var i = 0, l = select_inputs.length; i < l; i++) {
+ $('#' + select_inputs[i]).change(updateSections);
}
- MPR.updateSections();
- },
+ updateSections();
+ $('#mozProjectForm').submit(validateAndSubmit);
+ }
- fieldValue: function (id) {
- var field = Dom.get(id);
- if (!field) return '';
- if (field.type == 'text'
- || field.type == 'textarea')
- {
- return field.value;
- }
- return field.options[field.selectedIndex].value;
- },
-
- 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,
- 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,
- data_compliance_questions: false,
- };
-
- if (MPR.fieldValue('key_initiative') == 'Other') {
- page_sections.key_initiative_other_row = true;
- }
-
- if (MPR.fieldValue('mozilla_data') == 'Yes') {
- page_sections.legal_questions = true;
- page_sections.data_compliance_questions = true;
- page_sections.sec_review_questions = true;
- }
-
- if (MPR.fieldValue('separate_party') == 'Yes') {
- page_sections.initial_separate_party_questions = true;
-
- if (MPR.fieldValue('relationship_type')
- && MPR.fieldValue('relationship_type') != 'Hardware Purchase')
- {
- page_sections.legal_questions = true;
- }
+ function updateSections(e) {
+ if ($('#key_initiative').val() == 'Other') {
+ $('#key_initiative_other').show();
+ if ($(e.target).attr('id') == 'key_initiative') $('#key_initiative_other').focus();
+ } else {
+ $('#key_initiative_other').hide();
+ }
- if (MPR.fieldValue('relationship_type') == 'Vendor/Services'
- || MPR.fieldValue('relationship_type') == 'Firefox Distribution/Bundling')
- {
- page_sections.legal_sow_questions = true;
- page_sections.legal_vendor_services_where_row = true;
- }
+ if ($('#vendor_cost').val() == '< $25,000 PO Needed'
+ || $('#vendor_cost').val() == '> $25,000')
+ {
+ $('#finance_questions').show();
+ } else {
+ $('#finance_questions').hide();
+ }
- if (MPR.fieldValue('relationship_type') == 'Hardware Purchase') {
- page_sections.finance_questions = true;
- }
+ var do_sec_review = [
+ 'Engaging a new vendor company',
+ 'Adding a new SOW with a vendor',
+ 'Extending an SOW or renewing a contract',
+ 'Purchasing software',
+ 'Signing up for an online service',
+ 'Other'
+ ];
+ var contract_type = $('#contract_type').val();
+ if ((contract_type && $.inArray(contract_type, do_sec_review) >= 0)
+ || $('#mozilla_data').val() == 'Yes')
+ {
+ $('#sec_review_questions').show();
- if (MPR.fieldValue('data_access') == 'Yes') {
- page_sections.legal_questions = true;
- page_sections.sec_review_questions = true;
- page_sections.data_compliance_questions = true;
- }
+ } else {
+ $('#sec_review_questions').hide();
+ }
- if (MPR.fieldValue('vendor_cost') == '<= $25,000') {
- page_sections.po_needed_row = true;
- }
+ if ($('#mozilla_data').val() == 'Yes') {
+ $('#mozilla_data_explain_row').show();
+ if ($(e.target).attr('id') == 'mozilla_data') $('#mozilla_data_explain').focus();
- if (MPR.fieldValue('po_needed') == 'Yes') {
- page_sections.finance_questions = true;
- }
+ } else {
+ $('#mozilla_data_explain_row').hide();
+ }
- if (MPR.fieldValue('vendor_cost') == '> $25,000') {
- page_sections.finance_questions = true;
- }
+ if (contract_type == 'Other') {
+ $('#contract_type_other').show();
+ if ($(e.target).attr('id') == 'contract_type') $('#contract_type_other').focus();
+ }
+ else {
+ $('#contract_type_other').hide();
}
- if (MPR.fieldValue('legal_vendor_services_where') == 'A single country') {
- page_sections.legal_vendor_single_country = true;
+ if (contract_type == 'Engaging a new vendor company'
+ || contract_type == 'Engaging an individual (independent contractor, temp agency worker, incorporated)'
+ || contract_type == 'Adding a new SOW with a vendor')
+ {
+ $('#sow_details').show();
+ }
+ else {
+ $('#sow_details').hide();
}
- // Toggle the individual page_sections
- for (section in page_sections) {
- MPR.toggleShowSection(section, page_sections[section]);
+ if (contract_type == "Extending a SOW or renewing a contract"
+ || contract_type == "Purchasing software"
+ || contract_type == "Purchasing hardware"
+ || contract_type == "Signing up for an online service"
+ || contract_type == "Other")
+ {
+ $('#total_cost_row').show();
+ }
+ else {
+ $('#total_cost_row').hide();
}
- },
- toggleShowSection: function (section, show) {
- if (show) {
- Dom.removeClass(section, 'bz_default_hidden');
+ if (contract_type == 'Engaging an individual (independent contractor, temp agency worker, incorporated)') {
+ $('#independent_contractor_questions').show();
}
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";
- }
- }
- }
+ $('#independent_contractor_questions').hide();
}
- // Special case checks
- if (MPR.fieldValue('relationship_type') == 'Vendor/Services'
- && MPR.fieldValue('legal_vendor_services_where') == '')
- {
- alert_text += "Please select a value for vendor services where\n";
+ if ($('#independent_contractor_prev_work').val() == 'Yes') {
+ $('#independent_contractor_prev_work_bug_row').show();
+ if ($(e.target).attr('id') == 'independent_contractor_prev_work')
+ $('#independent_contractor_prev_work_bug').focus();
+ }
+ else {
+ $('#independent_contractor_prev_work_bug_row').hide();
}
- if (MPR.fieldValue('relationship_type') == 'Vendor/Services'
- && MPR.fieldValue('legal_vendor_services_where') == 'A single country'
- && MPR.fieldValue('legal_vendor_single_country') == '')
- {
- alert_text += "Please select a value for vendor services where single country\n";
+ if ($('#independent_contractor_dupe_services').val() == 'Yes') {
+ $('#independent_contractor_dupe_services_temp_row').show();
+ if ($(e.target).attr('id') == 'independent_contractor_dupe_services')
+ $('#independent_contractor_dupe_services_temp').focus();
+ }
+ else {
+ $('#independent_contractor_dupe_services_temp_row').hide();
}
- if (MPR.fieldValue('key_initiative') == 'Other') {
- if (!MPR.isFilledOut('key_initiative_other')) {
- alert_text += "Please enter a value for key initiative in the initial questions section\n";
- }
+ if ($('#sow_vendor_mozilla_systems').val() == 'Yes') {
+ $('#sow_vendor_mozilla_systems_explain_row').show();
+ if ($(e.target).attr('id') == 'sow_vendor_mozilla_systems')
+ $('#sow_vendor_mozilla_systems_explain').focus();
+ }
+ else {
+ $('#sow_vendor_mozilla_systems_explain_row').hide();
}
- if (MPR.fieldValue('separate_party') == '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 ($('#sow_vendor_onsite').val() == 'Yes') {
+ $('#sow_vendor_onsite_where_row').show();
+ if ($(e.target).attr('id') == 'sow_vendor_onsite')
+ $('#sow_vendor_onsite_where').focus();
+ }
+ else {
+ $('#sow_vendor_onsite_where_row').hide();
}
+ }
- if (MPR.fieldValue('vendor_cost') == '<= $25,000'
- && MPR.fieldValue('po_needed') == '')
- {
- alert_text += "Please select whether a PO is needed or not\n";
+ function validateAndSubmit(e) {
+ var alert_text = '',
+ section = '',
+ field = '';
+ for (section in required_fields) {
+ if ($('#' + section).is(':visible')) {
+ for (field in required_fields[section]) {
+ if (!isFilledOut(field)) {
+ alert_text += required_fields[section][field] + "\n";
+ }
+ }
+ }
}
if (alert_text) {
@@ -237,16 +236,53 @@ var MPR = {
return false;
}
+ $('#short_desc').val('Contract for ' +
+ $('#contract_type').val() +
+ ' with ' +
+ $('#other_party').val());
+
+ var component_map = {
+ "Engaging a new vendor company,": "Vendor/Services",
+ "Adding a new SOW with a vendor": "Vendor/Services",
+ "Extending a SOW or renewing a contract": "Vendor/Services",
+ "Purchasing hardware": "Vendor/Services",
+ "Other": "Vendor/Services",
+ "Engaging an individual (independent contractor, temp agency worker, incorporated)": "Independent Contractor Agreement",
+ "An agreement with a partner": "Firefox Distribution or Other Partner Agreement",
+ "Purchasing software": "License Review",
+ "Signing up for an online service" : "License Review"
+ }
+
+ var contract_type = $('#contract_type').val();
+ if (component_map[contract_type]) {
+ $('#component').val(component_map[contract_type]);
+ }
+
return true;
- },
+ }
//Takes a DOM element id and makes sure that it is filled out
- isFilledOut: function (elem_id) {
- var str = MPR.fieldValue(elem_id);
- return str.length > 0 ? true : false;
+ function isFilledOut(id) {
+ if (!id) return false;
+ var str = $('#' + id).val();
+ if (!str || str.length == 0) return false;
+ return true;
}
-};
-Event.onDOMReady(function () {
- MPR.init();
+ // date pickers
+ $('.date-field').datetimepicker({
+ format: 'Y-m-d',
+ datepicker: true,
+ timepicker: false,
+ scrollInput: false,
+ lazyInit: false,
+ closeOnDateSelect: true
+ });
+ $('.date-field-img')
+ .click(function(event) {
+ var id = $(event.target).attr('id').replace(/-img$/, '');
+ $('#' + id).datetimepicker('show');
+ })
+
+ init();
});