Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,7 @@
"search-by-version": "Search by version",
"search-channels": "Search channel",
"search-groups": "Search groups",
"search-scope-items": "Search scopes",
"search-members": "Search members",
"search-organizations": "Search organizations",
"search-role-bindings": "Search by user, group or role...",
Expand Down
16 changes: 10 additions & 6 deletions src/components/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface Props {
isLoading?: boolean
filterText?: string
filters?: { [key: string]: boolean }
filterLabels?: { [key: string]: string }
searchPlaceholder?: string
showAdd?: boolean
addButtonTestId?: string
Expand Down Expand Up @@ -94,6 +95,10 @@ const filterActivated = computed(() => {
}, 0)
})

function getFilterLabel(filter: string) {
return props.filterLabels?.[filter] ?? t(filter)
}

function sortClick(key: number) {
if (!props.columns[key].sortable)
return
Expand Down Expand Up @@ -125,10 +130,10 @@ function updateUrlParams() {
params.set('search', searchVal.value)
else params.delete('search')
if (props.filters) {
params.delete('filter')
Object.entries(props.filters).forEach(([key, value]) => {
if (value)
params.append('filter', key)
else params.delete('filter', key)
})
}
if (props.currentPage)
Expand Down Expand Up @@ -172,7 +177,6 @@ function loadFromUrlParams() {
newFilters[key] = filterParams.includes(key)
})
if (JSON.stringify(newFilters) !== JSON.stringify(props.filters)) {
console.log('update filters', newFilters, props.filters)
emit('update:filters', newFilters)
}
}
Expand Down Expand Up @@ -497,10 +501,10 @@ const paginationClass = computed(() => props.mobileFixedPagination
<span class="hidden md:block">{{ t(filterText) }}</span>
<IconDown class="hidden w-4 h-4 ml-2 md:block" />
</button>
<ul class="p-2 bg-white shadow w-52 d-dropdown-content d-menu rounded-box z-1 dark:bg-base-200">
<ul class="max-h-80 w-72 max-w-[calc(100vw-2rem)] overflow-y-auto border border-gray-200 bg-white p-2 shadow-xl d-dropdown-content d-menu rounded-box z-20 dark:border-gray-700 dark:bg-base-200">
<li v-for="(f, i) in filterList" :key="i">
<div
class="flex items-center p-2 rounded-sm cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600"
class="flex min-h-10 items-center rounded-md p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600"
>
<input
:id="`filter-radio-example-${i}`" :checked="filters?.[f]" type="checkbox"
Expand All @@ -512,9 +516,9 @@ const paginationClass = computed(() => props.mobileFixedPagination
>
<label
:for="`filter-radio-example-${i}`"
class="w-full ml-2 text-sm font-medium text-gray-900 rounded-sm cursor-pointer dark:text-gray-300 first-letter:uppercase"
class="w-full min-w-0 truncate ml-2 text-sm font-medium text-gray-900 rounded-sm cursor-pointer dark:text-gray-300"
>{{
t(f) }}</label>
getFilterLabel(f) }}</label>
</div>
</li>
</ul>
Expand Down
Loading
Loading