From: Fabrice Bellingard Date: Wed, 20 Feb 2013 14:50:01 +0000 (+0100) Subject: SONAR-4100 Put overall & project notifs in the same form X-Git-Tag: 3.5~78 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e239caaf2ba5388232caf02d4e5623be99ee189f;p=sonarqube.git SONAR-4100 Put overall & project notifs in the same form --- 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 @@

<%= message('my_profile.overall_notifications.title') -%>

-
- <% form_tag({:action => 'update_notifications'}, {:method => 'post'}) do %> @@ -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] %> <% end %> - - -
@@ -24,9 +22,4 @@ <% end %>
<%= submit_tag message('my_profile.notifications.submit') %>
- <% end %> -
\ 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 @@

<%= message('my_profile.per_project_notifications.title') -%>

- -
- <% form_tag({:action => 'update_per_project_notifications'}, {:method => 'post', :id => 'per_project_notif_form'}) do %> @@ -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(); } }); @@ -57,7 +54,7 @@ select_id = index.to_s + "_" + dispatcher %> - - <% end %>
- <% @channels.each do |channel| -%> <% end %> @@ -76,11 +73,6 @@ <% end %> -
<%= submit_tag message('my_profile.notifications.submit') %>
- <% end %> -
\ 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 %> + +<% end %> +

<%= message('my_profile.page') -%>

@@ -23,9 +31,9 @@
<% if User.editable_password? %> -

<%= message('my_profile.password.title') -%>

-
+

<%= message('my_profile.password.title') -%>

+ <% form_tag({:action => 'change_password'}, :id => 'pass_form_tag', :name => 'pass_form_tag') do -%> @@ -55,12 +63,21 @@ <% end -%> - <% unless @global_dispatchers.empty? -%> - <%= render "account/global_notifications" -%> - <% end %> +
+ <% form_tag({:action => 'update_notifications'}, {:method => 'post', :id => 'notif_form'}) do %> + + <% unless @global_dispatchers.empty? -%> + <%= render "account/global_notifications" -%> +

+ <% end %> - <% unless @per_project_dispatchers.empty? -%> - <%= render "account/per_project_notifications" -%> - <% end %> + <% unless @per_project_dispatchers.empty? -%> + <%= render "account/per_project_notifications" -%> + <% end %> + +

+ <%= submit_tag message('my_profile.notifications.submit') %> + <% end %> +
\ No newline at end of file