diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f0c8837017..5020faf7b6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -29,6 +29,7 @@ class ApplicationController < ActionController::Base helper 'footer_links' helper 'discourse' helper 'checkout' + helper 'link' helper 'terms_and_conditions' protect_from_forgery diff --git a/app/helpers/groups_helper.rb b/app/helpers/link_helper.rb similarity index 81% rename from app/helpers/groups_helper.rb rename to app/helpers/link_helper.rb index 0c1d722c5a..016fa8fda6 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/link_helper.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module GroupsHelper +module LinkHelper def link_to_service(baseurl, name, html_options = {}, &block) return if name.blank? @@ -15,8 +15,4 @@ module GroupsHelper prefix + url end end - - def strip_url(url) - url&.sub(%r{^https?://}i, '') - end end diff --git a/app/views/spree/orders/form/_update_buttons.html.haml b/app/views/spree/orders/form/_update_buttons.html.haml index 65e3e9cbf1..95818e67b3 100644 --- a/app/views/spree/orders/form/_update_buttons.html.haml +++ b/app/views/spree/orders/form/_update_buttons.html.haml @@ -1,16 +1,21 @@ .row - .columns.small-12.medium-3 + .columns.small-12.medium-5 - if current_order.nil? || current_order.distributor.nil? || current_order.distributor == @order.distributor - if current_order&.line_items.present? = link_to main_app.cart_path, :class => "button expand" do = t(:order_back_to_cart) - else - = link_to "#{main_app.enterprise_shop_path(@order.distributor)}#/shop", class: "button expand" do - = t(:order_back_to_store) + .columns.small-12.medium-6 + = link_to "#{main_app.enterprise_shop_path(@order.distributor)}#/shop", class: "button expand" do + = t(:order_back_to_store) + .columns.small-12.medium-6 + - if @order.distributor.website.present? + = link_to_service "https://", current_order.distributor.website, class: "button expand" do + = t(:order_back_to_website) - else   - if order.changes_allowed? - .columns.show-for-medium-up.medium-3   + .columns.show-for-medium-up.medium-1   .columns.small-12.medium-3 = link_to main_app.cancel_order_path(@order), method: :put, class: "button secondary expand", "data-confirm": t('orders_confirm_cancel') do %i.ofn-i_009-close diff --git a/config/locales/en.yml b/config/locales/en.yml index 82c667fb07..ade845a073 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1901,6 +1901,7 @@ en: order_hub_info: Hub Info order_back_to_store: Back To Store order_back_to_cart: Back To Cart + order_back_to_website: Back To Website bom_tip: "Use this page to alter product quantities across multiple orders. Products may also be removed from orders entirely, if required." diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/link_helper_spec.rb similarity index 50% rename from spec/helpers/groups_helper_spec.rb rename to spec/helpers/link_helper_spec.rb index 79b62b402b..6632df9928 100644 --- a/spec/helpers/groups_helper_spec.rb +++ b/spec/helpers/link_helper_spec.rb @@ -2,18 +2,11 @@ require 'spec_helper' -describe GroupsHelper, type: :helper do +describe LinkHelper, type: :helper do describe "ext_url" do it "adds prefix if missing" do expect(helper.ext_url("http://example.com/", "http://example.com/bla")).to eq("http://example.com/bla") expect(helper.ext_url("http://example.com/", "bla")).to eq("http://example.com/bla") end end - describe "strip_url" do - it "removes http(s)://" do - expect(helper.strip_url("http://example.com/")).to eq("example.com/") - expect(helper.strip_url("https://example.com/")).to eq("example.com/") - expect(helper.strip_url("example.com")).to eq("example.com") - end - end end