Commit 3a023c5e authored by Winnie Hellmann's avatar Winnie Hellmann

Make NamespaceSelect change URL when filtering

parent 34d53d2b
/* eslint-disable func-names, space-before-function-paren, no-var, comma-dangle, object-shorthand, no-else-return, prefer-template, quotes, prefer-arrow-callback, max-len */ /* eslint-disable func-names, space-before-function-paren, no-var, comma-dangle, object-shorthand, no-else-return, prefer-template, quotes, prefer-arrow-callback, max-len */
import Api from './api'; import Api from './api';
import './lib/utils/url_utility';
export default class NamespaceSelect { export default class NamespaceSelect {
constructor(opts) { constructor(opts) {
const isFilter = opts.dropdown.dataset.isFilter === 'true'; const isFilter = opts.dropdown.dataset.isFilter === 'true';
var fieldName; const fieldName = opts.dropdown.dataset.fieldName || 'namespace_id';
this.dropdown = $(opts.dropdown);
fieldName = 'namespace_id'; $(opts.dropdown).glDropdown({
if (this.dropdown.attr('data-field-name')) {
fieldName = this.dropdown.data('fieldName');
}
this.dropdown.glDropdown({
filterable: true, filterable: true,
selectable: true, selectable: true,
filterRemote: true, filterRemote: true,
...@@ -27,9 +24,8 @@ export default class NamespaceSelect { ...@@ -27,9 +24,8 @@ 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;
if (isFilter) { if (isFilter) {
anyNamespace = { const anyNamespace = {
text: 'Any namespace', text: 'Any namespace',
id: null id: null
}; };
...@@ -48,8 +44,13 @@ export default class NamespaceSelect { ...@@ -48,8 +44,13 @@ export default class NamespaceSelect {
}, },
renderRow: this.renderRow, renderRow: this.renderRow,
clicked(options) { clicked(options) {
const { e } = options; if (!isFilter) {
return e.preventDefault(); const { e } = options;
e.preventDefault();
}
},
url(namespace) {
return gl.utils.mergeUrlParams({ [fieldName]: namespace.id }, window.location.href);
}, },
}); });
} }
......
---
title: Make NamespaceSelect change URL when filtering
merge_request: 14888
author:
type: fixed
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