feat: creditNote => add conditional delete button visibility in credit note table

This commit is contained in:
puriphatt 2025-01-14 09:40:31 +07:00
parent dfa60d9288
commit 506b73eac2
2 changed files with 8 additions and 4 deletions

View file

@ -22,14 +22,12 @@ import useFlowStore from 'src/stores/flow';
import { pageTabs, columns, hslaColors } from './constants'; import { pageTabs, columns, hslaColors } from './constants';
import { CreditNoteStatus, useCreditNote } from 'src/stores/credit-note'; import { CreditNoteStatus, useCreditNote } from 'src/stores/credit-note';
import TableCreditNote from './TableCreditNote.vue'; import TableCreditNote from './TableCreditNote.vue';
import { ref } from 'vue';
import { dialogWarningClose } from 'src/stores/utils'; import { dialogWarningClose } from 'src/stores/utils';
const { t } = useI18n(); const { t } = useI18n();
const flow = useFlowStore(); const flow = useFlowStore();
const navigator = useNavigator(); const navigator = useNavigator();
const creditNote = useCreditNote(); const creditNote = useCreditNote();
const selectedQuotationId = ref<string>('');
const { stats, pageMax, page, data, pageSize } = storeToRefs(creditNote); const { stats, pageMax, page, data, pageSize } = storeToRefs(creditNote);
// NOTE: Variable // NOTE: Variable
@ -346,6 +344,7 @@ watch(
<TableCreditNote <TableCreditNote
:grid="pageState.gridView" :grid="pageState.gridView"
:visible-columns="pageState.fieldSelected" :visible-columns="pageState.fieldSelected"
:hide-delete="pageState.currentTab === CreditNoteStatus.Success"
@view="(v) => navigateTo({ statusDialog: 'info', creditId: v.id })" @view="(v) => navigateTo({ statusDialog: 'info', creditId: v.id })"
@delete="(v) => triggerDelete(v.id)" @delete="(v) => triggerDelete(v.id)"
> >

View file

@ -10,7 +10,11 @@ import KebabAction from 'src/components/shared/KebabAction.vue';
const creditNote = useCreditNote(); const creditNote = useCreditNote();
const { data, page } = storeToRefs(creditNote); const { data, page } = storeToRefs(creditNote);
const prop = defineProps<{ grid: boolean; visibleColumns: string[] }>(); const prop = defineProps<{
grid: boolean;
visibleColumns: string[];
hideDelete: boolean;
}>();
defineEmits<{ (evt: 'view' | 'delete', val: CreditNote): void }>(); defineEmits<{ (evt: 'view' | 'delete', val: CreditNote): void }>();
const visible = computed(() => const visible = computed(() =>
@ -52,7 +56,7 @@ const visible = computed(() =>
} & Omit<Parameters<QTableSlots['body']>[0], 'row'>" } & Omit<Parameters<QTableSlots['body']>[0], 'row'>"
> >
<q-tr :class="{ dark: $q.dark.isActive }" class="text-center"> <q-tr :class="{ dark: $q.dark.isActive }" class="text-center">
<q-td v-for="col in visible" :align="col.align"> <q-td v-for="(col, i) in visible" :align="col.align" :key="i">
<!-- NOTE: custom column will starts with # --> <!-- NOTE: custom column will starts with # -->
<template v-if="!col.name.startsWith('#')"> <template v-if="!col.name.startsWith('#')">
<span v-if="col.name !== 'quotationPayment'"> <span v-if="col.name !== 'quotationPayment'">
@ -72,6 +76,7 @@ const visible = computed(() =>
<KebabAction <KebabAction
hide-edit hide-edit
hide-toggle hide-toggle
:hide-delete
@delete="$emit('delete', props.row)" @delete="$emit('delete', props.row)"
@view="$emit('view', props.row)" @view="$emit('view', props.row)"
/> />