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
Jérome Perrin
gitlab-ce
Commits
bdf4007c
Commit
bdf4007c
authored
Nov 19, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adressing comments
parent
671a49cf
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
20 deletions
+21
-20
app/assets/javascripts/awards_handler.coffee
app/assets/javascripts/awards_handler.coffee
+3
-3
app/controllers/projects/notes_controller.rb
app/controllers/projects/notes_controller.rb
+6
-6
app/models/note.rb
app/models/note.rb
+3
-2
app/services/notes/create_service.rb
app/services/notes/create_service.rb
+2
-2
app/views/votes/_votes_block.html.haml
app/views/votes/_votes_block.html.haml
+7
-7
No files found.
app/assets/javascripts/awards_handler.coffee
View file @
bdf4007c
...
...
@@ -79,11 +79,11 @@ class @AwardsHandler
postEmoji
:
(
emoji
,
callback
)
->
$
.
post
@
post_emoji_url
,
{
emoji
:
emoji
$
.
post
@
post_emoji_url
,
{
note
:
{
note
:
emoji
noteable_type
:
@
noteable_type
noteable_id
:
@
noteable_id
},(
data
)
->
}
}
,(
data
)
->
if
data
.
ok
callback
.
call
()
...
...
app/controllers/projects/notes_controller.rb
View file @
bdf4007c
...
...
@@ -59,21 +59,21 @@ class Projects::NotesController < Projects::ApplicationController
end
def
award_toggle
noteable
=
params
[
:noteable_type
]
==
"Issue"
?
Issue
:
MergeRequest
noteable
=
noteable
.
find
(
params
[
:noteable_id
])
noteable
=
note_params
[
:noteable_type
]
==
"issue"
?
Issue
:
MergeRequest
noteable
=
noteable
.
find_by!
(
id:
note_params
[
:noteable_id
],
project:
project
)
data
=
{
noteable:
noteable
,
author:
current_user
,
is_award:
true
,
note:
params
[
:emoji
]
note:
note_params
[
:note
]
}
note
=
project
.
notes
.
find_by
(
data
)
note
=
noteable
.
notes
.
find_by
(
data
)
if
note
note
.
destroy
else
project
.
notes
.
create
(
data
)
Notes
::
CreateService
.
new
(
project
,
current_user
,
note_params
).
execute
end
render
json:
{
ok:
true
}
...
...
app/models/note.rb
View file @
bdf4007c
...
...
@@ -40,13 +40,14 @@ class Note < ActiveRecord::Base
delegate
:name
,
:email
,
to: :author
,
prefix:
true
validates
:note
,
:project
,
presence:
true
validates
:note
,
uniqueness:
{
scope:
[
:author
,
:noteable_type
,
:noteable_id
]
},
if:
->
(
n
)
{
n
.
is_award
}
validates
:line_code
,
format:
{
with:
/\A[a-z0-9]+_\d+_\d+\Z/
},
allow_blank:
true
# Attachments are deprecated and are handled by Markdown uploader
validates
:attachment
,
file_size:
{
maximum: :max_attachment_size
}
validates
:noteable_id
,
presence:
true
,
if:
->
(
n
)
{
n
.
noteable_type
.
present?
&&
n
.
noteable_type
!=
'Commit'
}
validates
:commit_id
,
presence:
true
,
if:
->
(
n
)
{
n
.
noteable_type
==
'Commit'
}
validates
:author
,
presence:
true
,
if:
->
(
n
)
{
n
.
is_award
}
validates
:author
,
presence:
true
mount_uploader
:attachment
,
AttachmentUploader
...
...
@@ -102,7 +103,7 @@ class Note < ActiveRecord::Base
end
def
grouped_awards
select
(
:note
).
distinct
.
map
do
|
note
|
awards
.
select
(
:note
).
distinct
.
map
do
|
note
|
[
note
.
note
,
where
(
note:
note
.
note
)
]
end
end
...
...
app/services/notes/create_service.rb
View file @
bdf4007c
...
...
@@ -35,11 +35,11 @@ module Notes
end
def
contains_emoji_only?
(
note
)
note
=~
/\A:
[-_+[:alnum:]]*:
\s?\z/
note
=~
/\A:
?[-_+[:alnum:]]*:?
\s?\z/
end
def
emoji_name
(
note
)
note
.
match
(
/\A:
([-_+[:alnum:]]*):
\s?/
)[
1
]
note
.
match
(
/\A:
?([-_+[:alnum:]]*):?
\s?/
)[
1
]
end
end
end
app/views/votes/_votes_block.html.haml
View file @
bdf4007c
.awards.votes-block
-
votable
.
notes
.
awards
.
grouped_awards
.
each
do
|
note
|
.
award
{
class:
(
note_active_class
(
note
.
last
,
current_user
)),
title:
emoji_author_list
(
note
.
last
,
current_user
)}
.icon
{
"data-emoji"
=>
"#{
note.first
}"
}
=
image_tag
url_to_emoji
(
note
.
first
),
height:
"20px"
,
width:
"20px"
-
votable
.
notes
.
awards
.
grouped_awards
.
each
do
|
emoji
,
notes
|
.award
{
class:
(
note_active_class
(
note
s
,
current_user
)),
title:
emoji_author_list
(
notes
,
current_user
)}
.icon
{
"data-emoji"
=>
"#{
emoji
}"
}
=
image_tag
url_to_emoji
(
emoji
),
height:
"20px"
,
width:
"20px"
.counter
=
note
.
last
.
count
=
note
s
.
count
-
if
current_user
.dropdown.awards-controls
%a
.add-award
{
"data-toggle"
=>
"dropdown"
,
"data-target"
=>
"#"
,
"href"
=>
"#"
}
=
icon
(
'
plus-squar
e-o'
)
=
icon
(
'
smil
e-o'
)
%ul
.dropdown-menu.awards-menu
-
emoji_list
.
each
do
|
emoji
|
%li
{
"data-emoji"
=>
"#{emoji}"
}=
image_tag
url_to_emoji
(
emoji
),
height:
"20px"
,
width:
"20px"
...
...
@@ -17,7 +17,7 @@
-
if
current_user
:coffeescript
post_emoji_url = "
#{
award_toggle_namespace_project_notes_path
(
@project
.
namespace
,
@project
)
}
"
noteable_type = "
#{
votable
.
class
}
"
noteable_type = "
#{
votable
.
class
.
name
.
underscore
}
"
noteable_id = "
#{
votable
.
id
}
"
window.awards_handler = new AwardsHandler(post_emoji_url, noteable_type, noteable_id)
...
...
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