-
Notifications
You must be signed in to change notification settings - Fork 11
Display multiple branches on add/edit page #2744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SamJamCul
wants to merge
1
commit into
main
Choose a base branch
from
multiple-branches-questions-page
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -32,33 +32,57 @@ | |||||
| </dd> | ||||||
| </div> | ||||||
|
|
||||||
| <% page.routing_conditions.each do |condition| %> | ||||||
| <% condition_page = self.condition_page(condition) %> | ||||||
| <% condition_page_position = self.condition_page_position(condition) %> | ||||||
| <div id="<%= PageListComponent::ErrorSummary::View.error_id(condition.id) %>" class="govuk-summary-list__row app-page-list__row <%= class_names( "govuk-form-group--error": condition.has_routing_errors?) %>"> | ||||||
| <% if @form.group.multiple_branches_enabled? && page.routing_conditions.present? %> | ||||||
| <div class="govuk-summary-list__row"> | ||||||
| <dt class="govuk-summary-list__key govuk-summary-list__key app-page-list__key"> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| <%= t("page_conditions.condition_name", question_number: condition_page_position) %> | ||||||
| <%= t("page_conditions.condition_name", question_number: page.position) %> | ||||||
| </dt> | ||||||
|
|
||||||
| <dd class="govuk-summary-list__value"> | ||||||
| <ul class="govuk-list govuk-!-margin-0"> | ||||||
| <% condition.validation_errors.each do |error| %> | ||||||
| <li class="app-page_list__route-text--error"> | ||||||
| <%= PageListComponent::ErrorSummary::View.generate_error_message(error.name, condition:, page: condition_page) %> | ||||||
| </li> | ||||||
| <% end %> | ||||||
| </ul> | ||||||
|
|
||||||
| <p> | ||||||
| <%= condition_description(condition) %> | ||||||
| </p> | ||||||
|
|
||||||
| <dd class="govuk-summary-list__actions govuk-!-padding-bottom-6"> | ||||||
| <%= govuk_link_to show_routes_path(form_id: @form.id, page_id: condition.check_page_id) do %> | ||||||
| <%= t("forms.form_overview.edit_with_visually_hidden_text_html", visually_hidden_text: t("page_conditions.condition_name", question_number: condition_page_position)) %> | ||||||
| <% if page.routing_conditions.first.answer_value.present? %> | ||||||
| <p><%= I18n.t("page_conditions.if_answer_is") %></p> | ||||||
| <ul class="govuk-list govuk-list--bullet"> | ||||||
| <% page.routing_conditions.each do |condition| %> | ||||||
| <li> | ||||||
| <%= branch_condition_description(condition) %> | ||||||
| </li> | ||||||
| <% end %> | ||||||
| </ul> | ||||||
| <% else %> | ||||||
| <p> | ||||||
| <%= branch_condition_description(page.routing_conditions.first) %> | ||||||
| </p> | ||||||
| <% end %> | ||||||
| </dd> | ||||||
| </div> | ||||||
| <% else %> | ||||||
| <% page.routing_conditions.each do |condition| %> | ||||||
| <% condition_page = self.condition_page(condition) %> | ||||||
| <% condition_page_position = self.condition_page_position(condition) %> | ||||||
| <div id="<%= PageListComponent::ErrorSummary::View.error_id(condition.id) %>" class="govuk-summary-list__row app-page-list__row <%= class_names( "govuk-form-group--error": condition.has_routing_errors?) %>"> | ||||||
| <dt class="govuk-summary-list__key govuk-summary-list__key app-page-list__key"> | ||||||
| <%= t("page_conditions.condition_name", question_number: condition_page_position) %> | ||||||
| </dt> | ||||||
|
|
||||||
| <dd class="govuk-summary-list__value"> | ||||||
| <ul class="govuk-list govuk-!-margin-0"> | ||||||
| <% condition.validation_errors.each do |error| %> | ||||||
| <li class="app-page_list__route-text--error"> | ||||||
| <%= PageListComponent::ErrorSummary::View.generate_error_message(error.name, condition:, page: condition_page) %> | ||||||
| </li> | ||||||
| <% end %> | ||||||
| </ul> | ||||||
|
|
||||||
| <p> | ||||||
| <%= condition_description(condition) %> | ||||||
| </p> | ||||||
|
|
||||||
| <dd class="govuk-summary-list__actions govuk-!-padding-bottom-6"> | ||||||
| <%= govuk_link_to show_routes_path(form_id: @form.id, page_id: condition.check_page_id) do %> | ||||||
| <%= t("forms.form_overview.edit_with_visually_hidden_text_html", visually_hidden_text: t("page_conditions.condition_name", question_number: condition_page_position)) %> | ||||||
| <% end %> | ||||||
| </dd> | ||||||
| </div> | ||||||
| <% end %> | ||||||
| <% end %> | ||||||
| <% end %> | ||||||
| </dl> | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,14 @@ def condition_description(condition) | |
| end | ||
| end | ||
|
|
||
| def branch_condition_description(condition) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about calling this |
||
| if condition.answer_value.present? | ||
| I18n.t("page_conditions.branch_condition_description", goto_page_question_text: goto_page_text_for_condition(condition), answer_value: answer_value_text_for_condition(condition)) | ||
| else | ||
| I18n.t("page_conditions.unconditional_description", goto_page_question_text: goto_page_text_for_condition(condition)) | ||
| end | ||
| end | ||
|
|
||
| def condition_check_page_text(condition) | ||
| check_page = @pages.find { |page| page.id == condition.check_page_id } | ||
| I18n.t("page_conditions.condition_check_page_text", check_page_question_text: check_page.question_text) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest using the feature service to check whether the feature is enabled, rather than looking at the form record directly.
Then in the tests whether the flag is enabled or not can be changed by mocking the feature service with the helpers in spec/support/features.rb, removing the need to add a group to the form in each test.