_search_bar.html.haml 9.93 KB
Newer Older
1
- type = local_assigns.fetch(:type)
2
- block_css_class = type != :boards_modal ? 'row-content-block second-block' : ''
3

Clement Ho's avatar
Clement Ho committed
4
.issues-filters
5
  .issues-details-filters.filtered-search-block{ class: block_css_class, "v-pre" => type == :boards_modal }
Clement Ho's avatar
Clement Ho committed
6 7 8 9 10 11 12
    = form_tag page_filter_path(without: [:assignee_id, :author_id, :milestone_title, :label_name, :search]), method: :get, class: 'filter-form js-filter-form' do
      - if params[:search].present?
        = hidden_field_tag :search, params[:search]
      - if @bulk_edit
        .check-all-holder
          = check_box_tag "check_all_issues", nil, false,
            class: "check_all_issues left"
13 14
      .issues-other-filters.filtered-search-wrapper
        .filtered-search-box
15 16 17 18 19 20 21 22
          - if type != :boards_modal && type != :boards
            = dropdown_tag(content_tag(:i, '', class: 'fa fa-history'),
              options: { wrapper_class: "filtered-search-history-dropdown-wrapper",
              toggle_class: "filtered-search-history-dropdown-toggle-button",
              dropdown_class: "filtered-search-history-dropdown",
              content_class: "filtered-search-history-dropdown-content",
              title: "Recent searches" }) do
              .js-filtered-search-history-dropdown
23 24 25 26
          .filtered-search-box-input-container
            .scroll-container
              %ul.tokens-container.list-unstyled
                %li.input-token
Luke "Jared" Bennett's avatar
Luke "Jared" Bennett committed
27
                  %input.form-control.filtered-search{ id: "filtered-search-#{type.to_s}", placeholder: 'Search or filter results...', data: { 'project-id' => @project.id, 'username-params' => @users.to_json(only: [:id, :username]), 'base-endpoint' => namespace_project_path(@project.namespace, @project) } }
28 29 30 31 32 33 34 35
              = icon('filter')
              %button.clear-search.hidden{ type: 'button' }
                = icon('times')
            #js-dropdown-hint.filtered-search-input-dropdown-menu.dropdown-menu.hint-dropdown
              %ul{ data: { dropdown: true } }
                %li.filter-dropdown-item{ data: { action: 'submit' } }
                  %button.btn.btn-link
                    = icon('search')
Clement Ho's avatar
Clement Ho committed
36
                    %span
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
                      Press Enter or click to search
              %ul.filter-dropdown{ data: { dynamic: true, dropdown: true } }
                %li.filter-dropdown-item
                  %button.btn.btn-link
                    -# Encapsulate static class name `{{icon}}` inside #{} to bypass
                    -# haml lint's ClassAttributeWithStaticValue
                    %i.fa{ class: "#{'{{icon}}'}" }
                    %span.js-filter-hint
                      {{hint}}
                    %span.js-filter-tag.dropdown-light-content
                      {{tag}}
            #js-dropdown-author.filtered-search-input-dropdown-menu.dropdown-menu{ data: { icon: 'pencil', hint: 'author', tag: '@author' } }
              %ul.filter-dropdown{ data: { dynamic: true, dropdown: true } }
                %li.filter-dropdown-item
                  %button.btn.btn-link.dropdown-user
                    %img.avatar{ alt: '{{name}}\'s avatar', width: '30', data: { src: '{{avatar_url}}' } }
                    .dropdown-user-details
                      %span
                        {{name}}
                      %span.dropdown-light-content
                        @{{username}}
            #js-dropdown-assignee.filtered-search-input-dropdown-menu.dropdown-menu{ data: { icon: 'user', hint: 'assignee', tag: '@assignee' } }
              %ul{ data: { dropdown: true } }
                %li.filter-dropdown-item{ data: { value: 'none' } }
                  %button.btn.btn-link
                    No Assignee
                %li.divider
              %ul.filter-dropdown{ data: { dynamic: true, dropdown: true } }
                %li.filter-dropdown-item
                  %button.btn.btn-link.dropdown-user
                    %img.avatar{ alt: '{{name}}\'s avatar', width: '30', data: { src: '{{avatar_url}}' } }
                    .dropdown-user-details
                      %span
                        {{name}}
                      %span.dropdown-light-content
                        @{{username}}
            #js-dropdown-milestone.filtered-search-input-dropdown-menu.dropdown-menu{ data: { icon: 'clock-o', hint: 'milestone', tag: '%milestone' } }
              %ul{ data: { dropdown: true } }
                %li.filter-dropdown-item{ data: { value: 'none' } }
                  %button.btn.btn-link
                    No Milestone
                %li.filter-dropdown-item{ data: { value: 'upcoming' } }
                  %button.btn.btn-link
                    Upcoming
                %li.filter-dropdown-item{ 'data-value' => 'started' }
                  %button.btn.btn-link
                    Started
                %li.divider
              %ul.filter-dropdown{ data: { dynamic: true, dropdown: true } }
                %li.filter-dropdown-item
                  %button.btn.btn-link.js-data-value
88
                    {{title}}
89 90 91 92 93 94 95 96 97 98 99 100
            #js-dropdown-label.filtered-search-input-dropdown-menu.dropdown-menu{ data: { icon: 'tag', hint: 'label', tag: '~label', type: 'array' } }
              %ul{ data: { dropdown: true } }
                %li.filter-dropdown-item{ data: { value: 'none' } }
                  %button.btn.btn-link
                    No Label
                %li.divider
              %ul.filter-dropdown{ data: { dynamic: true, dropdown: true } }
                %li.filter-dropdown-item
                  %button.btn.btn-link
                    %span.dropdown-label-box{ style: 'background: {{color}}' }
                    %span.label-title.js-data-value
                      {{title}}
