Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.5 KiB

module QuestionViewHelper
def caption(caption_text, page_header, conditional)
return nil unless caption_text && page_header.blank? && !conditional
{ text: caption_text.html_safe, size: "l" }
end
def legend(question, page_header, conditional)
{
text: [question.question_number_string(hidden: conditional || question.hide_question_number_on_page), question.header.html_safe].compact.join(" - "),
size: label_size(page_header, conditional, question),
tag: label_tag(page_header, conditional),
}
end
CLDC-2140 Scheme and location updates (#1455) * feat: update scheme status so incomplete unless has active locations * feat: update scheme typeahead text * feat: reject incomplete locations * feat: show completed/incomplete locations and validate when completed == 0 * feat: improve copy * feat: change active -> completed * feat: update scheme typeahead text * feat: reject incomplete locations * feat: show completed/incomplete locations and validate when completed == 0 * feat: improve copy * feat: change to confirmed to add clarification in code * feat: update scheme typeahead text * feat: reject incomplete locations * feat: show completed/incomplete locations and validate when completed == 0 * feat: improve copy * feat: update scheme typeahead text * feat: reject incomplete locations * feat: only confirm locations if complete (old) AND save button clicked (new) * feat: add unconfirmed scope * refactor: complete -> confirm * feat: fix tests * feat: update scheme typeahead text * feat: reject incomplete locations * feat: show completed/incomplete locations and validate when completed == 0 * feat: improve copy * feat: update scheme typeahead text * feat: reject incomplete locations * feat: only confirm locations if complete (old) AND save button clicked (new) * feat: add unconfirmed scope * refactor: complete -> confirm * feat: fix tests * feat: fix more tests * feat: fix more tests * refactor: rubocop * refactor: rubocop * refactor: rubocop * feat: add tests for incomplete schemes * refactor: linting * feat: test incomplete count too * feat: test unconfirmed locations aren't options in location_id * feat: test validation * feat: test when scheme is confirmed * feat: test when scheme is confirmed for support user * feat: test when location is confirmed * refactor: linting * refactor: consistent use of factorybot or not within a file * feat: confirm locations when complete even if save button not clicked, and update tests * refactor: simplify * refactor: simplify * refactor: move location helper methods to helpers * refactor: move scheme helper methods to helpers * refactor: formatting * refactor: po response * refactor: review response
2 years ago
def answer_option_synonyms(resource)
return unless resource.instance_of?(Scheme)
resource.locations.map(&:postcode).join(",")
end
def answer_option_append(resource)
return unless resource.instance_of?(Scheme)
confirmed_locations_count = resource.locations.confirmed.size
unconfirmed_locations_count = resource.locations.unconfirmed.size
"#{confirmed_locations_count} completed #{'location'.pluralize(confirmed_locations_count)}, #{unconfirmed_locations_count} incomplete #{'location'.pluralize(unconfirmed_locations_count)}"
end
def answer_option_hint(resource)
return unless resource.instance_of?(Scheme)
[resource.primary_client_group, resource.secondary_client_group].compact.join(", ")
end
private
def label_size(page_header, conditional, question)
return if question.plain_label.present?
page_header.blank? && !conditional ? "l" : "m"
end
def label_tag(page_header, conditional)
return "" if conditional
page_header.blank? ? "h1" : "div"
end
end