navigation_helper.rb revision 118a3240abc3c3ff233450b3551bd451d39ef6ea
883N/A# encoding: utf-8
883N/Amodule NavigationHelper
883N/A
883N/A def subnavigation(resource, pages, current_page, additional_actions = [])
883N/A
883N/A # add counters
883N/A pages.each do |row|
883N/A counter_key = "#{row[0]}_count"
883N/A row << resource.send(counter_key) if resource.respond_to?(counter_key)
883N/A end
883N/A
883N/A @page_title = resource.to_s
883N/A @page_title = "#{current_page.capitalize} ยท #{@page_title}" if current_page != pages[0][0]
883N/A
883N/A render :partial => '/shared/subnavigation', :locals => {
883N/A resource: resource,
883N/A current_page: current_page,
883N/A pages: pages,
883N/A additional_actions: additional_actions
883N/A }
883N/A end
883N/A
883N/A def ontology_nav(ontology, current_page)
883N/A
883N/A pages = [[:overview,ontology]]
883N/A
883N/A if ontology.distributed?
883N/A pages << [:children, [ontology, :children]]
883N/A else
883N/A pages << [:sentences, [ontology, :sentences]]
883N/A pages << [:entities, [ontology, :entities]]
883N/A end
883N/A
883N/A pages += [
883N/A [:versions, [ontology, :ontology_versions]],
883N/A [:metadata, [ontology, :metadata]],
883N/A [:comments, [ontology, :comments]]
883N/A ]
883N/A actions = []
883N/A
883N/A # nav link to permissions
883N/A pages << [:permissions, [ontology, :permissions]] if can? :permissions, ontology
956N/A
883N/A # action link to new version
883N/A actions << link_to('New version', [:new, ontology, :ontology_version ]) if can? :edit, ontology
883N/A
883N/A subnavigation(ontology, pages, current_page, actions)
883N/A end
883N/A
883N/A def team_nav(team, current_page)
883N/A pages = [
883N/A [:overview, team],
883N/A [:permissions, [team, :permissions]]
883N/A ]
883N/A
883N/A pages << [:members, [team, :team_users]] if can? :edit, team
883N/A
883N/A subnavigation(team, pages, current_page)
883N/A end
883N/A
883N/Aend
887N/A