101 102 103
        .filter-dropdown-container
          - if type == :boards
            - if can?(current_user, :admin_list, @project)
Phil Hughes's avatar
Phil Hughes committed
104
              .dropdown.prepend-left-10#js-add-list
105 106 107 108 109 110 111 112
                %button.btn.btn-create.btn-inverted.js-new-board-list{ type: "button", data: { toggle: "dropdown", labels: labels_filter_path, namespace_path: @project.try(:namespace).try(:path), project_path: @project.try(:path) } }
                  Add list
                .dropdown-menu.dropdown-menu-paging.dropdown-menu-align-right.dropdown-menu-issues-board-new.dropdown-menu-selectable
                  = render partial: "shared/issuable/label_page_default", locals: { show_footer: true, show_create: true, show_boards_content: true, title: "Add list" }
                  - if can?(current_user, :admin_label, @project)
                    = render partial: "shared/issuable/label_page_create"
                  = dropdown_loading
              #js-add-issues-btn.prepend-left-10
113
          - elsif type != :boards_modal
114
            = render 'shared/sort_dropdown'
Clement Ho's avatar
Clement Ho committed
115 116 117 118 119

    - if @bulk_edit
      .issues_bulk_update.hide
        = form_tag [:bulk_update, @project.namespace.becomes(Namespace), @project, type], method: :post, class: 'bulk-update'  do
          .filter-item.inline
120
            = dropdown_tag("Status", options: { toggle_class: "js-issue-status", title: "Change status", dropdown_class: "dropdown-menu-status dropdown-menu-selectable", data: { field_name: "update[state_event]", default_label: "Status" } } ) do
Clement Ho's avatar
Clement Ho committed
121 122
              %ul
                %li
Clement Ho's avatar
Clement Ho committed
123
                  %a{ href: "#", data: { id: "reopen" } } Open
Clement Ho's avatar
Clement Ho committed
124
                %li
Clement Ho's avatar
Clement Ho committed
125
                  %a{ href: "#", data: { id: "close" } } Closed
Clement Ho's avatar
Clement Ho committed
126
          .filter-item.inline
127 128 129 130 131
            - if type == :issues
              - field_name = "update[assignee_ids][]"
            - else
              - field_name = "update[assignee_id]"

Clement Ho's avatar
Clement Ho committed
132
            = dropdown_tag("Assignee", options: { toggle_class: "js-user-search js-update-assignee js-filter-submit js-filter-bulk-update", title: "Assign to", filter: true, dropdown_class: "dropdown-menu-user dropdown-menu-selectable",
133
              placeholder: "Search authors", data: { first_user: (current_user.username if current_user), null_user: true, current_user: true, project_id: @project.id, field_name: field_name } })
Clement Ho's avatar
Clement Ho committed
134
          .filter-item.inline
135
            = dropdown_tag("Milestone", options: { title: "Assign milestone", toggle_class: 'js-milestone-select js-extra-options js-filter-submit js-filter-bulk-update', filter: true, dropdown_class: "dropdown-menu-selectable dropdown-menu-milestone", placeholder: "Search milestones", data: { show_no: true, field_name: "update[milestone_id]", project_id: @project.id, milestones: namespace_project_milestones_path(@project.namespace, @project, :json), use_id: true, default_label: "Milestone" } })
Clement Ho's avatar
Clement Ho committed
136
          .filter-item.inline.labels-filter
137
            = render "shared/issuable/label_dropdown", classes: ['js-filter-bulk-update', 'js-multiselect'], dropdown_title: 'Apply a label', show_create: false, show_footer: false, extra_options: false, filter_submit: false, data_options: { persist_when_hide: "true", field_name: "update[label_ids][]", show_no: false, show_any: false, use_id: true, default_label: "Labels" }
Clement Ho's avatar
Clement Ho committed
138
          .filter-item.inline
139
            = dropdown_tag("Subscription", options: { toggle_class: "js-subscription-event", title: "Change subscription", dropdown_class: "dropdown-menu-selectable", data: { field_name: "update[subscription_event]", default_label: "Subscription" } } ) do
Clement Ho's avatar
Clement Ho committed
140 141
              %ul
                %li
Clement Ho's avatar
Clement Ho committed
142
                  %a{ href: "#", data: { id: "subscribe" } } Subscribe
Clement Ho's avatar
Clement Ho committed
143
                %li
Clement Ho's avatar
Clement Ho committed
144
                  %a{ href: "#", data: { id: "unsubscribe" } } Unsubscribe
Clement Ho's avatar
Clement Ho committed
145 146 147

          = hidden_field_tag 'update[issuable_ids]', []
          = hidden_field_tag :state_event, params[:state_event]
148
          .filter-item.inline.update-issues-btn
Clement Ho's avatar
Clement Ho committed
149 150
            = button_tag "Update #{type.to_s.humanize(capitalize: false)}", class: "btn update_selected_issues btn-save"

151 152 153 154 155 156
- unless type === :boards_modal
  :javascript
    new LabelsSelect();
    new MilestoneSelect();
    new IssueStatusSelect();
    new SubscriptionSelect();
157

158 159 160 161 162 163 164 165
    $(document).off('page:restore').on('page:restore', function (event) {
      if (gl.FilteredSearchManager) {
        new gl.FilteredSearchManager();
      }
      Issuable.init();
      new gl.IssuableBulkActions({
        prefixId: 'issue_',
      });
166
    });