end
+ def create_form
+ verify_ajax_request
+ render :partial => 'issue/create_form'
+ end
+
+ def create
+ verify_post_request
+ require_parameters :rule, :component
+
+ component_key = params[:component]
+ if Api::Utils.is_integer?(component_key)
+ component = Project.find(component_key)
+ component_key = (component ? component.key : nil)
+ end
+
+ issue = Internal.issues.create(params.merge({:component => component_key}))
+
+ @issue_results = Api.issues.find(issue.key)
+ render :partial => 'issue/issue', :locals => {:issue => @issue_results.issues.get(0)}
+ end
#
#
# * <tt>:placeholder</tt> - the label to display when nothing is selected. Default is ''.
# * <tt>:allow_clear</tt> - true if value can be de-selected. Default is false.
# * <tt>:show_search_box</tt> - true to display the search box. Default is false.
- # * <tt>:html_options</tt> - hash for html options (id, class, onchange, ...)
+ # * <tt>:open</tt> - true to open the select-box. Default is false. Since 3.6.
# * <tt>:select2_options</tt> - hash of select2 options
#
def dropdown_tag(name, option_tags, options={}, html_options={})
width=options[:width]||'250px'
html_id=html_options[:id]||name
show_search_box=options[:show_search_box]||false
- minimumResultsForSearch=show_search_box ? 0 : option_tags.size + 1;
+ minimumResultsForSearch=show_search_box ? 0 : option_tags.size + 1
js_options={
'minimumResultsForSearch' => minimumResultsForSearch,
html = select_tag(name, option_tags, html_options)
js = "$j('##{html_id}').select2({#{js_options.map { |k, v| "#{k}:#{v}" }.join(',')}});"
+ if options[:open]
+ js += "$j('##{html_id}').select2('open');"
+ end
"#{html}<script>#{js}</script>"
end
--- /dev/null
+<%
+ manual_rules = Rule.manual_rules
+ is_admin = has_role?(:admin)
+ form_id = "create-issue-#{params[:component]}-#{params[:line]}"
+ if manual_rules.empty? && !is_admin
+%>
+ <div class="warning">
+ No rules. Please contact the administrator.
+ <%= link_to_function message('cancel'), 'closeMIF(this)' -%>
+ </div>
+
+<% else %>
+ <form action="" class="code-issue-create-form" id="<%= form_id -%>">
+ <input type="hidden" name="line" value="<%= params[:line] -%>"/>
+ <input type="hidden" name="component" value="<%= params[:component] -%>"/>
+
+ <div class="code-issue">
+ <div class="code-issue-name">
+ <% unless manual_rules.empty? %>
+ <%= dropdown_tag 'rule',
+ options_for_select([[]].concat(manual_rules.map{|rule| [rule.name, rule.key] })),
+ {:show_search_box => true, :placeholder => 'Select a Rule', :open => true},
+ {:html_id => "#{form_id}-rules"} -%>
+ <% end %>
+ <% if is_admin %>
+ <a href="#">Add Rule</a>
+ <% end %>
+ </div>
+
+ <div class="code-issue-msg">
+ <textarea rows="4" name="message" class="width100 marginbottom5"></textarea>
+
+ <input type="submit" value="Create" onclick="return submitMIF(this);"> <%= link_to_function message('cancel'), 'closeMIF(this)' -%>
+ </div>
+ <div class="code-issue-form hidden"></div>
+ </div>
+ </form>
+
+<% end %>
\ No newline at end of file
<td class="plus">
- <a onclick="return sVF(this, <%= resource_id -%>,<%= index + 1 -%>,<%= gray_colspan -%>,<%= white_colspan -%>)"></a>
+ <a onclick="return openMIF(this, <%= resource_id -%>,<%= index + 1 -%>)"></a>
</td>
replaced.find('.open-modal').modal();
});
return false;
-}
\ No newline at end of file
+}
+
+function openMIF(elt, componentId, line) {
+ // TODO check if form is already displayed (by using form id)
+ $j.get(baseUrl + "/issue/create_form?component=" + componentId + "&line=" + line, function (html) {
+ $j(elt).closest('tr').find('td.line').append($j(html));
+ });
+ return false;
+}
+
+function closeMIF(elt) {
+ $j(elt).closest('.code-issue-create-form').remove();
+ return false;
+}
+
+function submitMIF(elt) {
+ var formElt = $j(elt).closest('form');
+ formElt.find('.loading').removeClass('hidden');
+ formElt.find(':submit').prop('disabled', true);
+ $j.ajax({
+ type: "POST",
+ url: baseUrl + '/issue/create',
+ data: formElt.serialize()}
+ ).success(function (data) {
+ formElt.html(data);
+ }
+ ).fail(function (jqXHR, textStatus) {
+ alert(textStatus);
+ });
+ return false;
+}
+
}
.code-issues {
background-color: #FFF;
- padding: 10px;
}
.code-issue {
background-color: #FFF;
margin: 0;
font-size: 12px;
+ padding: 5px 10px;
}
.code-issue-name {