Slide 101
Slide 101 text
class UserNavigationPresenter < BasePresenter
presents :user
attr_accessor :partials
def initialize(object, template, partials = [])
super(object, template)
@partials = partials
end
def render_search_bar
h.render nav_path('search_bar') if partials.include?(:search_bar)
end
def render_nav_content
partial = user.present? ? nav_path(current_user_nav) : nav_path('anonymous_user')
h.render partial
end
def render_tabs
h.content_tag :div, class: 'nav__tabs' do
h.succeed(h.link_to 'Jobs', h.jobs_path, class: job_tab_css, disabled: user.blank?) do
h.link_to 'Graduates', h.profiles_path, class: grad_tab_css
end
end
end
def render_job_button(css_class)
h.link_to 'Post a Job', h.new_employer_job_path, class: "button small js-job-button #{css_class}" if user && user.can_message_students?
end
def render_form_later_button
if defined?(h.step) && (['publish','complete'].include?(h.wizard_value(h.step)))
h.link_to 'Exit and continue later', h.after_publish_path, class: "button small nav--steps__button-save"
else
h.link_to 'Save and continue later', '', class: "button small nav--steps__button-save js-save-and-exit-profile", data: { disable_with: 'Saving…' }
end
end
end