Enhance board selector

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2020-05-15 09:06:25 +02:00
parent 55f31d74ae
commit b707ad0536

View File

@@ -24,6 +24,7 @@
<Modal @close="close"> <Modal @close="close">
<div id="modal-inner" :class="{ 'icon-loading': loading }"> <div id="modal-inner" :class="{ 'icon-loading': loading }">
<h1>{{ t('deck', 'Select the board to link to a project') }}</h1> <h1>{{ t('deck', 'Select the board to link to a project') }}</h1>
<input v-model="filter" type="text" :placeholder="t('deck', 'Search by board title')">
<ul v-if="!loading"> <ul v-if="!loading">
<li v-for="board in availableBoards" <li v-for="board in availableBoards"
:key="board.id" :key="board.id"
@@ -46,8 +47,15 @@
padding: 20px; padding: 20px;
} }
input {
width: 100%;
margin-bottom: 15px;
}
ul { ul {
min-height: 100px; min-height: 50vh;
max-height: 300px;
overflow: scroll;
} }
li { li {
@@ -90,6 +98,7 @@ export default {
}, },
data() { data() {
return { return {
filter: '',
boards: [], boards: [],
selectedBoard: null, selectedBoard: null,
loading: true, loading: true,
@@ -98,12 +107,16 @@ export default {
}, },
computed: { computed: {
availableBoards() { availableBoards() {
return this.boards.filter((board) => ('' + board.id !== '' + this.currentBoard)) return this.boards.filter((board) => (
'' + board.id !== '' + this.currentBoard
&& board.title.match(this.filter)
))
}, },
}, },
beforeMount() { beforeMount() {
this.fetchBoards() this.fetchBoards()
this.currentBoard = window.location.hash.match(/\/boards\/([0-9]+)/)[1] || null const hash = window.location.hash.match(/\/boards\/([0-9]+)/)
this.currentBoard = hash.length > 0 ? hash[1] : null
}, },
methods: { methods: {
fetchBoards() { fetchBoards() {