Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
6090e0a0b4bc
Commit
6090e0a0
authored
Feb 24, 2012
by
Dmitriy Zaporozhets
Browse files
move notes login to one controller
parent
dee775489db8
Changes
16
Hide whitespace changes
Inline
Side-by-side
app/assets/javascripts/note.js
View file @
6090e0a0
var
NoteList
=
{
notes_path
:
null
,
target_params
:
null
,
target_id
:
0
,
target_type
:
null
,
first_id
:
0
,
last_id
:
0
,
...
...
@@ -3,6 +7,5 @@
first_id
:
0
,
last_id
:
0
,
resource_name
:
null
,
disable
:
false
,
init
:
...
...
@@ -6,10 +9,12 @@
disable
:
false
,
init
:
function
(
resource_name
,
first_id
,
last_id
)
{
this
.
resource_name
=
resource_name
;
this
.
first_id
=
first_id
;
this
.
last_id
=
last_id
;
function
(
tid
,
tt
,
path
)
{
this
.
notes_path
=
path
+
"
.js
"
;
this
.
target_id
=
tid
;
this
.
target_type
=
tt
;
this
.
target_params
=
"
&target_type=
"
+
this
.
target_type
+
"
&target_id=
"
+
this
.
target_id
this
.
refresh
();
this
.
initRefresh
();
this
.
initLoadMore
();
},
...
...
@@ -19,8 +24,8 @@
$
(
'
.loading
'
).
show
();
$
.
ajax
({
type
:
"
GET
"
,
url
:
location
.
href
,
data
:
"
first_id=
"
+
this
.
first_id
,
url
:
this
.
notes_path
,
data
:
"
first_id=
"
+
this
.
first_id
+
this
.
target_params
,
complete
:
function
(){
$
(
'
.loading
'
).
hide
()},
dataType
:
"
script
"
});
},
...
...
@@ -56,8 +61,8 @@
// refersh notes list
$
.
ajax
({
type
:
"
GET
"
,
url
:
location
.
href
,
data
:
"
last_id=
"
+
this
.
last_id
,
url
:
this
.
notes_path
,
data
:
"
last_id=
"
+
this
.
last_id
+
this
.
target_params
,
dataType
:
"
script
"
});
},
...
...
@@ -66,8 +71,8 @@
// refersh notes list
$
.
ajax
({
type
:
"
GET
"
,
url
:
location
.
href
,
data
:
"
first_id=
"
+
this
.
first_id
+
"
&last_id=
"
+
this
.
last_id
,
url
:
this
.
notes_path
,
data
:
"
first_id=
"
+
this
.
first_id
+
"
&last_id=
"
+
this
.
last_id
+
this
.
target_params
,
dataType
:
"
script
"
});
},
...
...
app/controllers/application_controller.rb
View file @
6090e0a0
...
...
@@ -95,18 +95,6 @@
redirect_to
@project
unless
@project
.
repo_exists?
&&
@project
.
has_commits?
end
def
respond_with_notes
if
params
[
:last_id
]
&&
params
[
:first_id
]
@notes
=
@notes
.
where
(
"id >= ?"
,
params
[
:first_id
])
elsif
params
[
:last_id
]
@notes
=
@notes
.
where
(
"id > ?"
,
params
[
:last_id
])
elsif
params
[
:first_id
]
@notes
=
@notes
.
where
(
"id < ?"
,
params
[
:first_id
])
else
nil
end
end
def
no_cache_headers
response
.
headers
[
"Cache-Control"
]
=
"no-cache, no-store, max-age=0, must-revalidate"
response
.
headers
[
"Pragma"
]
=
"no-cache"
...
...
app/controllers/commits_controller.rb
View file @
6090e0a0
...
...
@@ -29,5 +29,4 @@
git_not_found!
and
return
unless
@commit
@notes
=
project
.
commit_notes
(
@commit
).
fresh
.
limit
(
20
)
@note
=
@project
.
build_commit_note
(
@commit
)
...
...
@@ -33,4 +32,3 @@
@note
=
@project
.
build_commit_note
(
@commit
)
@comments_allowed
=
true
@line_notes
=
project
.
commit_line_notes
(
@commit
)
...
...
@@ -35,10 +33,5 @@
@comments_allowed
=
true
@line_notes
=
project
.
commit_line_notes
(
@commit
)
respond_to
do
|
format
|
format
.
html
format
.
js
{
respond_with_notes
}
end
end
def
compare
...
...
app/controllers/issues_controller.rb
View file @
6090e0a0
...
...
@@ -49,7 +49,6 @@
end
def
show
@notes
=
@issue
.
notes
.
inc_author
.
order
(
"created_at DESC"
).
limit
(
20
)
@note
=
@project
.
notes
.
new
(
:noteable
=>
@issue
)
@commits
=
if
@issue
.
branch_name
&&
@project
.
repo
.
heads
.
map
(
&
:name
).
include?
(
@issue
.
branch_name
)
...
...
@@ -61,7 +60,7 @@
respond_to
do
|
format
|
format
.
html
format
.
js
{
respond_with_notes
}
format
.
js
end
end
...
...
app/controllers/merge_requests_controller.rb
View file @
6090e0a0
...
...
@@ -39,7 +39,6 @@
git_not_found!
and
return
end
@notes
=
@merge_request
.
notes
.
inc_author
.
order
(
"created_at DESC"
).
limit
(
20
)
@note
=
@project
.
notes
.
new
(
:noteable
=>
@merge_request
)
@commits
=
@project
.
repo
.
...
...
@@ -52,7 +51,7 @@
respond_to
do
|
format
|
format
.
html
format
.
js
{
respond_with_notes
}
format
.
js
end
end
...
...
app/controllers/notes_controller.rb
View file @
6090e0a0
...
...
@@ -9,6 +9,23 @@
respond_to
:js
def
index
@notes
=
case
params
[
:target_type
]
when
"commit"
then
project
.
commit_notes
(
project
.
commit
((
params
[
:target_id
]))).
fresh
.
limit
(
20
)
when
"wall"
then
project
.
common_notes
.
order
(
"created_at DESC"
).
fresh
.
limit
(
20
)
when
"issue"
then
project
.
issues
.
find
(
params
[
:target_id
]).
notes
.
inc_author
.
order
(
"created_at DESC"
).
limit
(
20
)
when
"merge_request"
then
project
.
merge_requests
.
find
(
params
[
:target_id
]).
notes
.
inc_author
.
order
(
"created_at DESC"
).
limit
(
20
)
end
respond_to
do
|
format
|
format
.
js
{
respond_with_notes
}
end
end
def
create
@note
=
@project
.
notes
.
new
(
params
[
:note
])
@note
.
author
=
current_user
...
...
@@ -34,4 +51,17 @@
end
end
protected
def
respond_with_notes
if
params
[
:last_id
]
&&
params
[
:first_id
]
@notes
=
@notes
.
where
(
"id >= ?"
,
params
[
:first_id
])
elsif
params
[
:last_id
]
@notes
=
@notes
.
where
(
"id > ?"
,
params
[
:last_id
])
elsif
params
[
:first_id
]
@notes
=
@notes
.
where
(
"id < ?"
,
params
[
:first_id
])
else
nil
end
end
end
app/controllers/projects_controller.rb
View file @
6090e0a0
...
...
@@ -82,5 +82,4 @@
def
wall
return
render_404
unless
@project
.
wall_enabled
@note
=
Note
.
new
...
...
@@ -86,6 +85,4 @@
@note
=
Note
.
new
@notes
=
@project
.
common_notes
.
order
(
"created_at DESC"
)
@notes
=
@notes
.
fresh
.
limit
(
20
)
respond_to
do
|
format
|
format
.
html
...
...
@@ -89,7 +86,6 @@
respond_to
do
|
format
|
format
.
html
format
.
js
{
respond_with_notes
}
end
end
...
...
app/views/commits/show.html.haml
View file @
6090e0a0
...
...
@@ -21,7 +21,7 @@
%p
.cgray
Showing
#{
pluralize
(
@commit
.
diffs
.
count
,
"changed file"
)
}
=
render
"commits/diffs"
,
:diffs
=>
@commit
.
diffs
=
render
"notes/notes"
=
render
"notes/notes"
,
:tid
=>
@commit
.
id
,
:tt
=>
"commit"
=
render
"notes/per_line_form"
...
...
app/views/issues/show.html.haml
View file @
6090e0a0
...
...
@@ -41,5 +41,5 @@
%div
=
simple_format
@issue
.
title
.issue_notes
=
render
"notes/notes"
.issue_notes
=
render
"notes/notes"
,
:tid
=>
@issue
.
id
,
:tt
=>
"issue"
app/views/issues/show.js.haml
deleted
100644 → 0
View file @
dee77548
=
render
"notes/load"
app/views/merge_requests/show.html.haml
View file @
6090e0a0
...
...
@@ -63,7 +63,7 @@
%img
{
:src
=>
"/assets/ajax-loader-facebook.gif"
,
:class
=>
"dashboard-loader"
}
.merge-request-notes
.merge_request_notes
=
render
"notes/notes"
.merge_request_notes
=
render
"notes/notes"
,
:tid
=>
@merge_request
.
id
,
:tt
=>
"merge_request"
.loading
{
:style
=>
"display:none;"
}
%center
=
image_tag
"ajax-loader.gif"
.clear
...
...
app/views/notes/_notes.html.haml
View file @
6090e0a0
...
...
@@ -2,7 +2,7 @@
=
render
"notes/form"
.clear
%hr
%ul
#notes-list
=
render
"notes/notes_list"
%ul
#notes-list
:javascript
$
(
'
.delete-note
'
).
live
(
'
ajax:success
'
,
function
()
{
...
...
@@ -22,5 +22,5 @@
$
(
'
.attach_holder
'
).
show
();
});
NoteList
.
init
(
"
wall
"
,
#{
@notes
.
last
.
try
(
:id
)
||
0
}
,
#{
@notes
.
first
.
try
(
:id
)
||
0
}
);
NoteList
.
init
(
"
#{
tid
}
"
,
"
#{
tt
}
"
,
"
#{
project_notes_path
(
@project
)
}
"
);
});
app/views/notes/index.js.haml
0 → 100644
View file @
6090e0a0
=
render
"notes/load"
app/views/projects/wall.html.haml
View file @
6090e0a0
%div
.wall_page
=
render
"notes/notes"
=
render
"notes/notes"
,
:tid
=>
nil
,
:tt
=>
"wall"
.loading
{
:style
=>
"display:none;"
}
%center
=
image_tag
"ajax-loader.gif"
...
...
app/views/projects/wall.js.haml
deleted
100644 → 0
View file @
dee77548
=
render
"notes/load"
config/routes.rb
View file @
6090e0a0
...
...
@@ -121,7 +121,7 @@
get
:search
end
end
resources
:notes
,
:only
=>
[
:create
,
:destroy
]
resources
:notes
,
:only
=>
[
:index
,
:create
,
:destroy
]
end
root
:to
=>
"projects#index"
end
Write
Preview
Supports
Markdown
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