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

Fix conflicts in filtered search

parent 15483879
......@@ -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() {
const hook = this.getCurrentHook();
......@@ -131,7 +114,6 @@ class FilteredSearchDropdown {
return updated;
});
hook.list.render(results);
>>>>>>> ce/master
}
}
}
......
import DropLab from '~/droplab/drop_lab';
import FilteredSearchContainer from './container';
<<<<<<< HEAD
(() => {
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;
if (this.page === 'issues' || this.page === 'boards') {
this.filteredSearchTokenKeys = gl.FilteredSearchTokenKeysWithWeights;
}
this.setupMapping();
this.cleanupWrapper = this.cleanup.bind(this);
document.addEventListener('beforeunload', this.cleanupWrapper);
=======
class FilteredSearchDropdownManager {
constructor(baseEndpoint = '', page) {
this.container = FilteredSearchContainer.container;
......@@ -30,6 +10,10 @@ class FilteredSearchDropdownManager {
this.filteredSearchInput = this.container.querySelector('.filtered-search');
this.page = page;
if (this.page === 'issues' || this.page === 'boards') {
this.filteredSearchTokenKeys = gl.FilteredSearchTokenKeysWithWeights;
}
this.setupMapping();
this.cleanupWrapper = this.cleanup.bind(this);
......@@ -40,7 +24,6 @@ class FilteredSearchDropdownManager {
if (this.droplab) {
this.droplab.destroy();
this.droplab = null;
>>>>>>> ce/master
}
this.setupMapping();
......@@ -78,48 +61,16 @@ class FilteredSearchDropdownManager {
element: this.container.querySelector('#js-dropdown-hint'),
},
};
}
<<<<<<< HEAD
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'),
},
if (this.page === 'issues' || this.page === 'boards') {
this.mapping.weight = {
reference: null,
gl: 'DropdownNonUser',
element: document.querySelector('#js-dropdown-weight'),
};
}
}
if (this.page === 'issues' || this.page === 'boards') {
this.mapping.weight = {
reference: null,
gl: 'DropdownNonUser',
element: document.querySelector('#js-dropdown-weight'),
};
}
=======
static addWordToInput(tokenName, tokenValue = '', clicked = false) {
const input = FilteredSearchContainer.container.querySelector('.filtered-search');
......@@ -128,7 +79,6 @@ class FilteredSearchDropdownManager {
if (clicked) {
gl.FilteredSearchVisualTokens.moveInputToTheRight();
>>>>>>> ce/master
}
}
......
......@@ -6,54 +6,6 @@ import RecentSearchesStore from './stores/recent_searches_store';
import RecentSearchesService from './services/recent_searches_service';
import eventHub from './event_hub';
<<<<<<< HEAD
(() => {
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;
if (page === 'issues' || page === 'boards') {
this.filteredSearchTokenKeys = gl.FilteredSearchTokenKeysWithWeights;
}
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),
);
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;
......@@ -63,6 +15,10 @@ class FilteredSearchManager {
this.tokensContainer = this.container.querySelector('.tokens-container');
this.filteredSearchTokenKeys = gl.FilteredSearchTokenKeys;
if (page === 'issues' || page === 'boards') {
this.filteredSearchTokenKeys = gl.FilteredSearchTokenKeysWithWeights;
}
this.recentSearchesStore = new RecentSearchesStore();
let recentSearchesKey = 'issue-recent-searches';
if (page === 'merge_requests') {
......@@ -83,7 +39,6 @@ class FilteredSearchManager {
// 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);
});
......@@ -154,14 +109,6 @@ class FilteredSearchManager {
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() {
this.filteredSearchInputForm.removeEventListener('submit', this.handleFormSubmit);
this.filteredSearchInput.removeEventListener('input', this.setDropdownWrapper);
......@@ -188,7 +135,6 @@ class FilteredSearchManager {
// 46 = Delete Key
if (e.keyCode === 8 || e.keyCode === 46) {
const { lastVisualToken } = gl.FilteredSearchVisualTokens.getLastVisualTokenBeforeInput();
>>>>>>> ce/master
if (this.filteredSearchInput.value === '' && lastVisualToken) {
this.filteredSearchInput.value = gl.FilteredSearchVisualTokens.getLastTokenPartial();
......@@ -276,18 +222,9 @@ class FilteredSearchManager {
editToken(e) {
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) {
gl.FilteredSearchVisualTokens.editToken(token);
this.tokenChange();
>>>>>>> ce/master
}
}
......@@ -335,21 +272,11 @@ class FilteredSearchManager {
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) => {
if (t.classList.contains('js-visual-token')) {
removeElements.push(t);
}
});
>>>>>>> ce/master
removeElements.forEach((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