diff options
| -rw-r--r-- | app/decorators/stop_area_decorator.rb | 17 | ||||
| -rw-r--r-- | app/decorators/stop_point_decorator.rb | 39 | 
2 files changed, 11 insertions, 45 deletions
diff --git a/app/decorators/stop_area_decorator.rb b/app/decorators/stop_area_decorator.rb index 1f3b3d16c..4e777292d 100644 --- a/app/decorators/stop_area_decorator.rb +++ b/app/decorators/stop_area_decorator.rb @@ -3,34 +3,35 @@ class StopAreaDecorator < Draper::Decorator    delegate_all -  def action_links +  def action_links(stop_area = nil)      links = [] +    stop_area ||= object      if h.policy(Chouette::StopArea).new?        links << Link.new(          content: h.t('stop_areas.actions.new'),          href: h.new_stop_area_referential_stop_area_path( -          object.stop_area_referential +          stop_area.stop_area_referential          )        )      end -    if h.policy(object).update? +    if h.policy(stop_area).update?        links << Link.new(          content: h.t('stop_areas.actions.edit'),          href: h.edit_stop_area_referential_stop_area_path( -          object.stop_area_referential, -          object +          stop_area.stop_area_referential, +          stop_area          )        )      end -    if h.policy(object).destroy? +    if h.policy(stop_area).destroy?        links << Link.new(          content: h.destroy_link_content('stop_areas.actions.destroy'),          href: h.stop_area_referential_stop_area_path( -          object.stop_area_referential, -          object +          stop_area.stop_area_referential, +          stop_area          ),          method: :delete,          data: { confirm: t('stop_areas.actions.destroy_confirm') } diff --git a/app/decorators/stop_point_decorator.rb b/app/decorators/stop_point_decorator.rb index a7229226f..196d6d490 100644 --- a/app/decorators/stop_point_decorator.rb +++ b/app/decorators/stop_point_decorator.rb @@ -1,44 +1,9 @@ -class StopPointDecorator < Draper::Decorator +class StopPointDecorator < StopAreaDecorator    decorates Chouette::StopPoint    delegate_all    def action_links -    links = [] - -    stop_area = object.stop_area - -    if h.policy(Chouette::StopArea).new? -      links << Link.new( -        content: h.t('stop_areas.actions.new'), -        href: h.new_stop_area_referential_stop_area_path( -          stop_area.stop_area_referential -        ) -      ) -    end - -    if h.policy(stop_area).update? -      links << Link.new( -        content: h.t('stop_areas.actions.edit'), -        href: h.edit_stop_area_referential_stop_area_path( -          stop_area.stop_area_referential, -          stop_area -        ) -      ) -    end - -    if h.policy(stop_area).destroy? -      links << Link.new( -        content: h.destroy_link_content('stop_areas.actions.destroy'), -        href: h.stop_area_referential_stop_area_path( -          stop_area.stop_area_referential, -          stop_area -        ), -        method: :delete, -        data: { confirm: t('stop_areas.actions.destroy_confirm') } -      ) -    end - -    links +    super(object.stop_area)    end  end  | 
