navigation_helper.rb revision 827e98b08be3acd813ab859061f7e6318b7f8abd
bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch# encoding: UTF-8
056e7cd4029d460afabff2dc27c269096d8661c1Timo Sirainen chain = resource_chain.last.is_a?(Ontology) ? resource_chain[0..-2] : resource_chain
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen pages << [:"Ontology urls", repository_url_maps_path(resource)]
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen pages << [:history, repository_ref_path(resource, 'master', path: nil, action: :history)]
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen pages << [:permissions, [*chain, :permissions]] if can? :permissions, resource
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen ['Content', ontology.distributed? ? :children : :entities],
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen @entities = ontology.distributed? ? [] : ontology.entities.groups_by_kind
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen @active_kind = @entities.first.kind if current_page == :entities
8e1491e4924e3f9fc474a99438b6297b8d1ce1f3Timo Sirainen pages << [:children, [*resource_chain, :children]]
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen pages << [:sentences, [*resource_chain, :sentences]]
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen # Add counters
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen row << ontology.send(counter_key) if ontology.respond_to?(counter_key)
c93aca832ee532010ead91b85fa9f614132e1be2Stephan Bosch @page_title = ontology.to_s
c93aca832ee532010ead91b85fa9f614132e1be2Stephan Bosch @page_title = "#{current_page.capitalize} · #{@page_title}" if current_page != pages[0][0]
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen render :partial => '/ontologies/info', :locals => {
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen resource: ontology,
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen current_page: current_page,
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen pages: pages,
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen additional_actions: [],
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen files: ontology.repository.paths_starting_with(ontology.basepath)
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen def subnavigation(resource, pages, current_page, additional_actions = [])
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen # Add counters
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen pages.each do |row|
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen counter_key = "#{row[0]}_count"
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen row << resource.send(counter_key) if resource.respond_to?(counter_key)
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen @page_title = current_page
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen @page_title = "#{current_page.capitalize} · #{@page_title}" if current_page != pages[0][0]
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen render :partial => '/shared/subnavigation', :locals => {
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen resource: resource,
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen current_page: current_page,
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen pages: pages,
20e04227229970d148801c507946666e2a9bd838Timo Sirainen additional_actions: additional_actions
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen def team_nav(team, current_page)
c7fd0af4fddec4a5a6d87d105a429e32429ae17dAki Tuomi [:overview, team],
c7fd0af4fddec4a5a6d87d105a429e32429ae17dAki Tuomi [:permissions, [team, :permissions]]
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen pages << [:members, [team, :team_users]] if can? :edit, team
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen subnavigation(team, pages, current_page)
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen def active_navigation(controller)
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen if params[:repository_id]
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen if params[:ontology_id]
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen return 'active' if controller == :ontologies
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen return 'active' if controller == :repositories
20e04227229970d148801c507946666e2a9bd838Timo Sirainen return 'active' if [controller.to_s, controller.to_s.gsub('_', '/')].include? params[:controller]
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen def menu_entry(title, controller)
eca38954bcf972618f6b85932a3690acbd2b673aTimo Sirainen content_tag :li, class: active_navigation(controller) do
eca38954bcf972618f6b85932a3690acbd2b673aTimo Sirainen link_to title, controller