Commit 82f7a6a6 authored by Winnie Hellmann's avatar Winnie Hellmann

Add search box to issue board switcher

parent 2e19d7fa
<script> <script>
import $ from 'jquery'; import $ from 'jquery';
import { throttle } from 'underscore'; import { throttle } from 'underscore';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon, GlSearchBox } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import boardsStore from '~/boards/stores/boards_store'; import boardsStore from '~/boards/stores/boards_store';
import BoardForm from './board_form.vue'; import BoardForm from './board_form.vue';
...@@ -14,6 +14,7 @@ export default { ...@@ -14,6 +14,7 @@ export default {
Icon, Icon,
BoardForm, BoardForm,
GlLoadingIcon, GlLoadingIcon,
GlSearchBox,
}, },
props: { props: {
currentBoard: { currentBoard: {
...@@ -79,12 +80,18 @@ export default { ...@@ -79,12 +80,18 @@ export default {
contentClientHeight: 0, contentClientHeight: 0,
maxPosition: 0, maxPosition: 0,
store: boardsStore, store: boardsStore,
filterTerm: '',
}; };
}, },
computed: { computed: {
currentPage() { currentPage() {
return this.state.currentPage; return this.state.currentPage;
}, },
filteredBoards() {
return this.boards.filter(board =>
board.name.toLowerCase().includes(this.filterTerm.toLowerCase()),
);
},
reload: { reload: {
get() { get() {
return this.state.reload; return this.state.reload;
...@@ -123,6 +130,12 @@ export default { ...@@ -123,6 +130,12 @@ export default {
$('#js-add-list').on('hide.bs.dropdown', this.handleDropdownHide); $('#js-add-list').on('hide.bs.dropdown', this.handleDropdownHide);
$('.js-new-board-list-tabs').on('click', this.handleDropdownTabClick); $('.js-new-board-list-tabs').on('click', this.handleDropdownTabClick);
}, },
mounted() {
// prevent dropdown from closing when search box is clicked
$(this.$el)
.find('.dropdown-header')
.on('click', event => event.stopPropagation());
},
methods: { methods: {
showPage(page) { showPage(page) {
this.state.reload = false; this.state.reload = false;
...@@ -207,6 +220,10 @@ export default { ...@@ -207,6 +220,10 @@ export default {
{{ board.name }} <icon name="chevron-down" /> {{ board.name }} <icon name="chevron-down" />
</button> </button>
<div class="dropdown-menu" :class="{ 'is-loading': loading }"> <div class="dropdown-menu" :class="{ 'is-loading': loading }">
<div class="dropdown-header position-relative">
<gl-search-box v-if="!loading" ref="searchBox" v-model="filterTerm" />
</div>
<div class="dropdown-content-faded-mask js-scroll-fade" :class="scrollFadeClass"> <div class="dropdown-content-faded-mask js-scroll-fade" :class="scrollFadeClass">
<ul <ul
v-if="!loading" v-if="!loading"
...@@ -214,7 +231,11 @@ export default { ...@@ -214,7 +231,11 @@ export default {
class="dropdown-list js-dropdown-list" class="dropdown-list js-dropdown-list"
@scroll.passive="throttledSetScrollFade" @scroll.passive="throttledSetScrollFade"
> >
<li v-for="otherBoard in boards" :key="otherBoard.id" class="js-dropdown-item"> <li
v-for="otherBoard in filteredBoards"
:key="otherBoard.id"
class="js-dropdown-item"
>
<a :href="`${boardBaseUrl}/${otherBoard.id}`"> {{ otherBoard.name }} </a> <a :href="`${boardBaseUrl}/${otherBoard.id}`"> {{ otherBoard.name }} </a>
</li> </li>
<li v-if="hasMissingBoards" class="small unclickable"> <li v-if="hasMissingBoards" class="small unclickable">
......
---
title: Add search field to issue board switcher
merge_request: 8862
author:
type: changed
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