finish UI

This commit is contained in:
2025-01-17 12:41:05 +08:00
parent e65d53f794
commit 8bd3c0a3a3
24 changed files with 952 additions and 48 deletions

View File

@@ -0,0 +1,33 @@
<template>
<div>
<plugin-table-action-icon v-if="canAdd" :is-add="true" title="Add Row" @click="onClick('add')" />
<plugin-table-action-icon v-if="canDelete" :is-add="false" title="Delete this row" @click="onClick('remove')" />
</div>
</template>
<script setup lang="ts">
import { createEmptyJoinTable } from '@/js/helper';
import type { SavedData } from '@/types/model';
import { defineProps, withDefaults, inject } from 'vue';
const props = withDefaults(
defineProps<{
canAdd?: boolean;
canDelete?: boolean;
tableId: number;
}>(),
{
canAdd: true,
canDelete: true,
},
);
const savedData = inject<SavedData>('savedData') as SavedData;
const onClick = (type: 'add' | 'remove') => {
if (type === 'add') {
savedData.joinTables.push(createEmptyJoinTable());
} else if (savedData.joinTables.length > 1) {
savedData.joinTables = savedData.joinTables.filter((t) => t.id !== props.tableId);
}
};
</script>