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
This commit is contained in:
parent
96af5fc3a7
commit
c0c26fb98e
4 changed files with 52 additions and 4 deletions
|
|
@ -1,4 +1,36 @@
|
||||||
new Vue({
|
new Vue({
|
||||||
el: '#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]
|
mixins: [windowMixin]
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,23 @@
|
||||||
%} {% block scripts %} {{ window_vars(user) }}
|
%} {% block scripts %} {{ window_vars(user) }}
|
||||||
<script src="/core/static/js/extensions.js"></script>
|
<script src="/core/static/js/extensions.js"></script>
|
||||||
{% endblock %} {% block page %}
|
{% endblock %} {% block page %}
|
||||||
|
<div class="row q-col-gutter-md q-mb-md">
|
||||||
|
<div class="col-sm-3 col-xs-8 q-ml-auto">
|
||||||
|
<q-input v-model="searchTerm" label="Search extensions">
|
||||||
|
<q-icon
|
||||||
|
v-if="searchTerm !== ''"
|
||||||
|
name="close"
|
||||||
|
@click="searchTerm = ''"
|
||||||
|
class="cursor-pointer q-mt-lg"
|
||||||
|
/>
|
||||||
|
</q-input>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row q-col-gutter-md">
|
<div class="row q-col-gutter-md">
|
||||||
<div
|
<div
|
||||||
class="col-6 col-md-4 col-lg-3"
|
class="col-6 col-md-4 col-lg-3"
|
||||||
v-for="extension in g.extensions"
|
v-for="extension in filteredExtensions"
|
||||||
:key="extension.code"
|
:key="extension.code"
|
||||||
>
|
>
|
||||||
<q-card>
|
<q-card>
|
||||||
|
|
|
||||||
|
|
@ -392,7 +392,7 @@ window.windowMixin = {
|
||||||
}
|
}
|
||||||
if (window.extensions) {
|
if (window.extensions) {
|
||||||
var user = this.g.user
|
var user = this.g.user
|
||||||
this.g.extensions = Object.freeze(
|
const extensions = Object.freeze(
|
||||||
window.extensions
|
window.extensions
|
||||||
.map(function (data) {
|
.map(function (data) {
|
||||||
return window.LNbits.map.extension(data)
|
return window.LNbits.map.extension(data)
|
||||||
|
|
@ -413,9 +413,13 @@ window.windowMixin = {
|
||||||
return obj
|
return obj
|
||||||
})
|
})
|
||||||
.sort(function (a, b) {
|
.sort(function (a, b) {
|
||||||
return a.name > b.name
|
const nameA = a.name.toUpperCase()
|
||||||
|
const nameB = b.name.toUpperCase()
|
||||||
|
return nameA < nameB ? -1 : nameA > nameB ? 1 : 0
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
this.g.extensions = extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,6 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
const themes = {{ LNBITS_THEME_OPTIONS | tojson }}
|
const themes = {{ LNBITS_THEME_OPTIONS | tojson }}
|
||||||
const LNBITS_DENOMINATION = {{ LNBITS_DENOMINATION | tojson}}
|
const LNBITS_DENOMINATION = {{ LNBITS_DENOMINATION | tojson}}
|
||||||
console.log(LNBITS_DENOMINATION)
|
|
||||||
if(themes && themes.length) {
|
if(themes && themes.length) {
|
||||||
window.allowedThemes = themes.map(str => str.trim())
|
window.allowedThemes = themes.map(str => str.trim())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue