aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstephenbroyer <stephen.broyer@sonarsource.com>2013-10-31 17:11:56 +0100
committerstephenbroyer <stephen.broyer@sonarsource.com>2013-10-31 17:12:21 +0100
commite5361dc9b700fc4f5b3acf5cbecb45d4384abf2f (patch)
tree5e856c7c9b2afa096fff19f7ea39dfcfc08a0584
parentf0f5058c481c3da9e63ff260963fb951182f5122 (diff)
downloadsonarqube-e5361dc9b700fc4f5b3acf5cbecb45d4384abf2f.tar.gz
sonarqube-e5361dc9b700fc4f5b3acf5cbecb45d4384abf2f.zip
SONAR-4762 Use modal windows in Action Plans pages of project settings
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb42
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_create_form.html.erb41
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_edit_form.html.erb41
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_new.html.erb40
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb40
5 files changed, 141 insertions, 63 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb
index bb4392c3db0..479991fde07 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb
@@ -27,36 +27,58 @@ class ActionPlansController < ApplicationController
load_action_plans()
end
- def edit
+ def create_form
+ load_action_plans()
+ render :partial => 'action_plans/create_form'
+ end
+
+ def edit_form
@action_plan = find_by_key(params[:plan_key])
load_action_plans()
- render 'index'
+ render :partial => 'action_plans/edit_form'
end
- def save
+ def edit
verify_post_request
options = {'project' => @resource.key, 'name' => params[:name], 'description' => params[:description], 'deadLine' => params[:deadline]}
- exiting_action_plan = find_by_key(params[:plan_key]) unless params[:plan_key].blank?
- if exiting_action_plan
- action_plan_result = Internal.issues.updateActionPlan(params[:plan_key], options)
+ action_plan_result = Internal.issues.updateActionPlan(params[:plan_key], options)
+
+ if action_plan_result.ok()
+ @action_plan = action_plan_result.get()
+ flash[:notice] = 'Successfully edited.'
+ render :text => 'ok', :status => 200
else
- action_plan_result = Internal.issues.createActionPlan(options)
+ @errors = []
+ @errors << action_plan_result.errors().map{|error| error.text ? error.text : Api::Utils.message(error.l10nKey, :params => error.l10nParams)}.join('<br/>')
+ @action_plan = find_by_key(params[:plan_key])
+ load_action_plans()
+ render :partial => 'action_plans/edit_form', :status => 400
end
+ end
+
+ def save
+ verify_post_request
+ options = {'project' => @resource.key, 'name' => params[:name], 'description' => params[:description], 'deadLine' => params[:deadline]}
+
+ action_plan_result = Internal.issues.createActionPlan(options)
if action_plan_result.ok()
@action_plan = action_plan_result.get()
- redirect_to :action => 'index', :id => @resource.id
+ flash[:notice] = 'Successfully created.'
+ render :text => 'ok', :status => 200
else
- flash[:error] = action_plan_result.errors().map{|error| error.text ? error.text : Api::Utils.message(error.l10nKey, :params => error.l10nParams)}.join('<br/>')
+ @errors = []
+ @errors << action_plan_result.errors().map{|error| error.text ? error.text : Api::Utils.message(error.l10nKey, :params => error.l10nParams)}.join('<br/>')
load_action_plans()
- render 'index'
+ render :partial => 'action_plans/create_form', :status => 400
end
end
def delete
verify_post_request
Internal.issues.deleteActionPlan(params[:plan_key])
+ flash[:notice] = 'Successfully deleted.'
redirect_to :action => 'index', :id => @resource.id
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_create_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_create_form.html.erb
new file mode 100644
index 00000000000..66a1024278c
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_create_form.html.erb
@@ -0,0 +1,41 @@
+<form action="<%= url_for :action => 'save' -%>" method="POST" id="create-action-plan-form">
+ <input type="hidden" name="id" value="<%= @resource.id -%>"/>
+ <input type="hidden" name="plan_key" value="<%= @action_plan.key() if @action_plan -%>"/>
+
+ <fieldset>
+ <div class="modal-head">
+ <h2><%=message('action_plans.create_form_title') -%></h2>
+ </div>
+ <div class="modal-body">
+ <% if @errors %>
+ <p class="error"><%= @errors -%></p>
+ <% end %>
+
+ <div class="modal-field">
+ <label for="user[login]"><%= message('action_plans.col.name') -%> <em class="mandatory">*</em></label>
+ <input type="text" name="name" id="name" value="<%= @action_plan ? @action_plan.name() : params[:name] -%>"/><br/>
+ </div>
+ <div class="modal-field">
+ <label for="user[login]"> <%= message('action_plans.col.due_for') -%> </label>
+ <input type="text" name="deadline" id="deadline" value="<%= @action_plan && @action_plan.deadLine() ? Api::Utils.format_date(@action_plan.deadLine()) : params[:deadline] -%>"/>
+ <br/>
+ <span class="note"><%= message('action_plans.date_format_help') -%></span>
+ <br/>
+ </div>
+ <div class="modal-field">
+ <label for="user[login]"><%= message('action_plans.col.description') -%> </label>
+ <textarea rows="5" cols="80" name="description" id="description" class="width100"><%= @action_plan ? @action_plan.description() : params['description'] -%></textarea>
+ </div>
+ </div>
+
+ <div class="modal-foot">
+ <input type="submit" value="<%= h(message('create')) -%>"/>
+ <%= link_to message('cancel'), { :controller => 'action_plans', :action => 'index', :id => @resource.id}, { :class => 'action' } %>
+ </div>
+ </fieldset>
+</form>
+
+<script>
+ $j("#create-action-plan-form").modalForm();
+</script>
+
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_edit_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_edit_form.html.erb
new file mode 100644
index 00000000000..d81e89f4a6a
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_edit_form.html.erb
@@ -0,0 +1,41 @@
+<form action="<%= url_for :action => 'edit' -%>" method="POST" id="edit-action-plan-form">
+ <input type="hidden" name="id" value="<%= @resource.id -%>"/>
+ <input type="hidden" name="plan_key" value="<%= @action_plan.key() if @action_plan -%>"/>
+
+ <fieldset>
+ <div class="modal-head">
+ <h2><%= message('action_plans.edit_action_plan') -%>: <%= @action_plan ? @action_plan.name() : params[:name] -%></h2>
+ </div>
+ <div class="modal-body">
+ <% if @errors %>
+ <p class="error"><%= @errors -%></p>
+ <% end %>
+
+ <div class="modal-field">
+ <label for="user[login]"><%= message('action_plans.col.name') -%> <em class="mandatory">*</em></label>
+ <input type="text" name="name" id="name" value="<%= @action_plan ? @action_plan.name() : params[:name] -%>"/><br/>
+ </div>
+ <div class="modal-field">
+ <label for="user[login]"> <%= message('action_plans.col.due_for') -%> </label>
+ <input type="text" name="deadline" id="deadline" value="<%= @action_plan && @action_plan.deadLine() ? Api::Utils.format_date(@action_plan.deadLine()) : params[:deadline] -%>"/>
+ <br/>
+ <span class="note"><%= message('action_plans.date_format_help') -%></span>
+ <br/>
+ </div>
+ <div class="modal-field">
+ <label for="user[login]"><%= message('action_plans.col.description') -%> </label>
+ <textarea rows="5" cols="80" name="description" id="description" class="width100"><%= @action_plan ? @action_plan.description() : params['description'] -%></textarea>
+ </div>
+ </div>
+
+ <div class="modal-foot">
+ <input type="submit" value="<%= h(message('edit')) -%>"/>
+ <%= link_to message('cancel'), { :controller => 'action_plans', :action => 'index', :id => @resource.id}, { :class => 'action' } %>
+ </div>
+ </fieldset>
+</form>
+
+<script>
+ $j("#edit-action-plan-form").modalForm();
+</script>
+
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_new.html.erb
deleted file mode 100644
index 924f50e5adb..00000000000
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_new.html.erb
+++ /dev/null
@@ -1,40 +0,0 @@
-<table class="admintable" width="100%">
- <form action="<%= url_for :action => 'save' -%>" method="POST" id="create-action-plan-form">
- <input type="hidden" name="id" value="<%= @resource.id -%>"/>
- <input type="hidden" name="plan_key" value="<%= @action_plan.key() if @action_plan -%>"/>
- <tbody>
- <tr>
- <td class="left"><h1 class="marginbottom10"><%= @action_plan && @action_plan.key() ? message('action_plans.edit_action_plan') : message('action_plans.create_form_title') -%></h1></td>
- </tr>
- <tr>
- <td class="left" valign="top">
- <%= message('action_plans.col.name') -%>:
- <br/>
- <input type="text" name="name" id="name" value="<%= @action_plan ? @action_plan.name() : params[:name] -%>"/>
- </td>
- </tr>
- <tr>
- <td class="left" valign="top">
- <%= message('action_plans.col.due_for') -%>:
- <br/>
- <input type="text" name="deadline" id="deadline" value="<%= @action_plan && @action_plan.deadLine() ? Api::Utils.format_date(@action_plan.deadLine()) : params[:deadline] -%>"/>
- <br/>
- <span class="note"><%= message('action_plans.date_format_help') -%></span>
- </td>
- </tr>
- <tr>
- <td class="left" valign="top">
- <%= message('action_plans.col.description') -%>:
- <br/>
- <textarea rows="5" cols="80" name="description" id="description" class="width100"><%= @action_plan ? @action_plan.description() : params['description'] -%></textarea>
- </td>
- </tr>
- <tr>
- <td class="left" valign="top">
- <input type="submit" value="<%= @action_plan && @action_plan.key() ? message('edit') : message('create') -%>"/>
- <%= link_to message('cancel'), { :controller => 'action_plans', :action => 'index', :id => @resource.id}, { :class => 'action' } %>
- </td>
- </tr>
- </tbody>
- </form>
-</table>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb
index 9e842a31497..41779bac8a3 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb
@@ -1,9 +1,16 @@
+<div class="line-block">
+ <% if profiles_administrator? %>
+ <ul style="float: right" class="horizontal">
+ <li class="marginleft10 add">
+ <a id="create-link-action_plans" href="<%=ApplicationController.root_context-%>/action_plans/create_form/<%= h(@resource.id) -%>" class="open-modal link-action">Add new action plan</a>
+ </li>
+ </ul>
+ <% end %>
+ <h1><%= message('action_plans.page_title') -%></h1>
+</div>
<table width="100%" id="action-plans">
<tr>
<td valign="top">
-
- <h1><%= message('action_plans.page_title') -%></h1>
-
<table class="width100 data sortable actionPlans" id="open-action-plans">
<thead>
<tr>
@@ -40,7 +47,7 @@
<td id="desc"><%= h(plan.description()) -%></td>
<td id="desc"><%= h(@users[plan.userLogin()]) -%></td>
<td class="thin nowrap right">
- <%= link_to message('edit'), {:action => 'edit', :id => @resource.id, :plan_key => plan.key()}, :class => 'link-action' -%>
+ <%= link_to message('edit'), {:action => 'edit_form', :id => @resource.id, :plan_key => plan.key()}, :class => 'open-modal link-action' -%>
&nbsp;
<%
close_confirmation_message = {}
@@ -51,7 +58,14 @@
<%= link_to message('close'),
{:action => 'change_status', :id => @resource.id, :plan_key => plan.key()}, {:method => 'POST', :class => 'link-action'}.merge(close_confirmation_message) -%>
&nbsp;
- <%= link_to message('delete'), {:action => 'delete', :id => @resource.id, :plan_key => plan.key()}, {:method => 'POST', :confirm => message('action_plans.confirm_delete'), :class => 'link-action link-red'} -%>
+ <%= link_to_action message('delete'), "#{ApplicationController.root_context}/action_plans/delete/#{h(@resource.id)}?plan_key=#{h(plan.key)}",
+ :class => 'link-action link-red',
+ :id => "delete_#{h(plan.key)}",
+ :confirm_button => message('delete'),
+ :confirm_title => 'Delete action plan: '+ h(plan.name()),
+ :confirm_msg => message('action_plans.confirm_delete'),
+ :confirm_msg_params => ''
+ -%>
</td>
</tr>
<% end %>
@@ -101,20 +115,20 @@
<%= link_to message('action_plans.reopen'),
{:action => 'change_status', :id => @resource.id, :plan_key => plan.key}, {:method => 'POST', :class => 'link-action'} -%>
&nbsp;
- <%= link_to message('delete'), {:action => 'delete', :id => @resource.id, :plan_key => plan.key}, {:method => 'POST', :confirm => message('action_plans.confirm_delete'), :class => 'link-action link-red'} -%>
+ <%= link_to_action message('delete'), "#{ApplicationController.root_context}/action_plans/delete/#{h(@resource.id)}?plan_key=#{h(plan.key)}",
+ :class => 'link-action link-red',
+ :id => "delete_#{h(plan.key)}",
+ :confirm_button => message('delete'),
+ :confirm_title => 'Delete action plan: '+ h(plan.name()),
+ :confirm_msg => message('action_plans.confirm_delete'),
+ :confirm_msg_params => ''
+ -%>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
-
- </td>
- <td class="sep"></td>
- <td width="210" valign="top" align="right">
- <div id="admin_form">
- <%= render :partial => 'new' %>
- </div>
</td>
</tr>
</table>