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
07eec9c6
Commit
07eec9c6
authored
Sep 14, 2012
by
Riyad Preukschas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Notes JS for reversed notes
parent
7563abbe
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
11 deletions
+27
-11
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+20
-7
app/contexts/notes/load_context.rb
app/contexts/notes/load_context.rb
+5
-2
app/models/note.rb
app/models/note.rb
+1
-1
app/views/notes/index.js.haml
app/views/notes/index.js.haml
+1
-1
No files found.
app/assets/javascripts/notes.js
View file @
07eec9c6
...
@@ -4,14 +4,17 @@ var NoteList = {
...
@@ -4,14 +4,17 @@ var NoteList = {
target_params
:
null
,
target_params
:
null
,
target_id
:
0
,
target_id
:
0
,
target_type
:
null
,
target_type
:
null
,
top_id
:
0
,
bottom_id
:
0
,
bottom_id
:
0
,
loading_more_disabled
:
false
,
loading_more_disabled
:
false
,
reversed
:
false
,
init
:
init
:
function
(
tid
,
tt
,
path
)
{
function
(
tid
,
tt
,
path
)
{
this
.
notes_path
=
path
+
"
.js
"
;
this
.
notes_path
=
path
+
"
.js
"
;
this
.
target_id
=
tid
;
this
.
target_id
=
tid
;
this
.
target_type
=
tt
;
this
.
target_type
=
tt
;
this
.
reversed
=
$
(
"
#notes-list
"
).
hasClass
(
"
reversed
"
);
this
.
target_params
=
"
&target_type=
"
+
this
.
target_type
+
"
&target_id=
"
+
this
.
target_id
;
this
.
target_params
=
"
&target_type=
"
+
this
.
target_type
+
"
&target_id=
"
+
this
.
target_id
;
// get initial set of notes
// get initial set of notes
...
@@ -69,12 +72,18 @@ var NoteList = {
...
@@ -69,12 +72,18 @@ var NoteList = {
* Replaces the content of #notes-list with the given html.
* Replaces the content of #notes-list with the given html.
*/
*/
setContent
:
setContent
:
function
(
last_id
,
html
)
{
function
(
first_id
,
last_id
,
html
)
{
this
.
top_id
=
first_id
;
this
.
bottom_id
=
last_id
;
this
.
bottom_id
=
last_id
;
$
(
"
#notes-list
"
).
html
(
html
);
$
(
"
#notes-list
"
).
html
(
html
);
//
I
nit infinite scrolling
//
i
nit infinite scrolling
this
.
initLoadMore
();
this
.
initLoadMore
();
// init getting new notes
if
(
this
.
reversed
)
{
this
.
initRefreshNew
();
}
},
},
...
@@ -114,7 +123,7 @@ var NoteList = {
...
@@ -114,7 +123,7 @@ var NoteList = {
$
.
ajax
({
$
.
ajax
({
type
:
"
GET
"
,
type
:
"
GET
"
,
url
:
this
.
notes_path
,
url
:
this
.
notes_path
,
data
:
"
loading_more=1&
after_id
=
"
+
this
.
bottom_id
+
this
.
target_params
,
data
:
"
loading_more=1&
"
+
(
this
.
reversed
?
"
before_id
"
:
"
after_id
"
)
+
"
=
"
+
this
.
bottom_id
+
this
.
target_params
,
complete
:
function
(){
$
(
'
.notes-status
'
).
removeClass
(
"
loading
"
)},
complete
:
function
(){
$
(
'
.notes-status
'
).
removeClass
(
"
loading
"
)},
beforeSend
:
function
()
{
$
(
'
.notes-status
'
).
addClass
(
"
loading
"
)
},
beforeSend
:
function
()
{
$
(
'
.notes-status
'
).
addClass
(
"
loading
"
)
},
dataType
:
"
script
"
});
dataType
:
"
script
"
});
...
@@ -142,7 +151,9 @@ var NoteList = {
...
@@ -142,7 +151,9 @@ var NoteList = {
this
.
loading_more_disabled
=
true
;
this
.
loading_more_disabled
=
true
;
// from now on only get new notes
// from now on only get new notes
this
.
initRefreshNew
();
if
(
!
this
.
reversed
)
{
this
.
initRefreshNew
();
}
},
},
...
@@ -164,14 +175,14 @@ var NoteList = {
...
@@ -164,14 +175,14 @@ var NoteList = {
},
},
/**
/**
* Gets the new set of notes
(i.e. all notes after )
.
* Gets the new set of notes.
*/
*/
getNew
:
getNew
:
function
()
{
function
()
{
$
.
ajax
({
$
.
ajax
({
type
:
"
GET
"
,
type
:
"
GET
"
,
url
:
this
.
notes_path
,
url
:
this
.
notes_path
,
data
:
"
loading_new=1&after_id=
"
+
this
.
bottom_id
+
this
.
target_params
,
data
:
"
loading_new=1&after_id=
"
+
(
this
.
reversed
?
this
.
top_id
:
this
.
bottom_id
)
+
this
.
target_params
,
dataType
:
"
script
"
});
dataType
:
"
script
"
});
},
},
...
@@ -189,7 +200,9 @@ var NoteList = {
...
@@ -189,7 +200,9 @@ var NoteList = {
*/
*/
appendNewNote
:
appendNewNote
:
function
(
id
,
html
)
{
function
(
id
,
html
)
{
if
(
id
!=
this
.
bottom_id
)
{
if
(
this
.
reversed
)
{
$
(
"
#new-notes-list
"
).
prepend
(
html
);
}
else
{
$
(
"
#new-notes-list
"
).
append
(
html
);
$
(
"
#new-notes-list
"
).
append
(
html
);
}
}
}
}
...
...
app/contexts/notes/load_context.rb
View file @
07eec9c6
...
@@ -4,6 +4,7 @@ module Notes
...
@@ -4,6 +4,7 @@ module Notes
target_type
=
params
[
:target_type
]
target_type
=
params
[
:target_type
]
target_id
=
params
[
:target_id
]
target_id
=
params
[
:target_id
]
after_id
=
params
[
:after_id
]
after_id
=
params
[
:after_id
]
before_id
=
params
[
:before_id
]
@notes
=
case
target_type
@notes
=
case
target_type
...
@@ -17,14 +18,16 @@ module Notes
...
@@ -17,14 +18,16 @@ module Notes
project
.
snippets
.
find
(
target_id
).
notes
.
fresh
project
.
snippets
.
find
(
target_id
).
notes
.
fresh
when
"wall"
when
"wall"
# this is the only case, where the order is DESC
# this is the only case, where the order is DESC
project
.
common_notes
.
order
(
"created_at DESC"
).
limit
(
50
)
project
.
common_notes
.
order
(
"created_at DESC
, id DESC
"
).
limit
(
50
)
when
"wiki"
when
"wiki"
project
.
wikis
.
reverse
.
map
{
|
w
|
w
.
notes
.
fresh
}.
flatten
[
0
..
20
]
project
.
wikis
.
reverse
.
map
{
|
w
|
w
.
notes
.
fresh
}.
flatten
[
0
..
20
]
end
end
@notes
=
if
after_id
@notes
=
if
after_id
@notes
.
where
(
"id > ?"
,
after_id
)
@notes
.
where
(
"id > ?"
,
after_id
)
else
elsif
before_id
@notes
.
where
(
"id < ?"
,
before_id
)
else
@notes
@notes
end
end
end
end
...
...
app/models/note.rb
View file @
07eec9c6
...
@@ -36,7 +36,7 @@ class Note < ActiveRecord::Base
...
@@ -36,7 +36,7 @@ class Note < ActiveRecord::Base
scope
:today
,
where
(
"created_at >= :date"
,
date:
Date
.
today
)
scope
:today
,
where
(
"created_at >= :date"
,
date:
Date
.
today
)
scope
:last_week
,
where
(
"created_at >= :date"
,
date:
(
Date
.
today
-
7
.
days
))
scope
:last_week
,
where
(
"created_at >= :date"
,
date:
(
Date
.
today
-
7
.
days
))
scope
:since
,
lambda
{
|
day
|
where
(
"created_at >= :date"
,
date:
(
day
))
}
scope
:since
,
lambda
{
|
day
|
where
(
"created_at >= :date"
,
date:
(
day
))
}
scope
:fresh
,
order
(
"created_at ASC"
)
scope
:fresh
,
order
(
"created_at ASC
, id ASC
"
)
scope
:inc_author_project
,
includes
(
:project
,
:author
)
scope
:inc_author_project
,
includes
(
:project
,
:author
)
scope
:inc_author
,
includes
(
:author
)
scope
:inc_author
,
includes
(
:author
)
...
...
app/views/notes/index.js.haml
View file @
07eec9c6
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
-
else
-
else
:plain
:plain
NoteList.setContent(
#{
@notes
.
last
.
id
}
, "
#{
escape_javascript
(
render
'notes/notes'
)
}
");
NoteList.setContent(
#{
@notes
.
first
.
id
}
,
#{
@notes
.
last
.
id
}
, "
#{
escape_javascript
(
render
'notes/notes'
)
}
");
-
else
-
else
-
if
loading_more_notes?
-
if
loading_more_notes?
...
...
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