Skip to content

Commit

Permalink
edit evaluations
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantk committed Nov 2, 2023
1 parent 907ced5 commit e967742
Show file tree
Hide file tree
Showing 18 changed files with 67 additions and 37 deletions.
2 changes: 1 addition & 1 deletion app/controllers/frameworks/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ def authorize_agent_scope = :access_frameworks_portal?
def portal_namespace = :frameworks

def set_back_url
@back_url = back_link_param if back_link_param.present?
@back_url = back_link_param || request.referer
end
end
2 changes: 0 additions & 2 deletions app/controllers/frameworks/evaluation_contacts_controller.rb

This file was deleted.

5 changes: 5 additions & 0 deletions app/controllers/frameworks/evaluations/contacts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Frameworks::Evaluations::ContactsController < Frameworks::ApplicationController
def edit; end

def update; end
end
19 changes: 17 additions & 2 deletions app/controllers/frameworks/evaluations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Frameworks::EvaluationsController < Frameworks::ApplicationController
before_action :redirect_to_register_tab, unless: :turbo_frame_request?, only: :index
before_action :set_form_options, only: %i[new create]
before_action :set_form_options, only: %i[new edit create update]

content_security_policy do |policy|
policy.style_src_attr :unsafe_inline
Expand Down Expand Up @@ -30,11 +30,26 @@ def create
end
end

def edit
@evaluation = Frameworks::Evaluation.find(params[:id])
end

def update
@evaluation = Frameworks::Evaluation.find(params[:id])

if @evaluation.update(evaluation_params)
redirect_to @evaluation
else
render :edit
end
end

private

def set_form_options
@frameworks = Frameworks::Framework.for_evaluation
@agents = Support::Agent.framework_evaluators
@contacts = Frameworks::ProviderContact.all
end

def filter_form_params
Expand All @@ -45,7 +60,7 @@ def filter_form_params
end

def evaluation_params
params.require(:frameworks_evaluation).permit(:framework_id, :assignee_id)
params.require(:frameworks_evaluation).permit(:framework_id, :assignee_id, :contact_id)
end

