navigation_helper.rb revision 00c175adc24043fbcd4cd5e3769c9d13e31ff831
# encoding: UTF-8
pages = [
]
subnavigation(resource, pages, current_page, options, [])
end
@top_level_pages = [
['Comments', :comments],
['Metadata', :metadata],
['Versions', :ontology_versions],
['Graphs', :graphs],
['Mappings', :mappings],
]
@metadatas = []
end
@symbols =
[]
else
end
@active_kind =
pages = []
else
end
actions = []
end
@page_title = "#{current_page.capitalize} · #{@page_title}"
end
}
end
# Add counters
pages.each do |row|
counter_key = "#{row[0]}_count"
row << resource.send(counter_key) if resource.respond_to?(counter_key)
end
@page_title = current_page
if current_page != pages[0][0]
@page_title = "#{current_page.capitalize} · #{@page_title}"
end
render partial: partial, locals: {
resource: resource,
current_page: current_page,
pages: pages,
additional_actions: additional_actions,
options: options
}
end
def team_nav(team, current_page)
pages = [
[:overview, team],
[:permissions, [team, :permissions]]
]
pages << [:members, [team, :team_users]] if can? :edit, team
subnavigation(team, pages, current_page)
end
def active_navigation(controller)
alternatives = [controller.to_s, controller.to_s.gsub('_', '/')]
if params[:repository_id]
if params[:ontology_id]
'active' if controller == :ontologies
else
'active' if controller == :repositories
end
elsif alternatives.include?(controller_name)
'active'
end
end
def menu_entry(title, controller)
content_tag :li, class: active_navigation(controller) do
link_to title, controller
end
end
# used for activating tabs in ontology view
def in_subcontroller?(page, current_page)
case page
when :symbols
%w(classes sentences theorems).include?(controller_name)
when :metadata
in_metadata?
end
end
# used for activating tabs in ontology view
def in_metadata?
ontology_nav_metadata.map { |m| m[1][-1].to_s }.include?(controller_name)
end
protected
def ontology_nav_metadata
[
['Projects', [*resource_chain, :projects]],
['Categories', [*resource_chain, :categories]],
['Tasks', [*resource_chain, :tasks]],
['License Models', [*resource_chain, :license_models]],
['Formality Levels', [*resource_chain, :formality_levels]]
]
end
def repository_settings_nav(repository, current_page)
pages = []
chain =
if resource_chain.last.is_a?(Ontology)
resource_chain[0..-2]
else
resource_chain
end
current_page = t("repository.#{current_page}")
pages << [t('repository.urlmaps'), repository_url_maps_path(repository)]
pages << [t('repository.errors'), repository_errors_path(repository)]
if can? :permissions, repository
pages << [t('repository.permissions'), [*chain, :permissions]]
end
if can? :edit, repository
pages << [t('repository.edit'), edit_repository_path(repository)]
end
subnavigation(repository, pages, current_page,
partial: '/repository_settings/subnav')
end
end