feat: let user filter its own extensions (#2774)

This commit is contained in:
Vlad Stan
2024-11-12 15:17:05 +02:00
committed by GitHub
parent fa18170ed7
commit 09b1623bb0
3 changed files with 36 additions and 10 deletions
File diff suppressed because one or more lines are too long
+23 -7
View File
@@ -67,19 +67,34 @@ window.app.component('lnbits-extension-list', {
data: function () {
return {
extensions: [],
user: null
user: null,
userExtensions: [],
searchTerm: ''
}
},
computed: {
userExtensions: function () {
watch: {
searchTerm(term) {
this.userExtensions = this.updateUserExtensions(term)
}
},
methods: {
updateUserExtensions: function (filterBy) {
if (!this.user) return []
var path = window.location.pathname
var userExtensions = this.user.extensions
const path = window.location.pathname
const userExtensions = this.user.extensions
return this.extensions
.filter(function (obj) {
return userExtensions.indexOf(obj.code) !== -1
.filter(function (o) {
return userExtensions.indexOf(o.code) !== -1
})
.filter(function (o) {
if (!filterBy) return true
return (
`${o.code} ${o.name} ${o.short_description} ${o.url}`
.toLocaleLowerCase()
.indexOf(filterBy.toLocaleLowerCase()) !== -1
)
})
.map(function (obj) {
obj.isActive = path.startsWith(obj.url)
@@ -101,6 +116,7 @@ window.app.component('lnbits-extension-list', {
.sort(function (a, b) {
return a.name.localeCompare(b.name)
})
this.userExtensions = this.updateUserExtensions()
} catch (error) {
LNbits.utils.notifyApiError(error)
}