Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0e33bf6e
Commit
0e33bf6e
authored
Jun 12, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored IssuesController
parent
3a2d7a66
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
45 deletions
+50
-45
app/assets/javascripts/issues.js
app/assets/javascripts/issues.js
+26
-0
app/controllers/issues_controller.rb
app/controllers/issues_controller.rb
+16
-16
app/views/issues/index.html.haml
app/views/issues/index.html.haml
+8
-29
No files found.
app/assets/javascripts/issues.js
View file @
0e33bf6e
...
@@ -35,3 +35,29 @@ function backToIssues(){
...
@@ -35,3 +35,29 @@ function backToIssues(){
});
});
});
});
}
}
function
initIssuesSearch
()
{
var
href
=
$
(
'
.issue_search
'
).
parent
().
attr
(
'
action
'
);
var
last_terms
=
''
;
$
(
'
.issue_search
'
).
keyup
(
function
()
{
var
terms
=
$
(
this
).
val
();
var
milestone_id
=
$
(
'
#milestone_id
'
).
val
();
var
status
=
$
(
'
#status
'
).
val
();
if
(
terms
!=
last_terms
)
{
last_terms
=
terms
;
if
(
terms
.
length
>=
2
||
terms
.
length
==
0
)
{
$
.
get
(
href
,
{
'
f
'
:
status
,
'
terms
'
:
terms
,
'
milestone_id
'
:
milestone_id
},
function
(
response
)
{
$
(
'
#issues-table
'
).
html
(
response
);
setSortable
();
});
}
}
});
$
(
'
.delete-issue
'
).
live
(
'
ajax:success
'
,
function
()
{
$
(
this
).
closest
(
'
tr
'
).
fadeOut
();
updatePage
();
});
}
app/controllers/issues_controller.rb
View file @
0e33bf6e
...
@@ -23,16 +23,9 @@ class IssuesController < ApplicationController
...
@@ -23,16 +23,9 @@ class IssuesController < ApplicationController
respond_to
:js
,
:html
respond_to
:js
,
:html
def
index
def
index
@issues
=
case
params
[
:f
].
to_i
@issues
=
issues_filtered
when
1
then
@project
.
issues
when
2
then
@project
.
issues
.
closed
when
3
then
@project
.
issues
.
opened
.
assigned
(
current_user
)
else
@project
.
issues
.
opened
end
@issues
=
@issues
.
where
(
:milestone_id
=>
params
[
:milestone_id
])
if
params
[
:milestone_id
].
present?
@issues
=
@issues
.
page
(
params
[
:page
]).
per
(
20
)
@issues
=
@issues
.
page
(
params
[
:page
]).
per
(
20
)
@issues
=
@issues
.
includes
(
:author
,
:project
).
order
(
"critical, updated_at"
)
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
# index.html.erb
format
.
html
# index.html.erb
...
@@ -111,15 +104,9 @@ class IssuesController < ApplicationController
...
@@ -111,15 +104,9 @@ class IssuesController < ApplicationController
def
search
def
search
terms
=
params
[
'terms'
]
terms
=
params
[
'terms'
]
@project
=
Project
.
find
(
params
[
'project'
])
@issues
=
issues_filtered
@issues
=
case
params
[
:status
].
to_i
when
1
then
@project
.
issues
when
2
then
@project
.
issues
.
closed
when
3
then
@project
.
issues
.
opened
.
assigned
(
current_user
)
else
@project
.
issues
.
opened
end
.
page
(
params
[
:page
]).
per
(
100
)
@issues
=
@issues
.
where
(
"title LIKE ?"
,
"%
#{
terms
}
%"
)
unless
terms
.
blank?
@issues
=
@issues
.
where
(
"title LIKE ?"
,
"%
#{
terms
}
%"
)
unless
terms
.
blank?
@issues
=
@issues
.
page
(
params
[
:page
]).
per
(
100
)
render
:partial
=>
'issues'
render
:partial
=>
'issues'
end
end
...
@@ -141,4 +128,17 @@ class IssuesController < ApplicationController
...
@@ -141,4 +128,17 @@ class IssuesController < ApplicationController
def
module_enabled
def
module_enabled
return
render_404
unless
@project
.
issues_enabled
return
render_404
unless
@project
.
issues_enabled
end
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
)
else
@project
.
issues
.
opened
end
@issues
=
@issues
.
where
(
:milestone_id
=>
params
[
:milestone_id
])
if
params
[
:milestone_id
].
present?
@issues
=
@issues
.
includes
(
:author
,
:project
).
order
(
"critical, updated_at"
)
@issues
end
end
end
app/views/issues/index.html.haml
View file @
0e33bf6e
...
@@ -41,27 +41,14 @@
...
@@ -41,27 +41,14 @@
=
render
"issues"
=
render
"issues"
:javascript
:javascript
var
href
=
$
(
'
.issue_search
'
).
parent
().
attr
(
'
action
'
);
$
(
function
(){
var
last_terms
=
''
;
initIssuesSearch
();
$
(
'
.issue_search
'
).
keyup
(
function
()
{
var
terms
=
$
(
this
).
val
();
var
project_id
=
$
(
'
#project_id
'
).
val
();
var
status
=
$
(
'
#status
'
).
val
();
if
(
terms
!=
last_terms
)
{
last_terms
=
terms
;
if
(
terms
.
length
>=
2
||
terms
.
length
==
0
)
{
$
.
get
(
href
,
{
'
status
'
:
status
,
'
terms
'
:
terms
,
project
:
project_id
},
function
(
response
)
{
$
(
'
#issues-table
'
).
html
(
response
);
setSortable
();
setSortable
();
$
(
"
#milestone_id
"
).
chosen
();
$
(
"
#milestone_id
"
).
live
(
"
change
"
,
function
(){
$
(
this
).
closest
(
"
form
"
).
submit
();
});
});
}
})
}
});
$
(
'
.delete-issue
'
).
live
(
'
ajax:success
'
,
function
()
{
$
(
this
).
closest
(
'
tr
'
).
fadeOut
();
updatePage
();});
function
setSortable
(){
function
setSortable
(){
$
(
'
#issues-table
'
).
sortable
({
$
(
'
#issues-table
'
).
sortable
({
...
@@ -83,11 +70,3 @@
...
@@ -83,11 +70,3 @@
}
}
});
});
}
}
$
(
function
(){
setSortable
();
$
(
"
#milestone_id
"
).
chosen
();
$
(
"
#milestone_id
"
).
live
(
"
change
"
,
function
(){
$
(
this
).
closest
(
"
form
"
).
submit
();
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment