Search code examples
rubyredmineredmine-plugins

redmine settings tab project


I want to put a new tab in the setting project on a Redmine plugin and I don't find how to do it.

I get the code of CCUL Project Managment plugin by ISITROL S.A.(www.isitrol.com) and replace de funcionlity with my funcionality, but I still can't change the name of the config_controller to my controller.

the helperpatch has this estructure: require 'redmine' require_dependency 'projects_helper'

module CCULProjectsHelperPatch
  def self.included(base)
  base.send(:include, ProjectsHelperMethodsCCUL)

  base.class_eval do
    unloadable
    alias_method_chain :project_settings_tabs, :coste
  end
 end
end

module ProjectsHelperMethodsCCUL
  def project_settings_tabs_with_coste
    @tabs = project_settings_tabs_without_coste
    @action = {:name => 'coste', :controller => 'coste_config', :action => :index, :partial => 'coste_config/index', :label => :tab_ccul}

    Rails.logger.info "old_tabs: #{@tabs}"
    Rails.logger.info "action: #{@action}"
    @tabs << @action #if User.current.allowed_to?(action, @project)
    @tabs
  end
end

ProjectsHelper.send(:include, CCULProjectsHelperPatch) unless ProjectsHelper.included_modules.include? CCULProjectsHelperPatch

I've changed the name of the controller(and controller file's name), the view's folder and the name of the controller in the init file (I change pm_config to coste_pm)

This is the init file:

Rails.configuration.to_prepare do
  require_dependency 'coste_project_helper_patch'
end

Redmine::Plugin.register :redmine_coste do
name 'Costes'
author 'Me'
description 'Plugin para calculo coste proyecto. Compatible con Redmine 2.3.x '
version '0.1.4'


project_module :coste do
permission :cost_manager, {:coste_config => [:index, :create], :coste_project => [:show]}
end

menu :project_menu, :coste, { :controller => 'coste_project', :action => 'show' }, :caption =>  :coste, :param => :project_id
menu :admin_menu, :coste, { :controller => 'coste_admin', :action => 'show' }, :caption => :coste
end

The error is "404 The page you were trying to acess doesn't exist or has been removed" when I try to access Settings of one project

I don't know what I need to change

I hope you can help me


Solution

  • I've found the problem, in the views templates of the settings the form had the old controller's name.

    For who is looking for a way to put the setting project tab like me: I need take the database information in the view. Redmine doesn't call the controller when it creates the project settings tabs And the code above is the basic to do it