diff --git a/application/controllers/api/frontend/v1/Bookmark.php b/application/controllers/api/frontend/v1/Bookmark.php index e152907b3..84c5406a9 100644 --- a/application/controllers/api/frontend/v1/Bookmark.php +++ b/application/controllers/api/frontend/v1/Bookmark.php @@ -31,8 +31,7 @@ class Bookmark extends FHCAPI_Controller 'delete' => self::PERM_LOGGED, 'insert' => self::PERM_LOGGED, 'update' => self::PERM_LOGGED, - 'changeOrder' => self::PERM_LOGGED, - 'getAllBookmarkTags' => self::PERM_LOGGED, + 'changeOrder' => self::PERM_LOGGED ]); $this->load->model('dashboard/Bookmark_model', 'BookmarkModel'); @@ -169,20 +168,5 @@ class Bookmark extends FHCAPI_Controller $this->terminateWithSuccess($update_result); } - - /** - * get all the bookmark tags associated to a user - * @access public - * @return void - */ - public function getAllBookmarkTags() - { - $this->BookmarkModel->addOrder("sort"); - $result = $this->BookmarkModel->getAllBookmarkTags($this->uid); - - $bookmarks = $this->getDataOrTerminateWithError($result); - - $this->terminateWithSuccess(current($bookmarks)); - } } diff --git a/application/models/dashboard/Bookmark_model.php b/application/models/dashboard/Bookmark_model.php index 8c70faf04..d9756294e 100644 --- a/application/models/dashboard/Bookmark_model.php +++ b/application/models/dashboard/Bookmark_model.php @@ -11,21 +11,4 @@ class Bookmark_model extends DB_Model $this->dbTable = 'dashboard.tbl_bookmark'; $this->pk = 'bookmark_id'; } - - /** - * returns all bookmark tags of a user - */ - public function getAllBookmarkTags($uid) - { - $qry = " - SELECT array_agg(DISTINCT tag) AS data - FROM ( - SELECT jsonb_array_elements_text(tag) AS tag - FROM dashboard.tbl_bookmark - WHERE uid = ? - ) t; - "; - - return $this->execQuery($qry, array('uid' => $uid)); - } } diff --git a/public/js/api/factory/widget/bookmark.js b/public/js/api/factory/widget/bookmark.js index 3f034fee6..2035a9f8f 100644 --- a/public/js/api/factory/widget/bookmark.js +++ b/public/js/api/factory/widget/bookmark.js @@ -48,11 +48,5 @@ export default { method: 'post', url: `/api/frontend/v1/Bookmark/changeOrder/${bookmark_id1}/${bookmark_id2}`, }; - }, - getAllBookmarkTags() { - return { - method: 'get', - url: '/api/frontend/v1/Bookmark/getAllBookmarkTags' - }; } }; \ No newline at end of file diff --git a/public/js/components/DashboardWidget/Url.js b/public/js/components/DashboardWidget/Url.js index 631f75022..38dad5ce7 100644 --- a/public/js/components/DashboardWidget/Url.js +++ b/public/js/components/DashboardWidget/Url.js @@ -31,7 +31,6 @@ export default { invalidURL: false, invalidTitel: false, }, - tagsArrayAC: [], selectedTags: [], newTag: null, selectedFilters: [], @@ -40,6 +39,12 @@ export default { sharedFiltered: {}, }), computed: { + availableTags() { + return (this.shared || []) + .map(bookmark => JSON.parse(bookmark.tag)) + .flat() + .filter((v, i, a) => v && a.indexOf(v) === i); + }, tagName() { return this.config.tag !== undefined && this.config.tag.length > 0 ? this.config.tag @@ -106,7 +111,6 @@ export default { .then((result) => { this.$fhcAlert.alertInfo(this.$p.t("bookmark", "bookmarkUpdated")); // refetch the bookmarks to see the updates - this.getAllBookmarkTags(); this.fetchBookmarks(); // reset the values for the title and url inputs this.clearInputs(); @@ -141,7 +145,6 @@ export default { .then((result) => { this.$fhcAlert.alertInfo(this.$p.t("bookmark", "bookmarkAdded")); // refetch the bookmarks to see the updates - this.getAllBookmarkTags(); this.fetchBookmarks(); this.$refs.createModal.hide(); // reset the values for the title and url inputs @@ -188,7 +191,6 @@ export default { this.$fhcAlert.alertInfo(this.$p.t("bookmark", "bookmarkDeleted")); // refetch the bookmarks to see the updates this.fetchBookmarks(); - this.getAllBookmarkTags(); }) .catch(this.$fhcAlert.handleSystemError); }, @@ -263,16 +265,6 @@ export default { return result; }, - getAllBookmarkTags(){ - this.$api - .call(ApiBookmark.getAllBookmarkTags()) - .then((res) => res.data) - .then((result) => { - //Version Autocomplete - this.tagsArrayAC = result.data; - }) - .catch(this.$fhcAlert.handleSystemError); - }, openFilterModal() { if (this.config.tags && this.config.tags.length) this.selectedFilters = [ ...this.config.tags ]; @@ -291,7 +283,7 @@ export default { const query = event.query ?? ""; // Filter for text - this.filteredArray = this.tagsArrayAC.filter(item => + this.filteredArray = this.availableTags.filter(item => item.toLowerCase().includes(query.toLowerCase()) ); @@ -303,7 +295,6 @@ export default { }, async mounted() { await this.fetchBookmarks(); - this.getAllBookmarkTags(); }, created() { // this.$emit('setConfig', true); // -> use this to enable widget config mode if needed @@ -532,7 +523,7 @@ export default {