def redirect_to_register_tab
Expand Down
2 changes: 1 addition & 1 deletion app/models/frameworks/evaluation/quick_editable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def quick_editor(note: latest_note&.body, next_key_date: self.next_key_date, nex

def quick_edit(details)
transaction do
update!(details) if details[:next_key_date_description].present?
update!(details.except(:note)) if details[:next_key_date_description].present?
add_note(details[:note]) if details[:note].present? && details[:note] != latest_note&.body
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/frameworks/activity_log_items/_history.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
</p>

<% if content_for?(:"#{activity_log_item.activity_id}_description") %>
<p class="hods-timeline__description">
<div class="hods-timeline__description">
<%= yield :"#{activity_log_item.activity_id}_description" %>
</p>
</div>
<% end %>
</div>
<% end %>
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<% end %>

<% content_for :"#{activity.id}_description" do %>
<%= activity.loaded_data.body %>
<%= simple_format(activity.loaded_data.body) %>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
% content_for :"#{activity.id}_subject" do %>
Added category "<%= activity.loaded_data.support_category.title %>"
<% content_for :"#{activity.id}_subject" do %>
Category "<%= activity.loaded_data.support_category.title %>" added
<% end %>
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<% content_for :"#{activity.id}_subject" do %>
Evaluation started
<% end %>

<% content_for :"#{activity.id}_description" do %>
<%= link_to "View Evalutaion #{activity.loaded_data.evaluation.reference}", activity.loaded_data.evaluation, class: "govuk-link", "data-turbo" => false %>
Evaluation started: <%= link_to activity.loaded_data.evaluation.reference, activity.loaded_data.evaluation, class: "govuk-link", "data-turbo" => false %>
<% end %>
21 changes: 21 additions & 0 deletions app/views/frameworks/evaluations/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<% edit ||= false %>

<%= form_for @evaluation do |f| %>
<%= f.govuk_select :framework_id, @frameworks.map {|framework| ["#{framework.reference_and_name} (#{framework.provider_name})", framework.id] },
disabled: edit,
options: { include_blank: "Select a framework" },
label: { text: "Framework", size: "m" } %>

<%= f.govuk_select :contact_id, @contacts.map {|contact| ["#{contact.name} (#{contact.provider_name})", contact.id] },
options: { include_blank: "Select a contact" },
label: { text: "Contact at provider", size: "m" } %>

<%= f.govuk_select :assignee_id, @agents.map {|agent| [agent.full_name, agent.id] },
options: { include_blank: "Select an agent" },
label: { text: "Case Owner", size: "m" } %>

<div class="govuk-button-group flex-align-center">
<%= f.govuk_submit edit ? "Save changes" : "Create evaluation" %>
<%= link_to "Cancel", @back_url, class: "govuk-link govuk-link--no-visited-state" %>
</div>
<% end %>
8 changes: 8 additions & 0 deletions app/views/frameworks/evaluations/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%= content_for :title, "GHBS | Frameworks | Evaluation | #{@evaluation.reference} | Edit" %>

<span class="govuk-caption-l">[<%= @evaluation.reference %>] Framework Evaluation</span>
<h1 class="govuk-heading-l">Edit Basic Details</h1>

<div class="govuk-!-width-two-thirds">
<%= render "form", edit: true %>
</div>
15 changes: 1 addition & 14 deletions app/views/frameworks/evaluations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,5 @@
<h1 class="govuk-heading-l">New Framework Evaluation</h1>

<div class="govuk-!-width-two-thirds">
<%= form_for @evaluation do |f| %>
<%= f.govuk_select :framework_id, @frameworks.map {|framework| [framework.reference_and_name, framework.id] },
options: { include_blank: "Select a framework" },
label: { text: "Framework" } %>

<%= f.govuk_select :assignee_id, @agents.map {|agent| [agent.full_name, agent.id] },
options: { include_blank: "Select an agent" },
label: { text: "Assignee" } %>

<div class="govuk-button-group flex-align-center">
<%= f.govuk_submit "Create evaluation" %>
<%= link_to "Cancel", @back_url, class: "govuk-link govuk-link--no-visited-state" %>
</div>
<% end %>
<%= render "form" %>
</div>
2 changes: 1 addition & 1 deletion app/views/frameworks/evaluations/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<span><strong class="govuk-tag govuk-tag--red">ACTION</strong></span>
<% end %>
<span><%= @evaluation.display_status %></span>
<span class="govuk-body">Case Owner: <%= @evaluation.display_assignee %></span>
<span class="govuk-body">Case Owner: <%= @evaluation.display_assignee %> (<%= link_to "Change", edit_frameworks_evaluation_path(@evaluation, back_to: current_url_b64, redirect_back: current_url_b64), class: "govuk-link govuk-link--no-visited-state", "target" => "_top" %>)</span>
</div>

<div class="govuk-grid-row">
Expand Down
4 changes: 3 additions & 1 deletion app/views/frameworks/evaluations/show/_framework.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
<%= link_to @evaluation.contact_name, frameworks_provider_contact_path(@evaluation.contact, back_to: current_url_b64(:framework)), class: "govuk-link", "data-turbo" => false %>
<% end %>
</dd>
<dd class="govuk-summary-list__actions"><%= link_to "Change", "#", class: "govuk-link", "data-turbo" => false %></dd>
<dd class="govuk-summary-list__actions">
<%= link_to "Change", edit_frameworks_evaluation_path(@evaluation, back_to: current_url_b64, redirect_back: current_url_b64), class: "govuk-link govuk-link--no-visited-state", "target" => "_top" %>
</dd>
</div>

<div class="govuk-summary-list__row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
visit frameworks_framework_path(framework)
click_on "Evaluations"
click_on "Add Evaluation"
select agent.full_name, from: "Assignee"
select agent.full_name, from: "Case Owner"

expect { click_on "Create evaluation" }.to change { framework.reload.evaluations.count }.from(0).to(1)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

it "can view the details of a framework" do
visit frameworks_root_path
puts Frameworks::ActivityLogItem.pluck :activity_type
click_on "books"
expect(page).to have_title("Books & Stationary")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
click_on "Save changes"

expect(page).to have_summary("Categories", "Laptops, Electricity")
click_on "History"
expect(page).to have_content('Added category "Laptops" to framework')
expect(page).to have_content('Added category "Electricity" to framework')
expect(page).to have_content('Category "Laptops" added')
expect(page).to have_content('Category "Electricity" added')
end
end

0 comments on commit e967742

Please sign in to comment.