From c9f399f5a7cd0f5e2fced05cb3f277091fb8542d Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Fri, 21 Sep 2012 18:20:35 +0200 Subject: [PATCH] SONAR-3623 use modal windows for renaming Q profiles --- .../app/controllers/profiles_controller.rb | 32 +++++++++++----- .../WEB-INF/app/views/layouts/_head.html.erb | 2 +- .../app/views/profiles/_rename_form.html.erb | 38 +++++++++++++++++++ .../WEB-INF/app/views/profiles/index.html.erb | 16 ++++---- .../main/webapp/javascripts/application.js | 9 +---- .../src/main/webapp/stylesheets/jquery-ui.css | 6 +-- .../src/main/webapp/stylesheets/layout.css | 4 ++ .../src/main/webapp/stylesheets/style.css | 36 +++++++++++++++++- 8 files changed, 113 insertions(+), 30 deletions(-) create mode 100644 sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_rename_form.html.erb diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb index 061183c3b84..f4dce0e9777 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb @@ -298,27 +298,41 @@ class ProfilesController < ApplicationController end + # GET /profiles/rename_form?id= + def rename_form + @profile = Profile.find(params[:id]) + render :partial => 'profiles/rename_form' + end # # - # POST /profiles/rename/?name= + # POST /profiles/rename?id=&name= # # def rename - profile = Profile.find(params[:id]) - name = params['rename_' + profile.id.to_s] + render :text => 'Not an ajax request', :status => '400' unless request.xhr? + + @profile = Profile.find(params[:id]) + name = params[:name] + success=false if name.blank? - flash[:warning]=message('quality_profiles.profile_name_cant_be_blank') + @error=message('quality_profiles.profile_name_cant_be_blank') else - existing=Profile.find(:first, :conditions => {:name => name, :language => profile.language, :enabled => true}) + existing=Profile.find(:first, :conditions => {:name => name, :language => @profile.language, :enabled => true}) if existing - flash[:warning]=message('quality_profiles.profile_name_already_exists') - elsif !profile.provided? - java_facade.renameProfile(profile.id, name) + @error=message('quality_profiles.profile_name_already_exists') + elsif !@profile.provided? + java_facade.renameProfile(@profile.id, name) + success=true end end - redirect_to :action => 'index' + + if success + render :text => 'ok', :status => 200 + else + render :partial => 'profiles/rename_form', :status => 400 + end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb index a17ff125ff9..c2f6ada98e3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb @@ -46,5 +46,5 @@ <%= javascript_include_tag 'resource' %> <% end %> - + \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_rename_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_rename_form.html.erb new file mode 100644 index 00000000000..f64315285e5 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_rename_form.html.erb @@ -0,0 +1,38 @@ + +
+ + + <% if @error %> +

<%= h @error -%>

+ <% end %> + +
+
+ + +
+
+ + +
+ +
+
+ \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb index 87df20e4c2b..e1e8e3bd93e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb @@ -130,12 +130,9 @@ - <% if !(profile.provided?) %> - <% form_tag(:action => 'rename', :id => profile.id) do -%> - <%= hidden_field_tag 'rename_' + profile.id.to_s %> - ", "<%= profile.name -%>"); if (name!=null) {$("rename_<%= profile.id %>").value=name; submit();} else {return false;}'> - <% end - end %> + <% if !profile.provided? %> + <%= message('rename') -%> + <% end %> @@ -153,7 +150,6 @@ :method => :post %> <% end %> - <% end %> <% end %> @@ -161,3 +157,9 @@

