mtinfo/app/js/components/item-list.js

57 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-02-11 11:32:39 +01:00
Vue.component("item-list", {
props: ["modname"],
2021-02-09 18:30:34 +01:00
data: function(){
return {
page: +this.$route.query.page || 1
};
},
watch: {
$route: function(){
this.page = +this.$route.query.page || 1;
}
},
2021-02-09 17:54:11 +01:00
computed: {
list: function(){
return Object.keys(mtinfo.items)
.filter(nodename => {
const parts = nodename.split(":");
if (this.modname){
return this.modname === parts[0];
}
return true;
})
.map(nodename => {
return mtinfo.items[nodename];
});
2021-02-09 17:54:11 +01:00
}
},
2021-01-16 21:03:43 +01:00
template: /*html*/`
<div>
2021-02-11 11:32:39 +01:00
<h4>Item list</h4>
2021-02-09 18:30:34 +01:00
<paged-table v-bind:list="list" v-bind:page="page">
2021-02-09 17:54:11 +01:00
<template v-slot:header>
2021-02-09 18:30:34 +01:00
<th>Mod</th>
<th>Type</th>
2021-02-09 18:30:34 +01:00
<th>Image</th>
<th>Nodename</th>
2021-02-09 17:54:11 +01:00
</template>
<template v-slot:row="{ item }">
<td>{{ item.name.substring(0, item.name.indexOf(":")) }}</td>
<td>
<span class="badge badge-secondary">{{ item.type }}</span>
</td>
2021-02-09 17:54:11 +01:00
<td>
2021-02-11 11:32:39 +01:00
<item-preview :item="item" size="32"/>
2021-02-09 17:54:11 +01:00
</td>
<td>
2021-02-11 11:32:39 +01:00
<router-link :to="'/items/' + item.name">
2021-02-09 17:54:11 +01:00
{{ item.name }}
</router-link>
</td>
</template>
</paged-table>
2021-01-16 21:03:43 +01:00
</div>
`
});