Skip to content

Commit

Permalink
Update tag sidebar and admin tags (#930)
Browse files Browse the repository at this point in the history
* add filter for fetch sidebar tags

* update admin tags fetch filter

* fetch tags by avaliable categories
  • Loading branch information
zhendi authored Feb 8, 2025
1 parent 07a6cf5 commit 7f688fd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
19 changes: 16 additions & 3 deletions frontend/src/components/admin_next/tags/AdminTagsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,23 @@
const fetchtags = async (current) => {
loading.value = true
const params = new URLSearchParams({
page: current || page.value,
per: per.value
});
if (keyword.value) {
params.append('category', keyword.value);
}
if (scope.value) {
params.append('scope', scope.value);
}
const { data, error } = await useFetchApi(
`/tags?page=${current || page.value}&per=${per.value}&category=${
keyword.value
}&scope=${scope.value || ''}`
`/tags?${params.toString()}`
).json()
if (data.value) {
tags.value = data.value.data
total.value = data.value.data?.length || 0
Expand All @@ -250,6 +262,7 @@
page.value = 1
loading.value = false
}
const deleteTag = async (tag) => {
const { data, error } = await useFetchApi(`/tags/${tag.id}`, {
method: 'DELETE'
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/components/tags/TagSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</div>
</template>

<script setup lang="ts">
<script setup>
import { ref, onMounted, computed, watch } from 'vue'
import TagList from './TagList.vue'
import useFetchApi from '../../packs/useFetchApi'
Expand Down Expand Up @@ -115,7 +115,14 @@
}
async function fetchTags() {
const { error, data } = await useFetchApi(`/tags`).json()
const params = new URLSearchParams({
scope: props.repoType,
built_in: true
})
avaliableCategories.value.forEach((category) => {
params.append('category', category.name)
})
const { error, data } = await useFetchApi(`/tags?${params.toString()}`).json()
if (!data.value) {
ElMessage({
message: error.value.msg || t('all.fetchError'),
Expand Down

0 comments on commit 7f688fd

Please sign in to comment.