Skip to content

Commit 9dfdcbc

Browse files
committed
Fixed incorrect proposal form rendering and improved order of fields (#4654)
<!-- Thanks for contributing to Hypha! Please ensure your contributions pass all necessary linting/testing and that the appropriate documentation has been updated. --> <!-- Describe briefly what your pull request changes. If this is resolving an issue, please specify below via "Fixes #<Github Issue ID>" --> Fixes #4652. Wraps the queryset in a `list` and changes the order of the fields into a more logical one where "Determinations" comes first, as it's selection is required to enable "Proposal Form" ## Test Steps <!-- If step does not require manual testing, skip/remove this section. Give a brief overview of the steps required for a user/dev to test this contribution. Important things to include: - Required user roles for where necessary (ie. "As a Staff Admin...") - Clear & validatable expected results (ie. "Confirm the submit button is now not clickable") - Language that can be understood by non-technical testers if being tested by users --> - [ ] Ensure the expected proposal form is rendered - [ ] Ensure that the "Determination" field is rendered before "Proposal Form"
1 parent 2d20bcc commit 9dfdcbc

3 files changed

Lines changed: 21 additions & 13 deletions

File tree

hypha/apply/determinations/views.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,10 @@ def get_form_class(self):
359359
form_fields[field_block.id].initial = TRANSITION_DETERMINATION[
360360
action
361361
]
362+
# Make capitalization consistent
363+
form_fields[field_block.id].label = form_fields[
364+
field_block.id
365+
].label.title()
362366
form_fields = self.add_proposal_form_field(form_fields, action)
363367
return type("WagtailStreamForm", (self.submission_form_class,), form_fields)
364368

@@ -389,7 +393,11 @@ def add_proposal_form_field(self, fields, action):
389393
help_text=proposal_form_help_text,
390394
required=True if action == "invited_to_proposal" else False,
391395
)
396+
# Move proposal form the be the second field as it's disabled until the first (determination) is input
392397
fields.move_to_end("proposal_form", last=False)
398+
fields.move_to_end(
399+
list(fields.keys())[1], last=False
400+
) # `last=False` moves the item to the start
393401
return fields
394402

395403
def get_success_url(self):

hypha/apply/funds/models/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def get_defined_fields(self, stage=None, form_index=0):
115115
stage_num = 1
116116
else:
117117
stage_num = self.workflow.stages.index(stage) + 1
118-
return self.forms.filter(stage=stage_num)[form_index].fields
118+
return list(self.forms.filter(stage=stage_num))[form_index].fields
119119

120120
def render_landing_page(self, request, form_submission=None, *args, **kwargs):
121121
# We only reach this page after creation of a new submission

hypha/static_src/javascript/determination-template.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@
2525

2626
getMatchingCopy(value) {
2727
const proposal_form = document.querySelector("#id_proposal_form");
28-
if (value === "0") {
29-
this.text = document.querySelector(
30-
'div[data-type="rejected"]'
31-
).textContent;
28+
if (["", "0", "1"].includes(value)) {
3229
if (proposal_form) {
3330
proposal_form.disabled = true;
3431
proposal_form.required = false;
3532
}
36-
} else if (value === "1") {
37-
this.text = document.querySelector(
38-
'div[data-type="more_info"]'
39-
).textContent;
40-
if (proposal_form) {
41-
proposal_form.disabled = true;
42-
proposal_form.required = false;
33+
if (value === "") {
34+
this.text = "";
35+
} else if (value === "0") {
36+
this.text = document.querySelector(
37+
'div[data-type="rejected"]'
38+
).textContent;
39+
} else if (value === "1") {
40+
this.text = document.querySelector(
41+
'div[data-type="more_info"]'
42+
).textContent;
4343
}
44-
} else {
44+
} else if (value === "2") {
4545
this.text = document.querySelector(
4646
'div[data-type="accepted"]'
4747
).textContent;

0 commit comments

Comments
 (0)