Commit 3c834a57 authored by Nick Thomas's avatar Nick Thomas

Fix conflicts in filtered search

parent 15483879
...@@ -103,23 +103,6 @@ class FilteredSearchDropdown { ...@@ -103,23 +103,6 @@ class FilteredSearchDropdown {
} }
} }
<<<<<<< HEAD
resetFilters() {
const hook = this.getCurrentHook();
if (hook) {
const data = hook.list.data || [];
if (!data) return;
const results = data.map((o) => {
const updated = o;
updated.droplab_hidden = false;
return updated;
});
hook.list.render(results);
}
=======
resetFilters() { resetFilters() {
const hook = this.getCurrentHook(); const hook = this.getCurrentHook();
...@@ -131,7 +114,6 @@ class FilteredSearchDropdown { ...@@ -131,7 +114,6 @@ class FilteredSearchDropdown {
return updated; return updated;
}); });
hook.list.render(results); hook.list.render(results);
>>>>>>> ce/master
} }
} }
} }
......
import DropLab from '~/droplab/drop_lab'; import DropLab from '~/droplab/drop_lab';
import FilteredSearchContainer from './container'; import FilteredSearchContainer from './container';
<<<<<<< HEAD class FilteredSearchDropdownManager {
(() => {
class FilteredSearchDropdownManager {
constructor(baseEndpoint = '', page) { constructor(baseEndpoint = '', page) {
this.container = FilteredSearchContainer.container; this.container = FilteredSearchContainer.container;
this.baseEndpoint = baseEndpoint.replace(/\/$/, ''); this.baseEndpoint = baseEndpoint.replace(/\/$/, '');
...@@ -18,20 +16,6 @@ import FilteredSearchContainer from './container'; ...@@ -18,20 +16,6 @@ import FilteredSearchContainer from './container';
this.setupMapping(); this.setupMapping();
this.cleanupWrapper = this.cleanup.bind(this);
document.addEventListener('beforeunload', this.cleanupWrapper);
=======
class FilteredSearchDropdownManager {
constructor(baseEndpoint = '', page) {
this.container = FilteredSearchContainer.container;
this.baseEndpoint = baseEndpoint.replace(/\/$/, '');
this.tokenizer = gl.FilteredSearchTokenizer;
this.filteredSearchTokenKeys = gl.FilteredSearchTokenKeys;
this.filteredSearchInput = this.container.querySelector('.filtered-search');
this.page = page;
this.setupMapping();
this.cleanupWrapper = this.cleanup.bind(this); this.cleanupWrapper = this.cleanup.bind(this);
document.addEventListener('beforeunload', this.cleanupWrapper); document.addEventListener('beforeunload', this.cleanupWrapper);
} }
...@@ -40,7 +24,6 @@ class FilteredSearchDropdownManager { ...@@ -40,7 +24,6 @@ class FilteredSearchDropdownManager {
if (this.droplab) { if (this.droplab) {
this.droplab.destroy(); this.droplab.destroy();
this.droplab = null; this.droplab = null;
>>>>>>> ce/master
} }
this.setupMapping(); this.setupMapping();
...@@ -48,39 +31,6 @@ class FilteredSearchDropdownManager { ...@@ -48,39 +31,6 @@ class FilteredSearchDropdownManager {
document.removeEventListener('beforeunload', this.cleanupWrapper); document.removeEventListener('beforeunload', this.cleanupWrapper);
} }
setupMapping() {
this.mapping = {
author: {
reference: null,
gl: 'DropdownUser',
element: this.container.querySelector('#js-dropdown-author'),
},
assignee: {
reference: null,
gl: 'DropdownUser',
element: this.container.querySelector('#js-dropdown-assignee'),
},
milestone: {
reference: null,
gl: 'DropdownNonUser',
extraArguments: [`${this.baseEndpoint}/milestones.json`, '%'],
element: this.container.querySelector('#js-dropdown-milestone'),
},
label: {
reference: null,
gl: 'DropdownNonUser',
extraArguments: [`${this.baseEndpoint}/labels.json`, '~'],
element: this.container.querySelector('#js-dropdown-label'),
},
hint: {
reference: null,
gl: 'DropdownHint',
element: this.container.querySelector('#js-dropdown-hint'),
},
};
}
<<<<<<< HEAD
setupMapping() { setupMapping() {
this.mapping = { this.mapping = {
author: { author: {
...@@ -119,7 +69,8 @@ class FilteredSearchDropdownManager { ...@@ -119,7 +69,8 @@ class FilteredSearchDropdownManager {
element: document.querySelector('#js-dropdown-weight'), element: document.querySelector('#js-dropdown-weight'),
}; };
} }
======= }
static addWordToInput(tokenName, tokenValue = '', clicked = false) { static addWordToInput(tokenName, tokenValue = '', clicked = false) {
const input = FilteredSearchContainer.container.querySelector('.filtered-search'); const input = FilteredSearchContainer.container.querySelector('.filtered-search');
...@@ -128,7 +79,6 @@ class FilteredSearchDropdownManager { ...@@ -128,7 +79,6 @@ class FilteredSearchDropdownManager {
if (clicked) { if (clicked) {
gl.FilteredSearchVisualTokens.moveInputToTheRight(); gl.FilteredSearchVisualTokens.moveInputToTheRight();
>>>>>>> ce/master
} }
} }
......
...@@ -6,9 +6,7 @@ import RecentSearchesStore from './stores/recent_searches_store'; ...@@ -6,9 +6,7 @@ import RecentSearchesStore from './stores/recent_searches_store';
import RecentSearchesService from './services/recent_searches_service'; import RecentSearchesService from './services/recent_searches_service';
import eventHub from './event_hub'; import eventHub from './event_hub';
<<<<<<< HEAD class FilteredSearchManager {
(() => {
class FilteredSearchManager {
constructor(page) { constructor(page) {
this.container = FilteredSearchContainer.container; this.container = FilteredSearchContainer.container;
this.filteredSearchInput = this.container.querySelector('.filtered-search'); this.filteredSearchInput = this.container.querySelector('.filtered-search');
...@@ -45,49 +43,6 @@ import eventHub from './event_hub'; ...@@ -45,49 +43,6 @@ import eventHub from './event_hub';
this.recentSearchesService.save(resultantSearches); this.recentSearchesService.save(resultantSearches);
}); });
if (this.filteredSearchInput) {
this.tokenizer = gl.FilteredSearchTokenizer;
this.dropdownManager = new gl.FilteredSearchDropdownManager(this.filteredSearchInput.getAttribute('data-base-endpoint') || '', page);
this.recentSearchesRoot = new RecentSearchesRoot(
this.recentSearchesStore,
this.recentSearchesService,
document.querySelector('.js-filtered-search-history-dropdown'),
=======
class FilteredSearchManager {
constructor(page) {
this.container = FilteredSearchContainer.container;
this.filteredSearchInput = this.container.querySelector('.filtered-search');
this.filteredSearchInputForm = this.filteredSearchInput.form;
this.clearSearchButton = this.container.querySelector('.clear-search');
this.tokensContainer = this.container.querySelector('.tokens-container');
this.filteredSearchTokenKeys = gl.FilteredSearchTokenKeys;
this.recentSearchesStore = new RecentSearchesStore();
let recentSearchesKey = 'issue-recent-searches';
if (page === 'merge_requests') {
recentSearchesKey = 'merge-request-recent-searches';
}
this.recentSearchesService = new RecentSearchesService(recentSearchesKey);
// Fetch recent searches from localStorage
this.fetchingRecentSearchesPromise = this.recentSearchesService.fetch()
.catch(() => {
// eslint-disable-next-line no-new
new Flash('An error occured while parsing recent searches');
// Gracefully fail to empty array
return [];
})
.then((searches) => {
// Put any searches that may have come in before
// we fetched the saved searches ahead of the already saved ones
const resultantSearches = this.recentSearchesStore.setRecentSearches(
this.recentSearchesStore.state.recentSearches.concat(searches),
>>>>>>> ce/master
);
this.recentSearchesService.save(resultantSearches);
});
if (this.filteredSearchInput) { if (this.filteredSearchInput) {
this.tokenizer = gl.FilteredSearchTokenizer; this.tokenizer = gl.FilteredSearchTokenizer;
this.dropdownManager = new gl.FilteredSearchDropdownManager(this.filteredSearchInput.getAttribute('data-base-endpoint') || '', page); this.dropdownManager = new gl.FilteredSearchDropdownManager(this.filteredSearchInput.getAttribute('data-base-endpoint') || '', page);
...@@ -154,14 +109,6 @@ class FilteredSearchManager { ...@@ -154,14 +109,6 @@ class FilteredSearchManager {
eventHub.$on('recentSearchesItemSelected', this.onrecentSearchesItemSelectedWrapper); eventHub.$on('recentSearchesItemSelected', this.onrecentSearchesItemSelectedWrapper);
} }
<<<<<<< HEAD
if (this.filteredSearchInput.value === '' && lastVisualToken) {
if (this.canEdit && !this.canEdit(lastVisualToken)) return;
this.filteredSearchInput.value = gl.FilteredSearchVisualTokens.getLastTokenPartial();
gl.FilteredSearchVisualTokens.removeLastTokenPartial();
}
=======
unbindEvents() { unbindEvents() {
this.filteredSearchInputForm.removeEventListener('submit', this.handleFormSubmit); this.filteredSearchInputForm.removeEventListener('submit', this.handleFormSubmit);
this.filteredSearchInput.removeEventListener('input', this.setDropdownWrapper); this.filteredSearchInput.removeEventListener('input', this.setDropdownWrapper);
...@@ -188,7 +135,6 @@ class FilteredSearchManager { ...@@ -188,7 +135,6 @@ class FilteredSearchManager {
// 46 = Delete Key // 46 = Delete Key
if (e.keyCode === 8 || e.keyCode === 46) { if (e.keyCode === 8 || e.keyCode === 46) {
const { lastVisualToken } = gl.FilteredSearchVisualTokens.getLastVisualTokenBeforeInput(); const { lastVisualToken } = gl.FilteredSearchVisualTokens.getLastVisualTokenBeforeInput();
>>>>>>> ce/master
if (this.filteredSearchInput.value === '' && lastVisualToken) { if (this.filteredSearchInput.value === '' && lastVisualToken) {
this.filteredSearchInput.value = gl.FilteredSearchVisualTokens.getLastTokenPartial(); this.filteredSearchInput.value = gl.FilteredSearchVisualTokens.getLastTokenPartial();
...@@ -276,18 +222,9 @@ class FilteredSearchManager { ...@@ -276,18 +222,9 @@ class FilteredSearchManager {
editToken(e) { editToken(e) {
const token = e.target.closest('.js-visual-token'); const token = e.target.closest('.js-visual-token');
<<<<<<< HEAD
if (this.canEdit && !this.canEdit(token)) return;
if (token) {
gl.FilteredSearchVisualTokens.editToken(token);
this.tokenChange();
}
=======
if (token) { if (token) {
gl.FilteredSearchVisualTokens.editToken(token); gl.FilteredSearchVisualTokens.editToken(token);
this.tokenChange(); this.tokenChange();
>>>>>>> ce/master
} }
} }
...@@ -335,21 +272,11 @@ class FilteredSearchManager { ...@@ -335,21 +272,11 @@ class FilteredSearchManager {
const removeElements = []; const removeElements = [];
<<<<<<< HEAD
[].forEach.call(this.tokensContainer.children, (t) => {
if (t.classList.contains('js-visual-token')) {
if (this.canEdit && !this.canEdit(t)) return;
removeElements.push(t);
}
});
=======
[].forEach.call(this.tokensContainer.children, (t) => { [].forEach.call(this.tokensContainer.children, (t) => {
if (t.classList.contains('js-visual-token')) { if (t.classList.contains('js-visual-token')) {
removeElements.push(t); removeElements.push(t);
} }
}); });
>>>>>>> ce/master
removeElements.forEach((el) => { removeElements.forEach((el) => {
el.parentElement.removeChild(el); el.parentElement.removeChild(el);
......
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