Issues tags: refactoring
This commit is contained in:
parent
50fdb2e7df
commit
5f356d6928
3 changed files with 39 additions and 20 deletions
|
@ -61,3 +61,18 @@ function initIssuesSearch() {
|
|||
$(this).closest('tr').fadeOut(); updatePage();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Init issues page
|
||||
*
|
||||
*/
|
||||
function issuesPage(){
|
||||
initIssuesSearch();
|
||||
setSortable();
|
||||
$("#label_name").chosen();
|
||||
$("#assignee_id").chosen();
|
||||
$("#milestone_id").chosen();
|
||||
$("#milestone_id, #assignee_id, #label_name").on("change", function(){
|
||||
$(this).closest("form").submit();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ class IssuesController < ApplicationController
|
|||
before_filter :project
|
||||
before_filter :module_enabled
|
||||
before_filter :issue, :only => [:edit, :update, :destroy, :show]
|
||||
helper_method :issues_filter
|
||||
|
||||
layout "project"
|
||||
|
||||
# Authorize
|
||||
|
@ -130,10 +132,10 @@ class IssuesController < ApplicationController
|
|||
end
|
||||
|
||||
def issues_filtered
|
||||
@issues = case params[:f].to_i
|
||||
when 1 then @project.issues
|
||||
when 2 then @project.issues.closed
|
||||
when 3 then @project.issues.opened.assigned(current_user)
|
||||
@issues = case params[:f]
|
||||
when issues_filter[:all] then @project.issues
|
||||
when issues_filter[:closed] then @project.issues.closed
|
||||
when issues_filter[:to_me] then @project.issues.opened.assigned(current_user)
|
||||
else @project.issues.opened
|
||||
end
|
||||
|
||||
|
@ -143,4 +145,13 @@ class IssuesController < ApplicationController
|
|||
@issues = @issues.includes(:author, :project).order("updated_at")
|
||||
@issues
|
||||
end
|
||||
|
||||
def issues_filter
|
||||
{
|
||||
all: "1",
|
||||
closed: "2",
|
||||
to_me: "3",
|
||||
open: "0"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,17 +18,17 @@
|
|||
.title
|
||||
.left
|
||||
%ul.nav.nav-pills.left
|
||||
%li{:class => ("active" if (params[:f] == "0" || !params[:f]))}
|
||||
= link_to project_issues_path(@project, :f => 0, :milestone_id => params[:milestone_id]) do
|
||||
%li{:class => ("active" if (params[:f] == issues_filter[:open] || !params[:f]))}
|
||||
= link_to project_issues_path(@project, :f => issues_filter[:open], :milestone_id => params[:milestone_id]) do
|
||||
Open
|
||||
%li{:class => ("active" if params[:f] == "2")}
|
||||
= link_to project_issues_path(@project, :f => 2, :milestone_id => params[:milestone_id]) do
|
||||
%li{:class => ("active" if params[:f] == issues_filter[:closed])}
|
||||
= link_to project_issues_path(@project, :f => issues_filter[:closed], :milestone_id => params[:milestone_id]) do
|
||||
Closed
|
||||
%li{:class => ("active" if params[:f] == "3")}
|
||||
= link_to project_issues_path(@project, :f => 3, :milestone_id => params[:milestone_id]) do
|
||||
%li{:class => ("active" if params[:f] == issues_filter[:to_me])}
|
||||
= link_to project_issues_path(@project, :f => issues_filter[:to_me], :milestone_id => params[:milestone_id]) do
|
||||
To Me
|
||||
%li{:class => ("active" if params[:f] == "1")}
|
||||
= link_to project_issues_path(@project, :f => 1, :milestone_id => params[:milestone_id]) do
|
||||
%li{:class => ("active" if params[:f] == issues_filter[:all])}
|
||||
= link_to project_issues_path(@project, :f => issues_filter[:all], :milestone_id => params[:milestone_id]) do
|
||||
All
|
||||
|
||||
.right
|
||||
|
@ -44,14 +44,7 @@
|
|||
|
||||
:javascript
|
||||
$(function(){
|
||||
initIssuesSearch();
|
||||
setSortable();
|
||||
$("#label_name").chosen();
|
||||
$("#assignee_id").chosen();
|
||||
$("#milestone_id").chosen();
|
||||
$("#milestone_id, #assignee_id, #label_name").live("change", function(){
|
||||
$(this).closest("form").submit();
|
||||
});
|
||||
issuesPage();
|
||||
})
|
||||
|
||||
function setSortable(){
|
||||
|
|
Loading…
Reference in a new issue