22 changed files with 69 additions and 89 deletions
@ -1,18 +1,18 @@ |
|||||||
class CheckAnswersSummaryListCardComponent < ViewComponent::Base |
class CheckAnswersSummaryListCardComponent < ViewComponent::Base |
||||||
attr_reader :questions, :lettings_log, :user |
attr_reader :questions, :log, :user |
||||||
|
|
||||||
def initialize(questions:, lettings_log:, user:) |
def initialize(questions:, log:, user:) |
||||||
@questions = questions |
@questions = questions |
||||||
@lettings_log = lettings_log |
@log = log |
||||||
@user = user |
@user = user |
||||||
super |
super |
||||||
end |
end |
||||||
|
|
||||||
def applicable_questions |
def applicable_questions |
||||||
questions.reject { |q| q.hidden_in_check_answers?(lettings_log, user) } |
questions.reject { |q| q.hidden_in_check_answers?(log, user) } |
||||||
end |
end |
||||||
|
|
||||||
def get_answer_label(question) |
def get_answer_label(question) |
||||||
question.answer_label(lettings_log).presence || "<span class=\"app-!-colour-muted\">You didn’t answer this question</span>".html_safe |
question.answer_label(log).presence || "<span class=\"app-!-colour-muted\">You didn’t answer this question</span>".html_safe |
||||||
end |
end |
||||||
end |
end |
||||||
|
@ -0,0 +1,30 @@ |
|||||||
|
class AllLog < ApplicationRecord |
||||||
|
self.table_name = :logs |
||||||
|
|
||||||
|
STATUS = { "not_started" => 0, "in_progress" => 1, "completed" => 2 }.freeze |
||||||
|
enum status: STATUS |
||||||
|
|
||||||
|
def read_only? |
||||||
|
true |
||||||
|
end |
||||||
|
|
||||||
|
def tenancycode? |
||||||
|
log_type == "lettings" |
||||||
|
end |
||||||
|
|
||||||
|
def needstype? |
||||||
|
log_type == "lettings" |
||||||
|
end |
||||||
|
|
||||||
|
def startdate? |
||||||
|
false |
||||||
|
end |
||||||
|
|
||||||
|
def is_general_needs? |
||||||
|
log_type == "lettings" |
||||||
|
end |
||||||
|
|
||||||
|
def created_by |
||||||
|
User.find(created_by_id) |
||||||
|
end |
||||||
|
end |
@ -1,25 +0,0 @@ |
|||||||
<ol class="app-task-list govuk-!-margin-top-8"> |
|
||||||
<% @sales_log.form.sections.map do |section| %> |
|
||||||
<li> |
|
||||||
<h2 class="app-task-list__section-heading"> |
|
||||||
<%= section.label %> |
|
||||||
</h2> |
|
||||||
<% if section.description %> |
|
||||||
<p class="govuk-body"><%= section.description.html_safe %></p> |
|
||||||
<% end %> |
|
||||||
<ul class="app-task-list__items"> |
|
||||||
<% section.subsections.map do |subsection| %> |
|
||||||
<% if subsection.applicable_questions(@sales_log).count > 0 || !subsection.enabled?(@sales_log) %> |
|
||||||
<% subsection_status = subsection.status(@sales_log) %> |
|
||||||
<li class="app-task-list__item"> |
|
||||||
<span class="app-task-list__task-name" id="<%= subsection.id.dasherize %>"> |
|
||||||
<%= subsection_link(subsection, @sales_log, current_user) %> |
|
||||||
</span> |
|
||||||
<%= status_tag(subsection_status, "app-task-list__tag") %> |
|
||||||
</li> |
|
||||||
<% end %> |
|
||||||
<% end %> |
|
||||||
</ul> |
|
||||||
</li> |
|
||||||
<% end %> |
|
||||||
</ol> |
|
@ -1,37 +0,0 @@ |
|||||||
<% content_for :title, "Log #{@sales_log.id}" %> |
|
||||||
<% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: { |
|
||||||
"Logs" => "/logs", |
|
||||||
content_for(:title) => "", |
|
||||||
}) %> |
|
||||||
|
|
||||||
<div class="govuk-grid-row"> |
|
||||||
<div class="govuk-grid-column-two-thirds-from-desktop"> |
|
||||||
<h1 class="govuk-heading-xl"> |
|
||||||
<%= content_for(:title) %> |
|
||||||
</h1> |
|
||||||
|
|
||||||
<% if @sales_log.status == "in_progress" %> |
|
||||||
<p class="govuk-body govuk-!-margin-bottom-7"><%= get_subsections_count(@sales_log, :completed) %> of <%= get_subsections_count(@sales_log, :all) %> sections completed.</p> |
|
||||||
<p class="govuk-body govuk-!-margin-bottom-2"> |
|
||||||
<% next_incomplete_section = get_next_incomplete_section(@sales_log) %> |
|
||||||
</p> |
|
||||||
<p> |
|
||||||
<% if next_incomplete_section.present? %> |
|
||||||
<a class="app-section-skip-link" href="#<%= next_incomplete_section.id.dasherize %>"> |
|
||||||
Skip to next incomplete section: <%= next_incomplete_section.label %> |
|
||||||
</a> |
|
||||||
<% end %> |
|
||||||
</p> |
|
||||||
<% elsif @sales_log.status == "not_started" %> |
|
||||||
<p class="govuk-body">This log has not been started.</p> |
|
||||||
<% elsif @sales_log.status == "completed" %> |
|
||||||
<p class="govuk-body"> |
|
||||||
<%= status_tag(@sales_log.status) %> |
|
||||||
</p> |
|
||||||
<p class="govuk-body"> |
|
||||||
You can <%= govuk_link_to "review and make changes to this log", "/logs/#{@sales_log.id}/review" %> until 2nd June <%= @sales_log.collection_start_year.present? ? @sales_log.collection_start_year + 1 : "" %>. |
|
||||||
</p> |
|
||||||
<% end %> |
|
||||||
<%= render "tasklist" %> |
|
||||||
</div> |
|
||||||
</div> |
|
Loading…
Reference in new issue