refactor: kebab action

This commit is contained in:
puriphatt 2024-08-27 11:46:26 +07:00
parent 5ec6d1c9d5
commit bc578d569c
11 changed files with 518 additions and 1357 deletions

View file

@ -65,7 +65,7 @@ import FormEmployeeWorkHistory from 'components/03_customer-management/FormEmplo
import FormEmployeeOther from 'components/03_customer-management/FormEmployeeOther.vue';
import useOptionStore from 'stores/options';
import { DialogContainer, DialogHeader } from 'components/dialog';
import ToggleButton from 'src/components/button/ToggleButton.vue';
import KebabAction from 'src/components/shared/KebabAction.vue';
const { t, locale } = useI18n();
const $q = useQuasar();
@ -267,10 +267,10 @@ function deleteCustomerById(id: string) {
dialog({
color: 'negative',
icon: 'mdi-alert',
title: t('deleteConfirmTitle'),
actionText: t('ok'),
title: t('dialog.title.confirmDelete'),
actionText: t('general.delete'),
persistent: true,
message: t('deleteConfirmMessage'),
message: t('dialog.message.confirmDelete'),
action: async () => {
await customerStore.deleteById(id);
@ -287,10 +287,10 @@ async function deleteCustomerBranchById(id: string) {
dialog({
color: 'negative',
icon: 'mdi-alert',
title: t('deleteConfirmTitle'),
actionText: t('ok'),
title: t('dialog.title.confirmDelete'),
actionText: t('general.delete'),
persistent: true,
message: t('deleteConfirmMessage'),
message: t('dialog.message.confirmDelete'),
action: async () => {
await customerStore.deleteBranchById(id);
flowStore.rotate();
@ -385,13 +385,13 @@ async function triggerChangeStatus(id: string, status: string) {
color: status !== 'INACTIVE' ? 'warning' : 'info',
icon:
status !== 'INACTIVE' ? 'mdi-alert' : 'mdi-message-processing-outline',
title: t('confirmChangeStatusTitle'),
title: t('dialog.title.confirmChangeStatus'),
actionText:
status !== 'INACTIVE' ? t('switchOffLabel') : t('switchOnLabel'),
status !== 'INACTIVE' ? t('general.close') : t('general.open'),
message:
status !== 'INACTIVE'
? t('confirmChangeStatusOffMessage')
: t('confirmChangeStatusOnMessage'),
? t('dialog.message.confirmChangeStatusOff')
: t('dialog.message.confirmChangeStatusOn'),
action: async () => {
if (currentTab.value === 'employee') {
await toggleStatusEmployee(id, status === 'INACTIVE' ? false : true)
@ -428,10 +428,10 @@ async function deleteEmployeeById(opts: {
dialog({
color: 'negative',
icon: 'mdi-alert',
title: t('deleteConfirmTitle'),
actionText: t('ok'),
title: t('dialog.title.confirmDelete'),
actionText: t('general.delete'),
persistent: true,
message: t('deleteConfirmMessage'),
message: t('dialog.message.confirmDelete'),
action: async () => {
if (opts.type === 'healthCheck') {
await employeeFormStore.deleteHealthCheck();
@ -1172,130 +1172,33 @@ const emptyCreateDialog = ref(false);
@click.stop="editCustomerForm(props.row.id)"
/>
<q-btn
icon="mdi-dots-vertical"
:id="`btn-dots-${props.row.code}`"
size="sm"
dense
round
flat
@click.stop
:key="props.row.id"
>
<q-menu class="bordered">
<q-list v-close-popup>
<q-item
:id="`view-detail-btn-${props.row.name}-view`"
@click.stop="
() => {
const { branch, ...payload } = props.row;
currentCustomer = payload;
editCustomerForm(props.row.id);
}
"
v-close-popup
clickable
dense
class="row q-py-sm"
style="white-space: nowrap"
>
<q-icon
name="mdi-eye-outline"
class="col-3"
size="xs"
style="color: hsl(var(--green-6-hsl))"
/>
<span class="col-9 q-px-md flex items-center">
{{ $t('general.viewDetail') }}
</span>
</q-item>
<q-item
:id="`view-detail-btn-${props.row.name}-edit`"
v-close-popup
clickable
dense
class="row q-py-sm"
style="white-space: nowrap"
@click="
async () => {
await editCustomerForm(props.row.id);
customerFormState.dialogType = 'edit';
customerFormState.readonly = false;
}
"
>
<q-icon
name="mdi-pencil-outline"
class="col-3"
size="xs"
style="color: hsl(var(--cyan-6-hsl))"
/>
<span class="col-9 q-px-md flex items-center">
{{ $t('general.edit') }}
</span>
</q-item>
<q-item
:id="`view-detail-btn-${props.row.name}-delete`"
dense
v-close-popup
:clickable="props.row.status === 'CREATED'"
class="row"
:class="{
'surface-3': props.row.status !== 'CREATED',
'app-text-muted':
props.row.status !== 'CREATED',
}"
style="white-space: nowrap"
@click="deleteCustomerById(props.row.id)"
>
<q-icon
name="mdi-trash-can-outline"
size="xs"
class="col-3"
:class="{
'app-text-negative':
props.row.status === 'CREATED',
}"
/>
<span class="col-9 q-px-md flex items-center">
{{ $t('general.delete') }}
</span>
</q-item>
<q-item dense>
<q-item-section class="q-py-sm">
<div
class="q-pa-sm surface-2 rounded flex items-center"
>
<ToggleButton
:id="`view-detail-btn-${props.row.name}-status`"
two-way
:model-value="
props.row.status !== 'INACTIVE'
"
@click="
async () => {
triggerChangeStatus(
props.row.id,
props.row.status,
);
}
"
/>
<span class="q-pl-md">
{{
props.row.status !== 'INACTIVE'
? $t('general.open')
: $t('general.close')
}}
</span>
</div>
</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
<KebabAction
:id-name="props.row.code"
:status="props.row.status"
@view="
() => {
const { branch, ...payload } = props.row;
currentCustomer = payload;
editCustomerForm(props.row.id);
}
"
@edit="
async () => {
await editCustomerForm(props.row.id);
customerFormState.dialogType = 'edit';
customerFormState.readonly = false;
}
"
@delete="deleteCustomerById(props.row.id)"
@change-status="
async () => {
triggerChangeStatus(
props.row.id,
props.row.status,
);
}
"
/>
</q-td>
</q-tr>
@ -1315,12 +1218,25 @@ const emptyCreateDialog = ref(false);
@view="
(item: any) => {
employeeFormState.drawerModal = true;
//employeeFormState.isEmployeeEdit = true;
employeeFormState.isEmployeeEdit = false;
employeeFormStore.assignFormDataEmployee(
item.id,
);
}
"
@edit="
(item: any) => editEmployeeFormPersonal(item.id)
"
@delete="
(item: any) => {
deleteEmployeeById({ id: item.id });
}
"
@toggle-status="
async (item: any) => {
triggerChangeStatus(item.id, item.status);
}
"
/>
</div>
</q-td>