summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPatricio Cano <suprnova32@gmail.com>2015-09-14 19:27:54 -0500
committerPatricio Cano <suprnova32@gmail.com>2015-09-14 19:27:54 -0500
commitadcae6ebd597c731b22a748b882b668e6301763f (patch)
tree59043f6fb2146dbb5a445b10f54c6016f5544697 /app
parentab56718feb0e155ae889afe900a009594f8acfa1 (diff)
downloadgitlab-ce-adcae6ebd597c731b22a748b882b668e6301763f.tar.gz
Notification level can now be saved from within the project view.
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/project.js.coffee6
-rw-r--r--app/assets/stylesheets/pages/projects.scss4
-rw-r--r--app/controllers/projects_controller.rb2
-rw-r--r--app/helpers/notifications_helper.rb20
-rw-r--r--app/models/notification.rb2
-rw-r--r--app/views/projects/buttons/_notifications.html.haml19
6 files changed, 32 insertions, 21 deletions
diff --git a/app/assets/javascripts/project.js.coffee b/app/assets/javascripts/project.js.coffee
index 39a433dfc91..94380ccac7b 100644
--- a/app/assets/javascripts/project.js.coffee
+++ b/app/assets/javascripts/project.js.coffee
@@ -24,3 +24,9 @@ class @Project
$.cookie('hide_no_password_message', 'false', { path: path })
$(@).parents('.no-password-message').remove()
e.preventDefault()
+
+ $('.update-notification').on 'click', (e) ->
+ e.preventDefault()
+ level = $(this).data('notification-level')
+ $('#notification_level').val(level)
+ $('#notification-form').submit() \ No newline at end of file
diff --git a/app/assets/stylesheets/pages/projects.scss b/app/assets/stylesheets/pages/projects.scss
index 361fd63bc79..8021b3bbffa 100644
--- a/app/assets/stylesheets/pages/projects.scss
+++ b/app/assets/stylesheets/pages/projects.scss
@@ -338,3 +338,7 @@ pre.light-well {
margin-top: -1px;
}
}
+
+.inline-form {
+ display: inline-block;
+}
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 2c80f237f86..fad5a706f49 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -82,7 +82,7 @@ class ProjectsController < ApplicationController
if @project.empty_repo?
render 'projects/empty'
else
- @membership_id = @project.project_members.where(user_id: current_user.id).first
+ @membership_id = @project.project_members.where(user_id: current_user.id).first.id
render :show
end
else
diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb
index 3cc59f9ca5b..4aa9ccedda0 100644
--- a/app/helpers/notifications_helper.rb
+++ b/app/helpers/notifications_helper.rb
@@ -17,23 +17,27 @@ module NotificationsHelper
case notification_level
when Notification::N_DISABLED
content_tag(:li) do
- icon('microphone-slash')
- 'Disabled'
+ link_to '#', class: 'update-notification', data: { notification_level: Notification::N_DISABLED } do
+ icon('microphone-slash', text: 'Disabled')
+ end
end
when Notification::N_PARTICIPATING
content_tag(:li) do
- icon('volume-up')
- 'Participating'
+ link_to '#', class: 'update-notification', data: { notification_level: Notification::N_PARTICIPATING } do
+ icon('volume-up', text: 'Participating')
+ end
end
when Notification::N_WATCH
content_tag(:li) do
- icon('globe')
- 'Watch'
+ link_to '#', class: 'update-notification', data: { notification_level: Notification::N_WATCH } do
+ icon('globe', text: 'Watch')
+ end
end
when Notification::N_MENTION
content_tag(:li) do
- icon('at')
- 'Mention'
+ link_to '#', class: 'update-notification', data: { notification_level: Notification::N_MENTION } do
+ icon('at', text: 'Mention')
+ end
end
else
# do nothing
diff --git a/app/models/notification.rb b/app/models/notification.rb
index 1395274173d..828378655ce 100644
--- a/app/models/notification.rb
+++ b/app/models/notification.rb
@@ -12,7 +12,7 @@ class Notification
class << self
def notification_levels
- [N_DISABLED, N_PARTICIPATING, N_WATCH, N_MENTION]
+ [N_DISABLED, N_MENTION, N_PARTICIPATING, N_WATCH]
end
def options_with_labels
diff --git a/app/views/projects/buttons/_notifications.html.haml b/app/views/projects/buttons/_notifications.html.haml
index fb30868fc6b..76e462a8986 100644
--- a/app/views/projects/buttons/_notifications.html.haml
+++ b/app/views/projects/buttons/_notifications.html.haml
@@ -1,15 +1,12 @@
- if current_user and !@membership_id.nil?
- %span.dropdown
- = form_tag profile_notifications_path, method: :put, remote: true do
- = hidden_field_tag :notification_type, 'project'
- = hidden_field_tag :notification_id, @membership_id
+ = form_tag profile_notifications_path, method: :put, remote: true, class: 'inline-form', id: 'notification-form' do
+ = hidden_field_tag :notification_type, 'project'
+ = hidden_field_tag :notification_id, @membership_id
+ = hidden_field_tag :notification_level
+ %span.dropdown
%a.dropdown-toggle.btn.btn-new{href: '#', "data-toggle" => "dropdown"}
= icon('bell')
Notifications
- %ul.dropdown-menu.dropdown-menu-right.project-home-dropdown
- - Notification.notification_levels.each do | level |
- = notification_list_item(level)
-
-
-
-
+ %ul.dropdown-menu.dropdown-menu-right.project-home-dropdown
+ - Notification.notification_levels.each do |level|
+ = notification_list_item(level) \ No newline at end of file