diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-12-13 11:57:43 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-12-13 11:57:43 +0100 |
commit | 42179b3f75feacda8e28c53bd963b8a861238537 (patch) | |
tree | 1c9f830f9046679a517d11cca2389e4ac8f9e474 /sonar-server | |
parent | 6d1f8d642f2e07f59808a35d9e1a9916ba3b1806 (diff) | |
download | sonarqube-42179b3f75feacda8e28c53bd963b8a861238537.tar.gz sonarqube-42179b3f75feacda8e28c53bd963b8a861238537.zip |
SONAR-3825 better error handling during copy of measure filter
Diffstat (limited to 'sonar-server')
3 files changed, 24 insertions, 17 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/measures_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/measures_controller.rb index a63af45542a..391c759f859 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/measures_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/measures_controller.rb @@ -138,18 +138,21 @@ class MeasuresController < ApplicationController access_denied unless logged_in? require_parameters :id - to_clone = find_filter(params[:id]) - @filter = MeasureFilter.new - @filter.name = params[:name] - @filter.description = params[:description] - @filter.user_id = current_user.id - @filter.shared = to_clone.shared - @filter.data = to_clone.data - @filter.shared = false - if @filter.save - current_user.favourited_measure_filters << @filter - render :text => @filter.id.to_s, :status => 200 + source = find_filter(params[:id]) + target = MeasureFilter.new + target.name = params[:name] + target.description = params[:description] + target.user_id = current_user.id + target.shared = source.shared + target.data = source.data + target.shared = false + if target.save + current_user.favourited_measure_filters << target + render :text => target.id.to_s, :status => 200 else + # keep the id (from source) and errors (from target) in the copy form + target.id= source.id + @filter = target render :partial => 'measures/copy_form', :status => 400 end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_copy_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_copy_form.html.erb index 68eef6d414c..89d14fa379c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_copy_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_copy_form.html.erb @@ -2,15 +2,19 @@ <input type="hidden" name="id" value="<%= @filter.id -%>"> <fieldset> <div class="form-head"> - <h2>Copy Filter: <%= h @filter.name -%></h2> + <h2>Copy Filter</h2> </div> <div class="form-body"> <% @filter.errors.each do |attr, msg| %> <p class="error"><%= h msg -%></p> <% end %> <div class="form-field"> + <label>Copy</label> + <input type="text" size="50" maxlength="100" value="<%= h @filter.name -%>" disabled="disabled"/> + </div> + <div class="form-field"> <label for="name">Name <em class="mandatory">*</em></label> - <input id="name" name="name" type="text" size="50" maxlength="100" value="<%= h @filter.name -%>"/> + <input id="name" name="name" type="text" size="50" maxlength="100" value=""/> </div> <div class="form-field"> <label for="description">Description</label> @@ -24,8 +28,8 @@ </fieldset> </form> <script> - $j("#copy-filter-form").modalForm({success:function (data) { - window.location = baseUrl + '/measures/filter/' + data; - }}); + $j("#copy-filter-form").modalForm({success: function (data) { + window.location = baseUrl + '/measures/filter/' + data; + }}); $j('#name').select(); </script>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/search.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/search.html.erb index 242bb0e6f4e..045cb0ac4d1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/search.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/search.html.erb @@ -35,7 +35,7 @@ <% end %> <% end %> </ul> - <div class="page_title"> + <div class="page_title" id="filter-title"> <% if @filter.name.present? %> <span class="h3"><%= h @filter.name -%></span> <span class="note"> |