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
Tatuya Kamada
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
Hide 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 */
/*= require filtered_search/filtered_search_dropdown */
(() => {
((global) => {
const dropdownData = [{
const dropdownData = [{
icon: 'fa-pencil',
icon: 'fa-pencil',
hint: 'author:',
hint: 'author:',
tag: '<author>'
tag: '<author>'
,
},{
},
{
icon: 'fa-user',
icon: 'fa-user',
hint: 'assignee:',
hint: 'assignee:',
tag: '<assignee>',
tag: '<assignee>',
},{
},
{
icon: 'fa-clock-o',
icon: 'fa-clock-o',
hint: 'milestone:',
hint: 'milestone:',
tag: '<milestone>',
tag: '<milestone>',
},{
},
{
icon: 'fa-tag',
icon: 'fa-tag',
hint: 'label:',
hint: 'label:',
tag: '<label>',
tag: '<label>',
...
@@ -27,7 +25,7 @@
...
@@ -27,7 +25,7 @@
droplabFilter: {
droplabFilter: {
template: 'hint',
template: 'hint',
filterFunction: this.filterMethod,
filterFunction: this.filterMethod,
}
}
,
};
};
}
}
...
@@ -41,7 +39,8 @@
...
@@ -41,7 +39,8 @@
const tag = selected.querySelector('.js-filter-tag').innerText.trim();
const tag = selected.querySelector('.js-filter-tag').innerText.trim();
if (tag.length) {
if (tag.length) {
gl.FilteredSearchDropdownManager.addWordToInput(this.getSelectedTextWithoutEscaping(token));
gl.FilteredSearchDropdownManager
.addWordToInput(this.getSelectedTextWithoutEscaping(token));
}
}
this.dismissDropdown();
this.dismissDropdown();
this.dispatchInputEvent();
this.dispatchInputEvent();
...
@@ -61,15 +60,16 @@
...
@@ -61,15 +60,16 @@
}
}
filterMethod(item, query) {
filterMethod(item, query) {
const updatedItem = item;
const { value } = gl.FilteredSearchTokenizer.getLastTokenObject(query);
const { value } = gl.FilteredSearchTokenizer.getLastTokenObject(query);
if (value === '') {
if (value === '') {
i
tem.droplab_hidden = false;
updatedI
tem.droplab_hidden = false;
} else {
} else {
item.droplab_hidden = item['hint']
.indexOf(value) === -1;
updatedItem.droplab_hidden = updatedItem.hint
.indexOf(value) === -1;
}
}
return
i
tem;
return
updatedI
tem;
}
}
init() {
init() {
...
@@ -77,5 +77,6 @@
...
@@ -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 */
/*= require filtered_search/filtered_search_dropdown */
(() => {
((global) => {
class DropdownNonUser extends gl.FilteredSearchDropdown {
class DropdownNonUser extends gl.FilteredSearchDropdown {
constructor(droplab, dropdown, input, endpoint, symbol) {
constructor(droplab, dropdown, input, endpoint, symbol) {
super(droplab, dropdown, input);
super(droplab, dropdown, input);
this.symbol = symbol;
this.symbol = symbol;
this.config = {
this.config = {
droplabAjax: {
droplabAjax: {
endpoint
: endpoint
,
endpoint,
method: 'setData',
method: 'setData',
loadingTemplate: this.loadingTemplate,
loadingTemplate: this.loadingTemplate,
},
},
droplabFilter: {
droplabFilter: {
filterFunction: this.filterWithSymbol.bind(this, this.symbol),
filterFunction: this.filterWithSymbol.bind(this, this.symbol),
}
}
,
};
};
}
}
itemClicked(e) {
itemClicked(e) {
super.itemClicked(e, (selected) => {
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)}`;
return `${this.symbol}${this.getEscapedText(title)}`;
});
});
}
}
...
@@ -46,30 +44,35 @@
...
@@ -46,30 +44,35 @@
}
}
filterWithSymbol(filterSymbol, item, query) {
filterWithSymbol(filterSymbol, item, query) {
const updatedItem = item;
const { value } = gl.FilteredSearchTokenizer.getLastTokenObject(query);
const { value } = gl.FilteredSearchTokenizer.getLastTokenObject(query);
const valueWithoutColon = value.slice(1).toLowerCase();
const valueWithoutColon = value.slice(1).toLowerCase();
const prefix = valueWithoutColon[0];
const prefix = valueWithoutColon[0];
const valueWithoutPrefix = valueWithoutColon.slice(1);
const valueWithoutPrefix = valueWithoutColon.slice(1);
const title =
i
tem.title.toLowerCase();
const title =
updatedI
tem.title.toLowerCase();
// Eg. filterSymbol = ~ for labels
// 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;
const match = title.indexOf(valueWithoutColon) !== -1;
i
tem.droplab_hidden = !match && !matchWithoutPrefix;
updatedI
tem.droplab_hidden = !match && !matchWithoutPrefix;
return
i
tem;
return
updatedI
tem;
}
}
renderContent(forceShowList = false) {
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);
super.renderContent(forceShowList);
}
}
init() {
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 */
/*= require filtered_search/filtered_search_dropdown */
(() => {
((global) => {
class DropdownUser extends gl.FilteredSearchDropdown {
class DropdownUser extends gl.FilteredSearchDropdown {
constructor(droplab, dropdown, input) {
constructor(droplab, dropdown, input) {
super(droplab, dropdown, input);
super(droplab, dropdown, input);
...
@@ -22,9 +20,8 @@
...
@@ -22,9 +20,8 @@
}
}
itemClicked(e) {
itemClicked(e) {
super.itemClicked(e, (selected) => {
super.itemClicked(e,
return selected.querySelector('.dropdown-light-content').innerText.trim();
selected => selected.querySelector('.dropdown-light-content').innerText.trim());
});
}
}
renderContent(forceShowList = false) {
renderContent(forceShowList = false) {
...
@@ -51,5 +48,6 @@
...
@@ -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';
const DATA_DROPDOWN_TRIGGER = 'data-dropdown-trigger';
class FilteredSearchDropdown {
class FilteredSearchDropdown {
...
@@ -72,7 +71,7 @@
...
@@ -72,7 +71,7 @@
if (firstTimeInitialized || forceRenderContent) {
if (firstTimeInitialized || forceRenderContent) {
this.renderContent(forceShowList);
this.renderContent(forceShowList);
} else if(currentHook.list.list.id !== this.dropdown.id) {
} else if
(currentHook.list.list.id !== this.dropdown.id) {
this.renderContent(forceShowList);
this.renderContent(forceShowList);
}
}
}
}
...
@@ -96,10 +95,15 @@
...
@@ -96,10 +95,15 @@
resetFilters() {
resetFilters() {
const hook = this.getCurrentHook();
const hook = this.getCurrentHook();
const data = hook.list.data;
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);
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 {
class FilteredSearchDropdownManager {
constructor() {
constructor() {
this.tokenizer = gl.FilteredSearchTokenizer;
this.tokenizer = gl.FilteredSearchTokenizer;
...
@@ -51,7 +50,7 @@
...
@@ -51,7 +50,7 @@
gl: 'DropdownHint',
gl: 'DropdownHint',
element: document.querySelector('#js-dropdown-hint'),
element: document.querySelector('#js-dropdown-hint'),
},
},
}
}
;
}
}
static addWordToInput(word, addSpace = false) {
static addWordToInput(word, addSpace = false) {
...
@@ -60,7 +59,7 @@
...
@@ -60,7 +59,7 @@
const hasExistingValue = value.length !== 0;
const hasExistingValue = value.length !== 0;
const { lastToken } = gl.FilteredSearchTokenizer.processTokens(value);
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
// Spaces inside the token means that the token value will be escaped by quotes
const hasQuotes = lastToken.value.indexOf(' ') !== -1;
const hasQuotes = lastToken.value.indexOf(' ') !== -1;
...
@@ -82,7 +81,8 @@
...
@@ -82,7 +81,8 @@
}
}
const filterIconPadding = 27;
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);
this.mapping[key].reference.setOffset(offset);
}
}
...
@@ -99,7 +99,7 @@
...
@@ -99,7 +99,7 @@
const glArguments = defaultArguments.concat(mappingKey.extraArguments || []);
const glArguments = defaultArguments.concat(mappingKey.extraArguments || []);
// Passing glArguments to `new gl[glClass](<arguments>)`
// 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) {
if (firstLoad) {
...
@@ -126,12 +126,13 @@
...
@@ -126,12 +126,13 @@
}
}
const match = gl.FilteredSearchTokenKeys.searchByKey(dropdownName.toLowerCase());
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';
const shouldOpenHintDropdown = !match && this.currentDropdown !== 'hint';
if (shouldOpenFilterDropdown || shouldOpenHintDropdown) {
if (shouldOpenFilterDropdown || shouldOpenHintDropdown) {
// `hint` is not listed as a tokenKey (since it is not a real `filter`)
// `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);
this.load(key, firstLoad);
}
}
...
@@ -146,7 +147,7 @@
...
@@ -146,7 +147,7 @@
// Eg. token = 'label:'
// Eg. token = 'label:'
const { tokenKey } = this.tokenizer.parseToken(lastToken);
const { tokenKey } = this.tokenizer.parseToken(lastToken);
this.loadDropdown(tokenKey);
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
// Token has been initialized into an object because it has a value
this.loadDropdown(lastToken.key);
this.loadDropdown(lastToken.key);
} else {
} else {
...
@@ -173,5 +174,6 @@
...
@@ -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 {
class FilteredSearchManager {
constructor() {
constructor() {
this.tokenizer = gl.FilteredSearchTokenizer;
this.tokenizer = gl.FilteredSearchTokenizer;
...
@@ -81,7 +80,7 @@
...
@@ -81,7 +80,7 @@
loadSearchParamsFromURL() {
loadSearchParamsFromURL() {
const params = gl.utils.getUrlParamsArray();
const params = gl.utils.getUrlParamsArray();
le
t inputValues = [];
cons
t inputValues = [];
params.forEach((p) => {
params.forEach((p) => {
const split = p.split('=');
const split = p.split('=');
...
@@ -125,13 +124,14 @@
...
@@ -125,13 +124,14 @@
}
}
search() {
search() {
le
t paths = [];
cons
t paths = [];
const { tokens, searchToken } = this.tokenizer.processTokens(this.filteredSearchInput.value);
const { tokens, searchToken } = this.tokenizer.processTokens(this.filteredSearchInput.value);
const currentState = gl.utils.getParameterByName('state') || 'opened';
const currentState = gl.utils.getParameterByName('state') || 'opened';
paths.push(`state=${currentState}`);
paths.push(`state=${currentState}`);
tokens.forEach((token) => {
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);
const { param } = gl.FilteredSearchTokenKeys.searchByKey(token.key);
let tokenPath = '';
let tokenPath = '';
...
@@ -156,5 +156,6 @@
...
@@ -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 = [{
const tokenKeys = [{
key: 'author',
key: 'author',
type: 'string',
type: 'string',
...
@@ -62,9 +61,11 @@
...
@@ -62,9 +61,11 @@
}
}
static searchByConditionKeyValue(key, value) {
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 {
class FilteredSearchTokenizer {
static parseToken(input) {
static parseToken(input) {
const colonIndex = input.indexOf(':');
const colonIndex = input.indexOf(':');
...
@@ -161,5 +160,6 @@
...
@@ -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 @@
...
@@ -128,7 +128,7 @@
// We can trust that each param has one & since values containing & will be encoded
// We can trust that each param has one & since values containing & will be encoded
// Remove the first character of search as it is always ?
// Remove the first character of search as it is always ?
return window.location.search.slice(1).split('&');
return window.location.search.slice(1).split('&');
}
}
;
gl.utils.getParameterByName = function(name) {
gl.utils.getParameterByName = function(name) {
var url = window.location.href;
var url = window.location.href;
...
...
app/assets/javascripts/lib/utils/text_utility.js
View file @
6700b76b
...
@@ -30,8 +30,7 @@
...
@@ -30,8 +30,7 @@
var
canvas
=
gl
.
text
.
getTextWidth
.
canvas
||
(
gl
.
text
.
getTextWidth
.
canvas
=
document
.
createElement
(
'
canvas
'
));
var
canvas
=
gl
.
text
.
getTextWidth
.
canvas
||
(
gl
.
text
.
getTextWidth
.
canvas
=
document
.
createElement
(
'
canvas
'
));
var
context
=
canvas
.
getContext
(
'
2d
'
);
var
context
=
canvas
.
getContext
(
'
2d
'
);
context
.
font
=
font
;
context
.
font
=
font
;
var
metrics
=
context
.
measureText
(
text
);
return
context
.
measureText
(
text
).
width
;
return
metrics
.
width
;
};
};
gl
.
text
.
selectedText
=
function
(
text
,
textarea
)
{
gl
.
text
.
selectedText
=
function
(
text
,
textarea
)
{
return
text
.
substring
(
textarea
.
selectionStart
,
textarea
.
selectionEnd
);
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