BigW Consortium Gitlab

Commit cf8ae790 by Clement Ho

Add filter params to search

parent 71dc5af9
...@@ -5,15 +5,19 @@ ...@@ -5,15 +5,19 @@
const validTokenKeys = [{ const validTokenKeys = [{
key: 'author', key: 'author',
type: 'string', type: 'string',
param: 'id',
},{ },{
key: 'assignee', key: 'assignee',
type: 'string' type: 'string',
param: 'id',
},{ },{
key: 'milestone', key: 'milestone',
type: 'string' type: 'string',
param: 'title',
},{ },{
key: 'label', key: 'label',
type: 'array' type: 'array',
param: 'name%5B%5D',
},]; },];
class FilteredSearchManager { class FilteredSearchManager {
...@@ -53,14 +57,14 @@ ...@@ -53,14 +57,14 @@
const tokenValue = i.slice(colonIndex + 1); const tokenValue = i.slice(colonIndex + 1);
const match = validTokenKeys.filter((v) => { const match = validTokenKeys.filter((v) => {
return v.name === tokenKey; return v.key === tokenKey;
})[0]; })[0];
if (match) { if (match && tokenValue.length > 0) {
this.tokens.push = { this.tokens.push({
key: match.key, key: match.key,
value: tokenValue, value: tokenValue,
}; });
} }
} else { } else {
searchTerms += i + ' '; searchTerms += i + ' ';
...@@ -72,8 +76,11 @@ ...@@ -72,8 +76,11 @@
} }
printTokens() { printTokens() {
console.log(this.tokens); console.log('tokens:')
console.log(this.searchToken); this.tokens.forEach((token) => {
console.log(token);
})
console.log('search: ' + this.searchToken);
} }
checkForEnter(event) { checkForEnter(event) {
...@@ -88,8 +95,13 @@ ...@@ -88,8 +95,13 @@
console.log('search'); console.log('search');
let path = '?scope=all&state=opened&utf8=✓'; let path = '?scope=all&state=opened&utf8=✓';
this.tokens.foreach((token) => {
this.tokens.forEach((token) => {
const param = validTokenKeys.find((t) => {
return t.key === token.key;
}).param;
path += `&${token.key}_${param}=${token.value}`;
}); });
if (this.searchToken) { if (this.searchToken) {
......
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