diff options
author | Fabrice Bellingard <fabrice.bellingard@sonarsource.com> | 2013-02-20 15:50:01 +0100 |
---|---|---|
committer | Fabrice Bellingard <fabrice.bellingard@sonarsource.com> | 2013-02-20 16:00:45 +0100 |
commit | e239caaf2ba5388232caf02d4e5623be99ee189f (patch) | |
tree | 4253af716262be68061dd412cf922b62338dc28a /sonar-server | |
parent | f995cca780d8eb66cadb1678f1cbc69dc5050d45 (diff) | |
download | sonarqube-e239caaf2ba5388232caf02d4e5623be99ee189f.tar.gz sonarqube-e239caaf2ba5388232caf02d4e5623be99ee189f.zip |
SONAR-4100 Put overall & project notifs in the same form
Diffstat (limited to 'sonar-server')
4 files changed, 36 insertions, 34 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/account_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/account_controller.rb index 6277b81c0cd..36afe854939 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/account_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/account_controller.rb @@ -62,17 +62,16 @@ class AccountController < ApplicationController end def update_notifications - notifications = params[:notifications] + # Global notifs + global_notifs = params[:global_notifs] Property.delete_all(['prop_key like ? AND user_id = ? AND resource_id IS NULL', 'notification.%', current_user.id]) - notifications.each_key { |key| current_user.add_property(:prop_key => 'notification.' + key, :text_value => 'true') } if notifications - redirect_to :action => 'index' - end + global_notifs.each_key { |key| current_user.add_property(:prop_key => 'notification.' + key, :text_value => 'true') } if global_notifs - def update_per_project_notifications - notifications = params[:notifications] + # Per project notifs + project_notifs = params[:project_notifs] Property.delete_all(['prop_key like ? AND user_id = ? AND resource_id IS NOT NULL', 'notification.%', current_user.id]) - if notifications - notifications.each do |r_id, per_project_notif| + if project_notifs + project_notifs.each do |r_id, per_project_notif| per_project_notif.each do |dispatch, channels| channels.each do |channel| current_user.add_property(:prop_key => 'notification.' + dispatch + '.' + channel, :text_value => 'true', :resource_id => r_id) @@ -81,6 +80,7 @@ class AccountController < ApplicationController end end + # New project added new_params = {} unless params[:new_project].blank? new_params[:new_project] = params[:new_project] diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/account/_global_notifications.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/account/_global_notifications.html.erb index 5332657ffd6..dbad8b052d3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/account/_global_notifications.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/account/_global_notifications.html.erb @@ -1,7 +1,5 @@ <h2><%= message('my_profile.overall_notifications.title') -%></h2> -<div class="admin marginbottom10"> - <% form_tag({:action => 'update_notifications'}, {:method => 'post'}) do %> <table class="form"> <tr> <td></td> @@ -15,7 +13,7 @@ <% for channel in @channels notification_id = dispatcher + '.' + channel.getKey() - check_box_id = 'notifications[' + notification_id + ']' + check_box_id = 'global_notifs[' + notification_id + ']' check_box_checked = @global_notifications[notification_id] %> <td class="center"> @@ -24,9 +22,4 @@ <% end %> </tr> <% end %> - <tr> - <td style="padding-top: 10px" colspan="<%= @global_dispatchers.size + 1 -%>"><%= submit_tag message('my_profile.notifications.submit') %></td> - </tr> </table> - <% end %> -</div>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/account/_per_project_notifications.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/account/_per_project_notifications.html.erb index 94a9d5d8e1c..38d7a3a53dd 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/account/_per_project_notifications.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/account/_per_project_notifications.html.erb @@ -1,7 +1,4 @@ <h2><%= message('my_profile.per_project_notifications.title') -%></h2> - -<div class="admin marginbottom10"> - <% form_tag({:action => 'update_per_project_notifications'}, {:method => 'post', :id => 'per_project_notif_form'}) do %> <table class="form"> <tr> @@ -16,7 +13,7 @@ var id = event.target.value; if (id != null) { //window.location = '<%= ApplicationController.root_context -%>/account/index?new_project=' + id; - $j('#per_project_notif_form').submit(); + $j('#notif_form').submit(); } }); </script> @@ -57,7 +54,7 @@ select_id = index.to_s + "_" + dispatcher %> <td> - <select id="<%= select_id -%>" name="notifications[<%= r_id.to_s -%>][<%= dispatcher-%>][]" multiple style="width: 100%"> + <select id="<%= select_id -%>" name="project_notifs[<%= r_id.to_s -%>][<%= dispatcher-%>][]" multiple style="width: 100%"> <% @channels.each do |channel| -%> <option value="<%= channel.getKey() -%>" <%= 'selected' if per_project_notif[dispatcher].include?(channel.getKey()) || (r_id==@new_project_id && channel.getKey()=='EmailNotificationChannel') -%>><%= message('notification.channel.' + channel.getKey()) -%></option> <% end %> @@ -76,11 +73,6 @@ <% end %> - <tr> - <td style="padding-top: 10px" colspan="<%= @per_project_dispatchers.size + 1 -%>"><%= submit_tag message('my_profile.notifications.submit') %></td> - </tr> <% end %> </table> - <% end %> -</div>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/account/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/account/index.html.erb index 4b630101a9e..ff23f8a1f25 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/account/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/account/index.html.erb @@ -1,3 +1,11 @@ +<% content_for :style do %> + <style> + h2 { + padding-bottom: 10px; + } + </style> +<% end %> + <div id="content"> <h1 class="marginbottom10"><%= message('my_profile.page') -%></h1> @@ -23,9 +31,9 @@ </div> <% if User.editable_password? %> - <h2><%= message('my_profile.password.title') -%></h2> - <div class="admin marginbottom10"> + <h2><%= message('my_profile.password.title') -%></h2> + <% form_tag({:action => 'change_password'}, :id => 'pass_form_tag', :name => 'pass_form_tag') do -%> <table class="form"> <tr> @@ -55,12 +63,21 @@ </div> <% end -%> - <% unless @global_dispatchers.empty? -%> - <%= render "account/global_notifications" -%> - <% end %> + <div class="admin marginbottom10"> + <% form_tag({:action => 'update_notifications'}, {:method => 'post', :id => 'notif_form'}) do %> + + <% unless @global_dispatchers.empty? -%> + <%= render "account/global_notifications" -%> + <br/><br/> + <% end %> - <% unless @per_project_dispatchers.empty? -%> - <%= render "account/per_project_notifications" -%> - <% end %> + <% unless @per_project_dispatchers.empty? -%> + <%= render "account/per_project_notifications" -%> + <% end %> + + <br/><br/> + <%= submit_tag message('my_profile.notifications.submit') %> + <% end %> + </div> </div>
\ No newline at end of file |