From d59956c1fda877db82d36a1417aa1c88f9d90e21 Mon Sep 17 00:00:00 2001
From: Pawel Gorczyca
Date: Tue, 27 Aug 2024 07:29:32 +0200
Subject: [PATCH] feat:[#83] Remove default offer
Remove creating default offer for service
Add panel `offers` in the service view
Move links to offers_path
Use wrapper in service views
Closes #83
---
.../description_component.html.haml | 37 +++------
.../presentable/details_component.html.haml | 66 ++++++----------
app/controllers/application_controller.rb | 14 ++++
.../services/bundles/drafts_controller.rb | 2 +-
.../services/bundles/publishes_controller.rb | 2 +-
.../backoffice/services/bundles_controller.rb | 4 +-
.../backoffice/services/drafts_controller.rb | 2 +-
.../services/offers/drafts_controller.rb | 2 +-
.../services/offers/publishes_controller.rb | 2 +-
.../backoffice/services/offers_controller.rb | 12 ++-
.../services/publishes_controller.rb | 2 +-
.../backoffice/services_controller.rb | 10 +--
.../projects/services/opinions_controller.rb | 2 +-
.../services/application_controller.rb | 4 +-
.../services/cancels_controller.rb | 2 +-
.../services/choose_offers_controller.rb | 59 ++++++++++++++
app/controllers/services/offers_controller.rb | 78 ++++++-------------
.../ordering_configurations_controller.rb | 2 +-
app/controllers/services_controller.rb | 16 +---
app/helpers/presentable/header_helper.rb | 13 ++++
app/helpers/service_helper.rb | 12 ++-
app/models/project_item/wizard.rb | 8 +-
app/policies/backoffice/offer_policy.rb | 4 -
app/policies/offer_policy.rb | 2 +-
.../service_context_policy.rb | 3 +-
app/policies/service_context_policy.rb | 2 +-
app/policies/service_policy.rb | 6 +-
app/services/service/create.rb | 13 ----
app/services/service/update.rb | 13 ----
.../services/_blank_prompt.html.haml | 2 +-
.../backoffice/services/_service.html.haml | 4 +-
.../backoffice/services/_wrapper.html.haml | 42 ++++++++++
.../services/bundles/edit.html.haml | 2 +-
.../backoffice/services/bundles/new.html.haml | 2 +-
.../services/offers/_form.html.haml | 29 +++----
.../backoffice/services/offers/edit.html.haml | 2 +-
.../services/offers/index.html.haml | 14 ++++
.../backoffice/services/offers/new.html.haml | 2 +-
.../backoffice/services/preview.html.haml | 40 ++++------
app/views/backoffice/services/show.html.haml | 40 +---------
app/views/comparisons/show.html.haml | 2 +-
.../_ask_question.html.haml | 0
.../components/presentable/_sidebar.html.haml | 10 +++
.../_backoffice_service_buttons.html.haml | 2 +-
.../header_component/_order_buttons.html.haml | 2 +-
.../_ordering_configuration_buttons.html.haml | 2 +-
.../links_component/_links.html.haml | 4 +-
app/views/favourites/_service.html.haml | 2 +-
app/views/home/_opinions.html.haml | 2 +-
app/views/home/index.html.haml | 2 +-
.../layouts/backoffice/_navbar.html.haml | 2 +-
.../services/_bundle_box.html.haml | 2 +-
.../services/_default_parameters.html.haml | 30 -------
.../common_parts/services/_offers.html.haml | 6 +-
.../projects/services/_details.html.haml | 2 +-
app/views/providers/show.html.haml | 23 ++++--
app/views/services/_bundle_box.html.haml | 7 +-
app/views/services/_bundled_offer.html.haml | 2 +-
app/views/services/_header.html.haml | 15 ++++
app/views/services/_offer.html.haml | 2 +-
app/views/services/_offers.html.haml | 6 +-
app/views/services/_offers_box.html.haml | 2 +-
app/views/services/_opinions.html.haml | 19 +----
.../services/_recommendation_v1.html.haml | 2 +-
app/views/services/_service.html.haml | 2 +-
app/views/services/_service_details.html.haml | 2 +-
app/views/services/_tabs.haml | 5 ++
app/views/services/_wrapper.html.haml | 40 ++++++++++
app/views/services/bundles/_offer.html.haml | 2 +-
.../_bundle_box.html.haml | 4 +-
.../_bundle_description.html.haml | 0
.../_bundle_links.html.haml | 0
.../_bundle_parameters.html.haml | 0
.../_offer.html.haml | 0
.../{offers => choose_offers}/show.html.haml | 6 +-
app/views/services/details/index.html.haml | 29 +------
app/views/services/guidelines/index.html.haml | 49 +-----------
.../services/information/_bundle.html.haml | 2 +-
app/views/services/offers/index.html.haml | 13 ++++
app/views/services/opinions/index.html.haml | 28 +------
.../ordering_configurations/show.html.haml | 29 +++++--
app/views/services/show.html.haml | 31 ++------
config/breadcrumbs/backoffice.rb | 5 ++
config/routes.rb | 7 +-
spec/features/add_item_to_project_spec.rb | 4 +-
.../backoffice/services/bundles_spec.rb | 4 +-
spec/features/backoffice/services_spec.rb | 54 +++----------
spec/features/filter_spec.rb | 2 +-
spec/features/order_spec.rb | 12 +--
spec/features/ordering_configuration_spec.rb | 2 +-
spec/features/service_spec.rb | 4 +-
spec/lib/import/resources_spec.rb | 17 ++--
spec/policies/service_policy_spec.rb | 4 +-
spec/services/service/create_spec.rb | 12 +--
.../service/pc_create_or_update_spec.rb | 11 +--
spec/services/service/update_spec.rb | 10 +--
.../resources/owned_resources.spec.ts | 2 +-
.../comparison/comparison.spec.ts | 4 +-
98 files changed, 508 insertions(+), 609 deletions(-)
create mode 100644 app/controllers/services/choose_offers_controller.rb
create mode 100644 app/views/backoffice/services/_wrapper.html.haml
create mode 100644 app/views/backoffice/services/offers/index.html.haml
rename app/views/components/presentable/{header_component => }/_ask_question.html.haml (100%)
create mode 100644 app/views/components/presentable/_sidebar.html.haml
delete mode 100644 app/views/layouts/common_parts/services/_default_parameters.html.haml
create mode 100644 app/views/services/_header.html.haml
create mode 100644 app/views/services/_wrapper.html.haml
rename app/views/services/{offers => choose_offers}/_bundle_box.html.haml (85%)
rename app/views/services/{offers => choose_offers}/_bundle_description.html.haml (100%)
rename app/views/services/{offers => choose_offers}/_bundle_links.html.haml (100%)
rename app/views/services/{offers => choose_offers}/_bundle_parameters.html.haml (100%)
rename app/views/services/{offers => choose_offers}/_offer.html.haml (100%)
rename app/views/services/{offers => choose_offers}/show.html.haml (76%)
create mode 100644 app/views/services/offers/index.html.haml
diff --git a/app/components/presentable/description_component.html.haml b/app/components/presentable/description_component.html.haml
index 91d7e29a2..3a6b60aca 100644
--- a/app/components/presentable/description_component.html.haml
+++ b/app/components/presentable/description_component.html.haml
@@ -1,27 +1,12 @@
-#desc.tab-pane.container.active.desc{ "aria-labelledby" => "home-tab", role: "tabpanel" }
- .row.justify-content-between
- %main.col-12.col-xl-9.pr-4.pt-4{ "data-shepherd-tour-target": "service-about" }
- .service-description-container
- = markdown(@object.description)
- .details-box-wrapper.mt-5
- = render Presentable::SidebarComponent.new(@object)
+.service-description-container
+ = markdown(@object.description)
+.details-box-wrapper.mt-5
+ = render Presentable::SidebarComponent.new(@object)
- = description_panels
- .related-container
- - unless @object.suspended?
- .row
- .col-12
- = render "services/related", related_services: @related_services, title: related_services_title,
- preview: @preview
-
- %sidebar.col-12.col-xl-3{ "data-shepherd-tour-target": "service-classification" }
- = render "components/presentable/explore_links", object: @object
- .right-panel-links
- - if !@object.public_contacts.empty? && (@question || @preview)
- = render "components/presentable/header_component/ask_question", question_link: new_question_link,
- question: @question,
- prompt: new_question_prompt,
- preview: @preview
- = render Presentable::LinksComponent.new(object: @object, preview: @preview)
- = additional_backoffice_info
- = render Presentable::ProviderInfoComponent.new(base: @object, preview: @preview) if @object.respond_to?(:resource_organisation)
+= description_panels
+.related-container
+ - unless @object.suspended?
+ .row
+ .col-12
+ = render "services/related", related_services: @related_services, title: related_services_title,
+ preview: @preview
diff --git a/app/components/presentable/details_component.html.haml b/app/components/presentable/details_component.html.haml
index 9f5e3261a..2389eb232 100644
--- a/app/components/presentable/details_component.html.haml
+++ b/app/components/presentable/details_component.html.haml
@@ -1,41 +1,25 @@
-#opinions.tab-pane.container.active{ "aria-labelledby": "opinions-tab", role: "tabpanel",
- "data-shepherd-tour-target": "service-details-content" }
- .row.justify-content-between
- %main.col-12.col-xl-9.pr-4.mb-4.pt-4
-
- .details-box-wrapper
- = render Presentable::SidebarComponent.new(@object)
- - details_columns.each do |column|
- - column.map do |group|
- - next unless display_detail?(group, @object)
- .details-box{
- class: "#{group[:name]}"
- }
- .details-header
- %h5= t("components.presentable.details_component.details.title.#{group[:name]}")
- .details-content
- = render "components/presentable/details_component/#{group[:template]}",
- object: @object,
- fields: group[:fields],
- type: group[:type] || "single",
- clazz: group[:clazz] || "",
- nested: group[:nested] || {},
- inactive: @object.suspended? && !group[:active_when_suspended],
- with_desc: group[:with_desc] || false,
- preview: @preview
- .related-container
- .row
- .col-12
- = render "services/related", related_services: @related_services, title: related_services_title,
- preview: @preview
-
- %sidebar.col-12.col-xl-3{ "data-shepherd-tour-target": "service-classification" }
- = render "components/presentable/explore_links", object: @object
- .right-panel-links
- - if !@object.public_contacts.empty? && (@question || @preview)
- = render "components/presentable/header_component/ask_question", question_link: new_question_link,
- question: @question,
- prompt: new_question_prompt,
- preview: @preview
- = render Presentable::LinksComponent.new(object: @object, preview: @preview)
- = render Presentable::ProviderInfoComponent.new(base: @object, preview: @preview) if @object.respond_to?(:resource_organisation)
+.details-box-wrapper
+ = render Presentable::SidebarComponent.new(@object)
+ - details_columns.each do |column|
+ - column.map do |group|
+ - next unless display_detail?(group, @object)
+ .details-box{
+ class: "#{group[:name]}"
+ }
+ .details-header
+ %h5= t("components.presentable.details_component.details.title.#{group[:name]}")
+ .details-content
+ = render "components/presentable/details_component/#{group[:template]}",
+ object: @object,
+ fields: group[:fields],
+ type: group[:type] || "single",
+ clazz: group[:clazz] || "",
+ nested: group[:nested] || {},
+ inactive: @object.suspended? && !group[:active_when_suspended],
+ with_desc: group[:with_desc] || false,
+ preview: @preview
+.related-container
+ .row
+ .col-12
+ = render "services/related", related_services: @related_services, title: related_services_title,
+ preview: @preview
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 17ddfa8b0..c3fc2550d 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -93,4 +93,18 @@ def turbo_frame_request?
def action
@action ||= action_name
end
+
+ def bundled
+ if @service.offers.published.select(&:bundled?).present?
+ @service
+ .offers
+ .published
+ .select(&:bundled?)
+ .map { |o| policy_scope(o.bundles).reject { |b| b.service.status.in?(Statusable::HIDEABLE_STATUSES) } }
+ .flatten
+ .uniq
+ else
+ []
+ end
+ end
end
diff --git a/app/controllers/backoffice/services/bundles/drafts_controller.rb b/app/controllers/backoffice/services/bundles/drafts_controller.rb
index c384f49c8..6f9a099e7 100644
--- a/app/controllers/backoffice/services/bundles/drafts_controller.rb
+++ b/app/controllers/backoffice/services/bundles/drafts_controller.rb
@@ -6,7 +6,7 @@ class Backoffice::Services::Bundles::DraftsController < Backoffice::ApplicationC
def create
if Bundle::Unpublish.call(@bundle)
flash[:notice] = "Bundle unpublished successfully"
- redirect_to backoffice_service_path(@service)
+ redirect_to backoffice_service_offers_path(@service)
else
flash[:alert] = "Bundle cannot be unpublished. Please ensure your form is properly completed. " +
"#{@bundle.errors.messages.each.map { |k, v| "The field #{k} #{v.join(", ")}" }.join(", ")}"
diff --git a/app/controllers/backoffice/services/bundles/publishes_controller.rb b/app/controllers/backoffice/services/bundles/publishes_controller.rb
index 7ba0a0112..aa509c0a6 100644
--- a/app/controllers/backoffice/services/bundles/publishes_controller.rb
+++ b/app/controllers/backoffice/services/bundles/publishes_controller.rb
@@ -6,7 +6,7 @@ class Backoffice::Services::Bundles::PublishesController < Backoffice::Applicati
def create
if Bundle::Publish.call(@bundle)
flash[:notice] = "Bundle published successfully"
- redirect_to backoffice_service_path(@service)
+ redirect_to backoffice_service_offers_path(@service)
else
flash[:alert] = "Bundle cannot be published. Please ensure your form is properly completed. " +
"#{@bundle.errors.messages.each.map { |k, v| "The field #{k} #{v.join(", ")}" }.join(", ")}"
diff --git a/app/controllers/backoffice/services/bundles_controller.rb b/app/controllers/backoffice/services/bundles_controller.rb
index 159ca3d0f..604fc8977 100644
--- a/app/controllers/backoffice/services/bundles_controller.rb
+++ b/app/controllers/backoffice/services/bundles_controller.rb
@@ -17,7 +17,7 @@ def create
@bundle = Bundle::Create.call(template)
if @bundle.persisted?
- redirect_to backoffice_service_path(@service), notice: "New bundle created successfully"
+ redirect_to backoffice_service_offers_path(@service), notice: "New bundle created successfully"
else
render :new, status: :unprocessable_entity
end
@@ -29,7 +29,7 @@ def edit
def update
template = permitted_attributes(Bundle.new)
if Bundle::Update.call(@bundle, transform_attributes(template))
- redirect_to backoffice_service_path(@service), notice: "Bundle updated successfully"
+ redirect_to backoffice_service_offers_path(@service), notice: "Bundle updated successfully"
else
render :edit, status: :unprocessable_entity
end
diff --git a/app/controllers/backoffice/services/drafts_controller.rb b/app/controllers/backoffice/services/drafts_controller.rb
index 5bca3c82b..047d05497 100644
--- a/app/controllers/backoffice/services/drafts_controller.rb
+++ b/app/controllers/backoffice/services/drafts_controller.rb
@@ -11,7 +11,7 @@ def create
flash[:alert] = "Service not #{params[:suspend] ? "suspended" : "unpublished"}. " +
"Reason: #{@service.errors.full_messages.join(", ")}"
end
- redirect_to backoffice_service_path(@service)
+ redirect_to backoffice_service_offers_path(@service)
end
private
diff --git a/app/controllers/backoffice/services/offers/drafts_controller.rb b/app/controllers/backoffice/services/offers/drafts_controller.rb
index 61cd20a6b..022d1365c 100644
--- a/app/controllers/backoffice/services/offers/drafts_controller.rb
+++ b/app/controllers/backoffice/services/offers/drafts_controller.rb
@@ -6,7 +6,7 @@ class Backoffice::Services::Offers::DraftsController < Backoffice::ApplicationCo
def create
if Offer::Unpublish.call(@offer)
flash[:notice] = "Offer unpublished successfully"
- redirect_to backoffice_service_path(@service)
+ redirect_to backoffice_service_offers_path(@service)
else
flash[:alert] = "Offer cannot be unpublished. Please ensure your form is properly completed. " +
"#{@offer.errors.messages.each.map { |k, v| "The field #{k} #{v.join(", ")}" }.join(", ")}"
diff --git a/app/controllers/backoffice/services/offers/publishes_controller.rb b/app/controllers/backoffice/services/offers/publishes_controller.rb
index 83be93991..2a1d08608 100644
--- a/app/controllers/backoffice/services/offers/publishes_controller.rb
+++ b/app/controllers/backoffice/services/offers/publishes_controller.rb
@@ -6,7 +6,7 @@ class Backoffice::Services::Offers::PublishesController < Backoffice::Applicatio
def create
if Offer::Publish.call(@offer)
flash[:notice] = "Offer published successfully"
- redirect_to backoffice_service_path(@service)
+ redirect_to backoffice_service_offers_path(@service)
else
flash[:alert] = "Offer cannot be published. Please ensure your form is properly completed. " +
"#{@offer.errors.messages.each.map { |k, v| "The field #{k} #{v.join(", ")}" }.join(", ")}"
diff --git a/app/controllers/backoffice/services/offers_controller.rb b/app/controllers/backoffice/services/offers_controller.rb
index 20fdaa4b6..399700f76 100644
--- a/app/controllers/backoffice/services/offers_controller.rb
+++ b/app/controllers/backoffice/services/offers_controller.rb
@@ -6,6 +6,12 @@ class Backoffice::Services::OffersController < Backoffice::ApplicationController
before_action :load_form_data, only: %i[fetch_subtypes]
after_action :reindex_offer, only: %i[create update destroy]
+ def index
+ @offers = policy_scope(@service.offers)
+ @bundles = policy_scope(@service.bundles)
+ @question = Service::Question.new(service: @service)
+ end
+
def new
@offer = Offer.new(service: @service)
authorize(@offer)
@@ -18,7 +24,7 @@ def create
@offer = Offer::Create.call(template)
if @offer.persisted?
- redirect_to backoffice_service_path(@service), notice: "New offer created successfully"
+ redirect_to backoffice_service_offers_path(@service), notice: "New offer created successfully"
else
render :new, status: :bad_request
end
@@ -36,7 +42,7 @@ def edit
def update
template = permitted_attributes(Offer)
if Offer::Update.call(@offer, transform_attributes(template, @service))
- redirect_to backoffice_service_path(@service), notice: "Offer updated successfully"
+ redirect_to backoffice_service_offers_path(@service), notice: "Offer updated successfully"
else
render :edit, status: :bad_request
end
@@ -45,7 +51,7 @@ def update
def destroy
@offer = @service.offers.find_by(iid: params[:id])
if Offer::Delete.call(@offer)
- redirect_to backoffice_service_path(@service), notice: "Offer removed successfully"
+ redirect_to backoffice_service_offers_path(@service), notice: "Offer removed successfully"
else
render :edit, status: :bad_request
end
diff --git a/app/controllers/backoffice/services/publishes_controller.rb b/app/controllers/backoffice/services/publishes_controller.rb
index 5e8b71ac3..4769f257a 100644
--- a/app/controllers/backoffice/services/publishes_controller.rb
+++ b/app/controllers/backoffice/services/publishes_controller.rb
@@ -9,7 +9,7 @@ def create
else
flash[:alert] = "Service not published. Reason: #{@service.errors.full_messages.join(", ")}"
end
- redirect_to backoffice_service_path(@service)
+ redirect_to backoffice_service_offers_path(@service)
end
private
diff --git a/app/controllers/backoffice/services_controller.rb b/app/controllers/backoffice/services_controller.rb
index 6f81e79f5..41645c5ad 100644
--- a/app/controllers/backoffice/services_controller.rb
+++ b/app/controllers/backoffice/services_controller.rb
@@ -26,12 +26,12 @@ def index
anchor: ("offer-#{params["anchor"]}" if params["anchor"].present?)
)
when "service"
- redirect_to backoffice_service_path(
+ redirect_to backoffice_service_offers_path(
Service.friendly.find(params["object_id"]),
anchor: ("offer-#{params["anchor"]}" if params["anchor"].present?)
)
when "datasource"
- redirect_to backoffice_service_path(Datasource.friendly.find(params["object_id"]))
+ redirect_to backoffice_service_offers_path(Datasource.friendly.find(params["object_id"]))
end
end
@services, @offers = search(scope)
@@ -81,7 +81,7 @@ def create
end
remove_temp_data!
- redirect_to backoffice_service_path(@service), notice: "New service created successfully"
+ redirect_to backoffice_service_offers_path(@service), notice: "New service created successfully"
end
def edit
@@ -108,14 +108,14 @@ def update
end
@service.store_analytics
remove_temp_data!
- redirect_to backoffice_service_path(@service), notice: "Service updated successfully"
+ redirect_to backoffice_service_offers_path(@service), notice: "Service updated successfully"
end
def destroy
if Service::Delete.new(@service).call
redirect_to backoffice_services_path, notice: "Service removed successfully"
else
- redirect_to backoffice_service_path(@service),
+ redirect_to backoffice_service_offers_path(@service),
alert: "Could not remove service. Reason: #{@service.errors.full_messages}"
end
end
diff --git a/app/controllers/projects/services/opinions_controller.rb b/app/controllers/projects/services/opinions_controller.rb
index 65b2b16c5..89f3febd5 100644
--- a/app/controllers/projects/services/opinions_controller.rb
+++ b/app/controllers/projects/services/opinions_controller.rb
@@ -18,7 +18,7 @@ def create
if @service_opinion.persisted?
Matomo::SendRequestJob.perform_later(@project_item, "Rate", @service_opinion.service_rating)
format.html do
- redirect_to project_service_path(@project, @project_item), notice: "Rating submitted successfully"
+ redirect_to project_service_offers_path(@project, @project_item), notice: "Rating submitted successfully"
end
else
format.html { render :new, status: :unprocessable_entity }
diff --git a/app/controllers/services/application_controller.rb b/app/controllers/services/application_controller.rb
index b6c38b89e..f96e99005 100644
--- a/app/controllers/services/application_controller.rb
+++ b/app/controllers/services/application_controller.rb
@@ -14,7 +14,7 @@ class Services::ApplicationController < ApplicationController
helper_method :step_title, :prev_title, :next_title
STEP_TITLES = {
- offers: "Offer selection",
+ choose_offer: "Offer selection",
information: "Access instructions",
configuration: "Configuration",
summary: "Final details"
@@ -27,7 +27,7 @@ def session_key
end
def ensure_in_session!
- redirect_to service_offers_path(@service), alert: "Service request template not found" unless @saved_state
+ redirect_to service_choose_offer_path(@service), alert: "Service request template not found" unless @saved_state
end
def load_and_authenticate_service!
diff --git a/app/controllers/services/cancels_controller.rb b/app/controllers/services/cancels_controller.rb
index 8846060a7..74875533a 100644
--- a/app/controllers/services/cancels_controller.rb
+++ b/app/controllers/services/cancels_controller.rb
@@ -7,6 +7,6 @@ def destroy
session.delete(session_key)
session.delete(:selected_project)
- redirect_to service_path(@service)
+ redirect_to service_offers_path(@service)
end
end
diff --git a/app/controllers/services/choose_offers_controller.rb b/app/controllers/services/choose_offers_controller.rb
new file mode 100644
index 000000000..5287cf387
--- /dev/null
+++ b/app/controllers/services/choose_offers_controller.rb
@@ -0,0 +1,59 @@
+# frozen_string_literal: true
+
+class Services::ChooseOffersController < Services::ApplicationController
+ skip_before_action :authenticate_user!
+
+ def show
+ init_step_data
+
+ unless step.visible?
+ if @offers.inclusive.size.positive?
+ params[:customizable_project_item] = { offer_id: @offers.inclusive.first.iid }
+ elsif @bundles.published.size.positive?
+ params[:customizable_project_item] = { bundle_id: @bundles.published.first.iid }
+ end
+
+ update
+ end
+ end
+
+ def update
+ @step = step(step_params)
+
+ if @step.valid?
+ save_in_session(@step)
+ redirect_to url_for([@service, next_step_key])
+ else
+ init_step_data
+ flash[:alert] = @step.error
+ render :show
+ end
+ end
+
+ private
+
+ def step_key
+ :choose_offer
+ end
+
+ def step_params
+ { offer_id: offer&.id, bundle_id: bundle&.id, project_id: session[:selected_project] }
+ end
+
+ def offer
+ form_params = params.fetch(:customizable_project_item, session[session_key] || {}).permit(:offer_id)
+ @service.offers.find_by(iid: form_params[:offer_id] || bundle&.main_offer&.iid)
+ end
+
+ def bundle
+ form_params = params.fetch(:customizable_project_item, session[session_key] || {}).permit(:bundle_id)
+ @service.bundles.find_by(iid: form_params[:bundle_id])
+ end
+
+ def init_step_data
+ @offers = policy_scope(@service.offers.inclusive).order(:iid)
+ @bundles = policy_scope(@service.bundles.published).order(:iid)
+ @bundled = policy_scope(@service.offers.published).order(:iid).select(&:bundled?).map(&:bundles)&.flatten
+ @step = step(session[session_key])
+ end
+end
diff --git a/app/controllers/services/offers_controller.rb b/app/controllers/services/offers_controller.rb
index 6153db8a6..bf99c3e02 100644
--- a/app/controllers/services/offers_controller.rb
+++ b/app/controllers/services/offers_controller.rb
@@ -1,59 +1,31 @@
# frozen_string_literal: true
-class Services::OffersController < Services::ApplicationController
- skip_before_action :authenticate_user!
-
- def show
- init_step_data
-
- unless step.visible?
- if @offers.inclusive.size.positive?
- params[:customizable_project_item] = { offer_id: @offers.inclusive.first.iid }
- elsif @bundles.published.size.positive?
- params[:customizable_project_item] = { bundle_id: @bundles.published.first.iid }
- end
-
- update
- end
- end
-
- def update
- @step = step(step_params)
-
- if @step.valid?
- save_in_session(@step)
- redirect_to url_for([@service, next_step_key])
- else
- init_step_data
- flash[:alert] = @step.error
- render :show
- end
- end
-
- private
-
- def step_key
- :offers
- end
-
- def step_params
- { offer_id: offer&.id, bundle_id: bundle&.id, project_id: session[:selected_project] }
- end
-
- def offer
- form_params = params.fetch(:customizable_project_item, session[session_key] || {}).permit(:offer_id)
- @service.offers.find_by(iid: form_params[:offer_id] || bundle&.main_offer&.iid)
- end
-
- def bundle
- form_params = params.fetch(:customizable_project_item, session[session_key] || {}).permit(:bundle_id)
- @service.bundles.find_by(iid: form_params[:bundle_id])
- end
-
- def init_step_data
+class Services::OffersController < ApplicationController
+ include Service::Autocomplete
+ include Service::Comparison
+ include Service::Monitorable
+ include Service::Recommendable
+
+ def index
+ @service = Service.includes(:offers).friendly.find(params[:service_id])
+
+ authorize(
+ ServiceContext.new(@service, params.key?(:from) && params[:from] == "backoffice_service"),
+ :show?,
+ policy_class: ServiceContextPolicy
+ )
+ redirect_to service_path(@service, q: session[:query][:q]) if @service.offers.inclusive.published.empty?
+ @service.store_analytics
+ @service.monitoring_status = fetch_status(@service.pid)
@offers = policy_scope(@service.offers.inclusive).order(:iid)
@bundles = policy_scope(@service.bundles.published).order(:iid)
- @bundled = policy_scope(@service.offers.published).order(:iid).select(&:bundled?).map(&:bundles)&.flatten
- @step = step(session[session_key])
+ @bundled = bundled
+ @similar_services = fetch_similar(@service.id, current_user&.id)
+ @related_services = @service.related_services
+
+ @service_opinions = ServiceOpinion.joins(project_item: :offer).where(offers: { service_id: @service })
+ @question = Service::Question.new(service: @service)
+ @favourite_services =
+ current_user&.favourite_services || Service.where(slug: Array(cookies[:favourites]&.split("&") || []))
end
end
diff --git a/app/controllers/services/ordering_configurations_controller.rb b/app/controllers/services/ordering_configurations_controller.rb
index 60dd7a76c..872fefc41 100644
--- a/app/controllers/services/ordering_configurations_controller.rb
+++ b/app/controllers/services/ordering_configurations_controller.rb
@@ -26,6 +26,6 @@ def load_and_authenticate_service!
else
not_authorized_message(e)
end
- redirect_to service_path(@service)
+ redirect_to service_offers_path(@service)
end
end
diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb
index d551170f1..dcaedfa33 100644
--- a/app/controllers/services_controller.rb
+++ b/app/controllers/services_controller.rb
@@ -27,7 +27,7 @@ def index
anchor: ("offer-#{params["anchor"]}" if params["anchor"].present?)
)
when "service"
- redirect_to service_path(
+ redirect_to service_offers_path(
Service.friendly.find(params["object_id"]),
q: params["q"],
anchor: ("offer-#{params["anchor"]}" if params["anchor"].present?)
@@ -125,20 +125,6 @@ def hide_horizontals?(init: true)
empty_listed || active_filters.size.positive? || params[:q].present? || @category.present?
end
- def bundled
- if @service.offers.published.select(&:bundled?).present?
- @service
- .offers
- .published
- .select(&:bundled?)
- .map { |o| policy_scope(o.bundles).reject { |b| b.service.status.in?(Statusable::HIDEABLE_STATUSES) } }
- .flatten
- .uniq
- else
- []
- end
- end
-
def external_search_enabled
EXTERNAL_SEARCH_ENABLED
end
diff --git a/app/helpers/presentable/header_helper.rb b/app/helpers/presentable/header_helper.rb
index 00b98fed8..09a5f8659 100644
--- a/app/helpers/presentable/header_helper.rb
+++ b/app/helpers/presentable/header_helper.rb
@@ -30,6 +30,19 @@ def about_link(service, query_params)
end
end
+ def offers_link(service, query_params)
+ query_params ||= {}
+ from = query_params[:from]
+ case from
+ when "ordering_configuration"
+ service_ordering_configuration_offers_path(service, query_params)
+ when "backoffice_service"
+ backoffice_service_offers_path(service, query_params)
+ else
+ service_offers_path(service, query_params)
+ end
+ end
+
def datasource_about_link(datasource, from)
case from
when "backoffice_datasource"
diff --git a/app/helpers/service_helper.rb b/app/helpers/service_helper.rb
index f0e108656..4e6e37fe0 100644
--- a/app/helpers/service_helper.rb
+++ b/app/helpers/service_helper.rb
@@ -101,7 +101,7 @@ def edit_offer_link(service, offer, controller_name)
case controller_name
when "ordering_configurations"
edit_service_ordering_configuration_offer_path(service, offer, from: params[:from])
- when "services"
+ else
edit_backoffice_service_offer_path(service, offer)
end
end
@@ -110,7 +110,7 @@ def edit_bundle_link(service, bundle, controller_name)
case controller_name
when "ordering_configuration"
edit_service_ordering_configuration_bundle_path(service, bundle, from: params[:from])
- when "service"
+ else
edit_backoffice_service_bundle_path(service, bundle)
end
end
@@ -126,4 +126,12 @@ def get_only_regions(locations)
def get_only_countries(locations)
locations.reject { |c| Country.regions.include? c }
end
+
+ def new_offer_prompt
+ "#{_("Create an offer for your service to maximise its visibility and usability.")}
" +
+ "#{_("With specified offers:")}" +
+ "
- #{_("Your service will be searchable in both the service catalog and the offers catalog")}
" +
+ "- #{_("Your service can be ordered directly in the Marketplace")}
" +
+ "- #{_("You can customize your service to attract more users")}
"
+ end
end
diff --git a/app/models/project_item/wizard.rb b/app/models/project_item/wizard.rb
index c17b6f730..0a20b2517 100644
--- a/app/models/project_item/wizard.rb
+++ b/app/models/project_item/wizard.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class ProjectItem::Wizard
- STEPS = %i[offers information configuration summary].freeze
+ STEPS = %i[choose_offer information configuration summary].freeze
def initialize(service)
@service = service
@@ -48,7 +48,7 @@ def model_name
end
end
- class OffersStep < Base
+ class ChooseOfferStep < Base
validates :offer, presence: true, unless: :bundle
validates :bundle, presence: true, unless: :offer
@@ -61,13 +61,13 @@ def error
end
end
- class InformationStep < OffersStep
+ class InformationStep < ChooseOfferStep
def visible?
true
end
end
- class ConfigurationStep < OffersStep
+ class ConfigurationStep < ChooseOfferStep
include ProjectItem::Customization
include ProjectItem::VoucherValidation
diff --git a/app/policies/backoffice/offer_policy.rb b/app/policies/backoffice/offer_policy.rb
index f8bd4c089..6f268cc1f 100644
--- a/app/policies/backoffice/offer_policy.rb
+++ b/app/policies/backoffice/offer_policy.rb
@@ -43,10 +43,6 @@ def permitted_attributes
]
end
- def delete?
- super && other_offers_with_service_order_type?
- end
-
def destroy?
super && other_offers_with_service_order_type?
end
diff --git a/app/policies/offer_policy.rb b/app/policies/offer_policy.rb
index 14fbe29c4..54cb1eeaa 100644
--- a/app/policies/offer_policy.rb
+++ b/app/policies/offer_policy.rb
@@ -4,7 +4,7 @@ class OfferPolicy < ApplicationPolicy
class Scope < Scope
def resolve
scope.joins(:service).where(
- "offers.status IN (?) AND services.status IN (?)",
+ "bundle_exclusive = false AND offers.status IN (?) AND services.status IN (?)",
Statusable::PUBLIC_STATUSES,
Statusable::VISIBLE_STATUSES
)
diff --git a/app/policies/ordering_configuration/service_context_policy.rb b/app/policies/ordering_configuration/service_context_policy.rb
index 4d8857068..f73b43f4b 100644
--- a/app/policies/ordering_configuration/service_context_policy.rb
+++ b/app/policies/ordering_configuration/service_context_policy.rb
@@ -3,7 +3,6 @@
class OrderingConfiguration::ServiceContextPolicy < ServiceContextPolicy
def show?
service = record.service
- super && !service.status.in?(Statusable::HIDEABLE_STATUSES) && service.owned_by?(user) &&
- service.upstream&.eosc_registry?
+ super && !service.status.in?(Statusable::HIDEABLE_STATUSES) && service.owned_by?(user)
end
end
diff --git a/app/policies/service_context_policy.rb b/app/policies/service_context_policy.rb
index 93d5dc4d3..c0306f474 100644
--- a/app/policies/service_context_policy.rb
+++ b/app/policies/service_context_policy.rb
@@ -13,7 +13,7 @@ def show?
def order?
permitted? && record.service.status.in?(Statusable::PUBLIC_STATUSES) && record.service.offers? &&
- record.service.offers.any?(&:published?)
+ (record.service.offers.inclusive.any?(&:published?) || record.service.bundles.any?(&:published?))
end
private
diff --git a/app/policies/service_policy.rb b/app/policies/service_policy.rb
index 10b42ab54..7bef0df36 100644
--- a/app/policies/service_policy.rb
+++ b/app/policies/service_policy.rb
@@ -12,7 +12,7 @@ def order?
end
def offers_show?
- enough_to_show? && any_published_offers?
+ any_published_offers?
end
def bundles_show?
@@ -29,10 +29,6 @@ def data_administrator?
private
- def enough_to_show?
- record.offers? && record.offers.inclusive.size + record&.bundles&.published&.size > 1
- end
-
def any_published_bundled_offers?
record.bundles.published.size.positive? ||
(
diff --git a/app/services/service/create.rb b/app/services/service/create.rb
index 94cee6522..bd0345e5e 100644
--- a/app/services/service/create.rb
+++ b/app/services/service/create.rb
@@ -10,19 +10,6 @@ def call
@service.update_logo!(@logo) if @logo && @service.logo.blank?
@service.save!
- new_offer =
- Offer.new(
- name: "Offer",
- description: "#{@service.name} Offer",
- order_type: @service.order_type,
- offer_category: @service.service_categories.first || Vocabulary::ServiceCategory.find_by(name: "Other"),
- order_url: @service.order_url,
- internal: @service.order_url.blank?,
- status: "published",
- service_id: @service.id,
- usage_counts_views: @service.usage_counts_views
- )
- Offer::Create.call(new_offer)
@service
rescue ActiveRecord::RecordNotSaved, ActiveRecord::RecordInvalid => e
Rails.logger.error "Service not saved: #{e}"
diff --git a/app/services/service/update.rb b/app/services/service/update.rb
index 591811108..bcbdc6f29 100644
--- a/app/services/service/update.rb
+++ b/app/services/service/update.rb
@@ -27,20 +27,7 @@ def call
status: "published"
}
Offer::Update.call(@service.offers.first, offer_partial)
- elsif @service.offers.published.empty?
- new_offer =
- Offer.new(
- name: "Offer",
- description: "#{@service.name} Offer",
- service: @service,
- offer_category: @service.service_categories.first || Vocabulary::ServiceCategory.find_by(name: "Other"),
- order_type: @service.order_type.presence,
- order_url: @service.order_url,
- status: "published"
- )
- Offer::Create.call(new_offer)
end
-
true
rescue ActiveRecord::RecordInvalid
false
diff --git a/app/views/backoffice/services/_blank_prompt.html.haml b/app/views/backoffice/services/_blank_prompt.html.haml
index 06bf8bf77..2cde87dc5 100644
--- a/app/views/backoffice/services/_blank_prompt.html.haml
+++ b/app/views/backoffice/services/_blank_prompt.html.haml
@@ -1,4 +1,4 @@
.empty-information.col-12.col-md-9.m-auto
%h2= title
- .details-intro= prompt
+ .details-intro= prompt.html_safe
= link_to link_text, link_path, class: "btn btn-primary"
diff --git a/app/views/backoffice/services/_service.html.haml b/app/views/backoffice/services/_service.html.haml
index 001465936..2109f0498 100644
--- a/app/views/backoffice/services/_service.html.haml
+++ b/app/views/backoffice/services/_service.html.haml
@@ -2,7 +2,5 @@
highlights: highlights[service.id],
service_offers: offers[service.id] do
= service_status(service)
- = link_to backoffice_service_path(service) do
+ = link_to backoffice_service_offers_path(service) do
= highlighted_for(:name, service, highlights[service.id])
- %br
- = offers_status(service) unless service.deleted?
diff --git a/app/views/backoffice/services/_wrapper.html.haml b/app/views/backoffice/services/_wrapper.html.haml
new file mode 100644
index 000000000..37905e284
--- /dev/null
+++ b/app/views/backoffice/services/_wrapper.html.haml
@@ -0,0 +1,42 @@
+.container.p-0.backoffice
+ = render "services/errors", service: service
+
+.container.p-0.backoffice
+ = render Presentable::StatusActionsComponent.new(object: service,
+ publish: policy([:backoffice, service]).publish?,
+ suspend: policy([:backoffice, service]).suspend?,
+ unpublish: policy([:backoffice, service]).unpublish?,
+ destroy: policy([:backoffice, service]).destroy?)
+
+.container.p-0.backoffice
+ .pt-3.service-box-redesign.service-detail.backoffice{ "data-shepherd-tour-target": "service-box" }
+ = render Presentable::HeaderComponent.new(object: service,
+ title: service.name,
+ abbreviation: service.abbreviation,
+ subtitle: service.tagline,
+ comparison_enabled: comparison_enabled,
+ show_checkboxes: false,
+ preview: local_assigns[:preview],
+ favourite_services: favourite_services) do |c|
+ - c.buttons do
+ = render "components/presentable/header_component/backoffice_service_buttons", service: service
+
+ = render "services/tabs", service: service, params: { from: "backoffice_service" }
+.tab-content
+ #desc.tab-pane.container.active.desc{ "aria-labelledby" => "home-tab", role: "tabpanel" }
+ .row.justify-content-between
+ %main.col-12.col-xl-9.pr-4.pt-4{ "data-shepherd-tour-target": "service-about" }
+ = yield
+ %sidebar.col-12.col-xl-3{ "data-shepherd-tour-target": "service-classification" }
+ = render "components/presentable/explore_links", object: service
+ .right-panel-links
+ - if !service.public_contacts.empty? && (question || preview)
+ = render "components/presentable/ask_question", question_link: new_question_link(service),
+ question: question,
+ prompt: new_question_prompt(service),
+ preview: local_assigns[:preview]
+ = render Presentable::LinksComponent.new(object: service, preview: local_assigns[:preview])
+ .right-panel-links.pt-4.pb-4
+ = render "components/presentable/updates", object: service
+ = render Presentable::ProviderInfoComponent.new(base: service,
+ preview: local_assigns[:preview]) if service.respond_to?(:resource_organisation)
diff --git a/app/views/backoffice/services/bundles/edit.html.haml b/app/views/backoffice/services/bundles/edit.html.haml
index 8f9669147..3c5b3ba80 100644
--- a/app/views/backoffice/services/bundles/edit.html.haml
+++ b/app/views/backoffice/services/bundles/edit.html.haml
@@ -9,4 +9,4 @@
bundle: @bundle,
show_delete_button: false,
bundle_form_source_module: [:backoffice, @service, @bundle],
- back_link: backoffice_service_path(@service)
+ back_link: backoffice_service_offers_path(@service)
diff --git a/app/views/backoffice/services/bundles/new.html.haml b/app/views/backoffice/services/bundles/new.html.haml
index 2a09149c2..bd31a686d 100644
--- a/app/views/backoffice/services/bundles/new.html.haml
+++ b/app/views/backoffice/services/bundles/new.html.haml
@@ -10,4 +10,4 @@
bundle: @bundle,
show_delete_button: false,
bundle_form_source_module: [:backoffice, @service, @bundle],
- back_link: backoffice_service_path(@service)
+ back_link: backoffice_service_offers_path(@service)
diff --git a/app/views/backoffice/services/offers/_form.html.haml b/app/views/backoffice/services/offers/_form.html.haml
index 84fb2a5f1..b56a92d27 100644
--- a/app/views/backoffice/services/offers/_form.html.haml
+++ b/app/views/backoffice/services/offers/_form.html.haml
@@ -53,17 +53,18 @@
.submit.d-none{ "data-offer-target": "submitRow" }
= f.button :submit, class: "btn btn-primary pl-5 pr-5 mobile-bottom-margin", "data-e2e": "create-offer-btn"
- - if policy([:backoffice, offer]).destroy?
- = link_to "Delete Offer", polymorphic_path(offer_form_source_module),
- data: { "turbo-confirm": _("This action cannot be undone. Confirm to delete the Offer."), "turbo-method": :delete },
- class: "btn btn-primary pl-4 pr-4 mobile-bottom-margin btn-danger ml-3"
- - if policy([:backoffice, offer]).draft?
- = link_to "Unpublish Offer", polymorphic_path(offer_form_source_module << :draft),
- class: "btn btn-primary pl-4 pr-4 mobile-bottom-margin btn-info ml-3",
- data: { "turbo-confirm": _("Confirm and unpublish the Offer. It will no longer be visible on the website."),
- "turbo-method": :post }
- - if policy([:backoffice, offer]).publish?
- = link_to "Publish Offer", polymorphic_path(offer_form_source_module << :publish),
- class: "btn btn-primary pl-4 pr-4 mobile-bottom-margin ml-3",
- data: { "turbo-confirm": _("Confirm and publish the Offer. It will be accessible on the website."),
- "turbo-method": :post }
+ - if offer.persisted?
+ - if policy([:backoffice, offer]).delete?
+ = link_to "Delete Offer", polymorphic_path(offer_form_source_module),
+ data: { "turbo-confirm": _("This action cannot be undone. Confirm to delete the Offer."), "turbo-method": :delete },
+ class: "btn btn-primary pl-4 pr-4 mobile-bottom-margin btn-danger ml-3"
+ - if policy([:backoffice, offer]).draft?
+ = link_to "Unpublish Offer", polymorphic_path(offer_form_source_module << :draft),
+ class: "btn btn-primary pl-4 pr-4 mobile-bottom-margin btn-info ml-3",
+ data: { "turbo-confirm": _("Confirm and unpublish the Offer. It will no longer be visible on the website."),
+ "turbo-method": :post }
+ - if policy([:backoffice, offer]).publish?
+ = link_to "Publish Offer", polymorphic_path(offer_form_source_module << :publish),
+ class: "btn btn-primary pl-4 pr-4 mobile-bottom-margin ml-3",
+ data: { "turbo-confirm": _("Confirm and publish the Offer. It will be accessible on the website."),
+ "turbo-method": :post }
diff --git a/app/views/backoffice/services/offers/edit.html.haml b/app/views/backoffice/services/offers/edit.html.haml
index 4718d25ed..111071df6 100644
--- a/app/views/backoffice/services/offers/edit.html.haml
+++ b/app/views/backoffice/services/offers/edit.html.haml
@@ -9,5 +9,5 @@
show_delete_button: true,
offer_form_source_module: [:backoffice, @service, @offer],
offer_delete_link: backoffice_service_offer_path(@service, @offer),
- back_link: backoffice_service_path(@service),
+ back_link: backoffice_service_offers_path(@service),
from: params[:from] || local_assigns[:from]
diff --git a/app/views/backoffice/services/offers/index.html.haml b/app/views/backoffice/services/offers/index.html.haml
new file mode 100644
index 000000000..ddb03c098
--- /dev/null
+++ b/app/views/backoffice/services/offers/index.html.haml
@@ -0,0 +1,14 @@
+- content_for :title, @service.name
+- breadcrumb :backoffice_service_offers, @service
+
+= render "backoffice/services/wrapper", service: @service, comparison_enabled: @comparison_enabled,
+ favourite_services: @favourite_services, question: @question, preview: false do
+ - if @offers.manageable.any?
+ = render "layouts/common_parts/services/offers", offers: @offers, service: @service, bundles: @bundles
+ - else
+ %h2 Showcase your service
+ %p
+ You added your service without creating an offer. It has appeared in our catalog for informational purposes only.
+ Users can find your service and see its details, but they can’t order or interact with it directly.
+ = render "backoffice/services/blank_prompt", title: _("Unlock the full potential of your service"),
+ prompt: new_offer_prompt, link_text: _("Create an offer"), link_path: new_backoffice_service_offer_path(@service)
diff --git a/app/views/backoffice/services/offers/new.html.haml b/app/views/backoffice/services/offers/new.html.haml
index 13d338b3e..5b85b45fe 100644
--- a/app/views/backoffice/services/offers/new.html.haml
+++ b/app/views/backoffice/services/offers/new.html.haml
@@ -7,4 +7,4 @@
offer: @offer,
show_delete_button: false,
offer_form_source_module: [:backoffice, @service, @offer],
- back_link: backoffice_service_path(@service)
+ back_link: backoffice_service_offers_path(@service)
diff --git a/app/views/backoffice/services/preview.html.haml b/app/views/backoffice/services/preview.html.haml
index 05b9ae242..a8165e39b 100644
--- a/app/views/backoffice/services/preview.html.haml
+++ b/app/views/backoffice/services/preview.html.haml
@@ -9,7 +9,7 @@
- if @service.persisted?
= link_to _("Go back to edit"), edit_backoffice_service_path(@service),
class: "btn btn-warning", "data-turbo": false
- = link_to _("Confirm changes"), backoffice_service_path(@service),
+ = link_to _("Confirm changes"), backoffice_service_offers_path(@service),
class: "btn btn-success", method: :put, "data-turbo": false
- else
= link_to _("Go back to edit"), new_backoffice_service_path,
@@ -18,28 +18,16 @@
= link_to _("Confirm changes"), backoffice_services_path,
class: "btn btn-success", type: :submit,
data: { e2e: "confirm-changes-btn", "turbo-method": :post }
-.container{ "data-controller": "preview" }
- .container.preview
- .pt-4.pl-3.pr-3.shadow-sm.rounded.service-box.service-detail
- = render Presentable::HeaderComponent.new(object: @service,
- title: @service.name,
- abbreviation: @service.abbreviation,
- subtitle: @service.tagline,
- comparison_enabled: @comparison_enabled,
- preview: true,
- favourite_services: @favourite_services) do |c|
- - c.buttons do
- = render "components/presentable/header_component/order_buttons", service: @service, preview: true
- = render "services/tabs", service: @service, preview: true
-
- .tab-content
- #about{ "data-preview-target": "content" }
- = render Presentable::DescriptionComponent.new(object: @service,
- similar_services: @similar_services, related_services: @related_services, preview: true) do |c|
- - c.description_panels do
- - if policy(@service).order? && (policy(@service).offers_show? || policy(@service).bundles_show?)
- = render "services/offers", offers: @offers, service: @service,
- bundles: @bundles, bundled: @bundled, preview: local_assigns[:preview]
- = render "taggable/details_section", taggable: @service, preview: true
- #details.d-none{ "data-preview-target": "content" }
- = render Presentable::DetailsComponent.new(@service, preview: true)
+= render "services/wrapper", service: @service, category: @category,
+ comparison_enabled: @comparison_enabled, compare_services: @compare_services,
+ favourite_services: @favourite_services, question: @question, tab_id: "desc", preview: true do
+ #about{ "data-preview-target": "content" }
+ = render Presentable::DescriptionComponent.new(object: @service,
+ similar_services: @similar_services, related_services: @related_services, preview: true) do |c|
+ - c.description_panels do
+ - if policy(@service).order? && (policy(@service).offers_show? || policy(@service).bundles_show?)
+ = render "services/offers", offers: @offers, service: @service,
+ bundles: @bundles, bundled: @bundled, preview: true
+ = render "taggable/details_section", taggable: @service, preview: true
+ #details.d-none{ "data-preview-target": "content" }
+ = render Presentable::DetailsComponent.new(@service, preview: true)
diff --git a/app/views/backoffice/services/show.html.haml b/app/views/backoffice/services/show.html.haml
index 0602af8d6..115604c35 100644
--- a/app/views/backoffice/services/show.html.haml
+++ b/app/views/backoffice/services/show.html.haml
@@ -1,45 +1,11 @@
- content_for :title, @service.name
- breadcrumb :backoffice_service, @service
-.container.p-0.backoffice
- - if @service.offers.blank? && !@service.deleted?
- .alert.alert-danger.mb-0.text-center
- = _("This service has no offers. Add one offer to make possible for a user to Access the service.")
- - elsif @service.published? && @service.offers.published.blank?
- .alert.alert-warning.mb-0.text-center
- -# haml-lint:disable MultilinePipe
- = ("The service is published but has no published offers. Publish one offer to make possible for a user to " + |
- "Access the service.") |
- -# haml-lint:enable MultilinePipe
- = render "services/errors", service: @service
-
-.container.p-0.backoffice
- = render Presentable::StatusActionsComponent.new(object: @service,
- publish: policy([:backoffice, @service]).publish?,
- suspend: policy([:backoffice, @service]).suspend?,
- unpublish: policy([:backoffice, @service]).unpublish?,
- destroy: policy([:backoffice, @service]).destroy?)
-
-.container.p-0.backoffice
- .pt-3.service-box-redesign.service-detail.backoffice{ "data-shepherd-tour-target": "service-box" }
- = render Presentable::HeaderComponent.new(object: @service,
- title: @service.name,
- abbreviation: @service.abbreviation,
- subtitle: @service.tagline,
- comparison_enabled: @comparison_enabled,
- show_checkboxes: false,
- preview: local_assigns[:preview],
- favourite_services: @favourite_services) do |c|
- - c.buttons do
- = render "components/presentable/header_component/backoffice_service_buttons", service: @service
-
- = render "services/tabs", service: @service, params: { from: "backoffice_service" }
-.tab-content
+= render "wrapper", service: @service, comparison_enabled: @comparison_enabled,
+ favourite_services: @favourite_services, question: @question, preview: false do
= render Presentable::DescriptionComponent.new(object: @service,
similar_services: @similar_services, related_services: @related_services,
- question: @question, from: "backoffice_service") do |c|
- - c.description_panels do
- = render "layouts/common_parts/services/offers", offers: @offers, service: @service, bundles: @bundles
+ from: "backoffice_service") do |c|
- c.additional_backoffice_info do
.right-panel-links.pt-4.pb-4
= render "components/presentable/updates", object: @service
diff --git a/app/views/comparisons/show.html.haml b/app/views/comparisons/show.html.haml
index b170fcd20..ad12aea3d 100644
--- a/app/views/comparisons/show.html.haml
+++ b/app/views/comparisons/show.html.haml
@@ -28,7 +28,7 @@
%i.far.fa-trash-alt
.service-title
= link_to service.name.truncate(30, separator: " "),
- service_path(service, fromc: params[:fromc], comp_link: true),
+ service_offers_path(service, fromc: params[:fromc], comp_link: true),
"data-probe": "", "data-service-id": service.id
.service-description
= service.description.truncate(80, separator: " ")
diff --git a/app/views/components/presentable/header_component/_ask_question.html.haml b/app/views/components/presentable/_ask_question.html.haml
similarity index 100%
rename from app/views/components/presentable/header_component/_ask_question.html.haml
rename to app/views/components/presentable/_ask_question.html.haml
diff --git a/app/views/components/presentable/_sidebar.html.haml b/app/views/components/presentable/_sidebar.html.haml
new file mode 100644
index 000000000..c1ea9326d
--- /dev/null
+++ b/app/views/components/presentable/_sidebar.html.haml
@@ -0,0 +1,10 @@
+%sidebar.col-12.col-xl-3{ "data-shepherd-tour-target": "service-classification" }
+ = render "components/presentable/explore_links", object: object
+ .right-panel-links
+ - if !object.public_contacts.empty? && (question || preview)
+ = render "components/presentable/ask_question", question_link: new_question_link(object),
+ question: question,
+ prompt: new_question_prompt(object),
+ preview: preview
+ = render Presentable::LinksComponent.new(object: object, preview: preview)
+ = render Presentable::ProviderInfoComponent.new(base: object, preview: preview) if object.respond_to?(:resource_organisation)
diff --git a/app/views/components/presentable/header_component/_backoffice_service_buttons.html.haml b/app/views/components/presentable/header_component/_backoffice_service_buttons.html.haml
index 7d2638282..b2cc4ea19 100644
--- a/app/views/components/presentable/header_component/_backoffice_service_buttons.html.haml
+++ b/app/views/components/presentable/header_component/_backoffice_service_buttons.html.haml
@@ -1,6 +1,6 @@
- if policy([:backoffice, service]).edit?
= link_to _("Edit #{service.type.downcase}"), edit_backoffice_service_path(service),
class: "btn btn-outline-primary d-block mb-3"
- = link_to _("Set parameters and offers"), backoffice_service_path(service, anchor: "offers"),
+ = link_to _("Set parameters and offers"), backoffice_service_offers_path(service, anchor: "offers"),
class: "btn btn-outline-secondary d-block mb-3"
= render "layouts/common_parts/services/order_type_label", object: service
diff --git a/app/views/components/presentable/header_component/_order_buttons.html.haml b/app/views/components/presentable/header_component/_order_buttons.html.haml
index 99e166043..e2bb5615b 100644
--- a/app/views/components/presentable/header_component/_order_buttons.html.haml
+++ b/app/views/components/presentable/header_component/_order_buttons.html.haml
@@ -1,7 +1,7 @@
- if local_assigns[:preview] || policy(ServiceContext.new(service,
params.key?(:from) && params[:from] == "backoffice_service")).order?
= link_to _("Access the service"),
- service_offers_path(service),
+ service_choose_offer_path(service),
class: "btn btn-primary d-block mb-3 py-3",
"data-e2e": "access-service-btn",
"data-probe": "",
diff --git a/app/views/components/presentable/header_component/_ordering_configuration_buttons.html.haml b/app/views/components/presentable/header_component/_ordering_configuration_buttons.html.haml
index 765b550b1..9058b1e14 100644
--- a/app/views/components/presentable/header_component/_ordering_configuration_buttons.html.haml
+++ b/app/views/components/presentable/header_component/_ordering_configuration_buttons.html.haml
@@ -1,4 +1,4 @@
-= link_to _("Back to the service"), service_path(service),
+= link_to _("Back to the service"), service_offers_path(service),
class: "btn btn-outline-primary d-block mb-3"
= link_to _("Set parameters and offers"), service_ordering_configuration_path(service,
anchor: "offers",
diff --git a/app/views/components/presentable/links_component/_links.html.haml b/app/views/components/presentable/links_component/_links.html.haml
index 51fd1d5f4..a2a19ed97 100644
--- a/app/views/components/presentable/links_component/_links.html.haml
+++ b/app/views/components/presentable/links_component/_links.html.haml
@@ -7,6 +7,6 @@
"data-preview-target": preview ? "link" : "")
- else
= link_to(t("components.presentable.sidebar_component.fields.#{field}"),
- object.suspended? && !field.in?(active_when_suspended) ? nil : object.send(field), "data-probe": "",
- "data-preview-target": preview ? "link" : "")
+ preview || (object.suspended? && !field.in?(active_when_suspended)) ? "javascript:;" : object.send(field),
+ "data-probe": "", "data-preview-target": preview ? "link" : "")
-# TODO: refactor dynamic translation (above)
diff --git a/app/views/favourites/_service.html.haml b/app/views/favourites/_service.html.haml
index 35eabc0ba..615860118 100644
--- a/app/views/favourites/_service.html.haml
+++ b/app/views/favourites/_service.html.haml
@@ -1,6 +1,6 @@
.row{ id: "box-#{service.id}", "data-favourite-target": "result", "data-e2e": "favourite-result" }
= render "service_details", service: service do
- = link_to service.name, service_path(service)
+ = link_to service.name, service_offers_path(service)
.row
- content_for :comparison_checkbox do
.mt-3.compare
diff --git a/app/views/home/_opinions.html.haml b/app/views/home/_opinions.html.haml
index b68edf2c7..e6dec4299 100644
--- a/app/views/home/_opinions.html.haml
+++ b/app/views/home/_opinions.html.haml
@@ -2,7 +2,7 @@
= _("Recent opinions")
- if opinion
- %a#opinion-link.card-title{ href: "#{service_path(opinion.project_item.service)}" }
+ %a#opinion-link.card-title{ href: "#{service_offers_path(opinion.project_item.service)}" }
= opinion.project_item.service.name
.row.mt-3
.col
diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml
index c2761e6f0..97e11085d 100644
--- a/app/views/home/index.html.haml
+++ b/app/views/home/index.html.haml
@@ -73,7 +73,7 @@
%i{ class: "ordertype #{order_type(service)}" }
-# TODO: refactor dynamic translation
= t("offers.type.#{order_type(service)}")
- %a.popular-title{ href: service_path(service) }= service.name
+ %a.popular-title{ href: service_offers_path(service) }= service.name
%a.popular-provider{ href: services_path(providers: service.resource_organisation.id) }
= service.resource_organisation.name
.popular-description{ data_toggle: "tooltip", title: service.description }
diff --git a/app/views/layouts/backoffice/_navbar.html.haml b/app/views/layouts/backoffice/_navbar.html.haml
index b4ad42d55..5487d6048 100644
--- a/app/views/layouts/backoffice/_navbar.html.haml
+++ b/app/views/layouts/backoffice/_navbar.html.haml
@@ -14,7 +14,7 @@
"data-toggle" => "collapse",
type: "button" }
%span.navbar-toggler-icon
- - if controller.action_name == "index"
+ - if controller.action_name == "index" && controller.controller_name != "offers"
#navbar-supported-content.collapse.navbar-collapse
%ul.navbar-nav
= nav_link controller: :services, html_options: { class: "nav-item" } do
diff --git a/app/views/layouts/common_parts/services/_bundle_box.html.haml b/app/views/layouts/common_parts/services/_bundle_box.html.haml
index b56a1276c..9ec3dc718 100644
--- a/app/views/layouts/common_parts/services/_bundle_box.html.haml
+++ b/app/views/layouts/common_parts/services/_bundle_box.html.haml
@@ -4,7 +4,7 @@
= service_status(bundle, "text-sm-left fa-pull-left badge-left")
= render "services/bundles/description", bundle: bundle
= render "services/bundle", bundled_offers: bundle.all_offers, parent: bundle.main_offer
- = render "services/offers/bundle_links",
+ = render "services/choose_offers/bundle_links",
contact_email: bundle.contact_email || "",
related_training: bundle.related_training ? bundle.related_training_url : "",
helpdesk_url: bundle.helpdesk_url || ""
diff --git a/app/views/layouts/common_parts/services/_default_parameters.html.haml b/app/views/layouts/common_parts/services/_default_parameters.html.haml
deleted file mode 100644
index 208fe1893..000000000
--- a/app/views/layouts/common_parts/services/_default_parameters.html.haml
+++ /dev/null
@@ -1,30 +0,0 @@
-- technical_parameters = offer.attributes.map(&:to_json)
-- published_offers_size = offer.service.offers.published.size
-.col-md-6.edit-offer{ "data-e2e": "offer" }
- .card.m-0.mb-5{ class: offer.default ? "default" : nil }
- - if offer.default && published_offers_size == 2
- .card-body.pt-0.collapse-group
- .container
- .row.info-row
- .col-12.col-sm-3
- = image_tag "icon-pencil.png", class: "icon-pencil"
- .col-12.col-sm-9.pl-0
- %p
- -# haml-lint:disable MultilinePipe
- = _("Your technical parameters configuration has been changed into a default offer. ")
- = _(" Please provide the offer Name and Description for a better user experience.") |
- -# haml-lint:enable MultilinePipe
- - else
- - content_for :status do
- = service_status(offer, "text-sm-left fa-pull-left badge-left")
- = render "services/offers/description", offer: offer
- = render "layouts/common_parts/services/parameters", technical_parameters: technical_parameters
-
- .card-button.text-center
- %label
- = link_to edit_offer_link(offer.service, offer, controller_name) do
- %span.btn.btn-outline-secondary.font-weight-bold
- - if published_offers_size == 1
- = _("Edit parameters")
- - else
- = _("Edit")
diff --git a/app/views/layouts/common_parts/services/_offers.html.haml b/app/views/layouts/common_parts/services/_offers.html.haml
index c73b434bf..30b7583d7 100644
--- a/app/views/layouts/common_parts/services/_offers.html.haml
+++ b/app/views/layouts/common_parts/services/_offers.html.haml
@@ -14,14 +14,12 @@
= _("Vouchers allow researchers to test different configurations or different services to choose the " + |
"best offer for their needs.") |
-# haml-lint:enable MultilinePipe
-%hr.bottom-hr.mt-5.mb-4
+
#offers
%h2.mb-4.mt-5.font-weight-normal
= _("Parameters and offers")
.row.parameters
- - if offers.present?
- = render partial: "layouts/common_parts/services/default_parameters", locals: { offer: offers.manageable.first }
- = render partial: "layouts/common_parts/services/offer", collection: offers[1..], as: :offer if offers.manageable.size > 1
+ = render partial: "layouts/common_parts/services/offer", collection: offers, as: :offer if offers.present?
= render "layouts/common_parts/services/new_offer", service: service if policy([:backoffice, service]).edit?
.row.parameters
%h2.mb-4.mt-5.font-weight-normal
diff --git a/app/views/projects/services/_details.html.haml b/app/views/projects/services/_details.html.haml
index 0e6d1ae4b..85a15f026 100644
--- a/app/views/projects/services/_details.html.haml
+++ b/app/views/projects/services/_details.html.haml
@@ -1,7 +1,7 @@
%dl
%dt
= _("Service name") + ":"
- %dd= link_to project_item.service.name, project_item.service
+ %dd= link_to project_item.service.name, service_offers_path(project_item.service)
- if project_item.service.offers_count > 1
%dl
%dt
diff --git a/app/views/providers/show.html.haml b/app/views/providers/show.html.haml
index 77c17abe6..fb04a8e87 100644
--- a/app/views/providers/show.html.haml
+++ b/app/views/providers/show.html.haml
@@ -14,9 +14,20 @@
= render "providers/tabs", provider: @provider
.tab-content.provider-view{ class: "#{"suspended" if @provider.suspended?}" }
- = render Presentable::DescriptionComponent.new(object: @provider,
- question: @question,
- preview: @provider.suspended? || local_assigns[:preview]) do |c|
- - c.description_panels do
- = render "providers/related", provider: @provider, related_services: @related_services
- = render "taggable/details_section", taggable: @provider
+ #desc.tab-pane.container.active.desc{ "aria-labelledby": "home-tab", role: "tabpanel" }
+ .row.justify-content-between
+ %main.col-12.col-xl-9.pr-4.pt-4{ "data-shepherd-tour-target": "service-about" }
+ = render Presentable::DescriptionComponent.new(object: @provider,
+ question: @question,
+ preview: @provider.suspended? || local_assigns[:preview]) do |c|
+ - c.description_panels do
+ = render "providers/related", provider: @provider, related_services: @related_services
+ = render "taggable/details_section", taggable: @provider
+ %sidebar.col-12.col-xl-3{ "data-shepherd-tour-target": "service-classification" }
+ .right-panel-links
+ - if !@provider.public_contacts.empty? && (@question || @preview)
+ = render "components/presentable/ask_question", question_link: new_question_link(@provider),
+ question: @question,
+ prompt: new_question_prompt(@provider),
+ preview: @preview
+ = render Presentable::LinksComponent.new(object: @provider, preview: @preview)
diff --git a/app/views/services/_bundle_box.html.haml b/app/views/services/_bundle_box.html.haml
index 69e749ab1..c2b8a43fa 100644
--- a/app/views/services/_bundle_box.html.haml
+++ b/app/views/services/_bundle_box.html.haml
@@ -3,15 +3,16 @@
= render "services/bundles/description", bundle: bundle
= render "services/bundle", bundled_offers: bundle.all_offers, parent: bundle.main_offer
.d-flex.pb-3.pt-3
- = render "services/offers/bundle_links",
+ = render "services/choose_offers/bundle_links",
contact_email: bundle.contact_email || "",
related_training: bundle.related_training_url || "",
helpdesk_url: bundle.helpdesk_url || ""
- if policy(ServiceContext.new(bundle.service,params.key?(:from) && params[:from] == "backoffice_service")).order?
.card-button.text-center.add-bundle
%label
- = link_to service_offers_path(bundle.service,
+ = link_to service_choose_offer_path(bundle.service,
customizable_project_item: { offer_id: bundle.main_offer.iid, bundle_id: bundle.iid }),
- data: { probe: "", service_id: bundle.service.id, turbo_method: :put } do
+ data: { preview_target: "#{"link" if preview}", probe: "",
+ service_id: bundle.service.id, turbo_method: :put } do
%span.btn.btn-secondary.font-weight-bolder.mt-2
= _("Select bundle")
diff --git a/app/views/services/_bundled_offer.html.haml b/app/views/services/_bundled_offer.html.haml
index 6811a0676..47452eb78 100644
--- a/app/views/services/_bundled_offer.html.haml
+++ b/app/views/services/_bundled_offer.html.haml
@@ -26,7 +26,7 @@
%i.fas.fa-tachometer-alt
= _("Technical Parameters")
.card-text{ "data-controller" => "paragraph" }
- = render "services/offers/bundle_parameters", id: offer.id,
+ = render "services/choose_offers/bundle_parameters", id: offer.id,
technical_parameters: offer.attributes.map(&:to_json)
.bundle-offer-order-type.badge.access-information.badge-right.style_order_required{ class: offer.order_type }
diff --git a/app/views/services/_header.html.haml b/app/views/services/_header.html.haml
new file mode 100644
index 000000000..2c44dadc2
--- /dev/null
+++ b/app/views/services/_header.html.haml
@@ -0,0 +1,15 @@
+.pt-4.service-box-redesign.service-detail{ "data-shepherd-tour-target": "service-box" }
+ = render Presentable::HeaderComponent.new(object: service,
+ title: service.name,
+ abbreviation: service.abbreviation,
+ subtitle: service.tagline,
+ comparison_enabled: comparison_enabled,
+ preview: local_assigns[:preview] || service.suspended?,
+ favourite_services: favourite_services) do |c|
+ - c.buttons do
+ = render "components/presentable/header_component/order_buttons", service: service
+ = render "services/tabs", service: service
+ - dynamic_class = (session[:comparison]&.size || 0).positive? ? "d-block" : "d-none"
+ #comparison-bar.comparison-bar.fixed-bottom{ class: dynamic_class,
+ "data-comparison-target": "bar", "data-e2e": "comparison-bar" }
+ = render "comparisons/bar", services: compare_services, category: category
diff --git a/app/views/services/_offer.html.haml b/app/views/services/_offer.html.haml
index 03f3b085f..fc98ec97b 100644
--- a/app/views/services/_offer.html.haml
+++ b/app/views/services/_offer.html.haml
@@ -6,7 +6,7 @@
- if policy(ServiceContext.new(offer.service, params.key?(:from) && params[:from] == "backoffice_service")).order?
.card-button.text-center
%label.d-block
- = link_to service_offers_path(offer.service, customizable_project_item: { offer_id: offer.iid }),
+ = link_to service_choose_offer_path(offer.service, customizable_project_item: { offer_id: offer.iid }),
data: { probe: "", "service-id": offer.service.id, e2e: "select-offer-btn",
"preview-target": local_assigns[:preview] ? "link" : "", "turbo-method": :put } do
%span.btn.btn-secondary.font-weight-bolder
diff --git a/app/views/services/_offers.html.haml b/app/views/services/_offers.html.haml
index d7027474e..7a5ac14a2 100644
--- a/app/views/services/_offers.html.haml
+++ b/app/views/services/_offers.html.haml
@@ -18,7 +18,7 @@
%h2.mb-4.mt-5.font-weight-bolder
= _("Services")
.row
- = render partial: "services/offer", collection: offers, as: :offer, locals: { preview: local_assigns[:preview] }
+ = render partial: "services/offer", collection: offers, as: :offer, locals: { preview: preview }
- if policy(service).bundles_show?
%h2.mb-3.mt-4.font-weight-bolder
= _("Bundles")
@@ -28,9 +28,9 @@
"of research. The bundle is configured to make your research easier and done more efficiently.") |
-# haml-lint:enable MultilinePipe
.row
- = render partial: "services/bundle_box", collection: bundles, as: :bundle, locals: { bundled: false }
+ = render partial: "services/bundle_box", collection: bundles, as: :bundle, locals: { bundled: false, preview: preview}
- if bundled.present?
.col-md-12
%h2.mb-4.font-weight-bolder
= _("This service is included in bundles:")
- = render partial: "services/bundle_box", collection: bundled, as: :bundle, locals: { bundled: true }
+ = render partial: "services/bundle_box", collection: bundled, as: :bundle, locals: { bundled: true, preview: preview }
diff --git a/app/views/services/_offers_box.html.haml b/app/views/services/_offers_box.html.haml
index eb3d4a820..2fc99e874 100644
--- a/app/views/services/_offers_box.html.haml
+++ b/app/views/services/_offers_box.html.haml
@@ -2,5 +2,5 @@
- service_offers.each do |offer, h|
%li
%span= link_to highlighted_for(:offer_name, offer, h),
- service_path(service, anchor: "offer-#{ offer.id }"),
+ service_offers_path(service, anchor: "offer-#{ offer.id }"),
"data-probe": "", "data-service-id": service.id
diff --git a/app/views/services/_opinions.html.haml b/app/views/services/_opinions.html.haml
index bcbfafd16..5289b8532 100644
--- a/app/views/services/_opinions.html.haml
+++ b/app/views/services/_opinions.html.haml
@@ -1,17 +1,2 @@
-#opinions.tab-pane.container.active{ "aria-labelledby" => "opinions-tab", role: "tabpanel" }
- .row
- %main.col-12.col-xl-9.pr-4.mb-4.pt-4
- = render(partial: "service_opinions/service_opinion",
- collection: service_opinions) || _("There are no reviews available.")
- %sidebar.col-12.col-xl-3{ "data-shepherd-tour-target": "service-classification" }
- = render "components/presentable/explore_links", object: service
- .right-panel-links
- - if !service.public_contacts.empty? && (question || preview)
- = render "components/presentable/header_component/ask_question", question_link: new_question_link(service),
- question: question,
- prompt: new_question_prompt,
- preview: preview
- = render Presentable::LinksComponent.new(object: service, preview: preview)
- - if service.respond_to?(:resource_organisation)
- .provider-panel
- = render Presentable::ProviderInfoComponent.new(base: service, preview: preview)
+= render(partial: "service_opinions/service_opinion",
+ collection: service_opinions) || _("There are no reviews available.")
diff --git a/app/views/services/_recommendation_v1.html.haml b/app/views/services/_recommendation_v1.html.haml
index ea8f9d83d..57c7b50ce 100644
--- a/app/views/services/_recommendation_v1.html.haml
+++ b/app/views/services/_recommendation_v1.html.haml
@@ -1,7 +1,7 @@
.service-info-box.recommendation.ver-1
%header
= link_to truncate(recommendation_v1.send(:name), length: 40, escape: false),
- service_path(recommendation_v1, fromc: category.present? ? category.slug : nil,
+ service_offers_path(recommendation_v1, fromc: category.present? ? category.slug : nil,
from_recommendation_panel: true), "data-probe": "recommendation-panel",
"data-service-id" => recommendation_v1.id
%article
diff --git a/app/views/services/_service.html.haml b/app/views/services/_service.html.haml
index e74763bd9..0b51d8122 100644
--- a/app/views/services/_service.html.haml
+++ b/app/views/services/_service.html.haml
@@ -2,7 +2,7 @@
service_offers: filtered_offers(offers[service.id]), comparison_enabled: comparison_enabled,
tour_overview_9_target: local_assigns[:tour_overview_9_target_on_counter] == service_counter do
= link_to highlighted_for(:name, service, highlights[service.id]),
- service_path(service, category.present? ? { fromc: category.slug } : nil),
+ service_offers_path(service, category.present? ? { fromc: category.slug } : nil),
"data-e2e": "service-name", "data-probe": "", "data-service-id": service.id
- content_for :comparison_checkbox do
.mt-3.compare
diff --git a/app/views/services/_service_details.html.haml b/app/views/services/_service_details.html.haml
index c33df508b..6dd73c04d 100644
--- a/app/views/services/_service_details.html.haml
+++ b/app/views/services/_service_details.html.haml
@@ -35,4 +35,4 @@
.service-logo
= presentable_logo(service, "align-center mx-4 service-logo", "120x120")
.backoffice-button-row.d-none{ class: ("d-block" if request.fullpath.include?("backoffice")) }
- = link_to "Manage service and offers", backoffice_service_path(service), class: "btn btn-primary"
+ = link_to "Manage service and offers", backoffice_service_offers_path(service), class: "btn btn-primary"
diff --git a/app/views/services/_tabs.haml b/app/views/services/_tabs.haml
index cc0ed077e..ca545bb3c 100644
--- a/app/views/services/_tabs.haml
+++ b/app/views/services/_tabs.haml
@@ -21,6 +21,11 @@
%a.nav-link.disabled.text-uppercase{ "data-probe" => "", "data-service-id" => service.id }
= _("Reviews (%{ssoc})") % { ssoc: service.service_opinion_count }
- else
+ - if request.fullpath.include?("backoffice") || policy_scope(service.offers).any?
+ %li.nav-item
+ = link_to _("Offers"), offers_link(service, go_to_search_query_params(params)),
+ class: "nav-link #{"active" if controller.controller_name == "offers" }", role: "tab",
+ data: { probe: "", "service-id": service.id, e2e: "service-about-btn" }
%li.nav-item
= link_to _("About"), about_link(service, go_to_search_query_params(params)),
class: "nav-link #{"active" if about_active }", role: "tab",
diff --git a/app/views/services/_wrapper.html.haml b/app/views/services/_wrapper.html.haml
new file mode 100644
index 000000000..962ebaab1
--- /dev/null
+++ b/app/views/services/_wrapper.html.haml
@@ -0,0 +1,40 @@
+%div{ "data-controller": "#{"preview" if preview}" }
+ .container{ class: "#{"suspended" if service.suspended?}", "data-controller": "comparison",
+ "data-shepherd-tour-target": "overview_10" }
+ .pt-4.service-box-redesign.service-detail{ "data-shepherd-tour-target": "service-box" }
+ = render Presentable::HeaderComponent.new(object: service,
+ title: service.name,
+ abbreviation: service.abbreviation,
+ subtitle: service.tagline,
+ comparison_enabled: comparison_enabled,
+ preview: preview || service.suspended?,
+ favourite_services: favourite_services) do |c|
+ - c.buttons do
+ - case params[:from]
+ - when "ordering_configuration"
+ = render "components/presentable/header_component/ordering_configuration_buttons", service: service
+ - when "backoffice_service"
+ = render "components/presentable/header_component/backoffice_service_buttons", service: service
+ - else
+ = render "components/presentable/header_component/order_buttons", service: service, preview: preview
+ = render "services/tabs", service: service
+ - dynamic_class = (session[:comparison]&.size || 0).positive? ? "d-block" : "d-none"
+ #comparison-bar.comparison-bar.fixed-bottom{ class: dynamic_class,
+ "data-comparison-target": "bar", "data-e2e": "comparison-bar" }
+ = render "comparisons/bar", services: compare_services, category: category
+ .tab-content
+ .tab-pane.container.active.desc{ id: tab_id, "aria-labelledby": "home-tab", role: "tabpanel" }
+ .row.justify-content-between
+ %main.col-12.col-xl-9.pr-4.pt-4{ "data-shepherd-tour-target": "service-about" }
+ = yield
+ %sidebar.col-12.col-xl-3{ "data-shepherd-tour-target": "service-classification" }
+ = render "components/presentable/explore_links", object: service
+ .right-panel-links
+ - if !service.public_contacts.empty? && (question || preview)
+ = render "components/presentable/ask_question", question_link: new_question_link(service),
+ question: question,
+ prompt: new_question_prompt(service),
+ preview: preview
+ = render Presentable::LinksComponent.new(object: service, preview: preview)
+ = render Presentable::ProviderInfoComponent.new(base: service,
+ preview: preview) if service.respond_to?(:resource_organisation)
diff --git a/app/views/services/bundles/_offer.html.haml b/app/views/services/bundles/_offer.html.haml
index 32e2661a3..6ac079502 100644
--- a/app/views/services/bundles/_offer.html.haml
+++ b/app/views/services/bundles/_offer.html.haml
@@ -7,7 +7,7 @@
.col-9.col-md-9
%h3
= link_to truncate(service.name, length: 40, escape: false),
- service_path(service)
+ service_offers_path(service)
- if service.horizontal
%span.horizontal-badge-new Horizontal service
- if providers_text(service).present?
diff --git a/app/views/services/offers/_bundle_box.html.haml b/app/views/services/choose_offers/_bundle_box.html.haml
similarity index 85%
rename from app/views/services/offers/_bundle_box.html.haml
rename to app/views/services/choose_offers/_bundle_box.html.haml
index f291baa0a..66aff3324 100644
--- a/app/views/services/offers/_bundle_box.html.haml
+++ b/app/views/services/choose_offers/_bundle_box.html.haml
@@ -1,8 +1,8 @@
.col-12.d-flex.align-items-stretch.bundle.bundle-order
.card.m-0.mb-5
- = render "services/offers/bundle_description", bundle: bundle
+ = render "services/choose_offers/bundle_description", bundle: bundle
= render "services/bundle", bundled_offers: bundle.all_offers, parent: bundle.main_offer
- = render "services/offers/bundle_links",
+ = render "services/choose_offers/bundle_links",
contact_email: bundle.contact_email || "",
related_training: bundle.related_training_url || "",
helpdesk_url: bundle.helpdesk_url || ""
diff --git a/app/views/services/offers/_bundle_description.html.haml b/app/views/services/choose_offers/_bundle_description.html.haml
similarity index 100%
rename from app/views/services/offers/_bundle_description.html.haml
rename to app/views/services/choose_offers/_bundle_description.html.haml
diff --git a/app/views/services/offers/_bundle_links.html.haml b/app/views/services/choose_offers/_bundle_links.html.haml
similarity index 100%
rename from app/views/services/offers/_bundle_links.html.haml
rename to app/views/services/choose_offers/_bundle_links.html.haml
diff --git a/app/views/services/offers/_bundle_parameters.html.haml b/app/views/services/choose_offers/_bundle_parameters.html.haml
similarity index 100%
rename from app/views/services/offers/_bundle_parameters.html.haml
rename to app/views/services/choose_offers/_bundle_parameters.html.haml
diff --git a/app/views/services/offers/_offer.html.haml b/app/views/services/choose_offers/_offer.html.haml
similarity index 100%
rename from app/views/services/offers/_offer.html.haml
rename to app/views/services/choose_offers/_offer.html.haml
diff --git a/app/views/services/offers/show.html.haml b/app/views/services/choose_offers/show.html.haml
similarity index 76%
rename from app/views/services/offers/show.html.haml
rename to app/views/services/choose_offers/show.html.haml
index 7541c3728..fea56d17d 100644
--- a/app/views/services/offers/show.html.haml
+++ b/app/views/services/choose_offers/show.html.haml
@@ -1,5 +1,5 @@
- content_for :title, _("Offer selection")
-= simple_form_for @step, url: service_offers_path(@service), method: :put,
+= simple_form_for @step, url: service_choose_offer_path(@service), method: :put,
html: { id: "order-form", role: "form", class: "btn-group-toogle",
data: { controller: "order", toogle: "buttons", turbo: false } } do |f|
@@ -7,7 +7,7 @@
%h2.mb-4.mt-5.font-bold
= _("Select an offer or service bundle")
.card-deck.row
- = render partial: "services/offers/offer",
+ = render partial: "services/choose_offers/offer",
collection: @offers, as: :offer, locals: { f: f, project_item: @step }
- if policy(@service).bundles_show? && @bundles.present?
.row
@@ -15,5 +15,5 @@
%h2.mb-4.mt-5.font-bold
= _("Service bundles")
.card-deck.row
- = render partial: "services/offers/bundle_box",
+ = render partial: "services/choose_offers/bundle_box",
collection: @bundles, as: :bundle, locals: { f: f, project_item: @step }
diff --git a/app/views/services/details/index.html.haml b/app/views/services/details/index.html.haml
index 8b643543c..c13432ecb 100644
--- a/app/views/services/details/index.html.haml
+++ b/app/views/services/details/index.html.haml
@@ -1,31 +1,8 @@
- content_for :title, @service.name
- breadcrumb :resource_details, @service
= render "services/errors", service: @service
-.container{ class: "#{"suspended" if @service.suspended?}", "data-controller": "comparison" }
- - dynamic_class = params[:from] == "backoffice_service" ? "backoffice" : nil
- .pt-4.service-box-redesign.service-detail{ class: dynamic_class }
- = render Presentable::HeaderComponent.new(object: @service,
- title: @service.name,
- subtitle: @service.tagline,
- abbreviation: @service.abbreviation,
- comparison_enabled: @comparison_enabled,
- preview: local_assigns[:preview] || @service.suspended?,
- show_checkboxes: params[:from].blank?,
- favourite_services: @favourite_services) do |c|
- - c.buttons do
- - case params[:from]
- - when "ordering_configuration"
- = render "components/presentable/header_component/ordering_configuration_buttons", service: @service
- - when "backoffice_service"
- = render "components/presentable/header_component/backoffice_service_buttons", service: @service
- - else
- = render "components/presentable/header_component/order_buttons", service: @service
-
- = render "services/tabs", service: @service
- - dynamic_class = (session[:comparison]&.size || 0).positive? ? "d-block" : "d-none"
- #comparison-bar.comparison-bar.fixed-bottom{ class: dynamic_class, "data-comparison-target": "bar" }
- = render "comparisons/bar", services: @compare_services, category: @category
-
-.tab-content
+= render "services/wrapper", service: @service, category: @category,
+ comparison_enabled: @comparison_enabled, compare_services: @compare_services,
+ favourite_services: @favourite_services, question: @question, tab_id: "opinions", preview: false do
= render Presentable::DetailsComponent.new(@service, similar_services: @similar_services, question: @question,
related_services: @related_services)
diff --git a/app/views/services/guidelines/index.html.haml b/app/views/services/guidelines/index.html.haml
index a19a2304f..d115d9094 100644
--- a/app/views/services/guidelines/index.html.haml
+++ b/app/views/services/guidelines/index.html.haml
@@ -1,51 +1,10 @@
- content_for :title, @service.name
- breadcrumb :resource_details, @service
-.container{ "data-controller": "comparison" }
- - header_class = params[:from] == "backoffice_service" ? "backoffice" : nil
- .pt-4.service-box-redesign.service-detail{ class: header_class }
- = render Presentable::HeaderComponent.new(object: @service,
- title: @service.name,
- subtitle: @service.tagline,
- comparison_enabled: @comparison_enabled,
- preview: local_assigns[:preview],
- show_checkboxes: params[:from].blank?,
- favourite_services: @favourite_services) do |c|
- - c.buttons do
- - case params[:from]
- - when "ordering_configuration"
- = render "components/presentable/header_component/ordering_configuration_buttons", service: @service
- - when "backoffice_service"
- = render "components/presentable/header_component/backoffice_service_buttons", service: @service
- - else
- = render "components/presentable/header_component/order_buttons", service: @service
-
- = render "services/tabs", service: @service
- - comparison_bar_class = (session[:comparison]&.size || 0).positive? ? "d-block" : "d-none"
- #comparison-bar.comparison-bar.fixed-bottom{ class: comparison_bar_class, "data-comparison-target": "bar" }
- = render "comparisons/bar", services: @compare_services, category: @category
-
-.tab-content
+= render "services/wrapper", service: @service, category: @category,
+ comparison_enabled: @comparison_enabled, compare_services: @compare_services,
+ favourite_services: @favourite_services, question: @question, tab_id: "opinions", preview: false do
- if @service.guidelines.blank?
- #opinions.tab-pane.container.active{ "aria-labelledby": "opinions-tab", role: "tabpanel",
- "data-shepherd-tour-target": "service-details-content" }
- .row
- %main.col-12.col-xl-9.pr-4.mb-4.pt-4
- This service has no Interoperability Guidelines
-
- %sidebar.col-12.col-xl-3{ "data-shepherd-tour-target": "service-classification" }
- = render "components/presentable/explore_links", object: @service
- .right-panel-links
- - if !@service.public_contacts.empty? && (@question || @preview)
- = render "components/presentable/header_component/ask_question",
- question_link: new_question_link(@service),
- question: @question,
- prompt: new_question_prompt,
- preview: @preview
- = render Presentable::LinksComponent.new(object: @service, preview: @preview)
- - if @service.respond_to?(:resource_organisation)
- .provider-panel
- = render Presentable::ProviderInfoComponent.new(base: @service, preview: @preview)
-
+ This service has no Interoperability Guidelines
- else
= render Presentable::DetailsComponent.new(@service, guidelines: true)
diff --git a/app/views/services/information/_bundle.html.haml b/app/views/services/information/_bundle.html.haml
index 6ebe0f870..40ca622a1 100644
--- a/app/views/services/information/_bundle.html.haml
+++ b/app/views/services/information/_bundle.html.haml
@@ -11,7 +11,7 @@
To find out more about Projects in EOSC Marketplace, please refer to our FAQ.
.small-links
- = render "services/offers/bundle_links",
+ = render "services/choose_offers/bundle_links",
contact_email: bundle.contact_email || "",
related_training: bundle.related_training_url || "",
helpdesk_url: bundle.helpdesk_url || ""
diff --git a/app/views/services/offers/index.html.haml b/app/views/services/offers/index.html.haml
new file mode 100644
index 000000000..0a54b3177
--- /dev/null
+++ b/app/views/services/offers/index.html.haml
@@ -0,0 +1,13 @@
+- content_for :title, @service.name
+- id = h(@service&.main_source&.eid) || h(@service&q.slug)
+:javascript
+ _paq.push(['trackEvent', 'Service', 'Visit', '#{id}']);
+- breadcrumb :service, @service
+= render "services/errors", service: @service
+= render "services/wrapper", service: @service, category: @category,
+ comparison_enabled: @comparison_enabled, compare_services: @compare_services,
+ favourite_services: @favourite_services, question: @question, tab_id: "desc", preview: false do
+ - if policy(@service).offers_show? || policy(@service).bundles_show?
+ = render "services/offers", offers: @offers, service: @service,
+ bundles: @bundles, bundled: @bundled,
+ preview: local_assigns[:preview] || @service.suspended?
diff --git a/app/views/services/opinions/index.html.haml b/app/views/services/opinions/index.html.haml
index c6b3b2df4..1177457c3 100644
--- a/app/views/services/opinions/index.html.haml
+++ b/app/views/services/opinions/index.html.haml
@@ -1,30 +1,8 @@
- content_for :title, @service.name
- breadcrumb :resource_opinions, @service
-.container{ "data-controller": "comparison" }
- - dynamic_class = params[:from] == "backoffice_service" ? "backoffice" : nil
- .pt-4.service-box-redesign.service-detail{ class: dynamic_class }
- = render Presentable::HeaderComponent.new(object: @service,
- title: @service.name,
- subtitle: @service.tagline,
- comparison_enabled: @comparison_enabled,
- preview: local_assigns[:preview],
- show_checkboxes: params[:from].blank?,
- favourite_services: @favourite_services) do |c|
- - c.buttons do
- - case params[:from]
- - when "ordering_configuration"
- = render "components/presentable/header_component/ordering_configuration_buttons", service: @service
- - when "backoffice_service"
- = render "components/presentable/header_component/backoffice_service_buttons", service: @service
- - else
- = render "components/presentable/header_component/order_buttons", service: @service
-
- = render "services/tabs", service: @service
- - dynamic_class = (session[:comparison]&.size || 0).positive? ? "d-block" : "d-none"
- #comparison-bar.comparison-bar.fixed-bottom{ class: dynamic_class, "data-comparison-target": "bar" }
- = render "comparisons/bar", services: @compare_services, category: @category
-
-.tab-content
+= render "services/wrapper", service: @service, category: @category,
+ comparison_enabled: @comparison_enabled, compare_services: @compare_services,
+ favourite_services: @favourite_services, question: @question, tab_id: "opinions", preview: false do
= render "services/opinions", service: @service, preview: @preview,
question: @question, service_opinions: @service_opinions
diff --git a/app/views/services/ordering_configurations/show.html.haml b/app/views/services/ordering_configurations/show.html.haml
index 292325a91..1429d6129 100644
--- a/app/views/services/ordering_configurations/show.html.haml
+++ b/app/views/services/ordering_configurations/show.html.haml
@@ -16,12 +16,25 @@
= render "components/presentable/header_component/ordering_configuration_buttons", service: @service
= render "services/tabs", service: @service, params: { from: "ordering_configuration" }
.tab-content
- = render Presentable::DescriptionComponent.new(object: @service,
- similar_services: @similar_services, related_services: @related_services,
- from: "ordering_configuration", question: @question) do |c|
- - c.description_panels do
- = render "layouts/common_parts/services/offers", offers: @offers, service: @service, bundles: @bundles
- = render "taggable/details_section", taggable: @service
-
+ #desc.tab-pane.container.active.desc{ "aria-labelledby": "home-tab", role: "tabpanel" }
+ .row.justify-content-between
+ %main.col-12.col-xl-9.pr-4.pt-4{ "data-shepherd-tour-target": "service-about" }
+ = render Presentable::DescriptionComponent.new(object: @service,
+ similar_services: @similar_services, related_services: @related_services,
+ from: "ordering_configuration", question: @question) do |c|
+ - c.description_panels do
+ = render "layouts/common_parts/services/offers", offers: @offers, service: @service, bundles: @bundles
+ = render "taggable/details_section", taggable: @service
+ %sidebar.col-12.col-xl-3{ "data-shepherd-tour-target": "service-classification" }
+ = render "components/presentable/explore_links", object: @service
+ .right-panel-links
+ - if !@service.public_contacts.empty? && (@question || @preview)
+ = render "components/presentable/ask_question", question_link: new_question_link(@service),
+ question: @question,
+ prompt: new_question_prompt(@service),
+ preview: @preview
+ = render Presentable::LinksComponent.new(object: @service, preview: @preview)
+ = render Presentable::ProviderInfoComponent.new(base: @service,
+ preview: @preview) if @service.respond_to?(:resource_organisation)
.container.mt-4.pt-4.related-container
- = render "services/related", related_services: @related_services, title: related_services_title
+ = render "services/related", related_services: @related_services, title: @related_services_title
diff --git a/app/views/services/show.html.haml b/app/views/services/show.html.haml
index faf730742..f37fb95cc 100644
--- a/app/views/services/show.html.haml
+++ b/app/views/services/show.html.haml
@@ -4,29 +4,8 @@
_paq.push(['trackEvent', 'Service', 'Visit', '#{id}']);
- breadcrumb :service, @service
= render "services/errors", service: @service
-%div
- .container{ class: "#{"suspended" if @service.suspended?}", "data-controller": "comparison",
- "data-shepherd-tour-target": "overview_10" }
- .pt-4.service-box-redesign.service-detail{ "data-shepherd-tour-target": "service-box" }
- = render Presentable::HeaderComponent.new(object: @service,
- title: @service.name,
- abbreviation: @service.abbreviation,
- subtitle: @service.tagline,
- comparison_enabled: @comparison_enabled,
- preview: local_assigns[:preview] || @service.suspended?,
- favourite_services: @favourite_services) do |c|
- - c.buttons do
- = render "components/presentable/header_component/order_buttons", service: @service
- = render "services/tabs", service: @service
- - dynamic_class = (session[:comparison]&.size || 0).positive? ? "d-block" : "d-none"
- #comparison-bar.comparison-bar.fixed-bottom{ class: dynamic_class,
- "data-comparison-target": "bar", "data-e2e": "comparison-bar" }
- = render "comparisons/bar", services: @compare_services, category: @category
- .tab-content
- = render Presentable::DescriptionComponent.new(object: @service,
- similar_services: @similar_services, related_services: @related_services, question: @question) do |c|
- - c.description_panels do
- - if policy(@service).offers_show? || policy(@service).bundles_show?
- = render "services/offers", offers: @offers, service: @service,
- bundles: @bundles, bundled: @bundled,
- preview: local_assigns[:preview] || @service.suspended?
+= render "services/wrapper", service: @service, category: @category,
+ comparison_enabled: @comparison_enabled, compare_services: @compare_services,
+ favourite_services: @favourite_services, question: @question, tab_id: "desc", preview: false do
+ = render Presentable::DescriptionComponent.new(object: @service,
+ similar_services: @similar_services, related_services: @related_services, question: @question)
diff --git a/config/breadcrumbs/backoffice.rb b/config/breadcrumbs/backoffice.rb
index 38c1a8b9b..df06dba0c 100644
--- a/config/breadcrumbs/backoffice.rb
+++ b/config/breadcrumbs/backoffice.rb
@@ -23,6 +23,11 @@
parent :backoffice_services
end
+crumb :backoffice_service_offers do |service|
+ link "Offers", backoffice_service_offers_path(service)
+ parent :backoffice_service, service
+end
+
crumb :resource_details do |service|
link "Details", service_details_path(service)
if params[:from]
diff --git a/config/routes.rb b/config/routes.rb
index 2f88975c1..d38ff6c66 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -24,7 +24,8 @@
resources :services, only: %i[index show], constraints: { id: %r{[^/]+} } do
scope module: :services do
- resource :offers, only: %i[show update]
+ resources :offers, only: %i[index]
+ resource :choose_offer, only: %i[show update]
resource :configuration, only: %i[show update]
resource :information, only: %i[show update]
resource :summary, only: %i[show create]
@@ -37,11 +38,11 @@
resources :bundles, only: :show
resource :ordering_configuration, only: :show do
scope module: :ordering_configuration do
- resources :offers, only: %i[new edit create update destroy] do
+ resources :offers, only: %i[index new edit create update destroy] do
resource :publish, controller: "offers/publishes", only: :create
resource :draft, controller: "offers/drafts", only: :create
end
- resources :bundles, only: %i[new edit create update destroy] do
+ resources :bundles, only: %i[index new edit create update destroy] do
resource :publish, controller: "bundles/publishes", only: :create
resource :draft, controller: "bundles/drafts", only: :create
end
diff --git a/spec/features/add_item_to_project_spec.rb b/spec/features/add_item_to_project_spec.rb
index b013dbbd3..292d4967a 100644
--- a/spec/features/add_item_to_project_spec.rb
+++ b/spec/features/add_item_to_project_spec.rb
@@ -18,7 +18,9 @@
visit project_services_path(project)
click_on "Add your first service"
- visit service_information_path(service)
+ visit service_path(service)
+
+ click_on "Access the service"
click_on "Next", match: :first
expect(page).to have_select("customizable_project_item_project_id", selected: "my fancy project")
diff --git a/spec/features/backoffice/services/bundles_spec.rb b/spec/features/backoffice/services/bundles_spec.rb
index cd9c9339e..ae81e993a 100644
--- a/spec/features/backoffice/services/bundles_spec.rb
+++ b/spec/features/backoffice/services/bundles_spec.rb
@@ -18,7 +18,7 @@
before { checkin_sign_in_as(send(user)) }
scenario "I can create new bundle" do
- visit backoffice_service_path(service)
+ visit backoffice_service_offers_path(service)
click_on "Add new bundle", match: :first
fill_in "Name", with: bundle.name
@@ -39,7 +39,7 @@
scenario "I can update bundle" do
bundle.save
second_offer = create(:offer)
- visit backoffice_service_path(service)
+ visit backoffice_service_offers_path(bundle.service)
within("#bundle-#{bundle.iid}") { click_on "Edit" }
diff --git a/spec/features/backoffice/services_spec.rb b/spec/features/backoffice/services_spec.rb
index c03b696ce..e098ad317 100644
--- a/spec/features/backoffice/services_spec.rb
+++ b/spec/features/backoffice/services_spec.rb
@@ -24,12 +24,12 @@
scenario "I can see any service" do
service = create(:service, name: "service1")
- visit backoffice_service_path(service)
+ visit backoffice_service_offers_path(service)
expect(page).to have_content("service1")
end
- scenario "I can create new service with default offer" do
+ scenario "I can create new service without default offer" do
category = create(:category)
provider = create(:provider)
scientific_domain = create(:scientific_domain)
@@ -101,9 +101,9 @@
fill_in "service_sources_attributes_0_eid", with: "12345a"
- expect { click_on "Create Service" }.to change { Offer.count }.by(1).and have_enqueued_job(
- Ess::UpdateJob
- ).exactly(2).times
+ expect { click_on "Create Service" }.to have_enqueued_job(Ess::UpdateJob).exactly(1).times
+
+ click_on "About"
expect(page).to have_content("service name")
expect(page).to have_content("service description")
@@ -158,6 +158,8 @@
expect(page).to have_content("New service created successfully")
+ click_on "About"
+
expect(page).to have_content("service name")
expect(page).to have_content("service description")
expect(page).to have_content("service tagline")
@@ -212,17 +214,6 @@
expect(page).to_not have_content(public_contacts.second.email)
end
- scenario "I can see warning about no offers" do
- service = create(:service)
-
- visit backoffice_service_path(service)
-
- expect(page).to have_content(
- "This service has no offers. " \
- "Add one offer to make possible for a user to Access the service."
- )
- end
-
scenario "I can preview service before create" do
provider = create(:provider)
scientific_domain = create(:scientific_domain)
@@ -260,7 +251,7 @@
click_on "Go back to edit"
expect { click_on "Create Service" }.to change { Service.count }.by(1).and have_enqueued_job(
Ess::UpdateJob
- ).exactly(2).times
+ ).exactly(1).times
expect(page).to have_content("service name")
end
@@ -335,7 +326,7 @@
click_on "Edit"
fill_in "service_name", with: "updated name"
- expect { click_on "Update Service" }.to have_enqueued_job(Ess::UpdateJob).exactly(2).times
+ expect { click_on "Update Service" }.to have_enqueued_job(Ess::UpdateJob).exactly(1).times
expect(page).to have_content("updated name")
end
@@ -492,7 +483,7 @@
end
end
- pending "I can update offer's order_type from service by removing second offer" do
+ scenario "I can update offer's order_type from service by removing second offer" do
service = create(:service, order_type: :other)
other_offer = create(:offer, order_type: :other, service: service)
offer_to_update = create(:offer, order_type: :order_required, service: service)
@@ -508,20 +499,6 @@
expect(offer_to_update.order_type).to eq("other")
end
- scenario "I can see warning about no published offers", js: true do
- service = create(:service)
-
- visit backoffice_service_path(service)
-
- expect(page).to have_content(
- "This service has no offers. " \
- "Add one offer to make possible for a user to Access the service."
- )
- offer = create(:offer, service: service)
- service.reload
- expect(service.offers).to eq([offer])
- end
-
scenario "I don't see warning about published offers in the deleted service", js: true do
service = create(:service, status: :deleted)
@@ -638,17 +615,6 @@
expect(page).to have_content("Offer removed successfully")
end
- scenario "I can see info if service has no offer" do
- service = create(:service, name: "my service")
-
- visit backoffice_service_path(service)
-
- expect(page).to have_content(
- "This service has no offers. " \
- "Add one offer to make possible for a user to Access the service."
- )
- end
-
scenario "I can change service status from publish to draft" do
service = create(:service, name: "my service")
diff --git a/spec/features/filter_spec.rb b/spec/features/filter_spec.rb
index 5c4a2f6a1..f839a9a2f 100644
--- a/spec/features/filter_spec.rb
+++ b/spec/features/filter_spec.rb
@@ -48,7 +48,7 @@
create(:service, name: "dd", providers: [provider], scientific_domains: [scientific_domain])
visit services_path(q: "dd", providers: [provider.id], scientific_domains: [scientific_domain.id])
- find("a[href='/services/dd']").click
+ find("a[href='/services/dd/offers']").click
click_on "Services"
expect(page).to have_text("Looking for: dd")
diff --git a/spec/features/order_spec.rb b/spec/features/order_spec.rb
index ef3e48010..58af01625 100644
--- a/spec/features/order_spec.rb
+++ b/spec/features/order_spec.rb
@@ -31,14 +31,14 @@
end
scenario "I can order service" do
- offer, _seconds_offer = create_list(:offer, 2, service: service)
+ offer, _second_offer = create_list(:offer, 2, service: service)
visit service_path(service)
click_on "Access the service", match: :first
# Step 1
- expect(page).to have_current_path(service_offers_path(service))
+ expect(page).to have_current_path(service_choose_offer_path(service))
expect(page).to have_text("Select an offer or service bundle")
expect(page).to have_selector(:link_or_button, "Next", exact: true)
@@ -414,7 +414,7 @@
visit service_information_path(service)
- expect(page).to have_current_path(service_offers_path(service))
+ expect(page).to have_current_path(service_choose_offer_path(service))
end
scenario "I'm redirected into service offers when offer is not chosen" do
@@ -422,7 +422,7 @@
visit service_configuration_path(service)
- expect(page).to have_current_path(service_offers_path(service))
+ expect(page).to have_current_path(service_choose_offer_path(service))
end
scenario "I'm redirected into order summary when project is not chosen" do
@@ -720,7 +720,7 @@
parent = create(:offer, service: service)
bundle = create(:bundle, service: service, main_offer: parent, offers: [child1, child2])
- visit service_path(service)
+ visit service_offers_path(service)
click_on "Select bundle"
@@ -803,7 +803,7 @@
user = build(:user)
stub_checkin(user)
- visit service_offers_path(service)
+ visit service_choose_offer_path(service)
expect do
# If new user is logged in using checkin new user record is created
diff --git a/spec/features/ordering_configuration_spec.rb b/spec/features/ordering_configuration_spec.rb
index 1aa7c2529..fd81a7470 100644
--- a/spec/features/ordering_configuration_spec.rb
+++ b/spec/features/ordering_configuration_spec.rb
@@ -112,7 +112,7 @@
scenario "I cannot delete offer if it's only one" do
visit service_ordering_configuration_path(service)
- click_on "Edit parameters"
+ click_on "Edit"
expect(page).to_not have_link("Delete Offer")
end
diff --git a/spec/features/service_spec.rb b/spec/features/service_spec.rb
index 8d6296d25..86e3615e5 100644
--- a/spec/features/service_spec.rb
+++ b/spec/features/service_spec.rb
@@ -144,7 +144,7 @@
default = create(:offer, description: "# Test default\r\n\rDescription default", service: service)
offer = create(:offer, description: "# Test offer\r\n\rDescription offer", service: service)
- visit service_path(offer.service)
+ visit service_offers_path(offer.service)
find(".card-body h1", text: "Test offer")
find(".card-body p", text: "Description offer")
@@ -215,7 +215,7 @@
]
)
- visit service_path(offer.service)
+ visit service_offers_path(offer.service)
expect(page).to have_text(offer1.name)
expect(page.body).to have_content("Number of CPU Cores")
diff --git a/spec/lib/import/resources_spec.rb b/spec/lib/import/resources_spec.rb
index 1a7e9c85b..0534634e4 100644
--- a/spec/lib/import/resources_spec.rb
+++ b/spec/lib/import/resources_spec.rb
@@ -96,23 +96,16 @@ def mock_access_token
mock_access_token
end
- it "should create an offer for a new services" do
+ it "shouldn't create an offer for a new services" do
expect { eosc_registry.call }.to output(
/PROCESSED: 3, CREATED: 3, UPDATED: 0, NOT MODIFIED: 0$/
- ).to_stdout.and change { Service.count }.by(3).and change { Offer.count }.by(3)
+ ).to_stdout.and change { Service.count }.by(3)
service = Service.first
- expect(service.offers).to_not be_nil
+ expect(service.offers).to be_empty
- offer = service.offers.first
-
- expect(offer.name).to eq("Offer")
- expect(offer.description).to eq("#{service.name} Offer")
- expect(offer.order_type).to eq("other")
- expect(offer.status).to eq("published")
-
- expect(Service.find_by(name: "MetalPDB").offers).to_not be_nil
- expect(Service.find_by(name: "PDB_REDO server").offers).to_not be_nil
+ expect(Service.find_by(name: "MetalPDB").offers).to be_empty
+ expect(Service.find_by(name: "PDB_REDO server").offers).to be_empty
end
it "should not update service which has upstream to null" do
diff --git a/spec/policies/service_policy_spec.rb b/spec/policies/service_policy_spec.rb
index 2d25c2a8c..f77cf796a 100644
--- a/spec/policies/service_policy_spec.rb
+++ b/spec/policies/service_policy_spec.rb
@@ -42,11 +42,11 @@ def resolve
expect(subject).to permit(user, service.reload)
end
- it "denies when there is only one offer" do
+ it "grants when there is only one offer" do
service = create(:service)
create(:offer, service: service)
- expect(subject).to_not permit(user, service.reload)
+ expect(subject).to permit(user, service.reload)
end
it "denies when there is not offers" do
diff --git a/spec/services/service/create_spec.rb b/spec/services/service/create_spec.rb
index 1bba84522..06b762fe6 100644
--- a/spec/services/service/create_spec.rb
+++ b/spec/services/service/create_spec.rb
@@ -11,18 +11,10 @@
expect(service).to be_persisted
end
- it "saves valid offer in the db" do
+ it "doesn't save valid offer in the db" do
service = described_class.new(build(:service)).call
service.reload
- expect(service.offers.size).to eq(1)
-
- offer = service.offers.first
-
- expect(offer.name).to eq("Offer")
- expect(offer.description).to eq("#{service.name} Offer")
- expect(offer.order_type).to eq(service.order_type)
- expect(offer.order_url).to eq(service.order_url)
- expect(offer.status).to eq("published")
+ expect(service.offers.size).to eq(0)
end
end
diff --git a/spec/services/service/pc_create_or_update_spec.rb b/spec/services/service/pc_create_or_update_spec.rb
index 2adcfe5ed..c5081c5bf 100644
--- a/spec/services/service/pc_create_or_update_spec.rb
+++ b/spec/services/service/pc_create_or_update_spec.rb
@@ -57,16 +57,7 @@
create(:provider_source, source_type: "eosc_registry", eid: "tp", provider: provider_tp)
service = create(:jms_service, prov_eid: "new.prov", name: "New supper service")
- expect { stub_described_class(service) }.to change { Offer.count }.by(1)
- offer = Offer.last
- service = Service.last
-
- expect(offer.name).to eq("Offer")
- expect(offer.description).to eq("#{service.name} Offer")
- expect(offer.order_type).to eq("other")
- expect(offer.status).to eq("published")
- expect(offer.service.id).to eq(service.id)
- expect(service.upstream_id).to eq(service.sources.first.id)
+ expect { stub_described_class(service) }.to_not change { Offer.count }
end
it "should add provider with improper data to the resource" do
diff --git a/spec/services/service/update_spec.rb b/spec/services/service/update_spec.rb
index d1a888715..d2d820f81 100644
--- a/spec/services/service/update_spec.rb
+++ b/spec/services/service/update_spec.rb
@@ -24,7 +24,7 @@
expect(offer).to be_published
end
- it "creates new offer by service update if offers_count equals 0" do
+ it "doesn't create new offer by service update if offers_count equals 0" do
service = create(:service, order_type: "fully_open_access")
expect(service.offers.size).to eq(0)
@@ -33,13 +33,7 @@
service.reload
- expect(service.offers.size).to eq(1)
-
- offer = service.offers.first
-
- expect(offer.order_type).to eq("fully_open_access")
- expect(offer.order_url).to eq("http://order.valid")
- expect(offer).to be_published
+ expect(service.offers.size).to eq(0)
end
it "doesn't create a new offer if service update fails" do
diff --git a/test/system/cypress/e2e/regression_tests/backoffice/resources/owned_resources.spec.ts b/test/system/cypress/e2e/regression_tests/backoffice/resources/owned_resources.spec.ts
index 2476fc565..b77feeba8 100644
--- a/test/system/cypress/e2e/regression_tests/backoffice/resources/owned_resources.spec.ts
+++ b/test/system/cypress/e2e/regression_tests/backoffice/resources/owned_resources.spec.ts
@@ -51,7 +51,7 @@ describe("Owned services", () => {
cy.get("[data-e2e='query-submit-btn']").click();
cy.get("[data-e2e='service-name']").should("include.text", value);
cy.contains("[data-e2e='service-name']", value).click();
- cy.get("[data-e2e='access-service-btn']").should("be.visible");
+ cy.get("[data-e2e='access-service-btn']").should("not.exist");
});
});
diff --git a/test/system/cypress/e2e/regression_tests/service-page/comparison/comparison.spec.ts b/test/system/cypress/e2e/regression_tests/service-page/comparison/comparison.spec.ts
index 261e9f091..fa82c25a7 100644
--- a/test/system/cypress/e2e/regression_tests/service-page/comparison/comparison.spec.ts
+++ b/test/system/cypress/e2e/regression_tests/service-page/comparison/comparison.spec.ts
@@ -33,7 +33,7 @@ describe("Comparison", () => {
it("should add and remove services from comparison - services from details page", () => {
cy.get("[data-e2e='service-name']").eq(0).click();
- cy.get("[data-e2e='access-service-btn']").should("be.visible");
+ cy.get("[data-e2e='service-details-btn']").should("be.visible");
cy.get("[data-e2e='comparison-checkbox']").click();
cy.get("[data-e2e='comparison-bar']").should("be.visible");
@@ -41,7 +41,7 @@ describe("Comparison", () => {
cy.go("back");
cy.get("[data-e2e='service-name']").eq(2).click();
- cy.get("[data-e2e='access-service-btn']").should("be.visible");
+ cy.get("[data-e2e='service-details-btn']").should("be.visible");
cy.get("[data-e2e='comparison-checkbox']").click();
cy.get("[data-e2e='compare-btn']").click();