BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
5583197e
Commit
5583197e
authored
Mar 29, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create NotificationSettings object only when user change value in dropdown
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
f8f68d6b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
5 deletions
+35
-5
project.js.coffee
app/assets/javascripts/project.js.coffee
+8
-1
notification_settings_controller.rb
app/controllers/projects/notification_settings_controller.rb
+22
-0
projects_controller.rb
app/controllers/projects_controller.rb
+2
-1
_notifications.html.haml
app/views/projects/buttons/_notifications.html.haml
+2
-3
routes.rb
config/routes.rb
+1
-0
No files found.
app/assets/javascripts/project.js.coffee
View file @
5583197e
...
...
@@ -38,12 +38,19 @@ class @Project
e
.
preventDefault
()
notification_level
=
$
(
@
).
data
'notification-level'
label
=
$
(
@
).
data
'notification-title'
$
(
'#notification_level'
).
val
(
notification_level
)
$
(
'#notification_
setting_
level'
).
val
(
notification_level
)
$
(
'#notification-form'
).
submit
()
$
(
'#notifications-button'
).
empty
().
append
(
"<i class='fa fa-bell'></i>"
+
label
+
"<i class='fa fa-angle-down'></i>"
)
$
(
@
).
parents
(
'ul'
).
find
(
'li.active'
).
removeClass
'active'
$
(
@
).
parent
().
addClass
'active'
$
(
'#notification-form'
).
on
'ajax:success'
,
(
e
,
data
)
->
if
data
.
saved
new
Flash
(
"Notification settings saved"
,
"notice"
)
else
new
Flash
(
"Failed to save new settings"
,
"alert"
)
@
projectSelectDropdown
()
projectSelectDropdown
:
->
...
...
app/controllers/projects/notification_settings_controller.rb
0 → 100644
View file @
5583197e
class
Projects
::
NotificationSettingsController
<
Projects
::
ApplicationController
def
create
notification_setting
=
project
.
notification_settings
.
new
(
notification_setting_params
)
notification_setting
.
user
=
current_user
saved
=
notification_setting
.
save
render
json:
{
saved:
saved
}
end
def
update
notification_setting
=
project
.
notification_settings
.
where
(
user_id:
current_user
).
find
(
params
[
:id
])
saved
=
notification_setting
.
update_attributes
(
notification_setting_params
)
render
json:
{
saved:
saved
}
end
private
def
notification_setting_params
params
.
require
(
:notification_setting
).
permit
(
:level
)
end
end
app/controllers/projects_controller.rb
View file @
5583197e
...
...
@@ -102,7 +102,8 @@ class ProjectsController < Projects::ApplicationController
@membership
=
@project
.
team
.
find_member
(
current_user
.
id
)
if
@membership
@notification_setting
=
current_user
.
notification_settings
.
find_or_create_for
(
@project
)
@notification_setting
=
current_user
.
notification_settings
.
find_or_initialize_by
(
source:
@project
)
@notification_setting
.
set_defaults
unless
@notification_setting
.
persisted?
end
end
...
...
app/views/projects/buttons/_notifications.html.haml
View file @
5583197e
-
if
@notification_setting
=
form_tag
profile_notifications_path
,
method: :put
,
remote:
true
,
class:
'inline'
,
id:
'notification-form'
do
=
hidden_field_tag
:notification_id
,
@notification_setting
.
id
=
hidden_field_tag
:notification_level
,
@notification_setting
.
level
=
form_for
[
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
@notification_setting
],
remote:
true
,
html:
{
class:
'inline'
,
id:
'notification-form'
}
do
|
f
|
=
f
.
hidden_field
:level
%span
.dropdown
%a
.dropdown-new.btn.notifications-btn
#notifications-button
{
href:
'#'
,
"data-toggle"
=>
"dropdown"
}
=
icon
(
'bell'
)
...
...
config/routes.rb
View file @
5583197e
...
...
@@ -606,6 +606,7 @@ Rails.application.routes.draw do
resources
:forks
,
only:
[
:index
,
:new
,
:create
]
resource
:import
,
only:
[
:new
,
:create
,
:show
]
resources
:notification_settings
,
only:
[
:create
,
:update
]
resources
:refs
,
only:
[]
do
collection
do
...
...
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