module BacklogsPlugin module Hooks class LayoutHook < Redmine::Hook::ViewListener # this ought to be view_issues_sidebar_queries_bottom, but # the entire queries toolbar is disabled if you don't have # custom queries def view_issues_sidebar_planning_bottom(context={ }) locals = {} locals[:sprints] = context[:project] ? Sprint.open_sprints(context[:project]) : [] locals[:project] = context[:project] locals[:sprint] = nil locals[:webcal] = (context[:request].ssl? ? 'webcals' : 'webcal') user = User.find_by_id(context[:request].session[:user_id]) locals[:key] = user ? user.api_key : nil q = context[:request].session[:query] if q && q[:filters] sprint = q[:filters]['fixed_version_id'] if sprint && sprint[:operator] == '=' && sprint[:values].size == 1 locals[:sprint] = Sprint.find_by_id(sprint[:values][0]) end end return context[:controller].send(:render_to_string, { :partial => 'backlogs/view_issues_sidebar', :locals => locals }) end def view_issues_show_details_bottom(context={ }) issue = context[:issue] snippet = '' if issue.is_story? snippet += "
' #snippet += context[:form].label(:story_points) snippet += context[:form].text_field(:story_points, :size => 3) snippet += '
' if issue.descendants.length != 0 snippet += javascript_include_tag 'jquery-1.4.2.min.js', :plugin => 'redmine_backlogs' snippet += <<-generatedscript generatedscript end end if issue.is_task? || (issue.is_story? && issue.descendants.length == 0) snippet += '' #snippet += context[:form].label(:remaining_hours) snippet += context[:form].text_field(:remaining_hours, :size => 3) snippet += '
' end return snippet end def view_versions_show_bottom(context={ }) version = context[:version] project = version.project snippet = '' if User.current.allowed_to?(:edit_wiki_pages, project) snippet += '' snippet += link_to l(:button_edit_wiki), {:controller => 'backlogs', :action => 'wiki_page_edit', :project_id => project.id, :sprint_id => version.id }, :class => 'icon icon-edit' snippet += '' # this wouldn't be necesary if the schedules plugin # didn't disable the contextual hook snippet += javascript_include_tag 'jquery-1.4.2.min.js', :plugin => 'redmine_backlogs' snippet += <<-generatedscript generatedscript end end def view_my_account(context={ }) return context[:controller].send(:render_to_string, { :partial => 'backlogs/view_my_account', :locals => {:user => context[:user], :color => context[:user].backlogs_preference(:task_color) } }) end end end end