2019-07-31 22:56:46 +05:30
|
|
|
import IssuableFilteredSearchTokenKeys from 'ee_else_ce/filtered_search/issuable_filtered_search_token_keys';
|
2017-08-17 22:00:37 +05:30
|
|
|
import FilteredSearchContainer from '../filtered_search/container';
|
2018-03-27 19:54:05 +05:30
|
|
|
import FilteredSearchManager from '../filtered_search/filtered_search_manager';
|
2018-12-13 13:39:08 +05:30
|
|
|
import boardsStore from './stores/boards_store';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
export default class FilteredSearchBoards extends FilteredSearchManager {
|
2017-09-10 17:25:29 +05:30
|
|
|
constructor(store, updateUrl = false, cantEdit = []) {
|
2018-03-27 19:54:05 +05:30
|
|
|
super({
|
|
|
|
page: 'boards',
|
2018-05-09 12:01:36 +05:30
|
|
|
isGroupDecendent: true,
|
2018-03-27 19:54:05 +05:30
|
|
|
stateFiltersSelector: '.issues-state-filters',
|
2019-09-30 21:07:59 +05:30
|
|
|
isGroup: IS_EE,
|
2019-07-31 22:56:46 +05:30
|
|
|
filteredSearchTokenKeys: IssuableFilteredSearchTokenKeys,
|
2018-03-27 19:54:05 +05:30
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
this.store = store;
|
|
|
|
this.updateUrl = updateUrl;
|
|
|
|
|
|
|
|
// Issue boards is slightly different, we handle all the requests async
|
|
|
|
// instead or reloading the page, we just re-fire the list ajax requests
|
|
|
|
this.isHandledAsync = true;
|
2018-03-17 18:26:18 +05:30
|
|
|
this.cantEdit = cantEdit.filter(i => typeof i === 'string');
|
|
|
|
this.cantEditWithValue = cantEdit.filter(i => typeof i === 'object');
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
updateObject(path) {
|
|
|
|
this.store.path = path.substr(1);
|
|
|
|
|
|
|
|
if (this.updateUrl) {
|
2018-12-13 13:39:08 +05:30
|
|
|
boardsStore.updateFiltersUrl();
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
removeTokens() {
|
|
|
|
const tokens = FilteredSearchContainer.container.querySelectorAll('.js-visual-token');
|
|
|
|
|
|
|
|
// Remove all the tokens as they will be replaced by the search manager
|
2018-12-13 13:39:08 +05:30
|
|
|
[].forEach.call(tokens, el => {
|
2017-08-17 22:00:37 +05:30
|
|
|
el.parentNode.removeChild(el);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.filteredSearchInput.value = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
updateTokens() {
|
|
|
|
this.removeTokens();
|
|
|
|
|
|
|
|
this.loadSearchParamsFromURL();
|
|
|
|
|
|
|
|
// Get the placeholder back if search is empty
|
|
|
|
this.filteredSearchInput.dispatchEvent(new Event('input'));
|
|
|
|
}
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
canEdit(tokenName, tokenValue) {
|
|
|
|
if (this.cantEdit.includes(tokenName)) return false;
|
2018-12-13 13:39:08 +05:30
|
|
|
return (
|
|
|
|
this.cantEditWithValue.findIndex(
|
|
|
|
token => token.name === tokenName && token.value === tokenValue,
|
|
|
|
) === -1
|
|
|
|
);
|
2017-09-10 17:25:29 +05:30
|
|
|
}
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|