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
0
Merge Requests
0
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
Kazuhiko Shiozaki
gitlab-ce
Commits
560b1ac5
Commit
560b1ac5
authored
Sep 18, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'riyad-update-votes-when-adding-notes'
parents
249cb19d
64e76a87
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
77 additions
and
7 deletions
+77
-7
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+40
-3
app/assets/stylesheets/common.scss
app/assets/stylesheets/common.scss
+12
-0
app/assets/stylesheets/sections/notes.scss
app/assets/stylesheets/sections/notes.scss
+5
-0
app/helpers/notes_helper.rb
app/helpers/notes_helper.rb
+8
-0
app/views/issues/show.html.haml
app/views/issues/show.html.haml
+1
-1
app/views/merge_requests/_show.html.haml
app/views/merge_requests/_show.html.haml
+1
-1
app/views/notes/_note.html.haml
app/views/notes/_note.html.haml
+10
-2
No files found.
app/assets/javascripts/notes.js
View file @
560b1ac5
...
...
@@ -21,15 +21,18 @@ var NoteList = {
this
.
getContent
();
$
(
"
#notes-list, #new-notes-list
"
).
on
(
"
ajax:success
"
,
"
.delete-note
"
,
function
()
{
$
(
this
).
closest
(
'
li
'
).
fadeOut
();
$
(
this
).
closest
(
'
li
'
).
fadeOut
(
function
()
{
$
(
this
).
remove
();
NoteList
.
updateVotes
();
});
});
$
(
"
.note-form-holder
"
).
on
(
"
ajax:before
"
,
function
(){
$
(
"
.submit_note
"
).
disable
()
$
(
"
.submit_note
"
).
disable
()
;
})
$
(
"
.note-form-holder
"
).
on
(
"
ajax:complete
"
,
function
(){
$
(
"
.submit_note
"
).
enable
()
$
(
"
.submit_note
"
).
enable
()
;
})
disableButtonIfEmptyField
(
"
.note-text
"
,
"
.submit_note
"
);
...
...
@@ -159,6 +162,8 @@ var NoteList = {
if
(
!
this
.
reversed
)
{
this
.
initRefreshNew
();
}
// make sure we are up to date
this
.
updateVotes
();
},
...
...
@@ -198,6 +203,7 @@ var NoteList = {
replaceNewNotes
:
function
(
html
)
{
$
(
"
#new-notes-list
"
).
html
(
html
);
this
.
updateVotes
();
},
/**
...
...
@@ -210,6 +216,37 @@ var NoteList = {
}
else
{
$
(
"
#new-notes-list
"
).
append
(
html
);
}
this
.
updateVotes
();
},
/**
* Recalculates the votes and updates them (if they are displayed at all).
*
* Assumes all relevant notes are displayed (i.e. there are no more notes to
* load via getMore()).
* Might produce inaccurate results when not all notes have been loaded and a
* recalculation is triggered (e.g. when deleting a note).
*/
updateVotes
:
function
()
{
var
votes
=
$
(
"
#votes .votes
"
);
var
notes
=
$
(
"
#notes-list, #new-notes-list
"
).
find
(
"
.note.vote
"
);
// only update if there is a vote display
if
(
votes
.
size
())
{
var
upvotes
=
notes
.
filter
(
"
.upvote
"
).
size
();
var
downvotes
=
notes
.
filter
(
"
.downvote
"
).
size
();
var
votesCount
=
upvotes
+
downvotes
;
var
upvotesPercent
=
votesCount
?
(
100.0
/
votesCount
*
upvotes
)
:
0
;
var
downvotesPercent
=
votesCount
?
(
100.0
-
upvotesPercent
)
:
0
;
// change vote bar lengths
votes
.
find
(
"
.bar-success
"
).
css
(
"
width
"
,
upvotesPercent
+
"
%
"
);
votes
.
find
(
"
.bar-danger
"
).
css
(
"
width
"
,
downvotesPercent
+
"
%
"
);
// replace vote numbers
votes
.
find
(
"
.upvotes
"
).
text
(
votes
.
find
(
"
.upvotes
"
).
text
().
replace
(
/
\d
+/
,
upvotes
));
votes
.
find
(
"
.downvotes
"
).
text
(
votes
.
find
(
"
.downvotes
"
).
text
().
replace
(
/
\d
+/
,
downvotes
));
}
}
};
...
...
app/assets/stylesheets/common.scss
View file @
560b1ac5
...
...
@@ -158,6 +158,18 @@ span.update-author {
padding
:
6px
;
}
}
&
.label-success
{
background-color
:
#8D8
;
color
:
#333
;
text-shadow
:
0
1px
1px
white
;
}
&
.label-error
{
background-color
:
#D88
;
color
:
#333
;
text-shadow
:
0
1px
1px
white
;
}
}
.event_label
{
...
...
app/assets/stylesheets/sections/notes.scss
View file @
560b1ac5
...
...
@@ -71,6 +71,11 @@
border-top
:
1px
solid
#eee
;
}
/* mark vote notes */
.voting_notes
.note
{
padding
:
8px
0
;
}
.notes-status
{
margin
:
18px
;
}
...
...
app/helpers/notes_helper.rb
View file @
560b1ac5
...
...
@@ -6,4 +6,12 @@ module NotesHelper
def
loading_new_notes?
params
[
:loading_new
].
present?
end
def
note_vote_class
(
note
)
if
note
.
upvote?
"vote upvote"
elsif
note
.
downvote?
"vote downvote"
end
end
end
app/views/issues/show.html.haml
View file @
560b1ac5
...
...
@@ -61,4 +61,4 @@
=
markdown
@issue
.
description
.issue_notes
#notes
=
render
"notes/notes_with_form"
,
tid:
@issue
.
id
,
tt:
"issue"
.issue_notes
.voting_notes
#notes
=
render
"notes/notes_with_form"
,
tid:
@issue
.
id
,
tt:
"issue"
app/views/merge_requests/_show.html.haml
View file @
560b1ac5
...
...
@@ -15,7 +15,7 @@
%i
.icon-list-alt
Diff
.merge_request_notes
#notes
{
class:
(
controller
.
action_name
==
'show'
)
?
""
:
"hide"
}
.merge_request_notes
.voting_notes
#notes
{
class:
(
controller
.
action_name
==
'show'
)
?
""
:
"hide"
}
=
render
(
"notes/notes_with_form"
,
tid:
@merge_request
.
id
,
tt:
"merge_request"
)
.merge-request-diffs
=
render
"merge_requests/show/diffs"
if
@diffs
...
...
app/views/notes/_note.html.haml
View file @
560b1ac5
%li
{
id:
dom_id
(
note
),
class:
"note"
}
%li
{
id:
dom_id
(
note
),
class:
"note
#{note_vote_class(note)}
"
}
=
image_tag
gravatar_icon
(
note
.
author
.
email
),
class:
"avatar s32"
%div
.note-author
%strong
=
note
.
author_name
...
...
@@ -6,8 +6,16 @@
%cite
.cgray
=
time_ago_in_words
(
note
.
updated_at
)
ago
-
if
note
.
upvote?
%span
.label.label-success
%i
.icon-thumbs-up
\+1
-
if
note
.
downvote?
%span
.label.label-error
%i
.icon-thumbs-down
\-1
-
if
(
note
.
author_id
==
current_user
.
id
)
||
can?
(
current_user
,
:admin_note
,
@project
)
=
link_to
[
@project
,
note
],
confirm:
'Are you sure?'
,
method: :delete
,
remote:
true
,
class:
"cred delete-note btn very_small"
do
=
link_to
[
@project
,
note
],
confirm:
'Are you sure?'
,
method: :delete
,
remote:
true
,
class:
"cred delete-note btn very_small"
do
%i
.icon-trash
Remove
...
...
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