mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-11 19:08:20 +00:00
Move Logic out of Table View
This commit is contained in:
parent
234ad792d1
commit
8976d32caf
1 changed files with 5 additions and 18 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const props = defineModel<{
|
const props = defineModel<{
|
||||||
title: string,
|
title: string,
|
||||||
loadData: () => void,
|
loading: boolean,
|
||||||
columns?: {
|
columns?: {
|
||||||
heading: string,
|
heading: string,
|
||||||
path: string,
|
path: string,
|
||||||
|
@ -10,32 +10,19 @@ const props = defineModel<{
|
||||||
}[],
|
}[],
|
||||||
data: Record<string, any>[],
|
data: Record<string, any>[],
|
||||||
tableProps: any,
|
tableProps: any,
|
||||||
|
selection?: number[],
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
let { title, columns, loadData, data, tableProps } = $(props);
|
let { title, columns, loadData, data, selection, tableProps } = $(props);
|
||||||
|
|
||||||
let loading = $ref(true);
|
|
||||||
|
|
||||||
async function load() {
|
|
||||||
console.debug("Start loading...");
|
|
||||||
loading = true;
|
|
||||||
loadData();
|
|
||||||
loading = false;
|
|
||||||
console.debug("Finished loading");
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async() => {
|
|
||||||
load();
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<PageHeader :title="title">
|
<PageHeader :title="title">
|
||||||
<button @click="load">Load</button>
|
<slot/>
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
<div v-if="loading" >Loading...</div>
|
<div v-if="loading" >Loading...</div>
|
||||||
<NiceTable v-else :columns="columns" v-bind="tableProps" :data="data"/>
|
<NiceTable v-else :columns="columns" v-model:selection="selection" v-bind="tableProps" :data="data"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
Loading…
Add table
Reference in a new issue