diff --git a/pinry-spa/src/components/Boards.vue b/pinry-spa/src/components/Boards.vue index e0341cd..8bd64aa 100644 --- a/pinry-spa/src/components/Boards.vue +++ b/pinry-spa/src/components/Boards.vue @@ -118,9 +118,9 @@ export default { BoardEditorUI, }, data: initialData, - props: ['boardUsername'], + props: ['filters'], watch: { - boardUsername() { + filters() { this.reset(); }, }, @@ -206,7 +206,18 @@ export default { return; } this.status.loading = true; - const promise = API.fetchBoardForUser(this.boardUsername, this.status.offset); + let promise; + if (this.filters.boardUsername) { + promise = API.fetchBoardForUser( + this.filters.boardUsername, + this.status.offset, + ); + } else if (this.filters.boardNameContains) { + promise = API.Board.fetchListWhichContains( + this.filters.boardNameContains, + this.status.offset, + ); + } promise.then( (resp) => { const { results, next } = resp.data; diff --git a/pinry-spa/src/components/api.js b/pinry-spa/src/components/api.js index 30d72a2..4d912f0 100644 --- a/pinry-spa/src/components/api.js +++ b/pinry-spa/src/components/api.js @@ -35,6 +35,11 @@ const Board = { const url = `${API_PREFIX}boards-auto-complete/`; return axios.get(url); }, + fetchListWhichContains(text, offset = 0, limit = 50) { + const prefix = `${API_PREFIX}boards/?search=${text}`; + const url = `${prefix}&offset=${offset}&limit=${limit}`; + return axios.get(url); + }, saveChanges(boardId, fieldsForm) { const url = `${API_PREFIX}boards/${boardId}/`; return axios.patch( diff --git a/pinry-spa/src/components/search/SearchPanel.vue b/pinry-spa/src/components/search/SearchPanel.vue index 381c5e9..04f1f1f 100644 --- a/pinry-spa/src/components/search/SearchPanel.vue +++ b/pinry-spa/src/components/search/SearchPanel.vue @@ -3,11 +3,12 @@
- + + +
@@ -35,9 +44,9 @@ export default { selectedOption: [], options: { Tag: [], - Board: [], }, name: '', + boardText: '', selected: null, }; }, @@ -45,12 +54,19 @@ export default { selectOption(filterName) { if (filterName === 'Tag') { this.selectedOption = this.options.Tag; - } else { - this.selectedOption = this.options.Board; } }, }, watch: { + boardText(newVal) { + if (newVal === '') { + return; + } + this.$emit( + 'selected', + { filterType: this.filterType, selected: newVal }, + ); + }, filterType(newVal) { this.selectOption(newVal); }, @@ -75,17 +91,6 @@ export default { }, }, created() { - api.Board.fetchSiteFullList().then( - (resp) => { - const options = []; - resp.data.forEach( - (board) => { - options.push(board.name); - }, - ); - this.options.Board = options; - }, - ); api.Tag.fetchList().then( (resp) => { const options = []; diff --git a/pinry-spa/src/views/Boards4User.vue b/pinry-spa/src/views/Boards4User.vue index 14edc95..93c4f26 100644 --- a/pinry-spa/src/views/Boards4User.vue +++ b/pinry-spa/src/views/Boards4User.vue @@ -1,7 +1,7 @@ @@ -13,7 +13,7 @@ export default { name: 'Boards4User', data() { return { - username: '', + filters: { boardUsername: null }, }; }, components: { @@ -24,12 +24,12 @@ export default { this.initialize(); }, beforeRouteUpdate(to, from, next) { - this.username = to.params.username; + this.filters = { boardUsername: to.params.username }; next(); }, methods: { initialize() { - this.username = this.$route.params.username; + this.filters = { boardUsername: this.$route.params.username }; }, }, }; diff --git a/pinry-spa/src/views/Search.vue b/pinry-spa/src/views/Search.vue index c0f4c83..7f409c3 100644 --- a/pinry-spa/src/views/Search.vue +++ b/pinry-spa/src/views/Search.vue @@ -2,36 +2,40 @@
- - + +