Skip to content
Snippets Groups Projects
Unverified Commit beff8b9b authored by Luke Bennett's avatar Luke Bennett
Browse files

Swapped out author dropdown and started on swapping out project dropdown

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