Commit c95fd3a0 authored by Winnie Hellmann's avatar Winnie Hellmann
Browse files

Make NamespaceSelect change URL when filtering

parent bf19cc3e8cf8
/* 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';
......@@ -3,14 +4,10 @@
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,5 +24,4 @@
},
data: function(term, dataCallback) {
return Api.namespaces(term, function(namespaces) {
var anyNamespace;
if (isFilter) {
......@@ -31,5 +27,5 @@
if (isFilter) {
anyNamespace = {
const anyNamespace = {
text: 'Any namespace',
id: null
};
......@@ -48,8 +44,13 @@
},
renderRow: this.renderRow,
clicked(options) {
const { e } = options;
return e.preventDefault();
if (!isFilter) {
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
Supports Markdown
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