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): basic framework register lists frameworks
- Loading branch information
Showing
20 changed files
with
246 additions
and
24 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
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,28 @@ | ||
class Frameworks::FrameworksController < Frameworks::ApplicationController | ||
before_action :redirect_to_register_tab, unless: :turbo_frame_request?, only: :index | ||
before_action :set_back_url, only: %i[new show] | ||
|
||
def new; end | ||
|
||
def index | ||
@frameworks = Frameworks::Framework.paginate(page: params[:frameworks_page]) | ||
end | ||
|
||
def show | ||
@framework = Frameworks::Framework.find(params[:id]) | ||
end | ||
|
||
private | ||
|
||
def filter_form_params | ||
params.require(:frameworks_filter).permit(:sort_by, :sort_order, :status, :provider) | ||
end | ||
|
||
def set_back_url | ||
@back_url = back_link_param | ||
end | ||
|
||
def redirect_to_register_tab | ||
redirect_to frameworks_root_path(anchor: "frameworks-register", **request.params.except(:controller, :action)) | ||
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
class Frameworks::Framework < ApplicationRecord | ||
include FafImportable | ||
include StatusChangeable | ||
include Presentable | ||
|
||
belongs_to :provider | ||
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,16 @@ | ||
module Frameworks::Framework::Filterable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
end | ||
|
||
class_name do | ||
def filtering(params) | ||
Filter.new(params) | ||
end | ||
|
||
def filtered_by(params) | ||
filtering(params).results | ||
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,25 @@ | ||
class Frameworks::Framework::Filtering | ||
include ActiveModel::Model | ||
include ActiveModel::Attributes | ||
include ActiveModel::Validations | ||
|
||
attribute :scoped_frameworks, default: -> { Frameworks::Framework } | ||
attribute :status, default: -> { [] } | ||
attribute :provider, default: -> { [] } | ||
attribute :sort_by | ||
attribute :sort_order | ||
|
||
def results | ||
results = scoped_frameworks | ||
|
||
filters.each_value { |filter| results = filter.filter(results) } | ||
|
||
results.sorted_by(sort_by:, sort_order:) | ||
end | ||
|
||
private | ||
|
||
def filters | ||
[] | ||
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,7 @@ | ||
module Frameworks::Framework::Presentable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
delegate :name, to: :provider, prefix: true | ||
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 |
---|---|---|
@@ -1 +1,13 @@ | ||
<h1 class="govuk-header-l">Frameworks Portal</h1> | ||
<div class="govuk-tabs" data-module="govuk-tabs" data-component="select-tab"> | ||
<ul class="govuk-tabs__list"> | ||
<li class="govuk-tabs__list-item govuk-tabs__list-item--selected"> | ||
<%= link_to "Frameworks Register", "#frameworks-register", class: "govuk-tabs__tab" %> | ||
</li> | ||
</ul> | ||
|
||
<%= turbo_frame_tag "frameworks-register-frame", src: frameworks_frameworks_path(frameworks_page: params[:frameworks_page]) do %> | ||
<div id="frameworks-register" class="govuk-tabs__panel govuk-tabs__panel"> | ||
<p class="govuk-body">Loading...</p> | ||
</div> | ||
<% end %> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<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">Framework Ref</dt> | ||
<dd class="govuk-summary-list__value"><%= link_to framework.provider_reference, frameworks_framework_path(framework, back_to: current_url_b64(:frameworks_register)), 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"><%= 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"><%= framework.provider_name %></dd> | ||
</div> | ||
|
||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">Category tags</dt> | ||
<dd class="govuk-summary-list__value"></dd> | ||
</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">Is approved?</dt> | ||
<dd class="govuk-summary-list__value"><%= render "framework_status", framework: %></dd> | ||
</div> | ||
|
||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">Start date</dt> | ||
<dd class="govuk-summary-list__value"><%= framework.starts_at&.strftime("%d %b %Y") %></dd> | ||
</div> | ||
|
||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key">End date</dt> | ||
<dd class="govuk-summary-list__value"><%= framework.ends_at&.strftime("%d %b %Y") %></dd> | ||
</div> | ||
</dl> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<strong class="govuk-tag <%= "govuk-tag--yellow" if framework.pending_evaluation? %> <%= "govuk-tag--grey" if framework.not_approved? %>"> | ||
<%= framework.status.humanize %> | ||
</strong> |
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,3 @@ | ||
<div class="filters-panel"> | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%= turbo_frame_tag "frameworks-register-frame" do %> | ||
<div id="frameworks-register" class="govuk-tabs__panel"> | ||
|
||
<div class="case-list govuk-grid-row"> | ||
<div class="govuk-grid-column-one-quarter"> | ||
<%= link_to "Add Framework", new_frameworks_framework_path(back_to: current_url_b64(:frameworks_register)), class: "govuk-button", "data-turbo" => false %> | ||
|
||
<%= render "index_filters" %> | ||
</div> | ||
|
||
<div class="govuk-grid-column-three-quarters"> | ||
<%= render @frameworks %> | ||
<%= render "components/pagination", records: @frameworks, page_param_name: :frameworks_page, pagination_params: { anchor: "frameworks-register" } %> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> |
Empty file.
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,3 @@ | ||
<h1 class="govuk-heading-l"><%= @framework.name %></h1> | ||
|
||
<p class="govuk-body">Content here</p> |
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
17 changes: 17 additions & 0 deletions
17
spec/features/frameworks/register/agent_can_browse_frameworks_register_spec.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,17 @@ | ||
require "rails_helper" | ||
|
||
describe "Agent can browse frameworks register", js: true do | ||
include_context "with a framework evaluation agent" | ||
|
||
before do | ||
create(:frameworks_framework, provider_reference: "books", name: "Books & Stationary") | ||
create(:frameworks_framework, provider_reference: "legal", name: "Legal services") | ||
create(:frameworks_framework, provider_reference: "water", name: "Water services") | ||
end | ||
|
||
it "lists all frameworks" do | ||
visit frameworks_root_path | ||
expect(page).to have_summary("Framework Ref", "books") | ||
expect(page).to have_summary("Framework Name", "Books & Stationary") | ||
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,15 @@ | ||
RSpec::Matchers.define :have_summary do |label, text| | ||
match do |page| | ||
page.all(".govuk-summary-list__key", text: label).any? { |key| key.sibling(".govuk-summary-list__value", text:).present? } | ||
end | ||
|
||
failure_message do |page| | ||
available_keys = page.all(".govuk-summary-list__key").map(&:text) | ||
<<~MESSAGE | ||
expected to find summary row with label "#{label}" and text "#{text}" but did not. | ||
Found summary keys: | ||
#{available_keys.join("\n")} | ||
MESSAGE | ||
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