Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
6700b76b
Commit
6700b76b
authored
Dec 13, 2016
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix eslint
parent
27b22040
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
81 additions
and
72 deletions
+81
-72
app/assets/javascripts/filtered_search/dropdown_hint.js.es6
app/assets/javascripts/filtered_search/dropdown_hint.js.es6
+15
-14
app/assets/javascripts/filtered_search/dropdown_non_user.js.es6
...sets/javascripts/filtered_search/dropdown_non_user.js.es6
+17
-14
app/assets/javascripts/filtered_search/dropdown_user.js.es6
app/assets/javascripts/filtered_search/dropdown_user.js.es6
+6
-8
app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es6
...vascripts/filtered_search/filtered_search_dropdown.js.es6
+10
-6
app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6
...s/filtered_search/filtered_search_dropdown_manager.js.es6
+13
-11
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
...avascripts/filtered_search/filtered_search_manager.js.es6
+8
-7
app/assets/javascripts/filtered_search/filtered_search_token_keys.js.es6
...scripts/filtered_search/filtered_search_token_keys.js.es6
+6
-5
app/assets/javascripts/filtered_search/filtered_search_tokenizer.es6
...javascripts/filtered_search/filtered_search_tokenizer.es6
+4
-4
app/assets/javascripts/lib/utils/common_utils.js.es6
app/assets/javascripts/lib/utils/common_utils.js.es6
+1
-1
app/assets/javascripts/lib/utils/text_utility.js
app/assets/javascripts/lib/utils/text_utility.js
+1
-2
No files found.
app/assets/javascripts/filtered_search/dropdown_hint.js.es6
View file @
6700b76b
/* eslint-disable no-param-reassign */
/*= require filtered_search/filtered_search_dropdown */
((global) => {
(() => {
const dropdownData = [{
icon: 'fa-pencil',
hint: 'author:',
tag: '<author>'
},{
tag: '<author>'
,
},
{
icon: 'fa-user',
hint: 'assignee:',
tag: '<assignee>',
},{
},
{
icon: 'fa-clock-o',
hint: 'milestone:',
tag: '<milestone>',
},{
},
{
icon: 'fa-tag',
hint: 'label:',
tag: '<label>',
...
...
@@ -27,7 +25,7 @@
droplabFilter: {
template: 'hint',
filterFunction: this.filterMethod,
}
}
,
};
}
...
...
@@ -41,7 +39,8 @@
const tag = selected.querySelector('.js-filter-tag').innerText.trim();
if (tag.length) {
gl.FilteredSearchDropdownManager.addWordToInput(this.getSelectedTextWithoutEscaping(token));
gl.FilteredSearchDropdownManager
.addWordToInput(this.getSelectedTextWithoutEscaping(token));
}
this.dismissDropdown();
this.dispatchInputEvent();
...
...
@@ -61,15 +60,16 @@
}
filterMethod(item, query) {
const updatedItem = item;
const { value } = gl.FilteredSearchTokenizer.getLastTokenObject(query);
if (value === '') {
i
tem.droplab_hidden = false;
updatedI
tem.droplab_hidden = false;
} else {
item.droplab_hidden = item['hint']
.indexOf(value) === -1;
updatedItem.droplab_hidden = updatedItem.hint
.indexOf(value) === -1;
}
return
i
tem;
return
updatedI
tem;
}
init() {
...
...
@@ -77,5 +77,6 @@
}
}
global.DropdownHint = DropdownHint;
})(window.gl || (window.gl = {}));
window.gl = window.gl || {};
gl.DropdownHint = DropdownHint;
})();
app/assets/javascripts/filtered_search/dropdown_non_user.js.es6
View file @
6700b76b
/* eslint-disable no-param-reassign */
/*= require filtered_search/filtered_search_dropdown */
((global) => {
(() => {
class DropdownNonUser extends gl.FilteredSearchDropdown {
constructor(droplab, dropdown, input, endpoint, symbol) {
super(droplab, dropdown, input);
this.symbol = symbol;
this.config = {
droplabAjax: {
endpoint
: endpoint
,
endpoint,
method: 'setData',
loadingTemplate: this.loadingTemplate,
},
droplabFilter: {
filterFunction: this.filterWithSymbol.bind(this, this.symbol),
}
}
,
};
}
itemClicked(e) {
super.itemClicked(e, (selected) => {
const title =
e.detail.
selected.querySelector('.js-data-value').innerText.trim();
const title = selected.querySelector('.js-data-value').innerText.trim();
return `${this.symbol}${this.getEscapedText(title)}`;
});
}
...
...
@@ -46,30 +44,35 @@
}
filterWithSymbol(filterSymbol, item, query) {
const updatedItem = item;
const { value } = gl.FilteredSearchTokenizer.getLastTokenObject(query);
const valueWithoutColon = value.slice(1).toLowerCase();
const prefix = valueWithoutColon[0];
const valueWithoutPrefix = valueWithoutColon.slice(1);
const title =
i
tem.title.toLowerCase();
const title =
updatedI
tem.title.toLowerCase();
// Eg. filterSymbol = ~ for labels
const matchWithoutPrefix = prefix === filterSymbol && title.indexOf(valueWithoutPrefix) !== -1;
const matchWithoutPrefix =
prefix === filterSymbol && title.indexOf(valueWithoutPrefix) !== -1;
const match = title.indexOf(valueWithoutColon) !== -1;
i
tem.droplab_hidden = !match && !matchWithoutPrefix;
return
i
tem;
updatedI
tem.droplab_hidden = !match && !matchWithoutPrefix;
return
updatedI
tem;
}
renderContent(forceShowList = false) {
this.droplab.changeHookList(this.hookId, this.dropdown, [droplabAjax, droplabFilter], this.config);
this.droplab
.changeHookList(this.hookId, this.dropdown, [droplabAjax, droplabFilter], this.config);
super.renderContent(forceShowList);
}
init() {
this.droplab.addHook(this.input, this.dropdown, [droplabAjax, droplabFilter], this.config).init();
this.droplab
.addHook(this.input, this.dropdown, [droplabAjax, droplabFilter], this.config).init();
}
}
global.DropdownNonUser = DropdownNonUser;
})(window.gl || (window.gl = {}));
window.gl = window.gl || {};
gl.DropdownNonUser = DropdownNonUser;
})();
app/assets/javascripts/filtered_search/dropdown_user.js.es6
View file @
6700b76b
/* eslint-disable no-param-reassign */
/*= require filtered_search/filtered_search_dropdown */
((global) => {
(() => {
class DropdownUser extends gl.FilteredSearchDropdown {
constructor(droplab, dropdown, input) {
super(droplab, dropdown, input);
...
...
@@ -22,9 +20,8 @@
}
itemClicked(e) {
super.itemClicked(e, (selected) => {
return selected.querySelector('.dropdown-light-content').innerText.trim();
});
super.itemClicked(e,
selected => selected.querySelector('.dropdown-light-content').innerText.trim());
}
renderContent(forceShowList = false) {
...
...
@@ -51,5 +48,6 @@
}
}
global.DropdownUser = DropdownUser;
})(window.gl || (window.gl = {}));
window.gl = window.gl || {};
gl.DropdownUser = DropdownUser;
})();
app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es6
View file @
6700b76b
/* eslint-disable no-param-reassign */
((global) => {
(() => {
const DATA_DROPDOWN_TRIGGER = 'data-dropdown-trigger';
class FilteredSearchDropdown {
...
...
@@ -72,7 +71,7 @@
if (firstTimeInitialized || forceRenderContent) {
this.renderContent(forceShowList);
} else if(currentHook.list.list.id !== this.dropdown.id) {
} else if
(currentHook.list.list.id !== this.dropdown.id) {
this.renderContent(forceShowList);
}
}
...
...
@@ -96,10 +95,15 @@
resetFilters() {
const hook = this.getCurrentHook();
const data = hook.list.data;
const results = data.map(o => o.droplab_hidden = false);
const results = data.map((o) => {
const updated = o;
updated.droplab_hidden = false;
return updated;
});
hook.list.render(results);
}
}
global.FilteredSearchDropdown = FilteredSearchDropdown;
})(window.gl || (window.gl = {}));
window.gl = window.gl || {};
gl.FilteredSearchDropdown = FilteredSearchDropdown;
})();
app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6
View file @
6700b76b
/* eslint-disable no-param-reassign */
((global) => {
(() => {
class FilteredSearchDropdownManager {
constructor() {
this.tokenizer = gl.FilteredSearchTokenizer;
...
...
@@ -51,7 +50,7 @@
gl: 'DropdownHint',
element: document.querySelector('#js-dropdown-hint'),
},
}
}
;
}
static addWordToInput(word, addSpace = false) {
...
...
@@ -60,7 +59,7 @@
const hasExistingValue = value.length !== 0;
const { lastToken } = gl.FilteredSearchTokenizer.processTokens(value);
if (
lastToken.hasOwnProperty(
'key')) {
if (
{}.hasOwnProperty.call(lastToken,
'key')) {
// Spaces inside the token means that the token value will be escaped by quotes
const hasQuotes = lastToken.value.indexOf(' ') !== -1;
...
...
@@ -82,7 +81,8 @@
}
const filterIconPadding = 27;
const offset = gl.text.getTextWidth(this.filteredSearchInput.value, this.font) + filterIconPadding;
const offset = gl.text
.getTextWidth(this.filteredSearchInput.value, this.font) + filterIconPadding;
this.mapping[key].reference.setOffset(offset);
}
...
...
@@ -99,7 +99,7 @@
const glArguments = defaultArguments.concat(mappingKey.extraArguments || []);
// Passing glArguments to `new gl[glClass](<arguments>)`
mappingKey.reference = new (Function.prototype.bind.apply(gl[glClass], glArguments));
mappingKey.reference = new (Function.prototype.bind.apply(gl[glClass], glArguments))
()
;
}
if (firstLoad) {
...
...
@@ -126,12 +126,13 @@
}
const match = gl.FilteredSearchTokenKeys.searchByKey(dropdownName.toLowerCase());
const shouldOpenFilterDropdown = match && this.currentDropdown !== match.key && this.mapping.hasOwnProperty(match.key);
const shouldOpenFilterDropdown = match && this.currentDropdown !== match.key
&& {}.hasOwnProperty.call(this.mapping, match.key);
const shouldOpenHintDropdown = !match && this.currentDropdown !== 'hint';
if (shouldOpenFilterDropdown || shouldOpenHintDropdown) {
// `hint` is not listed as a tokenKey (since it is not a real `filter`)
const key = match &&
match.hasOwnProperty(
'key') ? match.key : 'hint';
const key = match &&
{}.hasOwnProperty.call(match,
'key') ? match.key : 'hint';
this.load(key, firstLoad);
}
...
...
@@ -146,7 +147,7 @@
// Eg. token = 'label:'
const { tokenKey } = this.tokenizer.parseToken(lastToken);
this.loadDropdown(tokenKey);
} else if (
lastToken.hasOwnProperty(
'key')) {
} else if (
{}.hasOwnProperty.call(lastToken,
'key')) {
// Token has been initialized into an object because it has a value
this.loadDropdown(lastToken.key);
} else {
...
...
@@ -173,5 +174,6 @@
}
}
global.FilteredSearchDropdownManager = FilteredSearchDropdownManager;
})(window.gl || (window.gl = {}));
window.gl = window.gl || {};
gl.FilteredSearchDropdownManager = FilteredSearchDropdownManager;
})();
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
View file @
6700b76b
/* eslint-disable no-param-reassign */
((global) => {
(() => {
class FilteredSearchManager {
constructor() {
this.tokenizer = gl.FilteredSearchTokenizer;
...
...
@@ -81,7 +80,7 @@
loadSearchParamsFromURL() {
const params = gl.utils.getUrlParamsArray();
le
t inputValues = [];
cons
t inputValues = [];
params.forEach((p) => {
const split = p.split('=');
...
...
@@ -125,13 +124,14 @@
}
search() {
le
t paths = [];
cons
t paths = [];
const { tokens, searchToken } = this.tokenizer.processTokens(this.filteredSearchInput.value);
const currentState = gl.utils.getParameterByName('state') || 'opened';
paths.push(`state=${currentState}`);
tokens.forEach((token) => {
const condition = gl.FilteredSearchTokenKeys.searchByConditionKeyValue(token.key, token.value.toLowerCase());
const condition = gl.FilteredSearchTokenKeys
.searchByConditionKeyValue(token.key, token.value.toLowerCase());
const { param } = gl.FilteredSearchTokenKeys.searchByKey(token.key);
let tokenPath = '';
...
...
@@ -156,5 +156,6 @@
}
}
global.FilteredSearchManager = FilteredSearchManager;
})(window.gl || (window.gl = {}));
window.gl = window.gl || {};
gl.FilteredSearchManager = FilteredSearchManager;
})();
app/assets/javascripts/filtered_search/filtered_search_token_keys.js.es6
View file @
6700b76b
/* eslint-disable no-param-reassign */
((global) => {
(() => {
const tokenKeys = [{
key: 'author',
type: 'string',
...
...
@@ -62,9 +61,11 @@
}
static searchByConditionKeyValue(key, value) {
return conditions.find(condition => condition.tokenKey === key && condition.value === value) || null;
return conditions
.find(condition => condition.tokenKey === key && condition.value === value) || null;
}
}
global.FilteredSearchTokenKeys = FilteredSearchTokenKeys;
})(window.gl || (window.gl = {}));
window.gl = window.gl || {};
gl.FilteredSearchTokenKeys = FilteredSearchTokenKeys;
})();
app/assets/javascripts/filtered_search/filtered_search_tokenizer.es6
View file @
6700b76b
/* eslint-disable no-param-reassign */
((global) => {
(() => {
class FilteredSearchTokenizer {
static parseToken(input) {
const colonIndex = input.indexOf(':');
...
...
@@ -161,5 +160,6 @@
}
}
global.FilteredSearchTokenizer = FilteredSearchTokenizer;
})(window.gl || (window.gl = {}));
window.gl = window.gl || {};
gl.FilteredSearchTokenizer = FilteredSearchTokenizer;
})();
app/assets/javascripts/lib/utils/common_utils.js.es6
View file @
6700b76b
...
...
@@ -128,7 +128,7 @@
// We can trust that each param has one & since values containing & will be encoded
// Remove the first character of search as it is always ?
return window.location.search.slice(1).split('&');
}
}
;
gl.utils.getParameterByName = function(name) {
var url = window.location.href;
...
...
app/assets/javascripts/lib/utils/text_utility.js
View file @
6700b76b
...
...
@@ -30,8 +30,7 @@
var
canvas
=
gl
.
text
.
getTextWidth
.
canvas
||
(
gl
.
text
.
getTextWidth
.
canvas
=
document
.
createElement
(
'
canvas
'
));
var
context
=
canvas
.
getContext
(
'
2d
'
);
context
.
font
=
font
;
var
metrics
=
context
.
measureText
(
text
);
return
metrics
.
width
;
return
context
.
measureText
(
text
).
width
;
};
gl
.
text
.
selectedText
=
function
(
text
,
textarea
)
{
return
text
.
substring
(
textarea
.
selectionStart
,
textarea
.
selectionEnd
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment