aboutsummaryrefslogtreecommitdiff
path: root/src-vue/src/views/mods/LocalModsView.vue
blob: 38f7a9140f394960bdc54fbc95e6b32ceb991fe4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<template>
    <!-- Message displayed if no mod matched searched words -->
    <div v-if="mods.length === 0" class="noModMessage">
        {{ $t('mods.local.no_mods') }}
    </div>

    <el-scrollbar v-else>
        <local-mod-card v-for="mod of mods" v-bind:key="mod.name" :mod="mod" />
    </el-scrollbar>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import { NorthstarMod } from "../../../../src-tauri/bindings/NorthstarMod";
import { fuzzy_filter } from "../../utils/filter";
import LocalModCard from "../../components/LocalModCard.vue";

export default defineComponent({
    name: 'LocalModsView',
    components: { LocalModCard },
    computed: {
        installedMods(): NorthstarMod[] {
            return this.$store.state.installed_mods;
        },
        searchValue(): string {
            return this.$store.getters.searchWords;
        },
        mods(): NorthstarMod[] {
            if (this.searchValue.length === 0) {
                return this.installedMods;
            }

            return this.installedMods.filter((mod: NorthstarMod) => {
                return fuzzy_filter(mod.name, this.searchValue);
            });
        }
    },
    data() {
        return {
            global_load_indicator: false,
        };
    },
    methods: {
    },
    mounted() {
        this.$store.commit('loadInstalledMods');
    }
})
</script>

<style scoped>

</style>