diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2012-01-30 15:09:04 +0100 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2012-01-30 15:44:44 +0100 |
commit | 672b365a0eb737bf5fa8605f99e2990a34721d07 (patch) | |
tree | cf4aed4e74d40557f8debf03f76955a31d1b793e /sonar-server | |
parent | 6ddac77971fe906af9738f53e485b554064e45ce (diff) | |
download | sonarqube-672b365a0eb737bf5fa8605f99e2990a34721d07.tar.gz sonarqube-672b365a0eb737bf5fa8605f99e2990a34721d07.zip |
SONAR-3104 Improve the usability of the project 'History' page
- Remove possibility to specify an event category
- And then simplify the UI consequently
Diffstat (limited to 'sonar-server')
3 files changed, 40 insertions, 73 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb index f8016804530..7273a65e47d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb @@ -239,60 +239,40 @@ class ProjectController < ApplicationController redirect_to :action => 'history', :id => snapshot.root_project_id end - def new_event + def create_event snapshot=Snapshot.find(params[:sid]) not_found("Snapshot not found") unless snapshot access_denied unless is_admin?(snapshot) - @event = Event.new(:snapshot => snapshot, :resource => snapshot.resource) - @categories=EventCategory.categories(false) - @categories << EventCategory.other_category - render :partial => 'edit_event' - end - - def create_event - event = Event.new(params[:event]) - access_denied unless is_admin?(event.resource) - - if Event.already_exists(event.snapshot_id, event.name, event.category) - flash[:error] = message('project_history.event_already_exists', :params => [event.name, event.category]) + if Event.already_exists(snapshot.id, params[:event_name], EventCategory::KEY_OTHER) + flash[:error] = message('project_history.event_already_exists', :params => params[:event_name]) else - snapshots = find_project_snapshots(event.snapshot_id) + snapshots = find_project_snapshots(snapshot.id) snapshots.each do |snapshot| - e = Event.new(params[:event]) - e.snapshot = snapshot - e.resource_id = snapshot.project_id - e.event_date = snapshot.created_at + e = Event.new({:name => params[:event_name], + :category => EventCategory::KEY_OTHER, + :snapshot => snapshot, + :resource_id => snapshot.project_id, + :event_date => snapshot.created_at}) e.save! end - flash[:notice] = message('project_history.event_created', :params => event.name) + flash[:notice] = message('project_history.event_created', :params => params[:event_name]) end - redirect_to :action => 'history', :id => event.resource_id - end - - def edit_event - @event = Event.find(params[:id]) - not_found("Event not found") unless @event - access_denied unless is_admin?(@event.resource) - - @categories=EventCategory.categories(false) - @categories << EventCategory.other_category - render :partial => 'edit_event' + redirect_to :action => 'history', :id => snapshot.project_id end def update_event - event = Event.find(params[:event][:id]) + event = Event.find(params[:id]) not_found("Event not found") unless event access_denied unless is_admin?(event.resource) - if Event.already_exists(event.snapshot_id, params[:event][:name], params[:event][:category]) - flash[:error] = message('project_history.event_already_exists', :params => [event.name, event.category]) + if Event.already_exists(event.snapshot_id, params[:event_name], EventCategory::KEY_OTHER) + flash[:error] = message('project_history.event_already_exists', :params => event.name) else events = find_events(event) events.each do |e| - e.name = params[:event][:name] - e.category = params[:event][:category] + e.name = params[:event_name] e.save! end flash[:notice] = message('project_history.event_updated') diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/_edit_event.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/_edit_event.html.erb deleted file mode 100644 index 8cdffc2dd0c..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/_edit_event.html.erb +++ /dev/null @@ -1,26 +0,0 @@ -<% form_for(@event, :url => "#{ApplicationController.root_context}/project/#{@event.id ? 'update_event' : 'create_event'}") do |f| %> - <%= f.hidden_field :id %> - <%= f.hidden_field :resource_id %> - <%= f.hidden_field :snapshot_id %> - <table class="admin spaced"> - <tr> - <td colspan="2"><div id="event_form_errors" class="error" style="display:none"> </div></td> - </tr> - <tr> - <td class="left" nowrap="nowrap" valign="top" width="1%"> - <span class="comments"><%= message('events.name_required') -%></span><br> - <%= f.text_field :name, :onkeyup => "if (this.value=='') $('event_#{@event.id}_submit').disabled='true'; else $('event_#{@event.id}_submit').disabled='';" -%> - </td> - <td class="left" nowrap="nowrap" valign="top"> - <span class="comments"><%= message('category') -%></span><br> - <%= f.select(:category, @categories.collect {|c| [ message('event.category.' + c.name, :default => c.name), c.name ] }) %> - </td> - </tr> - <tr> - <td class="left" nowrap="nowrap" valign="top" colspan="2"> - <input id="event_<%= @event.id -%>_submit" type="submit" value="<%= message(@event.id ? 'update_verb' : 'create') -%>" name="save" <%= 'disabled' if @event.name.blank? -%>> - <a href="#" onclick="node=$('event_<%= @event.snapshot.id -%>_form'); node.removeChild(node.childNodes[0]);" class="action"><%= message('cancel') -%></a> - </td> - </tr> - </table> -<% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb index 10bbcc63772..a35a0af57ce 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb @@ -42,9 +42,7 @@ <tr id="version_<%= index -%>"> <td class="max-width"><%= version_event.name if version_event -%></td> <td class="small" style="padding-left:20px"> - <a id="version_<%= index -%>_change" href="#" onclick="$('version_<%= index -%>').hide();$('version_<%= index -%>_form').show();"> - <%= version_event ? message('project_history.rename_version') : message('project_history.create_version') -%> - </a> + <a id="version_<%= index -%>_change" href="#" onclick="$('version_<%= index -%>').hide();$('version_<%= index -%>_form').show();$('version_name_<%= index -%>').focus();return false;"><%= version_event ? message('project_history.rename_version') : message('project_history.create_version') -%></a> <% if version_event && !snapshot.islast? %> <%= link_to( message('project_history.remove_version'), { :action => 'delete_version', :sid => snapshot.id}, @@ -68,27 +66,42 @@ <td class="thin nowrap" style="padding-left: 20px;"> <table class="max-width"> <% other_events.each do |event| %> - <tr> + <tr id="event_<%= event.id -%>"> <td class="max-width"><%= event.name -%></td> <td class="small" style="padding-left:20px"> - <%= link_to_remote( message('project_history.edit_event'), - :url => { :action => 'edit_event', :id => event.id}, - :update => "event_#{snapshot.id}_form" ) %> + <a id="event_<%= event.id -%>_change" href="#" onclick="$('event_<%= event.id -%>').hide();$('event_<%= event.id -%>_form').show();$('event_name_<%= event.id -%>').focus();return false;"><%= message('project_history.edit_event') -%></a> <%= link_to( message('project_history.remove_version'), { :action => 'delete_event', :id => event.id}, :confirm => message('project_history.do_you_want_to_remove_version', :params => event.name) ) -%> </td> </tr> + <tr id="event_<%= event.id -%>_form" style="display:none;"> + <td colspan="2" class="admin"> + <% form_tag( {:action => 'update_event', :id => event.id }) do -%> + <input id="event_name_<%= event.id -%>" name="event_name" type="text" value="<%= event.name -%>" + onKeyUp="if (this.value=='') $('save_event_<%= event.id -%>').disabled='true'; else $('save_event_<%= event.id -%>').disabled='';"/> + <%= submit_tag message('save'), :id => 'save_event_' + event.id.to_s %> + <a href="#" onclick="$('event_<%= event.id -%>').show();$('event_<%= event.id -%>_form').hide();"><%= message('cancel') -%></a> + <% end %> + </td> + </tr> <% end %> - <tr> + <tr id="create_event_<%= index -%>"> <td colspan="2" class="small right"> - <%= link_to_remote( message('project_history.create_event'), - :url => { :action => 'new_event', :sid => snapshot.id}, - :update => "event_#{snapshot.id}_form" ) %> + <a id="create_event_<%= index -%>" href="#" onclick="$('create_event_<%= index -%>').hide();$('create_event_<%= index -%>_form').show();$('create_event_name_<%= index -%>').focus();return false;"><%= message('project_history.create_event') -%></a> + </td> + </tr> + <tr id="create_event_<%= index -%>_form" style="display:none;"> + <td colspan="2" class="admin"> + <% form_tag( {:action => 'create_event', :sid => snapshot.id }) do -%> + <input id="create_event_name_<%= index -%>" name="event_name" type="text" value="" + onKeyUp="if (this.value=='') $('create_save_event_<%= index -%>').disabled='true'; else $('create_save_event_<%= index -%>').disabled='';"/> + <%= submit_tag message('save'), :id => 'create_save_event_' + index.to_s %> + <a href="#" onclick="$('create_event_<%= index -%>').show();$('create_event_<%= index -%>_form').hide();"><%= message('cancel') -%></a> + <% end %> </td> </tr> </table> - <div id="event_<%= snapshot.id -%>_form"></div> </td> <td class="thin nowrap"> |