Commit 5f356d69 authored by randx's avatar randx

Issues tags: refactoring

parent 50fdb2e7
...@@ -61,3 +61,18 @@ function initIssuesSearch() { ...@@ -61,3 +61,18 @@ function initIssuesSearch() {
$(this).closest('tr').fadeOut(); updatePage(); $(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 ...@@ -3,6 +3,8 @@ class IssuesController < ApplicationController
before_filter :project before_filter :project
before_filter :module_enabled before_filter :module_enabled
before_filter :issue, :only => [:edit, :update, :destroy, :show] before_filter :issue, :only => [:edit, :update, :destroy, :show]
helper_method :issues_filter
layout "project" layout "project"
# Authorize # Authorize
...@@ -130,10 +132,10 @@ class IssuesController < ApplicationController ...@@ -130,10 +132,10 @@ class IssuesController < ApplicationController
end end
def issues_filtered def issues_filtered
@issues = case params[:f].to_i @issues = case params[:f]
when 1 then @project.issues when issues_filter[:all] then @project.issues
when 2 then @project.issues.closed when issues_filter[:closed] then @project.issues.closed
when 3 then @project.issues.opened.assigned(current_user) when issues_filter[:to_me] then @project.issues.opened.assigned(current_user)
else @project.issues.opened else @project.issues.opened
end end
...@@ -143,4 +145,13 @@ class IssuesController < ApplicationController ...@@ -143,4 +145,13 @@ class IssuesController < ApplicationController
@issues = @issues.includes(:author, :project).order("updated_at") @issues = @issues.includes(:author, :project).order("updated_at")
@issues @issues
end end
def issues_filter
{
all: "1",
closed: "2",
to_me: "3",
open: "0"
}
end
end end
...@@ -18,17 +18,17 @@ ...@@ -18,17 +18,17 @@
.title .title
.left .left
%ul.nav.nav-pills.left %ul.nav.nav-pills.left
%li{:class => ("active" if (params[:f] == "0" || !params[:f]))} %li{:class => ("active" if (params[:f] == issues_filter[:open] || !params[:f]))}
= link_to project_issues_path(@project, :f => 0, :milestone_id => params[:milestone_id]) do = link_to project_issues_path(@project, :f => issues_filter[:open], :milestone_id => params[:milestone_id]) do
Open Open
%li{:class => ("active" if params[:f] == "2")} %li{:class => ("active" if params[:f] == issues_filter[:closed])}
= link_to project_issues_path(@project, :f => 2, :milestone_id => params[:milestone_id]) do = link_to project_issues_path(@project, :f => issues_filter[:closed], :milestone_id => params[:milestone_id]) do
Closed Closed
%li{:class => ("active" if params[:f] == "3")} %li{:class => ("active" if params[:f] == issues_filter[:to_me])}
= link_to project_issues_path(@project, :f => 3, :milestone_id => params[:milestone_id]) do = link_to project_issues_path(@project, :f => issues_filter[:to_me], :milestone_id => params[:milestone_id]) do
To Me To Me
%li{:class => ("active" if params[:f] == "1")} %li{:class => ("active" if params[:f] == issues_filter[:all])}
= link_to project_issues_path(@project, :f => 1, :milestone_id => params[:milestone_id]) do = link_to project_issues_path(@project, :f => issues_filter[:all], :milestone_id => params[:milestone_id]) do
All All
.right .right
...@@ -44,14 +44,7 @@ ...@@ -44,14 +44,7 @@
:javascript :javascript
$(function(){ $(function(){
initIssuesSearch(); issuesPage();
setSortable();
$("#label_name").chosen();
$("#assignee_id").chosen();
$("#milestone_id").chosen();
$("#milestone_id, #assignee_id, #label_name").live("change", function(){
$(this).closest("form").submit();
});
}) })
function setSortable(){ function setSortable(){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment