fix: history search
This commit is contained in:
@@ -28,10 +28,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<details
|
<details
|
||||||
v-for="(filteredHistoryGroup, filteredHistoryGroupIndex) in groupByDate(
|
v-for="(
|
||||||
filteredHistory,
|
filteredHistoryGroup, filteredHistoryGroupIndex
|
||||||
'updatedOn'
|
) in filteredHistoryGroups"
|
||||||
)"
|
|
||||||
:key="`filteredHistoryGroup-${filteredHistoryGroupIndex}`"
|
:key="`filteredHistoryGroup-${filteredHistoryGroupIndex}`"
|
||||||
class="flex flex-col"
|
class="flex flex-col"
|
||||||
open
|
open
|
||||||
@@ -146,24 +145,28 @@ const history = useReadonlyStream<RESTHistoryEntry[] | GQLHistoryEntry[]>(
|
|||||||
)
|
)
|
||||||
|
|
||||||
const filteredHistory = computed(() => {
|
const filteredHistory = computed(() => {
|
||||||
const filteringHistory = history as any as Array<
|
const regExp = new RegExp(filterText.value, "gi")
|
||||||
RESTHistoryEntry | GQLHistoryEntry
|
const check = (obj: any) => {
|
||||||
>
|
if (obj !== null && typeof obj === "object") {
|
||||||
|
return Object.values(obj).some(check)
|
||||||
return filteringHistory.value.filter(
|
|
||||||
(entry: RESTHistoryEntry | GQLHistoryEntry) => {
|
|
||||||
return Object.keys(entry).some((key) => {
|
|
||||||
let value = entry[key as keyof typeof entry]
|
|
||||||
if (value) {
|
|
||||||
value = `${value}`
|
|
||||||
return value.toLowerCase().includes(filterText.value.toLowerCase())
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
if (Array.isArray(obj)) {
|
||||||
|
return obj.some(check)
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
(typeof obj === "string" || typeof obj === "number") &&
|
||||||
|
regExp.test(obj as string)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return (history.value as Array<RESTHistoryEntry | GQLHistoryEntry>).filter(
|
||||||
|
check
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const filteredHistoryGroups = computed(() =>
|
||||||
|
groupByDate(filteredHistory.value, "updatedOn")
|
||||||
|
)
|
||||||
|
|
||||||
const clearHistory = () => {
|
const clearHistory = () => {
|
||||||
if (props.page === "rest") clearRESTHistory()
|
if (props.page === "rest") clearRESTHistory()
|
||||||
else clearGraphqlHistory()
|
else clearGraphqlHistory()
|
||||||
|
|||||||
Reference in New Issue
Block a user