Make draggable a prop

This commit is contained in:
Samuel Lorch 2023-04-02 02:54:15 +02:00
parent 04a11626f5
commit 8d957a53e2
4 changed files with 6 additions and 5 deletions

View file

@ -16,8 +16,9 @@ const props = defineModel<{
sortBy?: string, sortBy?: string,
sortDesc?: boolean, sortDesc?: boolean,
selection?: number[], selection?: number[],
draggable?: boolean,
}>(); }>();
let { columns, data, sort, sortSelf, sortBy, sortDesc, selection } = $(props); let { columns, data, sort, sortSelf, sortBy, sortDesc, selection, draggable } = $(props);
const emit = defineEmits<{ const emit = defineEmits<{
(event: 'rowAction', index: number): void, (event: 'rowAction', index: number): void,
@ -126,7 +127,7 @@ function dragDropRow() {
</thead> </thead>
<tbody> <tbody>
<tr v-for="(row, index) in displayData" :key="index" <tr v-for="(row, index) in displayData" :key="index"
draggable="true" :draggable="draggable"
@click="() => rowSelection(index)" @click="() => rowSelection(index)"
@dblclick="() => emit('rowAction', index)" @dblclick="() => emit('rowAction', index)"
@dragstart="() => draggedRow = index" @dragstart="() => draggedRow = index"

View file

@ -32,6 +32,6 @@ onMounted(async() => {
<PageHeader title="DNAT Rules"> <PageHeader title="DNAT Rules">
<button @click="loadRules">Load Rules</button> <button @click="loadRules">Load Rules</button>
</PageHeader> </PageHeader>
<NiceTable :columns="columns" v-model:data="rules"/> <NiceTable :columns="columns" v-model:data="rules" draggable="true"/>
</div> </div>
</template> </template>

View file

@ -33,6 +33,6 @@ onMounted(async() => {
<PageHeader title="Forward Rules"> <PageHeader title="Forward Rules">
<button @click="loadRules">Load Rules</button> <button @click="loadRules">Load Rules</button>
</PageHeader> </PageHeader>
<NiceTable :columns="columns" v-model:data="rules"/> <NiceTable :columns="columns" v-model:data="rules" draggable="true"/>
</div> </div>
</template> </template>

View file

@ -32,6 +32,6 @@ onMounted(async() => {
<PageHeader title="SNAT Rules"> <PageHeader title="SNAT Rules">
<button @click="loadRules">Load Rules</button> <button @click="loadRules">Load Rules</button>
</PageHeader> </PageHeader>
<NiceTable :columns="columns" v-model:data="rules"/> <NiceTable :columns="columns" v-model:data="rules" draggable="true"/>
</div> </div>
</template> </template>