+++ /dev/null
-<tr id="createViolationRow<%= @line -%>">
- <% for index in 0...(params['gray_colspan'].to_i) %>
- <td class="gray"></td>
- <% end %>
- <% for index in 0...(params['white_colspan'].to_i) %>
- <td class="white"></td>
- <% end %>
- <td class="violations">
- <div id="createViolationCell<%= @line -%>">
- <% if @rules.empty? && !has_role?(:admin) %>
- <div class="warning"><%= message('code_viewer.create_violation.no_rules') -%> <a href="#" onclick="return hVF(<%= @line -%>)"><%= message('cancel') -%></a></div>
- <% else %>
- <% form_remote_tag :url => "#{ApplicationController.root_context}/resource/create_violation",
- :update => {:success => "createViolationCell#{@line}"},
- :html => {:id => "createViolationForm#{@line}"},
- :failure => "$('errorViolationForm#{@line}').update(request.responseText);$('errorViolationForm#{@line}').show()" do -%>
- <input type="hidden" name="resource" value="<%= params[:resource] -%>">
- <input type="hidden" name="line" value="<%= @line -%>">
- <input type="hidden" name="gray_colspan" value="<%= params[:gray_colspan] -%>">
- <input type="hidden" name="white_colspan" value="<%= params[:white_colspan] -%>">
-
- <div class="violation">
- <div class="vtitle">
- <select name="severity" class="withIcons">
- <% Severity::KEYS.each do |severity| %>
- <option class="sev_<%= severity -%>" value="<%= severity -%>" <%= 'selected' if severity==Severity::MAJOR -%>><%= message("severity.#{severity}") -%></option>
- <% end %>
- </select>
-
- <%= image_tag 'sep12.png' -%>
-
- <select class="select-rule-<%= @html_id -%>" name="rule" onkeyup="this.blur();this.focus();"
- onchange="if ($j(this).val()=='') {$j(this).next('input.new_rule_<%= @html_id -%>').show()} else {$j(this).next('input.new_rule_<%= @html_id -%>').hide()}">
- <% is_admin = current_user && has_role?(:admin)
- if is_admin
- %>
- <option value=""><%= message('code_viewer.create_violation.new_rule') -%></option>
- <% end %>
- <% unless @rules.empty? %>
- <optgroup label="<%= message('code_viewer.create_violation.rules') -%>">
- <% @rules.each do |rule| %>
- <option value="<%= rule.id -%>"><%= h rule.name -%></option>
- <% end %>
- </optgroup>
- <% end %>
- </select>
-
- <% if is_admin %>
- <input type="text" name="new_rule" size="50" class="new_rule_<%= @html_id -%>">
- <% end %>
-
-
- <%= image_tag 'sep12.png' -%>
-
- Assign to: <%= user_autocomplete_field "assignee_login", current_user.login -%>
- </div>
-
- <div class="discussionComment first">
- <textarea rows="5" name="message" style="width: 100%"></textarea>
-
- <div class="error" id="errorViolationForm<%= @line -%>" style="display: none"></div>
- <input type="submit" value="<%= message('code_viewer.create_violation.submit') -%>">
-
- <a href="#" onclick="return hVF(this, <%= @line -%>)"><%= message('cancel') -%></a>
- </div>
- </div>
- <% end %>
- <% end %>
- </div>
- </td>
-</tr>
-<script type="text/javascript">
- Form.Element.activate('select-rule-<%= @html_id -%>');
-
- function createViolation(elt){
- elt.submit(function (event) {
- $j.ajax({
- type: 'POST',
- url: elt.attr('action'),
- data: elt.serialize(),
- success: function (data) {
- var test = $j(elt).closest('.createViolationCell<%= @line.to_s %>');
- alert(test.attr('class'));
-// window.location.reload();
- },
- error: function (xhr, textStatus, errorThrown) {
-// $j("#"+ errorId).removeClass("hidden");
-// $j("#"+ errorId).html(xhr.responseText);
- }
- });
- return false;
- });
-
- return false;
- }
-</script>
\ No newline at end of file