Commit beff8b9b authored by Luke Bennett's avatar Luke Bennett

Swapped out author dropdown and started on swapping out project dropdown

parent 433d8a10
......@@ -202,6 +202,7 @@
var ref, ref1, ref2, ref3, searchFields, selector, self;
this.el = el1;
this.options = options;
console.log(this.options);
this.updateLabel = bind(this.updateLabel, this);
this.hidden = bind(this.hidden, this);
this.opened = bind(this.opened, this);
......
......@@ -49,6 +49,19 @@ module IssuablesHelper
end
end
def project_dropdown_label(project_id, default_label)
return default_label if project_id.nil?
return "Any project" if project_id == "0"
project = Project.find_by(id: project_id)
if project
project.name_with_namespace || project.name
else
default_label
end
end
def milestone_dropdown_label(milestone_title, default_label = "Milestone")
if milestone_title == Milestone::Upcoming.name
milestone_title = Milestone::Upcoming.title
......
......@@ -78,13 +78,11 @@ module TodosHelper
end
def todo_actions_options
actions = [
OpenStruct.new(id: '', title: 'Any Action'),
OpenStruct.new(id: Todo::ASSIGNED, title: 'Assigned'),
OpenStruct.new(id: Todo::MENTIONED, title: 'Mentioned')
[
{ id: '', text: 'Any Action' },
{ id: Todo::ASSIGNED, text: 'Assigned' },
{ id: Todo::MENTIONED, text: 'Mentioned' }
]
options_from_collection_for_select(actions, 'id', 'title', params[:action_id])
end
def todo_projects_options
......@@ -92,22 +90,18 @@ module TodosHelper
projects = projects.includes(:namespace)
projects = projects.map do |project|
OpenStruct.new(id: project.id, title: project.name_with_namespace)
{ id: project.id, text: project.name_with_namespace }
end
projects.unshift(OpenStruct.new(id: '', title: 'Any Project'))
options_from_collection_for_select(projects, 'id', 'title', params[:project_id])
projects.unshift({ id: '', text: 'Any Project' }).to_json
end
def todo_types_options
types = [
OpenStruct.new(title: 'Any Type', name: ''),
OpenStruct.new(title: 'Issue', name: 'Issue'),
OpenStruct.new(title: 'Merge Request', name: 'MergeRequest')
[
{ text: 'Any Type', id: '' },
{ text: 'Issue', id: 'Issue' },
{ text: 'Merge Request', id: 'MergeRequest' }
]
options_from_collection_for_select(types, 'name', 'title', params[:type])
end
private
......
......@@ -28,20 +28,23 @@
.row-content-block.second-block
= form_tag todos_filter_path(without: [:project_id, :author_id, :type, :action_id]), method: :get, class: 'filter-form' do
.filter-item.inline
= select_tag('project_id', todo_projects_options,
class: 'select2 trigger-submit', include_blank: true,
data: {placeholder: 'Project'})
- if params[:project_id].present?
= hidden_field_tag(:project_id, params[:project_id])
= dropdown_tag(project_dropdown_label(params[:project_id], 'Project'), options: { toggle_class: 'js-project-search js-filter-submit', title: 'Filter by project', filter: true, filterInput: 'input#search', dropdown_class: 'dropdown-menu-selectable dropdown-menu-project js-filter-submit',
placeholder: 'Search projects', data: { data: todo_projects_options, selected: params[:project_id], field_name: 'project_id', default_label: 'Project' } })
.filter-item.inline
= users_select_tag(:author_id, selected: params[:author_id],
placeholder: 'Author', class: 'trigger-submit', any_user: "Any Author", first_user: true, current_user: true)
- if params[:author_id].present?
= hidden_field_tag(:author_id, params[:author_id])
= dropdown_tag(user_dropdown_label(params[:author_id], 'Author'), options: { toggle_class: 'js-user-search js-filter-submit js-author-search', title: 'Filter by author', filter: true, filterInput: 'input#search', dropdown_class: 'dropdown-menu-user dropdown-menu-selectable dropdown-menu-author js-filter-submit',
placeholder: 'Search authors', data: { any_user: 'Any Author', first_user: (current_user.username if current_user), current_user: true, project_id: (@project.id if @project), selected: params[:author_id], field_name: 'author_id', default_label: 'Author' } })
.filter-item.inline
= select_tag('type', todo_types_options,
class: 'select2 trigger-submit', include_blank: true,
data: {placeholder: 'Type'})
-# = select_tag('type', todo_types_options,
-# class: 'select2 trigger-submit', include_blank: true,
-# data: {placeholder: 'Type'})
.filter-item.inline.actions-filter
= select_tag('action_id', todo_actions_options,
class: 'select2 trigger-submit', include_blank: true,
data: {placeholder: 'Action'})
-# = select_tag('action_id', todo_actions_options,
-# class: 'select2 trigger-submit', include_blank: true,
-# data: {placeholder: 'Action'})
.pull-right
.dropdown.inline.prepend-left-10
......@@ -80,6 +83,14 @@
:javascript
new UsersSelect();
$projectDropdown = $('.js-project-search');
$projectDropdown.glDropdown({
filterable: true,
selectable: true,
fieldName: 'project_id',
data: $projectDropdown.data('data')
});
$('form.filter-form').on('submit', function (event) {
event.preventDefault();
Turbolinks.visit(this.action + '&' + $(this).serialize());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment