From c7d350423bf616704e1efba787c5489afcf5e6f8 Mon Sep 17 00:00:00 2001 From: winkidney Date: Tue, 10 Dec 2019 20:45:19 +0800 Subject: [PATCH] Feature: Move tag-input top of description and add tag-auto-complete --- pinry-spa/src/components/api.js | 8 +++ .../components/pin_edit/PinCreateModal.vue | 49 ++++++++++++++++--- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/pinry-spa/src/components/api.js b/pinry-spa/src/components/api.js index b926e7f..9157d17 100644 --- a/pinry-spa/src/components/api.js +++ b/pinry-spa/src/components/api.js @@ -258,7 +258,15 @@ const User = { }, }; +const Tag = { + fetchList() { + const url = `${API_PREFIX}tags-auto-complete/`; + return axios.get(url); + }, +}; + export default { + Tag, Pin, Board, fetchPin, diff --git a/pinry-spa/src/components/pin_edit/PinCreateModal.vue b/pinry-spa/src/components/pin_edit/PinCreateModal.vue index 4f9b307..4b27bf7 100644 --- a/pinry-spa/src/components/pin_edit/PinCreateModal.vue +++ b/pinry-spa/src/components/pin_edit/PinCreateModal.vue @@ -38,6 +38,24 @@ > + + + + + + @@ -49,14 +67,6 @@ > - - - -
{ + this.tagOptions = resp.data; + }, + ); + }, + getFilteredTags(text) { + const filteredTagOptions = []; + AutoComplete.getFilteredOptions( + this.tagOptions, + text, + ).forEach( + (option) => { + filteredTagOptions.push(option.name); + }, + ); + this.editorMeta.filteredTagOptions = filteredTagOptions; + }, fetchBoardList() { API.Board.fetchFullList(this.username).then( (resp) => {