Skip to content

Commit

Permalink
changes in overall budget and research cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
neerajdarwin committed Dec 20, 2024
1 parent de8f7ca commit e9f5772
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
22 changes: 12 additions & 10 deletions ProjectApplication/project_core/forms/overall_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,19 @@ def __init__(self, *args, **kwargs):
if self._call is None:
self._call = self.instance.call

# Remove the `overall_budget` field if the question is not enabled
if not self._call.overall_budget_question:
self.fields.pop('overall_budget', None)
else:
# Add to the layout only if the field exists
self.helper.layout = Layout(
Div(
Div('overall_budget', css_class='col-6'),
css_class='row'
if self._call.overall_budget_question:
# Ensure the field is visible and set the layout
if 'overall_budget' in self.fields:
self.helper.layout = Layout(
Div(
Div('overall_budget', css_class='col-6'),
css_class='row'
)
)
)
else:
# Hide the field by changing its widget
if 'overall_budget' in self.fields:
self.fields['overall_budget'].widget = forms.HiddenInput()

# Set initial values for fields
if self.instance.id:
Expand Down
12 changes: 12 additions & 0 deletions ProjectApplication/project_core/static/js/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,22 @@ $(document).ready(function () {
}

function addValidation(callback) {
var max_budget = $('#total_budget').val();
errorMessages = []; // Clear error messages

var proposalTitle = $("input[name='proposal_application_form-title']").val();
var callId = $("input[name='proposal_application_form-call_id']").val();
var overall_budget = $("input[name='overall_budget_form-overall_budget']").val();
if (overall_budget > max_budget) {
alert('Budget is greater than the maximum budget for this call.');
$("input[name='overall_budget_form-overall_budget']").closest('.form-group').addClass("has-error");
let errorSpan = $('<span class="error-message is-invalid"></span>');
$("input[name='overall_budget_form-overall_budget']").closest('.form-group').find('.error-message').remove(); // Remove existing error span if any
$("input[name='overall_budget_form-overall_budget']").after(errorSpan);
} else {
$("input[name='overall_budget_form-overall_budget']").closest('.form-group').removeClass("has-error");
$("input[name='overall_budget_form-overall_budget']").closest('.form-group').find('.error-message').remove(); // Remove error span
}

//adding error span
$(".required_field").each(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@
</div>
{% else %}

<div class="step">
<div class="step step-3">
<span class="bullet"></span>
<span class="cursor-pointer">3. Budget Request</span>
</div>
<div class="step">
<div class="step step-4">
<span class="bullet"></span>
<span class="cursor-pointer">4. Summary</span>
</div>
Expand Down

0 comments on commit e9f5772

Please sign in to comment.