From 9f4584ef7427575fce4b8294b79f2368b130d8b6 Mon Sep 17 00:00:00 2001 From: Zog Date: Mon, 22 Jan 2018 11:39:34 +0100 Subject: Refs #5586; CR #2 --- app/assets/stylesheets/components/_buttons.sass | 4 +++- app/decorators/line_decorator.rb | 6 +++--- lib/af83/decorator/link.rb | 16 ++++++++-------- spec/lib/af83/decorator/decorator_link_spec.rb | 8 ++++---- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/app/assets/stylesheets/components/_buttons.sass b/app/assets/stylesheets/components/_buttons.sass index a7010ae09..93f9907a5 100644 --- a/app/assets/stylesheets/components/_buttons.sass +++ b/app/assets/stylesheets/components/_buttons.sass @@ -153,8 +153,10 @@ table, .table line-height: $line-height display: block font-size: 14px - &:hover + &:hover, &:focus text-decoration: none + background-color: whitesmoke + outline: none &:not(:first-child) position: relative diff --git a/app/decorators/line_decorator.rb b/app/decorators/line_decorator.rb index 7d247a99c..9171a6310 100644 --- a/app/decorators/line_decorator.rb +++ b/app/decorators/line_decorator.rb @@ -50,7 +50,7 @@ class LineDecorator < AF83::Decorator l.href { h.deactivate_line_referential_line_path(context[:line_referential], object) } l.method :put l.data confirm: h.t('lines.actions.deactivate_confirm') - l.extra_class "delete-action" + l.add_class "delete-action" end instance_decorator.action_link policy: :activate, secondary: :show, footer: :index do |l| @@ -58,14 +58,14 @@ class LineDecorator < AF83::Decorator l.href { h.activate_line_referential_line_path(context[:line_referential], object) } l.method :put l.data confirm: h.t('lines.actions.activate_confirm') - l.extra_class "delete-action" + l.add_class "delete-action" end instance_decorator.destroy_action_link do |l| l.content { h.destroy_link_content('lines.actions.destroy') } l.href { h.line_referential_line_path(context[:line_referential], object) } l.data confirm: h.t('lines.actions.destroy_confirm') - l.extra_class "delete-action" + l.add_class "delete-action" end end end diff --git a/lib/af83/decorator/link.rb b/lib/af83/decorator/link.rb index b1958532f..55db3f5bb 100644 --- a/lib/af83/decorator/link.rb +++ b/lib/af83/decorator/link.rb @@ -111,14 +111,14 @@ class AF83::Decorator::Link "Missing attributes: #{@missing_attributes.to_sentence}" end - def extra_class val=nil - if val.present? - @options[:link_class] ||= [] - @options[:link_class] << val - @options[:link_class].flatten! - else - (options[:link_class] || []).join(' ') - end + def add_class val + @options[:link_class] ||= [] + @options[:link_class] << val + @options[:link_class].flatten! + end + + def extra_class + (options[:link_class] || []).join(' ') end def html_options diff --git a/spec/lib/af83/decorator/decorator_link_spec.rb b/spec/lib/af83/decorator/decorator_link_spec.rb index 4e2726be9..0b2939421 100644 --- a/spec/lib/af83/decorator/decorator_link_spec.rb +++ b/spec/lib/af83/decorator/decorator_link_spec.rb @@ -31,18 +31,18 @@ RSpec.describe AF83::Decorator::Link, type: :decorator do end end - describe "#extra_class" do + describe "#add_class" do let(:link){ AF83::Decorator::Link.new(href: "foo", content: "foo", class: "initial_class") } it "should add to exisiting class" do expect(link.html_options[:class]).to eq "initial_class" - link.extra_class "new_class" + link.add_class "new_class" expect(link.html_options[:class]).to eq "initial_class new_class" - link.extra_class = "another_class" + link.add_class "another_class" expect(link.html_options[:class]).to eq "initial_class new_class another_class" - link.extra_class = %w(foo bar) + link.add_class %w(foo bar) expect(link.html_options[:class]).to eq "initial_class new_class another_class foo bar" end end -- cgit v1.2.3