Moved reduce function to a util
Fixed issue with modal window including main search bars tokens
This commit is contained in:
parent
4e5bf7d6dd
commit
fbf1cc6aab
|
@ -13,6 +13,7 @@ export default {
|
|||
FilteredSearchContainer.container = this.$el;
|
||||
|
||||
this.filteredSearch = new FilteredSearchBoards(this.store);
|
||||
this.filteredSearch.removeTokens();
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.filteredSearch.cleanup();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* global Vue */
|
||||
import Vue from 'vue';
|
||||
import modalFilters from './filters';
|
||||
|
||||
require('./tabs');
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* global Vue */
|
||||
/* global ListIssue */
|
||||
import queryData from '../../utils/query_data';
|
||||
|
||||
require('./header');
|
||||
require('./list');
|
||||
|
@ -72,29 +73,10 @@ require('./empty_state');
|
|||
loadIssues(clearIssues = false) {
|
||||
if (!this.showAddIssuesModal) return false;
|
||||
|
||||
const queryData = this.filter.path.split('&').reduce((dataParam, filterParam) => {
|
||||
if (filterParam === '') return dataParam;
|
||||
|
||||
const data = dataParam;
|
||||
const paramSplit = filterParam.split('=');
|
||||
const paramKeyNormalized = paramSplit[0].replace('[]', '');
|
||||
const isArray = paramSplit[0].indexOf('[]');
|
||||
const value = decodeURIComponent(paramSplit[1]).replace(/\+/g, ' ');
|
||||
|
||||
if (isArray !== -1) {
|
||||
if (!data[paramKeyNormalized]) {
|
||||
data[paramKeyNormalized] = [];
|
||||
}
|
||||
|
||||
data[paramKeyNormalized].push(value);
|
||||
} else {
|
||||
data[paramKeyNormalized] = value;
|
||||
}
|
||||
|
||||
return data;
|
||||
}, { page: this.page, per: this.perPage });
|
||||
|
||||
return gl.boardService.getBacklog(queryData).then((res) => {
|
||||
return gl.boardService.getBacklog(queryData(this.filter.path, {
|
||||
page: this.page,
|
||||
per: this.perPage,
|
||||
})).then((res) => {
|
||||
const data = res.json();
|
||||
|
||||
if (clearIssues) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import FilteredSearchContainer from '../filtered_search/container';
|
||||
|
||||
export default class FilteredSearchBoards extends gl.FilteredSearchManager {
|
||||
constructor(store, updateUrl = false) {
|
||||
super('boards');
|
||||
|
@ -18,13 +20,17 @@ export default class FilteredSearchBoards extends gl.FilteredSearchManager {
|
|||
}
|
||||
}
|
||||
|
||||
updateTokens() {
|
||||
const tokens = document.querySelectorAll('.js-visual-token');
|
||||
removeTokens() {
|
||||
const tokens = FilteredSearchContainer.container.querySelectorAll('.js-visual-token');
|
||||
|
||||
// Remove all the tokens as they will be replaced by the search manager
|
||||
[].forEach.call(tokens, (el) => {
|
||||
el.parentNode.removeChild(el);
|
||||
});
|
||||
}
|
||||
|
||||
updateTokens() {
|
||||
this.removeTokens();
|
||||
|
||||
this.loadSearchParamsFromURL();
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* eslint-disable space-before-function-paren, no-underscore-dangle, class-methods-use-this, consistent-return, no-shadow, no-param-reassign, max-len, no-unused-vars */
|
||||
/* global ListIssue */
|
||||
/* global ListLabel */
|
||||
import queryData from '../utils/query_data';
|
||||
|
||||
class List {
|
||||
constructor (obj) {
|
||||
|
@ -64,25 +65,7 @@ class List {
|
|||
}
|
||||
|
||||
getIssues (emptyIssues = true) {
|
||||
const data = gl.issueBoards.BoardsStore.filter.path.split('&').reduce((data, filterParam) => {
|
||||
if (filterParam === '') return data;
|
||||
const paramSplit = filterParam.split('=');
|
||||
const paramKeyNormalized = paramSplit[0].replace('[]', '');
|
||||
const isArray = paramSplit[0].indexOf('[]');
|
||||
const value = decodeURIComponent(paramSplit[1]).replace(/\+/g, ' ');
|
||||
|
||||
if (isArray !== -1) {
|
||||
if (!data[paramKeyNormalized]) {
|
||||
data[paramKeyNormalized] = [];
|
||||
}
|
||||
|
||||
data[paramKeyNormalized].push(value);
|
||||
} else {
|
||||
data[paramKeyNormalized] = value;
|
||||
}
|
||||
|
||||
return data;
|
||||
}, { page: this.page });
|
||||
const data = queryData(gl.issueBoards.BoardsStore.filter.path, { page: this.page });
|
||||
|
||||
if (this.label && data.label_name) {
|
||||
data.label_name = data.label_name.filter(label => label !== this.label.title);
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
export default (path, extraData) => {
|
||||
return path.split('&').reduce((data, filterParam) => {
|
||||
if (filterParam === '') return data;
|
||||
|
||||
const paramSplit = filterParam.split('=');
|
||||
const paramKeyNormalized = paramSplit[0].replace('[]', '');
|
||||
const isArray = paramSplit[0].indexOf('[]');
|
||||
const value = decodeURIComponent(paramSplit[1]).replace(/\+/g, ' ');
|
||||
|
||||
if (isArray !== -1) {
|
||||
if (!data[paramKeyNormalized]) {
|
||||
data[paramKeyNormalized] = [];
|
||||
}
|
||||
|
||||
data[paramKeyNormalized].push(value);
|
||||
} else {
|
||||
data[paramKeyNormalized] = value;
|
||||
}
|
||||
|
||||
return data;
|
||||
}, extraData);
|
||||
}
|
Loading…
Reference in New Issue