How to use SortHelper and Filters in a Redmine Plugin? » bugs_controller.rb
| 1 |
class BugsController < ApplicationController |
|---|---|
| 2 |
unloadable
|
| 3 |
before_filter :find_project, :authorize, :only => :index |
| 4 |
|
| 5 |
helper :sort |
| 6 |
include SortHelper |
| 7 |
|
| 8 |
def index |
| 9 |
sort_init 'livello_gravita','asc' |
| 10 |
sort_update %w(id livello_grativa name description) |
| 11 |
|
| 12 |
logger.info(@project.nil? ? "@project is nil" : "@project name is = #{@project.name}") |
| 13 |
@bugs = Bug.find(:all,:conditions => "title LIKE '%#{@project.name}%'",:order => sort_clause) |
| 14 |
|
| 15 |
#@bugs = Bug.search(@project.name)
|
| 16 |
|
| 17 |
flash[:notice] = "nessuna anomalia trovata!" if @bugs.nil? || @bugs.empty? |
| 18 |
end
|
| 19 |
|
| 20 |
#visualizza il dettaglio di una anomalia
|
| 21 |
def show |
| 22 |
@bug = Bug.find(params[:id]) |
| 23 |
respond_to do |format| |
| 24 |
format.html # show.html.erb |
| 25 |
format.xml { render :xml => @bug } |
| 26 |
end
|
| 27 |
end
|
| 28 |
|
| 29 |
def find_project |
| 30 |
@project = Project.find(params[:project_id]) |
| 31 |
end
|
| 32 |
|
| 33 |
def list |
| 34 |
end
|
| 35 |
end
|