_form.html.haml 3.11 KB
Newer Older
1
%div.issue-form-holder
2
  %h3.page-title= @issue.new_record? ? "New Issue" : "Edit Issue ##{@issue.iid}"
3
  = form_for [@project, @issue] do |f|
4
    -if @issue.errors.any?
5
      .alert.alert-error
6 7 8
        - @issue.errors.full_messages.each do |msg|
          %span= msg
          %br
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
9 10
    .issue-box
      .title
11
        .control-group
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
12
          = f.label :title do
13
            %strong= "Subject *"
14
          .controls
15
            = f.text_field :title, maxlength: 255, class: "input-xxlarge js-gfm-input", autofocus: true, required: true
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
16
      .context
17
        .control-group
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
18 19 20 21
          .issue_assignee.pull-left
            = f.label :assignee_id do
              %i.icon-user
              Assign to
22
            .controls
23
              .pull-left
24
                = f.select(:assignee_id, assignee_options(@issue), { include_blank: "Select a user" }, {class: 'chosen'})
25 26 27
              .pull-right
                 
                = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
28 29 30 31
          .issue_milestone.pull-left
            = f.label :milestone_id do
              %i.icon-time
              Milestone
32
            .controls= f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone" }, {class: 'chosen'})
33

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
34
      .description
35
        .control-group
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
36 37
          = f.label :label_list do
            %i.icon-tag
38
            Labels
39
          .controls
40
            = f.text_field :label_list, maxlength: 2000, class: "input-xxlarge"
41
            %p.hint Separate labels with commas.
42

43
        .control-group
44
          = f.label :description, "Details"
45
          .controls
46
            = f.text_area :description, class: "input-xxlarge js-gfm-input", rows: 14
47
            %p.hint Issues are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}.
48

49

50
    .form-actions
51
      - if @issue.new_record?
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
52
        = f.submit 'Submit new issue', class: "btn btn-create"
53
      -else
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
54
        = f.submit 'Save changes', class: "btn-save btn"
55

56
      - cancel_path = @issue.new_record? ? project_issues_path(@project) : project_issue_path(@project, @issue)
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
57
      = link_to "Cancel", cancel_path, class: 'btn btn-cancel'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
58 59 60 61 62




:javascript
63 64 65 66 67 68 69
  $("#issue_label_list")
    .bind( "keydown", function( event ) {
      if ( event.keyCode === $.ui.keyCode.TAB &&
        $( this ).data( "autocomplete" ).menu.active ) {
        event.preventDefault();
      }
    })
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
70 71
    .bind("click", function(event) {
      $(this).autocomplete("search", "");
72
    })
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
    .autocomplete({
      minLength: 0,
      source: function( request, response ) {
        response( $.ui.autocomplete.filter(
          #{raw labels_autocomplete_source}, extractLast( request.term ) ) );
      },
      focus: function() {
        return false;
      },
      select: function(event, ui) {
        var terms = split( this.value );
        terms.pop();
        terms.push( ui.item.value );
        terms.push( "" );
        this.value = terms.join( ", " );
        return false;
      }
    });
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
91

92
  $('.assign-to-me-link').on('click', function(e){
93
    $('#issue_assignee_id').val("#{current_user.id}").trigger("chosen:updated");
94 95
    e.preventDefault();
  });