Review changes, simplified dropdown init
This commit is contained in:
parent
bd595eb82c
commit
0ccdb41ced
|
@ -30,9 +30,9 @@
|
||||||
|
|
||||||
Todos.prototype.initFilters = function() {
|
Todos.prototype.initFilters = function() {
|
||||||
new UsersSelect();
|
new UsersSelect();
|
||||||
this.initProjectFilterDropdown();
|
this.initFilterDropdown($('.js-project-search'), 'project_id', true);
|
||||||
this.initTypeFilterDropdown();
|
this.initFilterDropdown($('.js-type-search'), 'type');
|
||||||
this.initActionFilterDropdown();
|
this.initFilterDropdown($('.js-action-search'), 'action_id');
|
||||||
|
|
||||||
$('form.filter-form').on('submit', function (event) {
|
$('form.filter-form').on('submit', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -40,47 +40,16 @@
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Todos.prototype.initProjectFilterDropdown = function() {
|
Todos.prototype.initFilterDropdown = function($dropdown, fieldName, isFilterable) {
|
||||||
$projectDropdown = $('.js-project-search');
|
$dropdown.glDropdown({
|
||||||
$projectDropdown.glDropdown({
|
|
||||||
filterable: true,
|
|
||||||
selectable: true,
|
selectable: true,
|
||||||
fieldName: 'project_id',
|
filterable: isFilterable,
|
||||||
data: $projectDropdown.data('data'),
|
fieldName: fieldName,
|
||||||
|
data: $dropdown.data('data'),
|
||||||
clicked: function() {
|
clicked: function() {
|
||||||
if ($projectDropdown.hasClass('js-filter-submit')) {
|
return $dropdown.closest('form.filter-form').submit();
|
||||||
return $projectDropdown.closest('form.filter-form').submit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
};
|
|
||||||
|
|
||||||
Todos.prototype.initTypeFilterDropdown = function() {
|
|
||||||
$typeDropdown = $('.js-type-search');
|
|
||||||
$typeDropdown.glDropdown({
|
|
||||||
selectable: true,
|
|
||||||
fieldName: 'type',
|
|
||||||
data: $typeDropdown.data('data'),
|
|
||||||
clicked: function() {
|
|
||||||
if ($typeDropdown.hasClass('js-filter-submit')) {
|
|
||||||
return $typeDropdown.closest('form.filter-form').submit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Todos.prototype.initActionFilterDropdown = function() {
|
|
||||||
$actionDropdown = $('.js-action-search');
|
|
||||||
$actionDropdown.glDropdown({
|
|
||||||
selectable: true,
|
|
||||||
fieldName: 'action_id',
|
|
||||||
data: $actionDropdown.data('data'),
|
|
||||||
clicked: function() {
|
|
||||||
if ($actionDropdown.hasClass('js-filter-submit')) {
|
|
||||||
return $actionDropdown.closest('form.filter-form').submit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Todos.prototype.doneClicked = function(e) {
|
Todos.prototype.doneClicked = function(e) {
|
||||||
|
|
|
@ -30,12 +30,12 @@
|
||||||
.filter-item.inline
|
.filter-item.inline
|
||||||
- if params[:project_id].present?
|
- if params[:project_id].present?
|
||||||
= hidden_field_tag(:project_id, params[:project_id])
|
= 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',
|
= 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#project-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' } })
|
placeholder: 'Search projects', data: { data: todo_projects_options } })
|
||||||
.filter-item.inline
|
.filter-item.inline
|
||||||
- if params[:author_id].present?
|
- if params[:author_id].present?
|
||||||
= hidden_field_tag(:author_id, params[:author_id])
|
= 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',
|
= 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#author-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' } })
|
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
|
||||||
- if params[:type].present?
|
- if params[:type].present?
|
||||||
|
|
Loading…
Reference in New Issue