Commit 4c98357f authored by Patricio Cano's avatar Patricio Cano

Added Global to the drop downs and updated the label of the button to show the...

Added Global to the drop downs and updated the label of the button to show the current level instead of `Notifications`
parent de1ffce7
...@@ -27,8 +27,16 @@ class @Project ...@@ -27,8 +27,16 @@ class @Project
$('.update-notification').on 'click', (e) -> $('.update-notification').on 'click', (e) ->
e.preventDefault() e.preventDefault()
level = $(@).data 'notification-level' notification_level = $(@).data 'notification-level'
$('#notification_level').val(level) $('#notification_level').val(notification_level)
$('#notification-form').submit() $('#notification-form').submit()
label = null
switch notification_level
when 0 then label = ' Disabled '
when 1 then label = ' Participating '
when 2 then label = ' Watching '
when 3 then label = ' Global '
when 4 then label = ' On Mention '
$('#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' $(@).parents('ul').find('li.active').removeClass 'active'
$(@).parent().addClass 'active' $(@).parent().addClass 'active'
\ No newline at end of file
...@@ -24,19 +24,25 @@ module NotificationsHelper ...@@ -24,19 +24,25 @@ module NotificationsHelper
when Notification::N_PARTICIPATING when Notification::N_PARTICIPATING
content_tag(:li, class: active_level_for(user_membership, 'participating?')) do content_tag(:li, class: active_level_for(user_membership, 'participating?')) do
link_to '#', class: 'update-notification', data: { notification_level: Notification::N_PARTICIPATING } do link_to '#', class: 'update-notification', data: { notification_level: Notification::N_PARTICIPATING } do
icon('volume-up fw', text: 'Participating') icon('volume-up fw', text: 'Participate')
end end
end end
when Notification::N_WATCH when Notification::N_WATCH
content_tag(:li, class: active_level_for(user_membership, 'watch?')) do content_tag(:li, class: active_level_for(user_membership, 'watch?')) do
link_to '#', class: 'update-notification', data: { notification_level: Notification::N_WATCH } do link_to '#', class: 'update-notification', data: { notification_level: Notification::N_WATCH } do
icon('globe fw', text: 'Watch') icon('eye fw', text: 'Watch')
end end
end end
when Notification::N_MENTION when Notification::N_MENTION
content_tag(:li, class: active_level_for(user_membership, 'mention?')) do content_tag(:li, class: active_level_for(user_membership, 'mention?')) do
link_to '#', class: 'update-notification', data: { notification_level: Notification::N_MENTION } do link_to '#', class: 'update-notification', data: { notification_level: Notification::N_MENTION } do
icon('at fw', text: 'Mention') icon('at fw', text: 'On mention')
end
end
when Notification::N_GLOBAL
content_tag(:li, class: active_level_for(user_membership, 'global?')) do
link_to '#', class: 'update-notification', data: { notification_level: Notification::N_GLOBAL } do
icon('globe fw', text: 'Global')
end end
end end
else else
...@@ -44,12 +50,14 @@ module NotificationsHelper ...@@ -44,12 +50,14 @@ module NotificationsHelper
end end
end end
def notification_label(user_membership)
Notification.new(user_membership).to_s
end
def active_level_for(user_membership, level) def active_level_for(user_membership, level)
value = Notification.new(user_membership) value = Notification.new(user_membership)
if value.global? if value.send(level)
return 'active' if current_user.notification.send(level) 'active'
elsif value.send(level)
return 'active'
end end
end end
end end
...@@ -26,7 +26,7 @@ class Notification ...@@ -26,7 +26,7 @@ class Notification
end end
def project_notification_levels def project_notification_levels
[N_DISABLED, N_PARTICIPATING, N_WATCH, N_GLOBAL, N_MENTION] [N_DISABLED, N_MENTION, N_PARTICIPATING, N_WATCH, N_GLOBAL]
end end
end end
...@@ -57,4 +57,21 @@ class Notification ...@@ -57,4 +57,21 @@ class Notification
def level def level
target.notification_level target.notification_level
end end
def to_s
case level
when N_DISABLED
'Disabled'
when N_PARTICIPATING
'Participating'
when N_WATCH
'Watching'
when N_MENTION
'On mention'
when N_GLOBAL
'Global'
else
# do nothing
end
end
end end
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
= hidden_field_tag :notification_id, @membership.id = hidden_field_tag :notification_id, @membership.id
= hidden_field_tag :notification_level = hidden_field_tag :notification_level
%span.dropdown %span.dropdown
%a.dropdown-toggle.btn.btn-new{href: '#', "data-toggle" => "dropdown"} %a.dropdown-toggle.btn.btn-new#notifications-button{href: '#', "data-toggle" => "dropdown"}
= icon('bell') = icon('bell')
Notifications = notification_label(@membership)
= icon('angle-down') = icon('angle-down')
%ul.dropdown-menu.dropdown-menu-right.project-home-dropdown %ul.dropdown-menu.dropdown-menu-right.project-home-dropdown
- Notification.notification_levels.each do |level| - Notification.project_notification_levels.each do |level|
= notification_list_item(level, @membership) = notification_list_item(level, @membership)
\ No newline at end of file
...@@ -132,11 +132,11 @@ class Spinach::Features::Project < Spinach::FeatureSteps ...@@ -132,11 +132,11 @@ class Spinach::Features::Project < Spinach::FeatureSteps
end end
step 'I click notifications drop down button' do step 'I click notifications drop down button' do
click_link 'Notifications' click_link 'notifications-button'
end end
step 'I choose Mention setting' do step 'I choose Mention setting' do
click_link 'Mention' click_link 'On mention'
end end
step 'I should see Notification saved message' do step 'I should see Notification saved message' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment