2017-04-17 07:01:11 +00:00
|
|
|
const tokenKeys = [{
|
|
|
|
key: 'author',
|
|
|
|
type: 'string',
|
|
|
|
param: 'username',
|
|
|
|
symbol: '@',
|
|
|
|
}, {
|
|
|
|
key: 'assignee',
|
|
|
|
type: 'string',
|
|
|
|
param: 'username',
|
|
|
|
symbol: '@',
|
|
|
|
}, {
|
|
|
|
key: 'milestone',
|
|
|
|
type: 'string',
|
|
|
|
param: 'title',
|
|
|
|
symbol: '%',
|
|
|
|
}, {
|
|
|
|
key: 'label',
|
|
|
|
type: 'array',
|
|
|
|
param: 'name[]',
|
|
|
|
symbol: '~',
|
|
|
|
}];
|
2016-12-13 04:15:31 +00:00
|
|
|
|
2017-04-17 07:01:11 +00:00
|
|
|
const alternativeTokenKeys = [{
|
|
|
|
key: 'label',
|
|
|
|
type: 'string',
|
|
|
|
param: 'name',
|
|
|
|
symbol: '~',
|
|
|
|
}];
|
2017-01-24 20:03:39 +00:00
|
|
|
|
2017-04-17 07:01:11 +00:00
|
|
|
const tokenKeysWithAlternative = tokenKeys.concat(alternativeTokenKeys);
|
2017-01-24 20:03:39 +00:00
|
|
|
|
2017-04-17 07:01:11 +00:00
|
|
|
const conditions = [{
|
|
|
|
url: 'assignee_id=0',
|
|
|
|
tokenKey: 'assignee',
|
|
|
|
value: 'none',
|
|
|
|
}, {
|
|
|
|
url: 'milestone_title=No+Milestone',
|
|
|
|
tokenKey: 'milestone',
|
|
|
|
value: 'none',
|
|
|
|
}, {
|
|
|
|
url: 'milestone_title=%23upcoming',
|
|
|
|
tokenKey: 'milestone',
|
|
|
|
value: 'upcoming',
|
|
|
|
}, {
|
|
|
|
url: 'milestone_title=%23started',
|
|
|
|
tokenKey: 'milestone',
|
|
|
|
value: 'started',
|
|
|
|
}, {
|
|
|
|
url: 'label_name[]=No+Label',
|
|
|
|
tokenKey: 'label',
|
|
|
|
value: 'none',
|
|
|
|
}];
|
2016-12-13 04:15:31 +00:00
|
|
|
|
2017-04-17 07:01:11 +00:00
|
|
|
class FilteredSearchTokenKeys {
|
|
|
|
static get() {
|
|
|
|
return tokenKeys;
|
|
|
|
}
|
2016-12-13 04:15:31 +00:00
|
|
|
|
2017-04-17 07:01:11 +00:00
|
|
|
static getAlternatives() {
|
|
|
|
return alternativeTokenKeys;
|
|
|
|
}
|
2017-01-24 20:03:39 +00:00
|
|
|
|
2017-04-17 07:01:11 +00:00
|
|
|
static getConditions() {
|
|
|
|
return conditions;
|
|
|
|
}
|
2016-12-15 18:54:24 +00:00
|
|
|
|
2017-04-17 07:01:11 +00:00
|
|
|
static searchByKey(key) {
|
|
|
|
return tokenKeys.find(tokenKey => tokenKey.key === key) || null;
|
|
|
|
}
|
2016-12-13 04:15:31 +00:00
|
|
|
|
2017-04-17 07:01:11 +00:00
|
|
|
static searchBySymbol(symbol) {
|
|
|
|
return tokenKeys.find(tokenKey => tokenKey.symbol === symbol) || null;
|
|
|
|
}
|
2016-12-13 04:15:31 +00:00
|
|
|
|
2017-04-17 07:01:11 +00:00
|
|
|
static searchByKeyParam(keyParam) {
|
|
|
|
return tokenKeysWithAlternative.find((tokenKey) => {
|
|
|
|
let tokenKeyParam = tokenKey.key;
|
2016-12-16 16:22:09 +00:00
|
|
|
|
2017-04-17 07:01:11 +00:00
|
|
|
if (tokenKey.param) {
|
|
|
|
tokenKeyParam += `_${tokenKey.param}`;
|
|
|
|
}
|
2016-12-16 16:22:09 +00:00
|
|
|
|
2017-04-17 07:01:11 +00:00
|
|
|
return keyParam === tokenKeyParam;
|
|
|
|
}) || null;
|
|
|
|
}
|
2016-12-13 04:15:31 +00:00
|
|
|
|
2017-04-17 07:01:11 +00:00
|
|
|
static searchByConditionUrl(url) {
|
|
|
|
return conditions.find(condition => condition.url === url) || null;
|
|
|
|
}
|
2016-12-13 04:15:31 +00:00
|
|
|
|
2017-04-17 07:01:11 +00:00
|
|
|
static searchByConditionKeyValue(key, value) {
|
|
|
|
return conditions
|
|
|
|
.find(condition => condition.tokenKey === key && condition.value === value) || null;
|
2016-11-30 18:30:52 +00:00
|
|
|
}
|
2017-04-17 07:01:11 +00:00
|
|
|
}
|
2016-11-30 18:30:52 +00:00
|
|
|
|
2017-04-17 07:01:11 +00:00
|
|
|
window.gl = window.gl || {};
|
|
|
|
gl.FilteredSearchTokenKeys = FilteredSearchTokenKeys;
|