generated from dxw/rails-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fworks): quick edit framework evaluations
Jira: PWNN-1694
- Loading branch information
1 parent
84b69e5
commit 085a7f9
Showing
27 changed files
with
271 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Parse date fields as Dates | ||
# | ||
# Useful for extracting dates out of govuk_date_fields | ||
module HasDateParams | ||
extend ActiveSupport::Concern | ||
|
||
# @param form_param [Symbol] | ||
# @param date_field [Symbol] | ||
# | ||
# @return [Hash] | ||
def date_param(form_param, date_field) | ||
date = params.fetch(form_param, {}).permit(date_field) | ||
{ day: date["#{date_field}(3i)"], month: date["#{date_field}(2i)"], year: date["#{date_field}(1i)"] } | ||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
app/controllers/framework_requests/contract_start_dates_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/controllers/frameworks/evaluations/quick_edits_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class Frameworks::Evaluations::QuickEditsController < Frameworks::ApplicationController | ||
include HasDateParams | ||
|
||
before_action :evaluation, only: %i[edit update] | ||
|
||
def edit | ||
@quick_edit = @evaluation.quick_editor | ||
end | ||
|
||
def update | ||
@quick_edit = @evaluation.quick_editor(**quick_edit_params) | ||
|
||
if @quick_edit.valid? | ||
@quick_edit.save! | ||
redirect_to frameworks_root_path(anchor: "evaluations"), notice: "Evaluation updated" | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
private | ||
|
||
def evaluation | ||
@evaluation = Frameworks::Evaluation.find(params[:evaluation_id]) | ||
end | ||
|
||
def quick_edit_params | ||
form_params | ||
.except("next_key_date(3i)", "next_key_date(2i)", "next_key_date(1i)") | ||
.merge(next_key_date: date_param(:quick_edit, :next_key_date).compact_blank) | ||
.to_h | ||
.symbolize_keys | ||
end | ||
|
||
def form_params | ||
params.require(:quick_edit).permit(:note, :next_key_date, :next_key_date_description) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...port/case/validation/has_next_key_date.rb → .../concerns/validation/has_next_key_date.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Frameworks::Evaluation::Noteable | ||
extend ActiveSupport::Concern | ||
|
||
def add_note(note) | ||
log_activity_event("note_added", body: note) | ||
end | ||
|
||
def latest_note | ||
event = Frameworks::ActivityEvent.added_notes(self).last | ||
return if event.nil? | ||
|
||
OpenStruct.new( | ||
body: event.loaded_data.body, | ||
author: event.activity_log_item.actor.initials, | ||
date: event.created_at.strftime("%d %b %y"), | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Frameworks::Evaluation::QuickEditable | ||
extend ActiveSupport::Concern | ||
|
||
def quick_editor(note: latest_note&.body, next_key_date: self.next_key_date, next_key_date_description: self.next_key_date_description) | ||
Frameworks::Evaluation::QuickEditor.new(frameworks_evaluation: self, note:, next_key_date:, next_key_date_description:) | ||
end | ||
|
||
def quick_edit(details) | ||
transaction do | ||
update!(details.except(:note)) | ||
add_note(details[:note]) if details[:note].present? && details[:note] != latest_note&.body | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class Frameworks::Evaluation::QuickEditor | ||
include ActiveModel::Model | ||
include ActiveModel::Attributes | ||
include ActiveModel::Validations | ||
include Validation::HasNextKeyDate | ||
|
||
attribute :frameworks_evaluation | ||
attribute :note | ||
attribute :next_key_date | ||
attribute :next_key_date_description | ||
|
||
def save! | ||
frameworks_evaluation.quick_edit(note:, next_key_date:, next_key_date_description:) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...ws/frameworks/activity_log_items/activity/activity_event/evaluations/_note_added.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<% content_for :"#{activity.id}_subject" do %> | ||
Note Added | ||
<% end %> | ||
|
||
<% content_for :"#{activity.id}_description" do %> | ||
<%= activity.loaded_data.body %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,86 @@ | ||
<div class="govuk-grid-row case-panel"> | ||
<div class="govuk-grid-column-one-half govuk-!-margin-bottom-3"> | ||
<dl class="govuk-summary-list"> | ||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">Case ID</dt> | ||
<dd class="govuk-summary-list__value"><%= link_to evaluation.reference, frameworks_evaluation_path(evaluation, back_to: current_url_b64(:evaluations)), class: "govuk-link", "data-turbo" => false %></dd> | ||
</div> | ||
<div class="govuk-grid-column-full"> | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-one-half govuk-!-margin-bottom-3"> | ||
<dl class="govuk-summary-list"> | ||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">Case ID</dt> | ||
<dd class="govuk-summary-list__value"><%= link_to evaluation.reference, frameworks_evaluation_path(evaluation, back_to: current_url_b64(:evaluations)), class: "govuk-link", "data-turbo" => false %></dd> | ||
</div> | ||
|
||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">Framework Name</dt> | ||
<dd class="govuk-summary-list__value"><%= evaluation.framework_name %></dd> | ||
</div> | ||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">Framework Name</dt> | ||
<dd class="govuk-summary-list__value"><%= evaluation.framework_name %></dd> | ||
</div> | ||
|
||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">Framework Provider</dt> | ||
<dd class="govuk-summary-list__value"><%= evaluation.framework_provider_name %></dd> | ||
</div> | ||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">Framework Provider</dt> | ||
<dd class="govuk-summary-list__value"><%= evaluation.framework_provider_name %></dd> | ||
</div> | ||
|
||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">Categories</dt> | ||
<dd class="govuk-summary-list__value"><%= evaluation.framework_category_names %></dd> | ||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">Categories</dt> | ||
<dd class="govuk-summary-list__value"><%= evaluation.framework_category_names %></dd> | ||
</div> | ||
</dl> | ||
</div> | ||
</dl> | ||
</div> | ||
|
||
<div class="govuk-grid-column-one-half"> | ||
<dl class="govuk-summary-list"> | ||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">Status</dt> | ||
<dd class="govuk-summary-list__value"><%= evaluation.display_status %></dd> | ||
<div class="govuk-grid-column-one-half"> | ||
<dl class="govuk-summary-list"> | ||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">Status</dt> | ||
<dd class="govuk-summary-list__value"><%= evaluation.display_status %></dd> | ||
</div> | ||
|
||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">Assignee</dt> | ||
<dd class="govuk-summary-list__value"><%= evaluation.display_assignee %></dd> | ||
</div> | ||
|
||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">Updated</dt> | ||
<dd class="govuk-summary-list__value"><%= evaluation.display_last_updated %></dd> | ||
</div> | ||
</dl> | ||
</div> | ||
</div> | ||
|
||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">Assignee</dt> | ||
<dd class="govuk-summary-list__value"><%= evaluation.display_assignee %></dd> | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-full"> | ||
<p class="govuk-body"> | ||
<%= link_to "Quick edit", edit_frameworks_evaluation_quick_edit_path(evaluation, back_to: current_url_b64(:evaluations)), class: "govuk-link govuk-link--no-visited-state", "target" => "_top" %> | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">Updated</dt> | ||
<dd class="govuk-summary-list__value"><%= evaluation.display_last_updated %></dd> | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-one-half"> | ||
<% if evaluation.latest_note.present? %> | ||
<%= simple_format("<b>Note:</b> #{evaluation.latest_note.date} #{evaluation.latest_note.author} - " + evaluation.latest_note.body, class: "govuk-body") %> | ||
<% end %> | ||
</div> | ||
<div class="govuk-grid-column-one-half"> | ||
<% if evaluation.next_key_date.present? %> | ||
<dl class="govuk-summary-list"> | ||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key"> | ||
<%= I18n.t("support.case.label.next_key_date.label") %> | ||
</dt> | ||
<dd class="govuk-summary-list__value"> | ||
<%= evaluation.next_key_date_formatted %> | ||
</dd> | ||
</div> | ||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key"> | ||
<%= I18n.t("support.case.label.next_key_date.description2") %> | ||
</dt> | ||
<dd class="govuk-summary-list__value"> | ||
<%= simple_format(evaluation.next_key_date_description, class: "govuk-body") %> | ||
</dd> | ||
</div> | ||
</dl> | ||
<% end %> | ||
</div> | ||
</dl> | ||
</div> | ||
</div> | ||
</div> |
22 changes: 22 additions & 0 deletions
22
app/views/frameworks/evaluations/quick_edits/edit.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<%= content_for :title, "GHBS | Frameworks | Evaluation #{@evaluation.reference} | Quick edit" %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-one-third"> | ||
<h1 class="govuk-heading-l"><%= I18n.t("frameworks.evaluation.quick_edit.header", reference: @evaluation.reference) %></h1> | ||
<%= form_with model: @quick_edit, | ||
scope: :quick_edit, | ||
url: frameworks_evaluation_quick_edit_path(back_to: Base64.encode64(@back_url)), | ||
method: :patch do |form| %> | ||
<%= form.govuk_error_summary %> | ||
|
||
<%= form.govuk_text_area :note, rows: 5, label: { text: I18n.t("frameworks.evaluation.quick_edit.add_note"), size: "m" } %> | ||
|
||
<%= render "support/cases/components/next_key_date", form: form %> | ||
|
||
<div class="govuk-button-group"> | ||
<%= form.submit I18n.t("generic.button.save"), class: "govuk-button", role: "button" %> | ||
<%= link_to "Exit without saving", @back_url, class: "govuk-link govuk-link--no-visited-state" %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.