From af58ba523c2da78b116892de61b594de27938d17 Mon Sep 17 00:00:00 2001 From: Nihal Mohammed Date: Mon, 18 Apr 2022 15:09:11 +0530 Subject: [PATCH 1/2] Renamed groups_helper to link_helper and removed strip_url method, as well as updated specs and ApplicationHelper. Added "Back To Website" button and i18n. --- app/controllers/application_controller.rb | 1 + app/helpers/{groups_helper.rb => link_helper.rb} | 6 +----- .../spree/orders/form/_update_buttons.html.haml | 13 ++++++++++--- config/locales/en.yml | 1 + .../{groups_helper_spec.rb => link_helper_spec.rb} | 9 +-------- 5 files changed, 14 insertions(+), 16 deletions(-) rename app/helpers/{groups_helper.rb => link_helper.rb} (81%) rename spec/helpers/{groups_helper_spec.rb => link_helper_spec.rb} (50%) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b9a40dafe5..ae22816f5a 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..5620ebf1fc 100644 --- a/app/views/spree/orders/form/_update_buttons.html.haml +++ b/app/views/spree/orders/form/_update_buttons.html.haml @@ -1,12 +1,19 @@ .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) + .wrapper + .row + .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? diff --git a/config/locales/en.yml b/config/locales/en.yml index e639a9faa5..8e3d4d28c8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1860,6 +1860,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 From f5ecc6ffe48fd26cfe7b38a46ef9d694798172ef Mon Sep 17 00:00:00 2001 From: Nihal Mohammed Date: Mon, 9 May 2022 23:29:40 +0530 Subject: [PATCH 2/2] Change gap between columns to fit new button --- .../orders/form/_update_buttons.html.haml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/views/spree/orders/form/_update_buttons.html.haml b/app/views/spree/orders/form/_update_buttons.html.haml index 5620ebf1fc..95818e67b3 100644 --- a/app/views/spree/orders/form/_update_buttons.html.haml +++ b/app/views/spree/orders/form/_update_buttons.html.haml @@ -5,19 +5,17 @@ = link_to main_app.cart_path, :class => "button expand" do = t(:order_back_to_cart) - else - .wrapper - .row - .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) + .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