diff --git a/app/controllers/frameworks/application_controller.rb b/app/controllers/frameworks/application_controller.rb
index 851c92c72..089862853 100644
--- a/app/controllers/frameworks/application_controller.rb
+++ b/app/controllers/frameworks/application_controller.rb
@@ -1,6 +1,7 @@
class Frameworks::ApplicationController < ApplicationController
include SupportAgents
before_action { Current.actor = current_agent }
+ before_action :set_back_url
private
@@ -8,6 +9,6 @@ def authorize_agent_scope = :access_frameworks_portal?
def portal_namespace = :frameworks
def set_back_url
- @back_url = back_link_param
+ @back_url = back_link_param if back_link_param.present?
end
end
diff --git a/app/controllers/frameworks/frameworks_controller.rb b/app/controllers/frameworks/frameworks_controller.rb
index 9dac9df6b..e41677c05 100644
--- a/app/controllers/frameworks/frameworks_controller.rb
+++ b/app/controllers/frameworks/frameworks_controller.rb
@@ -1,12 +1,15 @@
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]
- before_action :load_form_options, only: %i[new create]
+ before_action :load_form_options, only: %i[new edit create update]
def new
@framework = Frameworks::Framework.new
end
+ def edit
+ @framework = Frameworks::Framework.find(params[:id])
+ end
+
def index
@filtering = Frameworks::Framework.filtering(filter_form_params)
@frameworks = @filtering.results.paginate(page: params[:frameworks_page])
@@ -27,6 +30,16 @@ def create
end
end
+ def update
+ @framework = Frameworks::Framework.find(params[:id])
+
+ if @framework.update(framework_params)
+ redirect_to frameworks_framework_path(@framework)
+ else
+ render :edit
+ end
+ end
+
private
def load_form_options
diff --git a/app/controllers/frameworks/provider_contacts_controller.rb b/app/controllers/frameworks/provider_contacts_controller.rb
index 0d60a9dda..1feeee5b3 100644
--- a/app/controllers/frameworks/provider_contacts_controller.rb
+++ b/app/controllers/frameworks/provider_contacts_controller.rb
@@ -1,6 +1,6 @@
class Frameworks::ProviderContactsController < Frameworks::ApplicationController
before_action :redirect_to_register_tab, unless: :turbo_frame_request?, only: :index
- before_action :set_back_url, only: %i[show edit]
+ before_action :load_form_options, only: %i[new edit update create]
def index
@filtering = Frameworks::ProviderContact.filtering(filter_form_params)
@@ -12,10 +12,24 @@ def show
@activity_log_items = @provider_contact.activity_log_items.paginate(page: params[:activities_page])
end
+ def new
+ @provider_contact = Frameworks::ProviderContact.new
+ end
+
def edit
@provider_contact = Frameworks::ProviderContact.find(params[:id])
end
+ def create
+ @provider_contact = Frameworks::ProviderContact.new(provider_contact_params)
+
+ if @provider_contact.save
+ redirect_to frameworks_provider_contact_path(@provider_contact)
+ else
+ render :new
+ end
+ end
+
def update
@provider_contact = Frameworks::ProviderContact.find(params[:id])
@@ -28,12 +42,16 @@ def update
private
+ def load_form_options
+ @providers = Frameworks::Provider.all
+ end
+
def filter_form_params
params.fetch(:provider_contacts_filter, {}).permit(:sort_by, :sort_order, provider: [])
end
def provider_contact_params
- params.require(:frameworks_provider_contact).permit(:name, :email, :phone)
+ params.require(:frameworks_provider_contact).permit(:name, :email, :phone, :provider_id)
end
def redirect_to_register_tab
diff --git a/app/controllers/frameworks/providers_controller.rb b/app/controllers/frameworks/providers_controller.rb
index 546314ebe..a97579c32 100644
--- a/app/controllers/frameworks/providers_controller.rb
+++ b/app/controllers/frameworks/providers_controller.rb
@@ -1,6 +1,5 @@
class Frameworks::ProvidersController < Frameworks::ApplicationController
before_action :redirect_to_register_tab, unless: :turbo_frame_request?, only: :index
- before_action :set_back_url, only: %i[new show]
def index
@filtering = Frameworks::Provider.filtering(filter_form_params)
@@ -12,8 +11,40 @@ def show
@activity_log_items = @provider.activity_log_items.paginate(page: params[:activities_page])
end
+ def new
+ @provider = Frameworks::Provider.new
+ end
+
+ def edit
+ @provider = Frameworks::Provider.find(params[:id])
+ end
+
+ def create
+ @provider = Frameworks::Provider.new(provider_params)
+
+ if @provider.save
+ redirect_to frameworks_provider_path(@provider)
+ else
+ render :new
+ end
+ end
+
+ def update
+ @provider = Frameworks::Provider.find(params[:id])
+
+ if @provider.update(provider_params)
+ redirect_to frameworks_provider_path(@provider)
+ else
+ render :edit
+ end
+ end
+
private
+ def provider_params
+ params.require(:frameworks_provider).permit(:name, :short_name)
+ end
+
def filter_form_params
params.fetch(:providers_filter, {}).permit(
:sort_by, :sort_order
diff --git a/app/models/frameworks/provider/sortable.rb b/app/models/frameworks/provider/sortable.rb
index 2b0e34d0e..02063d890 100644
--- a/app/models/frameworks/provider/sortable.rb
+++ b/app/models/frameworks/provider/sortable.rb
@@ -14,7 +14,7 @@ def sorted_by(sort_by:, sort_order:)
def available_sort_options
[
- ["Short Name", "short_name"]
+ ["Short Name", "short_name"],
]
end
diff --git a/app/models/frameworks/provider_contact.rb b/app/models/frameworks/provider_contact.rb
index 534e3bd37..79470e84a 100644
--- a/app/models/frameworks/provider_contact.rb
+++ b/app/models/frameworks/provider_contact.rb
@@ -10,4 +10,5 @@ class Frameworks::ProviderContact < ApplicationRecord
validates :name, presence: true
validates :email, presence: true
+ validates :provider_id, presence: true
end
diff --git a/app/views/frameworks/frameworks/_form.html.erb b/app/views/frameworks/frameworks/_form.html.erb
new file mode 100644
index 000000000..164044f3e
--- /dev/null
+++ b/app/views/frameworks/frameworks/_form.html.erb
@@ -0,0 +1,53 @@
+<%= f.govuk_fieldset legend: { text: 'Basic Details' } do %>
+ <%= f.govuk_text_field :name %>
+ <%= f.govuk_text_field :short_name, width: "one-third", label: { text: "Abbreviated name" } %>
+ <%= f.govuk_text_field :url, label: { text: "Providers URL" } %>
+ <%= f.govuk_text_field :reference, width: "one-third", label: { text: "Providers reference" } %>
+<% end %>
+
+
+ <%= f.govuk_select :provider_id, @providers.map {|provider| [provider.short_name, provider.id] },
+ "data-select-option-filter-target" => "input",
+ options: { include_blank: "Select a provider" },
+ label: { text: "Provider" } %>
+
+ <%= f.govuk_select :provider_contact_id, @provider_contacts.map {|contact| [contact.display_name, contact.id, { "data-provider-id" => contact.provider_id }] },
+ "data-select-option-filter-target" => "output",
+ options: { include_blank: "Select a contact" },
+ label: { text: "Provider contact" } %>
+
+
+<%= f.govuk_fieldset legend: { text: 'Availability' } do %>
+
+
+ <%= f.govuk_date_field :dfe_start_date, legend: { size: "s", text: "DfE start date", class: "" } %>
+
+
+ <%= f.govuk_date_field :dfe_end_date, legend: { size: "s", text: "DfE end date", class: "" } %>
+
+
+
+
+ <%= f.govuk_date_field :provider_start_date, legend: { size: "s", text: "Provider start date" } %>
+
+
+ <%= f.govuk_date_field :provider_end_date, legend: { size: "s", text: "Provider end date" } %>
+
+
+<% end %>
+
+<%= f.govuk_fieldset legend: { text: 'Other' } do %>
+ <% dps_options = [[true, 'Yes'], [false, 'No']] %>
+ <%= f.govuk_collection_radio_buttons :dps, dps_options, :first, :last, inline: true, legend: { size: 's', text: 'Is this framework a DPS (Dynamic purchasing system)?' } %>
+
+ <% lot_options = [['single', 'Single-lot'], ['multi', 'Multi-lot']] %>
+ <%= f.govuk_collection_radio_buttons :lot, lot_options, :first, :last, inline: true, legend: { size: 's', text: 'Is this framework a single or multi lot?' } %>
+
+ <% status_options = Frameworks::Framework.statuses.map {|status, id| [status, status.humanize] } %>
+ <%= f.govuk_collection_radio_buttons :status, status_options, :first, :last, legend: { size: 's', text: 'Approval Status' } %>
+<% end %>
+
+
+ <%= f.govuk_submit submit %>
+ <%= link_to "Cancel", @framework, class: "govuk-link govuk-link--no-visited-state" %>
+
diff --git a/app/views/frameworks/frameworks/_index_filters.html.erb b/app/views/frameworks/frameworks/_index_filters.html.erb
index 83029c4bf..ed6f04594 100644
--- a/app/views/frameworks/frameworks/_index_filters.html.erb
+++ b/app/views/frameworks/frameworks/_index_filters.html.erb
@@ -2,6 +2,8 @@
<%= I18n.t("support.case.label.filters") %>
<%= form_with model: @filtering, scope: :frameworks_filter, method: :get, url: frameworks_frameworks_path, html: { "data-controller" => "case-filters" } do |form| %>
+
+
<%= link_to I18n.t("support.case.filter.buttons.clear"), frameworks_frameworks_path(viewing_from_entity: params[:viewing_from_entity]), class: "govuk-button govuk-button--secondary", role: "button" %>
<%= form.govuk_select :sort_by,
diff --git a/app/views/frameworks/frameworks/edit.html.erb b/app/views/frameworks/frameworks/edit.html.erb
new file mode 100644
index 000000000..c3f90ef10
--- /dev/null
+++ b/app/views/frameworks/frameworks/edit.html.erb
@@ -0,0 +1,14 @@
+<%= content_for :title, "GHBS | Frameworks | Edit Framework" %>
+
+<%= turbo_frame_tag dom_id(@framework) do %>
+
+Edit Framework
+<%= @framework.name %>
+
+
+ <%= form_for @framework do |f| %>
+ <%= render "frameworks/frameworks/form", f:, submit: "Save changes" %>
+ <% end %>
+
+
+<% end %>
diff --git a/app/views/frameworks/frameworks/new.html.erb b/app/views/frameworks/frameworks/new.html.erb
index ad9c73f86..8adc82011 100644
--- a/app/views/frameworks/frameworks/new.html.erb
+++ b/app/views/frameworks/frameworks/new.html.erb
@@ -3,60 +3,7 @@
New Framework
-<%= form_for @framework do |f| %>
- <%= f.govuk_fieldset legend: { text: 'Basic Details' } do %>
- <%= f.govuk_text_field :name %>
- <%= f.govuk_text_field :short_name, width: "one-third", label: { text: "Abbreviated name" } %>
- <%= f.govuk_text_field :url, label: { text: "Providers URL" } %>
- <%= f.govuk_text_field :reference, width: "one-third", label: { text: "Providers reference" } %>
+ <%= form_for @framework do |f| %>
+ <%= render "frameworks/frameworks/form", f:, submit: "Create framework" %>
<% end %>
-
-
- <%= f.govuk_select :provider_id, @providers.map {|provider| [provider.short_name, provider.id] },
- "data-select-option-filter-target" => "input",
- options: { include_blank: "Select a provider" },
- label: { text: "Provider" } %>
-
- <%= f.govuk_select :provider_contact_id, @provider_contacts.map {|contact| [contact.display_name, contact.id, { "data-provider-id" => contact.provider_id }] },
- "data-select-option-filter-target" => "output",
- options: { include_blank: "Select a contact" },
- label: { text: "Provider contact" } %>
-
-
- <%= f.govuk_fieldset legend: { text: 'Availability' } do %>
-
-
- <%= f.govuk_date_field :dfe_start_date, legend: { size: "s", text: "DfE start date", class: "" } %>
-
-
- <%= f.govuk_date_field :dfe_end_date, legend: { size: "s", text: "DfE end date", class: "" } %>
-
-
-
-
- <%= f.govuk_date_field :provider_start_date, legend: { size: "s", text: "Provider start date" } %>
-
-
- <%= f.govuk_date_field :provider_end_date, legend: { size: "s", text: "Provider end date" } %>
-
-
- <% end %>
-
- <%= f.govuk_fieldset legend: { text: 'Other' } do %>
- <% dps_options = [[true, 'Yes'], [false, 'No']] %>
- <%= f.govuk_collection_radio_buttons :dps, dps_options, :first, :last, inline: true, legend: { size: 's', text: 'Is this framework a DPS (Dynamic purchasing system)?' } %>
-
- <% lot_options = [['single', 'Single-lot'], ['multi', 'Multi-lot']] %>
- <%= f.govuk_collection_radio_buttons :lot, lot_options, :first, :last, inline: true, legend: { size: 's', text: 'Is this framework a single or multi lot?' } %>
-
- <% status_options = Frameworks::Framework.statuses.map {|status, id| [status, status.humanize] } %>
- <%= f.govuk_collection_radio_buttons :status, status_options, :first, :last, legend: { size: 's', text: 'Approval Status' } %>
- <% end %>
-
-
- <%= f.govuk_submit "Create framework" %>
- <%= link_to "Cancel", @back_url, class: "govuk-link govuk-link--no-visited-state" %>
-
-
-<% end %>
diff --git a/app/views/frameworks/frameworks/show.html.erb b/app/views/frameworks/frameworks/show.html.erb
index 5ad3707fe..1a2588fd7 100644
--- a/app/views/frameworks/frameworks/show.html.erb
+++ b/app/views/frameworks/frameworks/show.html.erb
@@ -1,5 +1,7 @@
<%= content_for :title, "GHBS | Frameworks | #{@framework.name}" %>
+<%= turbo_frame_tag dom_id(@framework) do %>
+
<%= @framework.reference_and_short_name %>
<%= @framework.name %>
@@ -36,3 +38,10 @@
<% end %>
+
+Actions
+
+ - <%= link_to "Edit Framework", edit_frameworks_framework_path(@framework), class: "govuk-link" %>
+
+
+<% end %>
diff --git a/app/views/frameworks/frameworks/show/_framework_provider.html.erb b/app/views/frameworks/frameworks/show/_framework_provider.html.erb
index 0cf66357e..24a6a3d0c 100644
--- a/app/views/frameworks/frameworks/show/_framework_provider.html.erb
+++ b/app/views/frameworks/frameworks/show/_framework_provider.html.erb
@@ -1,7 +1,7 @@
- Provider
- - <%= link_to @framework.provider_name, frameworks_provider_path(@framework.provider, back_to: current_url_b64(:framework_provider)), class: "govuk-link", "data-turbo" => false %>
+ - <%= link_to @framework.provider_name, frameworks_provider_path(@framework.provider, back_to: current_url_b64(:framework_provider)), class: "govuk-link", "data-turbo" => false if @framework.provider.present? %>
@@ -11,7 +11,7 @@
- Framework Owner
- - <%= link_to @framework.provider_framework_owner_name, frameworks_provider_contact_path(@framework.provider_contact, back_to: current_url_b64(:framework_provider)), class: "govuk-link", "data-turbo" => false %>
+ - <%= link_to @framework.provider_framework_owner_name, frameworks_provider_contact_path(@framework.provider_contact, back_to: current_url_b64(:framework_provider)), class: "govuk-link", "data-turbo" => false if @framework.provider_contact.present? %>
diff --git a/app/views/frameworks/provider_contacts/_form.html.erb b/app/views/frameworks/provider_contacts/_form.html.erb
new file mode 100644
index 000000000..a2ef0d849
--- /dev/null
+++ b/app/views/frameworks/provider_contacts/_form.html.erb
@@ -0,0 +1,12 @@
+<%= f.govuk_text_field :name %>
+<%= f.govuk_text_field :email %>
+<%= f.govuk_text_field :phone %>
+
+<%= f.govuk_select :provider_id, @providers.map {|provider| [provider.short_name, provider.id] },
+ options: { include_blank: "Select a provider" },
+ label: { text: "Provider" } %>
+
+
+ <%= f.govuk_submit submit %>
+ <%= link_to "Cancel", @provider_contact, class: "govuk-link govuk-link--no-visited-state" %>
+
diff --git a/app/views/frameworks/provider_contacts/_index_filters.html.erb b/app/views/frameworks/provider_contacts/_index_filters.html.erb
index f0a57af14..80f78033f 100644
--- a/app/views/frameworks/provider_contacts/_index_filters.html.erb
+++ b/app/views/frameworks/provider_contacts/_index_filters.html.erb
@@ -2,7 +2,9 @@
<%= I18n.t("support.case.label.filters") %>
<%= form_with model: @filtering, scope: :provider_contacts_filter, method: :get, url: frameworks_provider_contacts_path, html: { "data-controller" => "case-filters" } do |form| %>
- <%= link_to I18n.t("support.case.filter.buttons.clear"), frameworks_provider_contacts_path, class: "govuk-button govuk-button--secondary", role: "button" %>
+
+
+ <%= link_to I18n.t("support.case.filter.buttons.clear"), frameworks_provider_contacts_path(viewing_from_entity: params[:viewing_from_entity]), class: "govuk-button govuk-button--secondary", role: "button" %>
<%= form.govuk_select :sort_by,
options_for_select(@filtering.available_sort_options, @filtering.sort_by),
diff --git a/app/views/frameworks/provider_contacts/edit.html.erb b/app/views/frameworks/provider_contacts/edit.html.erb
index d6af6a289..f9e54409f 100644
--- a/app/views/frameworks/provider_contacts/edit.html.erb
+++ b/app/views/frameworks/provider_contacts/edit.html.erb
@@ -8,14 +8,7 @@
<%= form_for @provider_contact do |f| %>
- <%= f.govuk_text_field :name %>
- <%= f.govuk_text_field :email %>
- <%= f.govuk_text_field :phone %>
-
-
- <%= f.govuk_submit "Save changes" %>
- <%= link_to "Cancel", @provider_contact, class: "govuk-link govuk-link--no-visited-state" %>
-
+ <%= render "frameworks/provider_contacts/form", f:, submit: "Save changes" %>
<% end %>
<% end %>
diff --git a/app/views/frameworks/provider_contacts/index.html.erb b/app/views/frameworks/provider_contacts/index.html.erb
index 9babb80a3..f46eb1cb7 100644
--- a/app/views/frameworks/provider_contacts/index.html.erb
+++ b/app/views/frameworks/provider_contacts/index.html.erb
@@ -2,6 +2,10 @@