Commit 7e88a886 by Ahsan Ulhaq

Financial Assistance Form Updates

ECOM-4544
parent 849e3b79
...@@ -1298,6 +1298,10 @@ def financial_assistance_form(request): ...@@ -1298,6 +1298,10 @@ def financial_assistance_form(request):
mode_slug=CourseMode.VERIFIED mode_slug=CourseMode.VERIFIED
).exists() ).exists()
] ]
incomes = ['Less than $5,000', '$5,000 - $10,000', '$10,000 - $15,000', '$15,000 - $20,000', '$20,000 - $25,000']
annual_incomes = [
{'name': _(income), 'value': income} for income in incomes # pylint: disable=translation-of-non-string
]
return render_to_response('financial-assistance/apply.html', { return render_to_response('financial-assistance/apply.html', {
'header_text': FINANCIAL_ASSISTANCE_HEADER, 'header_text': FINANCIAL_ASSISTANCE_HEADER,
'student_faq_url': marketing_link('FAQ'), 'student_faq_url': marketing_link('FAQ'),
...@@ -1328,12 +1332,12 @@ def financial_assistance_form(request): ...@@ -1328,12 +1332,12 @@ def financial_assistance_form(request):
}, },
{ {
'name': 'income', 'name': 'income',
'type': 'text', 'type': 'select',
'label': FA_INCOME_LABEL, 'label': FA_INCOME_LABEL,
'placeholder': _('income in US Dollars ($)'), 'placeholder': '',
'defaultValue': '', 'defaultValue': '',
'required': True, 'required': True,
'restrictions': {}, 'options': annual_incomes,
'instructions': _('Specify your annual household income in US Dollars.') 'instructions': _('Specify your annual household income in US Dollars.')
}, },
{ {
......
...@@ -38,14 +38,10 @@ ...@@ -38,14 +38,10 @@
var context = data.context, var context = data.context,
fields = context.fields; fields = context.fields;
// Add default option to array // Add default option to course array
if ( fields[0].options.length > 1 ) { this.addDefaultOption(fields, 0);
fields[0].options.unshift({ // Add default option to household income array
name: '- ' + gettext('Choose one') + ' -', this.addDefaultOption(fields, 1);
value: '',
default: true
});
}
// Set non-form data needed to render the View // Set non-form data needed to render the View
this.context = { this.context = {
...@@ -138,6 +134,16 @@ ...@@ -138,6 +134,16 @@
this.toggleDisableButton(true); this.toggleDisableButton(true);
$submissionContainer.removeClass('hidden'); $submissionContainer.removeClass('hidden');
} }
},
addDefaultOption: function(array, index) {
if ( array[index].options.length > 1 ) {
array[index].options.unshift({
name: '- ' + gettext('Choose one') + ' -',
value: '',
default: true
});
}
} }
}); });
} }
......
...@@ -32,13 +32,19 @@ define([ ...@@ -32,13 +32,19 @@ define([
instructions: 'Specify your annual income in USD.', instructions: 'Specify your annual income in USD.',
label: 'Annual Income', label: 'Annual Income',
name: 'income', name: 'income',
placeholder: 'income in USD ($)', options: [
{'name': 'Less than $5,000', 'value': 'Less than $5,000'},
{'name': '$5,000 - $10,000', 'value': '$5,000 - $10,000'},
{'name': '$10,000 - $15,000', 'value': '$10,000 - $15,000'},
{'name': '$15,000 - $20,000', 'value': '$15,000 - $20,000'},
{'name': '$20,000 - $25,000', 'value': '$20,000 - $25,000'}
],
placeholder: '',
required: true, required: true,
restrictions: {}, type: 'select'
type: 'text'
}, { }, {
defaultValue: '', defaultValue: '',
instructions: 'Use between 250 and 500 words or so in your response.', instructions: 'Your response should contain approximately 250 - 500 words.',
label: 'Tell us about your current financial situation, including any unusual circumstances.', label: 'Tell us about your current financial situation, including any unusual circumstances.',
name: 'reason_for_applying', name: 'reason_for_applying',
placeholder: '', placeholder: '',
...@@ -103,11 +109,13 @@ define([ ...@@ -103,11 +109,13 @@ define([
validCountry; validCountry;
completeForm = function() { completeForm = function() {
var options = context.fields[0].options, var courseOptions = context.fields[0].options,
selectValue = options[options.length - 1].value; courseSelectValue = courseOptions[courseOptions.length - 1].value;
var incomeOptions = context.fields[1].options,
incomeSelectValue = incomeOptions[incomeOptions.length - 1].value;
view.$('#financial-assistance-course').val(selectValue); view.$('#financial-assistance-course').val(courseSelectValue);
view.$('#financial-assistance-income').val(1312); view.$('#financial-assistance-income').val(incomeSelectValue);
view.$('textarea').html(Array(802).join("w")); view.$('textarea').html(Array(802).join("w"));
}; };
...@@ -170,8 +178,8 @@ define([ ...@@ -170,8 +178,8 @@ define([
it('should load the form based on passed in context', function() { it('should load the form based on passed in context', function() {
var $form = view.$('.financial-assistance-form'); var $form = view.$('.financial-assistance-form');
expect($form.find('select').attr('name')).toEqual(context.fields[0].name); expect($form.find('select').first().attr('name')).toEqual(context.fields[0].name);
expect($form.find('input[type=text]').first().attr('name')).toEqual(context.fields[1].name); expect($form.find('select').last().attr('name')).toEqual(context.fields[1].name);
expect($form.find('textarea').first().attr('name')).toEqual(context.fields[2].name); expect($form.find('textarea').first().attr('name')).toEqual(context.fields[2].name);
expect($form.find('input[type=checkbox]').attr('name')).toEqual(context.fields[5].name); expect($form.find('input[type=checkbox]').attr('name')).toEqual(context.fields[5].name);
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment