feat: refs #8224 add value action

This commit is contained in:
William Buezas 2024-12-12 09:36:59 -03:00
parent 395402fce0
commit af8b0b48d0
4 changed files with 21 additions and 14 deletions

View File

@ -1,5 +1,5 @@
<script setup>
import { computed } from 'vue';
import { computed, onMounted } from 'vue';
import { useArrayData } from 'composables/useArrayData';
import { buildFilter } from 'filters/filterPanel';
@ -38,9 +38,6 @@ const isFilterAllowed = computed(() => contextMenuProps.value.filterEnabled);
const isActionAllowed = computed(() => contextMenuProps.value.actionEnabled);
const fieldName = computed(() => $props.tableCol.name);
const fieldValue = computed(() => $props.tableRow[fieldName.value]);
const copyValueField = computed(
() => contextMenuProps.value.copyValueField || fieldName.value
);
const menuItems = computed(() => {
// If item does not have type, it will be displayed
@ -153,7 +150,8 @@ const removeAllFilters = () => {
* value to the clipboard
*/
const copyValue = () => {
navigator.clipboard.writeText($props.tableRow[copyValueField.value]);
if ($props.tableCol?.format)
navigator.clipboard.writeText($props.tableCol?.format($props.tableRow));
};
const menuActions = {
@ -163,6 +161,12 @@ const menuActions = {
removeAllFilters: () => removeAllFilters(),
copyValue: () => copyValue(),
};
onMounted(() => {
console.log('row data', $props.tableRow);
console.log('col data', $props.tableCol);
console.log('test: ', $props.tableCol.format($props.tableRow));
});
</script>
<template>

View File

@ -1,9 +1,9 @@
import { useI18n } from 'vue-i18n';
import { i18n } from 'src/boot/i18n';
export default function (value, symbol = 'EUR', fractionSize = 2) {
if (value == null || value === '') value = 0;
const { locale } = useI18n();
const locale = i18n.global?.locale?.value;
const options = {
style: 'currency',

View File

@ -1,4 +1,4 @@
import { useI18n } from 'vue-i18n';
import { i18n } from 'src/boot/i18n';
export default function (value, options = {}) {
if (!value) return;
@ -9,8 +9,7 @@ export default function (value, options = {}) {
options.year = 'numeric';
}
const { locale } = useI18n();
const date = new Date(value);
const locale = i18n.global?.locale?.value;
return new Intl.DateTimeFormat(locale.value, options).format(date);
}

View File

@ -149,6 +149,7 @@ const columns = computed(() => [
filterEnabled: true,
actionEnabled: true,
},
format: (row) => row.id,
},
{
align: 'left',
@ -172,7 +173,7 @@ const columns = computed(() => [
actionEnabled: true,
copyValueField: 'salesPerson',
},
format: (row, dashIfEmpty) => dashIfEmpty(row.salesPerson),
format: (row) => dashIfEmpty(row.salesPerson),
},
{
align: 'left',
@ -211,7 +212,7 @@ const columns = computed(() => [
filterEnabled: true,
actionEnabled: true,
},
format: (row, dashIfEmpty) => dashIfEmpty(toTimeFormat(row.zoneLanding)),
format: (row) => dashIfEmpty(toTimeFormat(row.zoneLanding)),
},
{
align: 'left',
@ -223,6 +224,7 @@ const columns = computed(() => [
filterEnabled: true,
actionEnabled: true,
},
format: (row) => row.nickname,
},
{
align: 'left',
@ -234,6 +236,7 @@ const columns = computed(() => [
filterEnabled: false,
actionEnabled: true,
},
format: (row) => row.addressNickname,
},
{
align: 'left',
@ -265,6 +268,7 @@ const columns = computed(() => [
filterEnabled: true,
actionEnabled: true,
},
format: (row) => row.state,
},
{
align: 'left',
@ -285,7 +289,7 @@ const columns = computed(() => [
filterEnabled: true,
actionEnabled: true,
},
format: (row, dashIfEmpty) => dashIfEmpty(row.zoneName),
format: (row) => dashIfEmpty(row.zoneName),
},
{
align: 'left',
@ -324,7 +328,7 @@ const columns = computed(() => [
filterEnabled: false,
actionEnabled: false,
},
format: (row, dashIfEmpty) => dashIfEmpty(row.packing),
format: (row) => dashIfEmpty(row.packing),
},
{
align: 'right',