<% end %> + +<% content_for :javascript_header do %> + $j(document).ready(function () { + $j('.open-modal').modal(); + }); +<% end %> diff --git a/sonar-server/src/main/webapp/javascripts/application.js b/sonar-server/src/main/webapp/javascripts/application.js index ffcd14ce03f..5fcbff6a86f 100644 --- a/sonar-server/src/main/webapp/javascripts/application.js +++ b/sonar-server/src/main/webapp/javascripts/application.js @@ -284,13 +284,9 @@ Treemap.prototype.onLoaded = function (componentsSize) { draggable:false, autoOpen:false, modal:true, + minHeight: 50, resizable:false, dialogClass:o.dialogClass, - open:function (event,ui) { - $j('.ui-widget-overlay').bind('click', function () { - $j('#modal').dialog('close'); - }) - }, close: function() { $j('#modal').remove(); } @@ -306,8 +302,6 @@ Treemap.prototype.onLoaded = function (componentsSize) { return false; }); - - }); } }); @@ -315,4 +309,5 @@ Treemap.prototype.onLoaded = function (componentsSize) { function closeModalWindow() { $j('#modal').dialog('close'); + return false; } \ No newline at end of file diff --git a/sonar-server/src/main/webapp/stylesheets/jquery-ui.css b/sonar-server/src/main/webapp/stylesheets/jquery-ui.css index e17356e0599..2f131a68a02 100755 --- a/sonar-server/src/main/webapp/stylesheets/jquery-ui.css +++ b/sonar-server/src/main/webapp/stylesheets/jquery-ui.css @@ -17,14 +17,12 @@ .ui-helper-clearfix { zoom: 1; } .ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } .ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%;background: none repeat scroll 0 0 rgba(0, 0, 0, 0.5) } -.ui-widget { font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif; font-size: 1.1em; } .ui-widget .ui-widget { font-size: 1em; } -.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif; font-size: 1em; } .ui-widget-content { border: 1px solid #dddddd; background: #eeeeee 50% top repeat-x; color: #333333; } .ui-widget-content a { color: #333333; } .ui-widget-header { border: 1px solid #e78f08; background: #f6a828 50% 50% repeat-x; color: #ffffff; font-weight: bold; } .ui-widget-header a { color: #ffffff; } .ui-widget-shadow { margin: -5px 0 0 -5px; padding: 5px; background: #000000 50% 50% repeat-x; opacity: .20;filter:Alpha(Opacity=20); -moz-border-radius: 5px; -khtml-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } -.ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.5);background-color: #FFF} +.ui-dialog { position: absolute; width: 300px; overflow: hidden; box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.5);background-color: #FFF} .ui-dialog .ui-dialog-titlebar { display:none } -.ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; } \ No newline at end of file +.ui-dialog .ui-dialog-content { position: relative; border: 0; background: none; overflow: auto; zoom: 1; } \ No newline at end of file diff --git a/sonar-server/src/main/webapp/stylesheets/layout.css b/sonar-server/src/main/webapp/stylesheets/layout.css index 7dd4a87c418..b6410c2ba6d 100644 --- a/sonar-server/src/main/webapp/stylesheets/layout.css +++ b/sonar-server/src/main/webapp/stylesheets/layout.css @@ -250,3 +250,7 @@ body, a { .nolayout { padding: 10px; } + +#modal { + display: none; +} \ No newline at end of file diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css index 7b6ab514660..fa9cf6cb609 100644 --- a/sonar-server/src/main/webapp/stylesheets/style.css +++ b/sonar-server/src/main/webapp/stylesheets/style.css @@ -1,6 +1,5 @@ /* CSS optimized by http://www.cleancss.com */ - /* ------------------- PROJECTS SEARCH FORM ------------------- */ #projectSearch { color: #444; @@ -19,6 +18,7 @@ padding: 4px 0; margin-top: 10px; } + .ie6-warn { color: #EEE; background: #FF5252; @@ -975,6 +975,7 @@ table.reviewDetails td img { .discussionComment li { list-style: square inside; } + .discussionComment pre { padding: 10px; border: 1px dashed #DDD; @@ -2274,13 +2275,13 @@ td.spacer-top { padding: 4px 5px; vertical-align: top; } + .table > tfoot > tr > td { font-size: 93%; color: #777; padding: 4px 5px; } - .table-bordered > tbody { border-left: 1px solid #DDD; border-right: 1px solid #DDD; @@ -2345,3 +2346,34 @@ select.medium-width { #dependencies .colbody > div > img { //vertical-align: baseline; } + +.modal-title { + border-bottom: 1px solid #ccc; + padding: 0.5em; + background-color: #EFEFEF; +} +.form-field { + padding: 5px; +} +.form-field label:before { + content: ""; +} +.form-field label { + display: block; + text-align: right; + width: 120px; + float: left; + line-height: 1; + padding: 5px 5px 0 0; +} +.form-footer { + text-align: right; + padding: 0.5em; + border-top: 1px solid #CCC; +} +.form-footer input { + margin-right: 10px; +} +input[type=text] { + height: 20px; +} -- 2.39.5