BigW Consortium Gitlab

Commit 3a023c5e by 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 */
import Api from './api';
import './lib/utils/url_utility';
export default class NamespaceSelect {
constructor(opts) {
const isFilter = opts.dropdown.dataset.isFilter === 'true';
var fieldName;
this.dropdown = $(opts.dropdown);
fieldName = 'namespace_id';
if (this.dropdown.attr('data-field-name')) {
fieldName = this.dropdown.data('fieldName');
}
this.dropdown.glDropdown({
const fieldName = opts.dropdown.dataset.fieldName || 'namespace_id';
$(opts.dropdown).glDropdown({
filterable: true,
selectable: true,
filterRemote: true,
......@@ -27,9 +24,8 @@ export default class NamespaceSelect {
},
data: function(term, dataCallback) {
return Api.namespaces(term, function(namespaces) {
var anyNamespace;
if (isFilter) {
anyNamespace = {
const anyNamespace = {
text: 'Any namespace',
id: null
};
......@@ -48,8 +44,13 @@ export default class NamespaceSelect {
},
renderRow: this.renderRow,
clicked(options) {
if (!isFilter) {
const { e } = options;
return e.preventDefault();
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