Commit 6bae610c authored by Winnie Hellmann's avatar Winnie Hellmann

Replace showAny for NamespaceSelect by isFilter

parent fcc82ab6
...@@ -3,16 +3,13 @@ import Api from './api'; ...@@ -3,16 +3,13 @@ import Api from './api';
export default class NamespaceSelect { export default class NamespaceSelect {
constructor(opts) { constructor(opts) {
var fieldName, showAny; const isFilter = opts.dropdown.dataset.isFilter === 'true';
var fieldName;
this.dropdown = $(opts.dropdown); this.dropdown = $(opts.dropdown);
showAny = true;
fieldName = 'namespace_id'; fieldName = 'namespace_id';
if (this.dropdown.attr('data-field-name')) { if (this.dropdown.attr('data-field-name')) {
fieldName = this.dropdown.data('fieldName'); fieldName = this.dropdown.data('fieldName');
} }
if (this.dropdown.attr('data-show-any')) {
showAny = this.dropdown.data('showAny');
}
this.dropdown.glDropdown({ this.dropdown.glDropdown({
filterable: true, filterable: true,
selectable: true, selectable: true,
...@@ -31,7 +28,7 @@ export default class NamespaceSelect { ...@@ -31,7 +28,7 @@ export default class NamespaceSelect {
data: function(term, dataCallback) { data: function(term, dataCallback) {
return Api.namespaces(term, function(namespaces) { return Api.namespaces(term, function(namespaces) {
var anyNamespace; var anyNamespace;
if (showAny) { if (isFilter) {
anyNamespace = { anyNamespace = {
text: 'Any namespace', text: 'Any namespace',
id: null id: null
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
= hidden_field_tag :namespace_id, params[:namespace_id] = hidden_field_tag :namespace_id, params[:namespace_id]
- namespace = Namespace.find(params[:namespace_id]) - namespace = Namespace.find(params[:namespace_id])
- toggle_text = "#{namespace.kind}: #{namespace.full_path}" - toggle_text = "#{namespace.kind}: #{namespace.full_path}"
= dropdown_toggle(toggle_text, { toggle: 'dropdown' }, { toggle_class: 'js-namespace-select large' }) = dropdown_toggle(toggle_text, { toggle: 'dropdown', is_filter: 'true' }, { toggle_class: 'js-namespace-select large' })
.dropdown-menu.dropdown-select.dropdown-menu-align-right .dropdown-menu.dropdown-select.dropdown-menu-align-right
= dropdown_title('Namespaces') = dropdown_title('Namespaces')
= dropdown_filter("Search for Namespace") = dropdown_filter("Search for Namespace")
......
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
= f.label :new_namespace_id, "Namespace", class: 'control-label' = f.label :new_namespace_id, "Namespace", class: 'control-label'
.col-sm-10 .col-sm-10
.dropdown .dropdown
= dropdown_toggle('Search for Namespace', { toggle: 'dropdown', field_name: 'new_namespace_id', show_any: 'false' }, { toggle_class: 'js-namespace-select large' }) = dropdown_toggle('Search for Namespace', { toggle: 'dropdown', field_name: 'new_namespace_id' }, { toggle_class: 'js-namespace-select large' })
.dropdown-menu.dropdown-select .dropdown-menu.dropdown-select
= dropdown_title('Namespaces') = dropdown_title('Namespaces')
= dropdown_filter("Search for Namespace") = dropdown_filter("Search for Namespace")
......
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