Skip to content

Commit 15ba01d

Browse files
frankduncanfrjo
andauthored
Enable group stream boxes when in draft and edit mode (#4032)
Fixes #4031 They are disabled when editing a proposal in general, but in the case of a draft, the users sometimes need to be able to edit them in order to finish an application. This fix may be incomplete, as it does not allow the group forms to have the full functionality of hiding the followup forms when "No" is selected, and showing them when "Yes" is selected. Co-authored-by: Fredrik Jonsson <frjo@xdeb.org>
1 parent d276514 commit 15ba01d

5 files changed

Lines changed: 10 additions & 19 deletions

File tree

hypha/apply/funds/templates/funds/application_base.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ <h4>
5858
{% for field in form %}
5959
{% if field.field %}
6060
{% if field.field.multi_input_field %}
61-
{% include "forms/includes/multi_input_field.html" with is_application=True %}
61+
{% include "forms/includes/multi_input_field.html" %}
6262
{% else %}
63-
{% include "forms/includes/field.html" with is_application=True %}
63+
{% include "forms/includes/field.html" %}
6464
{% endif %}
6565
{% else %}
6666
{% if field.group_number > 1 %}

hypha/apply/funds/templates/funds/application_preview.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
{% for field in form %}
2121
{% if field.field %}
2222
{% if field.field.multi_input_field %}
23-
{% include "forms/includes/multi_input_field.html" with is_application=True %}
23+
{% include "forms/includes/multi_input_field.html" %}
2424
{% else %}
25-
{% include "forms/includes/field.html" with is_application=True %}
25+
{% include "forms/includes/field.html" %}
2626
{% endif %}
2727
{% else %}
2828
<div class="max-w-none field-block prose">

hypha/apply/funds/views/submission_edit.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
)
3939
from hypha.apply.projects.forms import ProjectCreateForm
4040
from hypha.apply.projects.models.project import PROJECT_STATUS_CHOICES
41-
from hypha.apply.stream_forms.blocks import GroupToggleBlock
4241
from hypha.apply.todo.options import PROJECT_WAITING_PF, PROJECT_WAITING_SOW
4342
from hypha.apply.todo.views import add_task_to_user
4443
from hypha.apply.users.decorators import (
@@ -281,21 +280,13 @@ def get_form_class(self):
281280
When trying to save as draft, this method will return a version of form
282281
class that doesn't validate required fields while saving.
283282
284-
The method also disables any group toggle fields in the form, as they
285-
are not supported on edit forms.
286-
287283
Returns:
288284
class: The form class for the view.
289285
"""
290286
is_draft = True if "save" in self.request.POST else False
291287
form_fields = self.object.get_form_fields(
292288
draft=is_draft, form_data=self.object.raw_data, user=self.request.user
293289
)
294-
field_blocks = self.object.get_defined_fields()
295-
for field_block in field_blocks:
296-
if isinstance(field_block.block, GroupToggleBlock):
297-
# Disable group toggle field as it is not supported on edit forms.
298-
form_fields[field_block.id].disabled = True
299290
return type(
300291
"WagtailStreamForm", (self.object.submission_form_class,), form_fields
301292
)

hypha/apply/templates/forms/includes/field.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{% load i18n util_tags heroicons %}
22

33
{% with widget_type=field|widget_type field_type=field|field_type %}
4-
<div class="form__group {{ field.id_for_label }} form__group--{{ widget_type }} {% if widget_type == 'checkbox_input' %} form__group--checkbox{% endif %}{% if widget_type == 'clearable_file_input' or widget_type == 'multi_file_input' or widget_type == 'single_file_field_widget' or widget_type == 'multi_file_field_widget' %} form__group--file{% endif %}{% if field.help_text %} form__group--wrap{% endif %}{% if field.errors %} form__error{% endif %}{% if is_application and field.field.group_number > 1 %} field-group field-group-{{ field.field.group_number }}{% endif %}{% if is_application and field.field.grouper_for %} form-fields-grouper{% endif %}"
5-
{% if is_application and field.field.grouper_for %}
4+
<div class="form__group {{ field.id_for_label }} form__group--{{ widget_type }} {% if widget_type == 'checkbox_input' %} form__group--checkbox{% endif %}{% if widget_type == 'clearable_file_input' or widget_type == 'multi_file_input' or widget_type == 'single_file_field_widget' or widget_type == 'multi_file_field_widget' %} form__group--file{% endif %}{% if field.help_text %} form__group--wrap{% endif %}{% if field.errors %} form__error{% endif %}{% if field.field.group_number > 1 %} field-group field-group-{{ field.field.group_number }}{% endif %}{% if field.field.grouper_for %} form-fields-grouper{% endif %}"
5+
{% if field.field.grouper_for %}
66
data-grouper-for="{{ field.field.grouper_for }}"
77
data-toggle-on="{{ field.field.choices.0.0 }}"
88
data-toggle-off="{{ field.field.choices.1.0 }}"
99
{% endif %}
10-
{% if is_application and field.field.group_number > 1 %}
10+
{% if field.field.group_number > 1 %}
1111
data-hidden="{% if not show_all_group_fields and not field.field.visible %}true{% else %}false{% endif %}"
1212
data-required="{{ field.field.required_when_visible }}"
1313
{% endif %}

hypha/apply/templates/forms/includes/multi_input_field.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% load heroicons %}
22
<div
3-
class="form__item{% if field.help_text %} form__group--wrap{% endif %}{% if field.errors %} form__error{% endif %}{% if not field.initial %} multi-input-field-hidden{% endif %}{% if is_application and field.field.group_number > 1 %} field-group field-group-{{ field.field.group_number }}{% endif %}"
4-
{% if is_application and field.field.group_number > 1 %} data-hidden="{% if not show_all_group_fields %}true{% else %}false{% endif %}"{% endif %}
3+
class="form__item{% if field.help_text %} form__group--wrap{% endif %}{% if field.errors %} form__error{% endif %}{% if not field.initial %} multi-input-field-hidden{% endif %}{% if field.field.group_number > 1 %} field-group field-group-{{ field.field.group_number }}{% endif %}"
4+
{% if field.field.group_number > 1 %} data-hidden="{% if not show_all_group_fields %}true{% else %}false{% endif %}"{% endif %}
55
data-multi-field-for="{{ field.field.multi_input_id }}"
66
>
77
{{ field }}
@@ -11,7 +11,7 @@
1111

1212
{% if field.field.multi_input_add_button %}
1313
<button
14-
class="button button--primary button--narrow multi-input-add-btn my-2{% if is_application and field.field.group_number > 1 %} field-group field-group-{{ field.field.group_number }}{% endif %}"
14+
class="button button--primary button--narrow multi-input-add-btn my-2{% if field.field.group_number > 1 %} field-group field-group-{{ field.field.group_number }}{% endif %}"
1515
type="button" data-multi-field-id="{{ field.field.multi_input_id }}"
1616
data-multi-visibility-index="{{ field.field.visibility_index }}"
1717
data-multi-max-index="{{ field.field.max_index }}"

0 commit comments

Comments
 (0)