lifeto-shop/src/components/CharacterInventory.vue

52 lines
1.6 KiB
Vue
Raw Normal View History

2022-07-01 01:27:18 +00:00
<template>
2022-07-03 10:25:12 +00:00
<HotTable
2022-07-01 01:27:18 +00:00
ref="hotTableComponent"
2022-07-03 10:25:12 +00:00
:settings="DefaultSettings()"
></HotTable>
2022-07-01 01:27:18 +00:00
</template>
2022-07-03 10:25:12 +00:00
<script lang="ts" setup>
import { ref } from 'vue';
import { HotTable, HotColumn } from '@handsontable/vue3';
2022-07-01 01:27:18 +00:00
2022-07-03 10:25:12 +00:00
const session = storage.GetSession()
const api:LTOApi = new LTOApiv0(session)
const {invs, activeTable, columns, tags} = useStoreRef()
const hotTableComponent = ref<any>(null)
const updateTable = () => {
if (invs.value.has(activeTable.value)) {
const chardat = invs.value.get(activeTable.value)
if (chardat) {
const it = new InventoryTable(chardat!, { columns: columns.value, tags: tags.value })
const hot = (hotTableComponent.value.hotInstance as Handsontable)
const build = it.BuildTable()
hot.updateSettings(build.settings)
hot.updateData(build.data)
}
}
}
2022-07-01 01:27:18 +00:00
// register Handsontable's modules
registerAllModules();
2022-07-03 10:25:12 +00:00
watch([columns.value.dirty,tags.value.dirty, activeTable], () => {
updateTable()
})
2022-07-01 01:27:18 +00:00
</script>
2022-07-03 10:25:12 +00:00
<script lang="ts">
import { defineComponent, computed, PropType, defineProps, defineEmits, watch} from 'vue';
import { registerAllModules } from 'handsontable/registry';
import { DefaultSettings, InventoryTable, TableRecipe } from '../lib/table';
import { Columns, ColumnByNames, ColumnInfo } from '../lib/columns';
import { TricksterItem, SampleData } from '../lib/trickster';
import Handsontable from 'handsontable';
import { useStoreRef } from '../state/state';
import { storage } from '../session_storage';
import { LTOApi, LTOApiv0 } from '../lib/lifeto';
</script>
<style src="handsontable/dist/handsontable.full.css">
</style>