Browse Source
* add synonyms, appended text and hint text to the autocomplete * update test part 1 * refactor synonym, append and hint methods to take in resource * Fix tests and lint * Change min autocomplete character length to 1 * change testpull/701/head
kosiakkatrina
2 years ago
committed by
GitHub
8 changed files with 106 additions and 18 deletions
@ -1,13 +1,18 @@ |
|||||||
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %> |
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %> |
||||||
|
|
||||||
<% selected = @case_log.public_send(question.id) || "" %> |
<% selected = @case_log.public_send(question.id) || "" %> |
||||||
<% answers = question.displayed_answer_options(@case_log).map { |key, value| OpenStruct.new(id: key, name: value) } %> |
<% answers = question.displayed_answer_options(@case_log).map { |key, value| OpenStruct.new(id: key, name: value.respond_to?(:service_name) ? value.service_name : nil, resource: value) } %> |
||||||
<%= f.govuk_collection_select question.id.to_sym, |
<%= f.govuk_select(question.id.to_sym, |
||||||
answers, |
label: legend(question, page_header, conditional), |
||||||
:id, |
"data-controller": "accessible-autocomplete", |
||||||
:name, |
caption: caption(caption_text, page_header, conditional), |
||||||
caption: caption(caption_text, page_header, conditional), |
hint: { text: question.hint_text&.html_safe }) do %> |
||||||
label: legend(question, page_header, conditional), |
<% answers.each do |answer| %> |
||||||
hint: { text: question.hint_text&.html_safe }, |
<option value="<%= answer.id %>" |
||||||
options: { disabled: [""], selected: }, |
data-synonyms="<%= question.answer_option_synonyms(answer.resource) %>" |
||||||
"data-controller": "accessible-autocomplete" %> |
data-append="<%= question.answer_option_append(answer.resource) %>" |
||||||
|
data-hint="<%= question.answer_option_hint(answer.resource) %>" |
||||||
|
<%= @case_log[question.id] == answer.name || @case_log[question.id] == answer.resource || @case_log[question.id].to_s == answer.id ? "selected" : "" %> |
||||||
|
<%= answer.id == "" ? "disabled" : "" %>><%= answer.name || answer.resource %></option> |
||||||
|
<% end %> |
||||||
|
<% end %> |
||||||
|
Loading…
Reference in new issue