make tagsArrayAC a computed and rename it to availableTags

This commit is contained in:
chfhtw
2026-04-27 10:03:36 +02:00
parent 9109ead81c
commit dfe05cbfa8
4 changed files with 9 additions and 57 deletions
@@ -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));
}
}
@@ -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));
}
}
-6
View File
@@ -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'
};
}
};
+8 -17
View File
@@ -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 {
<PvMultiSelect
v-model="selectedFilters"
id="tagFilterUrl"
:options="tagsArrayAC"
:options="availableTags"
display="chip"
:placeholder="$p.t('bookmark', 'noFilter')"
:maxSelectedLabels="3"