Commit 9c486814 authored by Clement Ho's avatar Clement Ho

Make changes to make it more flexible for new filters

parent fd90a996
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
if (selected.tagName === 'LI') { if (selected.tagName === 'LI') {
if (selected.hasAttribute('data-value')) { if (selected.hasAttribute('data-value')) {
this.dismissDropdown(); this.dismissDropdown();
} else { } else {
const token = selected.querySelector('.js-filter-hint').innerText.trim(); const token = selected.querySelector('.js-filter-hint').innerText.trim();
const tag = selected.querySelector('.js-filter-tag').innerText.trim(); const tag = selected.querySelector('.js-filter-tag').innerText.trim();
......
...@@ -101,7 +101,8 @@ ...@@ -101,7 +101,8 @@
const match = gl.FilteredSearchTokenKeys.searchByKeyParam(keyParam); const match = gl.FilteredSearchTokenKeys.searchByKeyParam(keyParam);
if (match) { if (match) {
const sanitizedKey = keyParam.slice(0, keyParam.indexOf('_')); const indexOf = keyParam.indexOf('_');
const sanitizedKey = indexOf !== -1 ? keyParam.slice(0, keyParam.indexOf('_')) : keyParam;
const symbol = match.symbol; const symbol = match.symbol;
let quotationsToUse = ''; let quotationsToUse = '';
...@@ -137,14 +138,19 @@ ...@@ -137,14 +138,19 @@
const { param } = gl.FilteredSearchTokenKeys.searchByKey(token.key); const { param } = gl.FilteredSearchTokenKeys.searchByKey(token.key);
let tokenPath = ''; let tokenPath = '';
let keyParam = token.key;
if (param) {
keyParam += `_${param}`;
}
if (token.wildcard && condition) { if (token.wildcard && condition) {
tokenPath = condition.url; tokenPath = condition.url;
} else if (token.wildcard) { } else if (token.wildcard) {
// wildcard means that the token does not have a symbol // wildcard means that the token does not have a symbol
tokenPath = `${token.key}_${param}=${encodeURIComponent(token.value)}`; tokenPath = `${keyParam}=${encodeURIComponent(token.value)}`;
} else { } else {
// Remove the token symbol // Remove the token symbol
tokenPath = `${token.key}_${param}=${encodeURIComponent(token.value.slice(1))}`; tokenPath = `${keyParam}=${encodeURIComponent(token.value.slice(1))}`;
} }
paths.push(tokenPath); paths.push(tokenPath);
......
...@@ -57,7 +57,15 @@ ...@@ -57,7 +57,15 @@
} }
static searchByKeyParam(keyParam) { static searchByKeyParam(keyParam) {
return tokenKeys.find(tokenKey => keyParam === `${tokenKey.key}_${tokenKey.param}`) || null; return tokenKeys.find((tokenKey) => {
let tokenKeyParam = tokenKey.key;
if (tokenKey.param) {
tokenKeyParam += `_${tokenKey.param}`;
}
return keyParam === tokenKeyParam;
}) || null;
} }
static searchByConditionUrl(url) { static searchByConditionUrl(url) {
......
...@@ -89,6 +89,10 @@ ...@@ -89,6 +89,10 @@
overflow-y: hidden; overflow-y: hidden;
border-radius: 0; border-radius: 0;
.fa {
width: 15px;
}
.dropdown-label-box { .dropdown-label-box {
border-color: $white-light; border-color: $white-light;
border-style: solid; border-style: solid;
......
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