Skip to content

Commit

Permalink
Adds assessment status
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDancingClown committed Feb 20, 2024
1 parent 42eb511 commit b202db0
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
9 changes: 9 additions & 0 deletions app/controllers/assessor/form_answers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ def show
def edit
authorize resource, :edit?

unless assessor_assignment.status
assessor_assignment.update(status: "viewed")
end

@form = resource.award_form.decorate(answers: HashWithIndifferentAccess.new(resource.document))
end

Expand All @@ -120,4 +124,9 @@ def resolve_layout
"application-assessor"
end
end

def assessor_assignment
AssessorAssignment.find_by(assessor_id: current_assessor.id, form_answer_id: resource.id) ||
resource.assessor_assignments.build(assessor: current_assessor, award_year: @award_year)
end
end
1 change: 1 addition & 0 deletions app/services/assessor_assignment_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def save
resource.assign_attributes(update_params)
resource.editable = current_subject
resource.assessed_at = DateTime.now unless assignment_request?
resource.status = "in_progress"
resource.save
end

Expand Down
17 changes: 12 additions & 5 deletions app/views/assessor/form_answers/_list_body.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ tbody.govuk-table__body
em
' Not found

td.govuk-table__cell = obj.dashboard_status

td.govuk-table__cell
= obj.sub_group.try(:text) || "Not assigned"

td.govuk-table__cell
- if obj.ceremonial_county.present?
= obj.ceremonial_county.name
Expand All @@ -31,6 +26,18 @@ tbody.govuk-table__body
span.muted
= obj.last_updated_by

td.govuk-table__cell
- assignment = obj.assessor_assignments.find_by_assessor_id(current_assessor.id)
- if assignment&.submitted_at
strong.govuk-tag.govuk-tag--green
| Submitted
- elsif assignment&.status == "in_progress"
strong.govuk-tag.govuk-tag--yellow
| In progress
- elsif assignment&.status == "viewed"
strong.govuk-tag.govuk-tag--blue
| Viewed

td.govuk-table__cell
- aria_label = obj.company_or_nominee_name.present? ? "View submitted nomination, for #{obj.company_or_nominee_name}" : "View submitted nomination, nominee name not yet specified"
= link_to polymorphic_url([namespace_name, obj], search_id: params[:search_id], year: params[:year], page: params[:page]), aria: { label: aria_label }, class: 'govuk-link', target: :_blank do
Expand Down
6 changes: 2 additions & 4 deletions app/views/assessor/form_answers/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,14 @@ h1.govuk-heading-xl
tr.govuk-table__row
th.sortable.govuk-table__header scope="col" width="250"
= sort_link f, "Group name", @search, :company_or_nominee_name, disabled: @search.query?
th.govuk-table__header scope="col" width="250"
| Status
th.govuk-table__header scope="col" width="200"
| National assessor Sub-group
th.govuk-table__header scope="col" width="200"
| Lord Lieutenancy assigned
th.govuk-table__header scope="col" width="200"
| Type of group
th.sortable.govuk-table__header scope="col" width="130"
= sort_link f, "Last updated", @search, :audit_updated_at, disabled: @search.query?
th.govuk-table__header scope="col" width="150"
| Status
th.govuk-table__header scope="col" View
= render(partial: "list_body")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddStatusToAssessorAssignments < ActiveRecord::Migration[7.1]
def change
add_column :assessor_assignments, :status, :string
end
end
2 changes: 0 additions & 2 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3838,5 +3838,3 @@ INSERT INTO "schema_migrations" (version) VALUES
('20211013073349'),
('20211104074415'),
('20211214111643');


0 comments on commit b202db0

Please sign in to comment.