diff --git a/app/assets/javascripts/project.js.coffee b/app/assets/javascripts/project.js.coffee index 39a433dfc91b530a734f5c98c4268a2ef6a4ee1b..94380ccac7b0956de0ccf9d8cd3b85c8138cffe1 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 361fd63bc79463c4eb5e4a6cc450bf85e676a345..8021b3bbffabab551a8d975925c7529ab9566d3c 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 2c80f237f86ce040bb944f497c82e8a2a1fea831..fad5a706f491f43636fae034a3128f1db37068ac 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 3cc59f9ca5b416448792c9aa363ebfe46e08a3ae..4aa9ccedda073e3a3f2547e7fbb25cc38e470087 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 1395274173d4d18609167b6b9f6ed12abc133076..828378655ceca937f0c436c1dd27ed3ec28b9b3d 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 fb30868fc6be6c93217fc25be106c00e58e1cd81..76e462a898695a8047ab7f2906500b607ad423c9 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