lnbits-legend/lnbits/core/static/js/extensions.js
blackcoffeexbt c0c26fb98e
Extension list UI improvements (#769)
* Extensions list is now sorted alphabetically

* Added extension list search

* Prettified changes

* Removed console.log

* Code improvements based on motorina0 feedback

* Remove console.log from lnbits/templates/base.html

Run prettier
2022-07-23 10:46:30 +02:00

37 lines
879 B
JavaScript

new Vue({
el: '#vue',
data: function () {
return {
searchTerm: '',
filteredExtensions: null
}
},
mounted() {
this.filteredExtensions = this.g.extensions
},
watch: {
searchTerm(term) {
// Reset the filter
this.filteredExtensions = this.g.extensions
if (term !== '') {
// Filter the extensions list
function extensionNameContains(searchTerm) {
return function (extension) {
return (
extension.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
extension.shortDescription
.toLowerCase()
.includes(searchTerm.toLowerCase())
)
}
}
this.filteredExtensions = this.filteredExtensions.filter(
extensionNameContains(term)
)
}
}
},
mixins: [windowMixin]
})