SECTION=Navigation::SECTION_HOME
- verify :method => :post, :only => [:violation_assign, :violation_flag_as_false_positive,:violation_save_comment, :violation_delete_comment], :redirect_to => {:action => :error_not_post}
+ verify :method => :post,
+ :only => [:assign, :comment_form, :flag_as_false_positive,
+ :violation_assign, :violation_flag_as_false_positive,:violation_save_comment, :violation_delete_comment],
+ :redirect_to => {:action => :error_not_post}
helper(:reviews,:markdown)
def index
render :partial => 'reviews/show'
end
+ # GET
+ def assign_form
+ @user_options = options_for_users()
+ render :partial => "assign_form"
+ end
+
+ # POST
+ def assign
+ @review = Review.find (params[:id])
+ unless current_user
+ render :text => "<b>Cannot edit the review</b> : access denied."
+ return
+ end
+
+ @review.assignee = User.find params[:assignee_id]
+ @review.save
+
+ render :partial => 'reviews/show'
+ end
+
+ # GET
+ def comment_form
+ @review = Review.find (params[:id])
+ render :partial => 'reviews/comment_form'
+ end
+
+ # POST
+ def save_comment
+ @review = Review.find (params[:id])
+ unless current_user
+ render :text => "<b>Cannot create the comment</b> : access denied."
+ return
+ end
+
+ if params[:comment_id]
+ comment = @review.comments.find(params[:comment_id].to_i)
+ if comment
+ comment.text=params[:text]
+ comment.save!
+ end
+ else
+ @review.comments.create!(:user => current_user, :text => params[:text])
+ end
+
+ render :partial => "reviews/show"
+ end
+
+ # GET
+ def false_positive_form
+ render :partial => 'reviews/false_positive_form'
+ end
+
+ # POST
+ def flag_as_false_positive
+ @review = Review.find (params[:id])
+ unless current_user
+ render :text => "<b>Cannot create the comment</b> : access denied."
+ return
+ end
+
+ RuleFailure.find( :all, :conditions => [ "permanent_id = ?", @review.rule_failure_permanent_id ] ).each do |violation|
+ violation.switched_off=true
+ violation.save!
+ end
+
+ @review.review_type = Review::TYPE_FALSE_POSITIVE
+ @review.status = Review::STATUS_CLOSED
+ @review.save!
+ unless params[:comment].blank?
+ @review.comments.create(:review_text => params[:comment], :user_id => current_user.id)
+ end
+
+ render :partial => "reviews/show"
+ end
+
#
#
<%= link_to_remote (violation.false_positive? ? "Unflag false-positive" : "Flag as false-positive"),
:url => { :controller => "reviews", :action => "violation_false_positive_form", :id => violation.id, :false_positive => !violation.false_positive? },
:update => "reviewForm" + violation.id.to_s,
- :complete => "$('vActions" + violation.id.to_s + "').hide();$('reviewForm" + violation.id.to_s + "').show();$('reviewText" + violation.id.to_s + "').focus();" -%>
+ :complete => "$('vActions" + violation.id.to_s + "').hide();$('reviewForm" + violation.id.to_s + "').show();$('commentText" + violation.id.to_s + "').focus();" -%>
</span>
<% end %>
--- /dev/null
+<% form_tag :html => {:style => "display:inline"} do %>
+ <%= hidden_field_tag :id, params[:review_id] -%>
+ <%= select_tag "assignee_id", options_for_select(@user_options, current_user.id.to_s) %>
+
+ <%= submit_to_remote "submit_btn", "Assign",
+ :url => { :action => 'assign' },
+ :update => "review" -%>
+
+ <%= link_to_remote 'Cancel',
+ :url => { :action => 'show', :id => params[:review_id] },
+ :update => "review" %>
+<% end %>
\ No newline at end of file
--- /dev/null
+<%
+ button=(@comment ? 'Update comment' : 'Add comment')
+%>
+<form method="POST" action="save_comment">
+ <input type="hidden" name="id" value="<%= params[:id] -%>"/>
+ <% if @comment %>
+ <input type="hidden" name="comment_id" value="<%= @comment.id -%>"/>
+ <% end %>
+
+ <table class="width100">
+ <tr>
+ <td style="vertical-align:top">
+ <textarea id="commentText" rows="8" name="text" style="width: 100%" onkeyup="if (this.value=='') $('submit_btn').disabled='true'; else $('submit_btn').disabled='';"><%= @comment.text if @comment -%></textarea>
+ <br/>
+ <%= submit_to_remote "submit_btn", button, :url => { :action => 'save_comment'}, :html => { :id => "submit_btn", :disabled => "true" }, :update => 'review' -%>
+ <%= link_to_remote 'Cancel', :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%>
+ </td>
+ <td class="sep"></td>
+ <td style="vertical-align:top;width: 90px">
+ <h3>Help Tips</h3>
+ <table>
+ <tr>
+ <td>*bold*</td>
+ <td class="sep"></td>
+ <td><b>bold</b></td>
+ </tr>
+ <tr>
+ <td>''code''</td>
+ <td class="sep"></td>
+ <td><code>code</code></td>
+ </tr>
+ <tr>
+ <td colspan="3">* Bulleted point</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+</form>
--- /dev/null
+<form method="POST" action="violation_flag_as_false_positive">
+ <input type="hidden" name="id" value="<%= params[:id] -%>"/>
+ <h3>Why is it a false-positive ?</h3>
+ <textarea id="commentText" rows="8" name="comment" style="width: 100%" onkeyup="if (this.value=='') $('submit_btn').disabled='true'; else $('submit_btn').disabled='';"></textarea>
+ <%= submit_to_remote "submit_btn", "Flag as false-positive", :url => { :action => 'flag_as_false_positive' }, :html => { :id => "submit_btn", :disabled => "true" }, :update => 'review' -%>
+ <%= link_to_remote 'Cancel', :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%>
+</form>
<div class="reportTitle">
<div style="float: right"><span class="violation_date">#<%= review.id.to_s -%></span></div>
<h2><%= h(review.title) -%></h2>
+
+ <% if current_user && review.status != "CLOSED" %>
+ <span class="actions" id="rActions">
+
+ <%= image_tag("sep12.png") -%>
+
+ <%= link_to_remote (review.assignee_id ? "Reassign" : "Assign"),
+ :url => { :controller => "reviews", :action => "assign_form", :review_id => review.id},
+ :update => "assignForm",
+ :complete => "$('rActions').hide(); $('commentAction').hide(); $('assignee_id').focus();" -%>
+
+
+ <%= link_to_remote ("Flag as false-positive"),
+ :url => { :controller => "reviews", :action => "false_positive_form", :id => review.id },
+ :update => "reviewForm",
+ :complete => "$('rActions').hide(); $('commentAction').hide(); $('reviewForm').show();$('commentText').focus();" -%>
+ </span>
+ <% end %>
+
</div>
<table class="reportDetails">
Assignee:
</td>
<td class="val">
- <%= review.assignee ? h(review.assignee.name) : '-'-%>
+ <span id="assignForm">
+ <%= review.assignee ? h(review.assignee.name) : '-'-%>
+ </span>
</td>
<td class="key">
Created by:
</div>
<% end %>
</div>
+
+ <% if current_user && review.status != "CLOSED" %>
+ <div class="discussionComment" id="reviewForm" style="display:none"></div>
+ <div style="padding: 5px" id="commentAction">
+ <%= link_to_remote "Add comment",
+ :url => { :controller => "reviews", :action => "comment_form", :id => review.id },
+ :update => "reviewForm",
+ :complete => "$('rActions').hide();$('commentAction').hide();$('reviewForm').show();$('commentText').focus()" -%>
+ </div>
+ <% end %>
+
</div>
\ No newline at end of file
-
-
<%
button=(@comment ? 'Update comment' : 'Add comment')
%>
<input type="hidden" name="false_positive" value="true"/>
<% end %>
<h3><%= title -%></h3>
- <textarea rows="8" name="comment" style="width: 100%" onkeyup="if (this.value=='') $('submit_btn').disabled='true'; else $('submit_btn').disabled='';"></textarea>
+ <textarea id="commentText<%= params[:id] -%>" rows="8" name="comment" style="width: 100%" onkeyup="if (this.value=='') $('submit_btn').disabled='true'; else $('submit_btn').disabled='';"></textarea>
<%= submit_to_remote "submit_btn", button, :url => { :action => 'violation_flag_as_false_positive' }, :html => { :id => "submit_btn", :disabled => "true" }, :update => 'vId'+params[:id] -%>
<%= link_to_remote 'Cancel', :url => {:action => 'display_violation', :id => params[:id]}, :update => 'vId' + params[:id] -%>
</form>
<thead>
<tr>
<th width="1%" nowrap>St.</th>
- <th width="1%">Project</th>
<th>Title</th>
+ <th width="1%">Project</th>
<th width="1%" nowrap>Se.</th>
<th>Assignee</th>
<th>Age</th>
+ <th width="1%" nowrap>Id</th>
</tr>
</thead>
%>
<tr class="<%= cycle('even', 'odd') -%>">
<td><img src="<%= ApplicationController.root_context -%>/images/status/<%= review.status -%>.png"/></td>
- <td><%= review.project.name -%>
- <br/><span class="note"><%= review.resource.long_name -%></span></td>
<td>
<%= link_to_remote(h(review.title), :update => 'review', :url => {:action => 'show', :id => review.id}, :loading => 'onReviewLoading()', :complete => "onReviewLoaded()") -%>
</td>
+ <td><%= review.project.name -%>
+ <br/><span class="note"><%= review.resource.long_name -%></span></td>
<td><img src="<%= ApplicationController.root_context -%>/images/priority/<%= review.severity -%>.png"/></td>
<td><%= review.assignee ? h(review.assignee.name) : '-' -%></td>
<td><%= distance_of_time_in_words_to_now(review.created_at) -%></td>
+ <td style="font-weight:bold">
+ <%= link_to_remote( "#"+h(review.id), :update => 'review', :url => {:action => 'show', :id => review.id}, :loading => 'onReviewLoading()', :complete => "onReviewLoaded()") -%>
+ </td>
</tr>
<%
end
div.reportTitle {
- background-color: #CAE3F2;
+ background-color: #E4ECF3;
color: #4B9FD5;
line-height: 2.2em;
margin: 0;
font-size: 100%;
text-shadow: 0 1px 0 #FFFFFF;
}
+div.reportTitle span.actions {
+ font-size: 12px;
+}
table.reportDetails {
width: 100%;
border: 0;
div.discussionComment h4 img {
vertical-align: sub;
}
+div.discussionComment li {
+ list-style: square inside;
+}