diff --git a/ama_layout.gemspec b/ama_layout.gemspec index 2ef18b9c..9ddc837b 100644 --- a/ama_layout.gemspec +++ b/ama_layout.gemspec @@ -35,6 +35,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'breadcrumbs_on_rails', '>= 3' spec.add_dependency 'browser', '~> 2.0' + spec.add_dependency 'draper' spec.add_dependency 'foundation-rails', '<= 6.4.3.0' spec.add_dependency 'rails', '>= 4.2' spec.add_dependency 'redis-rails' diff --git a/app/views/ama_layout/agent/_sidebar.html.erb b/app/views/ama_layout/agent/_sidebar.html.erb index 0a7525b0..4f2040b2 100644 --- a/app/views/ama_layout/agent/_sidebar.html.erb +++ b/app/views/ama_layout/agent/_sidebar.html.erb @@ -2,7 +2,7 @@

Online Account

diff --git a/app/views/ama_layout/v2/_sidebar.html.erb b/app/views/ama_layout/v2/_sidebar.html.erb index 0a7525b0..4f2040b2 100644 --- a/app/views/ama_layout/v2/_sidebar.html.erb +++ b/app/views/ama_layout/v2/_sidebar.html.erb @@ -2,7 +2,7 @@

Online Account

diff --git a/app/views/ama_layout/v2/_siteheader.html.erb b/app/views/ama_layout/v2/_siteheader.html.erb index 6139db28..fb2c6276 100644 --- a/app/views/ama_layout/v2/_siteheader.html.erb +++ b/app/views/ama_layout/v2/_siteheader.html.erb @@ -17,7 +17,6 @@
  • Contact Us
  • - <%= navigation.account_toggle(self) %> <%= navigation.top_nav %> diff --git a/app/views/ama_layout/v2/_sub_nav.html.erb b/app/views/ama_layout/v2/_sub_nav.html.erb index f9d42541..3a7c2f50 100644 --- a/app/views/ama_layout/v2/_sub_nav.html.erb +++ b/app/views/ama_layout/v2/_sub_nav.html.erb @@ -1,3 +1,3 @@ diff --git a/app/views/ama_layout/v2/_top_sub_nav.html.erb b/app/views/ama_layout/v2/_top_sub_nav.html.erb index 749cd4ad..23d98080 100644 --- a/app/views/ama_layout/v2/_top_sub_nav.html.erb +++ b/app/views/ama_layout/v2/_top_sub_nav.html.erb @@ -1,3 +1,3 @@ diff --git a/app/views/ama_layout/v3/_sidebar.html.erb b/app/views/ama_layout/v3/_sidebar.html.erb index 0a7525b0..4f2040b2 100644 --- a/app/views/ama_layout/v3/_sidebar.html.erb +++ b/app/views/ama_layout/v3/_sidebar.html.erb @@ -2,7 +2,7 @@

    Online Account

    diff --git a/app/views/ama_layout/v3/_siteheader.html.erb b/app/views/ama_layout/v3/_siteheader.html.erb index 7a98e2fb..5fb90efc 100644 --- a/app/views/ama_layout/v3/_siteheader.html.erb +++ b/app/views/ama_layout/v3/_siteheader.html.erb @@ -17,7 +17,6 @@
  • Contact Us
  • - <%= navigation.account_toggle(self) %> <%= navigation.top_nav %> diff --git a/app/views/ama_layout/v3/_sub_nav.html.erb b/app/views/ama_layout/v3/_sub_nav.html.erb index f9d42541..3a7c2f50 100644 --- a/app/views/ama_layout/v3/_sub_nav.html.erb +++ b/app/views/ama_layout/v3/_sub_nav.html.erb @@ -1,3 +1,3 @@ diff --git a/app/views/ama_layout/v3/_top_sub_nav.html.erb b/app/views/ama_layout/v3/_top_sub_nav.html.erb index 749cd4ad..23d98080 100644 --- a/app/views/ama_layout/v3/_top_sub_nav.html.erb +++ b/app/views/ama_layout/v3/_top_sub_nav.html.erb @@ -1,3 +1,3 @@ diff --git a/app/views/application/_account_toggle.html.erb b/app/views/application/_account_toggle.html.erb deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/ama_layout.rb b/lib/ama_layout.rb index cfadf1c5..497a2c70 100644 --- a/lib/ama_layout.rb +++ b/lib/ama_layout.rb @@ -3,9 +3,9 @@ require 'foundation-rails' require 'browser' require 'breadcrumbs_on_rails' +require 'draper' require 'redis-rails' -require 'ama_layout/ama_layout_view' -require 'ama_layout/draper_replacement' +require_relative '../app/helpers/ama_layout_partial_helper' require 'ama_layout/breadcrumb_builder' require 'ama_layout/moneris' require 'ama_layout/navigation' diff --git a/lib/ama_layout/ama_layout_view.rb b/lib/ama_layout/ama_layout_view.rb deleted file mode 100644 index e5bcf15a..00000000 --- a/lib/ama_layout/ama_layout_view.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -require_relative '../../app/helpers/ama_layout_partial_helper' - -module AmaLayout - class AmaLayoutView < ActionView::Base - include AmaLayoutPartialHelper - - attr_accessor :view_data - - def initialize(args) - self.view_data = args[:view_data] - controller = view_data.try(:controller) || ::ApplicationController.new - context = controller.view_paths - super(context, {}, controller) - end - - def method_missing(method, *args, &block) - view_data.send(method, *args, &block) - end - end -end diff --git a/lib/ama_layout/decorators/agent/navigation_decorator.rb b/lib/ama_layout/decorators/agent/navigation_decorator.rb index 86dddf97..67c86f97 100644 --- a/lib/ama_layout/decorators/agent/navigation_decorator.rb +++ b/lib/ama_layout/decorators/agent/navigation_decorator.rb @@ -2,8 +2,10 @@ module AmaLayout module Agent - class NavigationDecorator - include AmaLayout::DraperReplacement + class NavigationDecorator < Draper::Decorator + include AmaLayoutPartialHelper + + delegate_all def items object.items.map(&:decorate) @@ -22,13 +24,13 @@ def sign_out_link def top_nav return '' unless user - h.render partial: ama_layout_partial('agent/top_nav'), locals: { navigation: self } + h.render partial: 'ama_layout/agent/top_nav', locals: { navigation: self } end def sidebar return '' unless user - h.render partial: ('sidebar'), locals: { navigation: self } + h.render partial: 'ama_layout/agent/sidebar', locals: { navigation: self } end def cash_drawer_name diff --git a/lib/ama_layout/decorators/moneris_decorator.rb b/lib/ama_layout/decorators/moneris_decorator.rb index 5d77ad43..a4bf0faa 100644 --- a/lib/ama_layout/decorators/moneris_decorator.rb +++ b/lib/ama_layout/decorators/moneris_decorator.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + module AmaLayout - class MonerisDecorator - include AmaLayout::DraperReplacement + class MonerisDecorator < Draper::Decorator + delegate_all def textbox h.raw File.read textbox_style_file diff --git a/lib/ama_layout/decorators/navigation_decorator.rb b/lib/ama_layout/decorators/navigation_decorator.rb index 356b782c..f84af23b 100644 --- a/lib/ama_layout/decorators/navigation_decorator.rb +++ b/lib/ama_layout/decorators/navigation_decorator.rb @@ -1,8 +1,10 @@ # frozen_string_literal: true module AmaLayout - class NavigationDecorator - include AmaLayout::DraperReplacement + class NavigationDecorator < Draper::Decorator + include AmaLayoutPartialHelper + + delegate_all def items object.items.map(&:decorate) @@ -40,10 +42,6 @@ def name_or_email display_name.present? ? "Welcome, #{display_name.titleize}" : email end - def account_toggle(view_data = {}) - h(view_data).render partial: 'account_toggle' - end - def notification_icon return '' unless user diff --git a/lib/ama_layout/decorators/navigation_item_decorator.rb b/lib/ama_layout/decorators/navigation_item_decorator.rb index 2dc46b38..ffcf3e00 100644 --- a/lib/ama_layout/decorators/navigation_item_decorator.rb +++ b/lib/ama_layout/decorators/navigation_item_decorator.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + module AmaLayout - class NavigationItemDecorator - include AmaLayout::DraperReplacement + class NavigationItemDecorator < Draper::Decorator + include AmaLayoutPartialHelper + + delegate_all def sub_nav object.sub_nav.map { |sn| sn.decorate } @@ -11,11 +15,11 @@ def sub_nav_class end def top_sub_nav - h.render partial: "ama_layout/top_sub_nav", locals: { sub_nav: sub_nav } if sub_nav.any? + h.render partial: ama_layout_partial('top_sub_nav'), locals: { sub_nav: sub_nav } if sub_nav.any? end def sidebar_sub_nav - h.render partial: "ama_layout/sub_nav", locals: { sub_nav: sub_nav } if sub_nav.any? + h.render partial: ama_layout_partial('sub_nav'), locals: { sub_nav: sub_nav } if sub_nav.any? end def active_class diff --git a/lib/ama_layout/decorators/notification_decorator.rb b/lib/ama_layout/decorators/notification_decorator.rb index 0474d571..72553d16 100644 --- a/lib/ama_layout/decorators/notification_decorator.rb +++ b/lib/ama_layout/decorators/notification_decorator.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + module AmaLayout - class NotificationDecorator - include AmaLayout::DraperReplacement + class NotificationDecorator < Draper::Decorator + include AmaLayoutPartialHelper + + delegate_all ICONS = { notice: { diff --git a/lib/ama_layout/draper_replacement.rb b/lib/ama_layout/draper_replacement.rb deleted file mode 100644 index 855e7c86..00000000 --- a/lib/ama_layout/draper_replacement.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -require_relative '../../app/helpers/ama_layout_partial_helper' - -module AmaLayout - module DraperReplacement - extend ActiveSupport::Concern - - included do - include AmaLayoutPartialHelper - - attr_accessor :object, :controller - - def h(view_data = {}) - AmaLayoutView.new(view_data: view_data) - end - - def initialize(args = {}) - self.object = args - end - - def method_missing(method, *args, &block) - return super unless delegatable?(method) - - (object || DraperReplacement).send(method, *args, &block) - end - - def delegatable?(method) - object.respond_to?(method) || DraperReplacement.respond_to?(method) - end - - def self.decorate_collection(objects = {}) - objects.map { |o| self.new(o) } - end - end - end -end diff --git a/lib/ama_layout/version.rb b/lib/ama_layout/version.rb index 6e3f8dca..376b0bf6 100644 --- a/lib/ama_layout/version.rb +++ b/lib/ama_layout/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module AmaLayout - VERSION = '11.3.1' + VERSION = '12.0.0' end diff --git a/spec/agent/navigation_spec.rb b/spec/agent/navigation_spec.rb index acc4b69e..e65edd90 100644 --- a/spec/agent/navigation_spec.rb +++ b/spec/agent/navigation_spec.rb @@ -11,7 +11,7 @@ File.join(Gem.loaded_specs["ama_layout"].full_gem_path, "spec", "ama_layout", "fixtures", "agent_navigation.yml") end let(:user) { double("user") } - let(:subject) { described_class.new(user: user, nav_file_path: file_path, current_url: '/') } + subject { described_class.new(user: user, nav_file_path: file_path, current_url: '/') } it "uses the overridden file path" do expect(subject.items.first.text).to eq "Waffles" diff --git a/spec/ama_layout/controllers/pages_controller_spec.rb b/spec/ama_layout/controllers/pages_controller_spec.rb deleted file mode 100644 index 5a87911e..00000000 --- a/spec/ama_layout/controllers/pages_controller_spec.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'spec_helper' - -describe PagesController, type: :controller do - UNSUPPORTED_BROWSER_HEADERS = { - 'IE 6' => 'MSIE 6.0', - 'IE 7' => 'MSIE 7.0', - 'IE 8' => 'MSIE 8.0' - } - - SUPPORTED_BROWSER_HEADERS = { - 'IE 9' => 'MSIE 9.0', - 'IE 10' => 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)', - 'IE 11' => 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko', - 'EDGE' => 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10136' - } - - let(:browser_url) { 'http://windows.microsoft.com/en-ca/internet-explorer/download-ie' } - let(:message) do - I18n.t('errors.unsupported_ie', ie_path: browser_url) - .gsub(/>/, '>') - .gsub(/