mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-20 22:22:16 +01:00
Add "Date" grouping option to reporting
This commit is contained in:
committed by
Gregor Vostrak
parent
de13c07855
commit
111e12df12
@@ -116,25 +116,43 @@ const subGroup = computed(() => {
|
||||
}
|
||||
return 'project';
|
||||
});
|
||||
const { emptyPlaceholder } = useReportingStore();
|
||||
const { emptyPlaceholder, getNameForReportingRowEntry } = useReportingStore();
|
||||
|
||||
/**
|
||||
* The public report endpoint has no descriptor for time group types, so their labels are
|
||||
* derived from the raw group key.
|
||||
*/
|
||||
function resolveLabel(
|
||||
description: string | null | undefined,
|
||||
key: string | null | undefined,
|
||||
groupedType: string
|
||||
) {
|
||||
if (description !== null && description !== undefined) {
|
||||
return description;
|
||||
}
|
||||
return (
|
||||
getNameForReportingRowEntry(key ?? null, groupedType, reportDateFormat.value) ??
|
||||
emptyPlaceholder[groupedType] ??
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
const groupedPieChartData = computed(() => {
|
||||
return (
|
||||
aggregatedTableTimeEntries.value?.grouped_data?.map((entry) => {
|
||||
if (entry.description === null) {
|
||||
const groupedType = aggregatedTableTimeEntries.value?.grouped_type ?? 'project';
|
||||
const name = resolveLabel(entry.description, entry.key, groupedType);
|
||||
if (name === emptyPlaceholder[groupedType]) {
|
||||
return {
|
||||
value: entry.seconds,
|
||||
name:
|
||||
emptyPlaceholder[
|
||||
aggregatedTableTimeEntries.value?.grouped_type ?? 'project'
|
||||
] ?? '',
|
||||
name: name,
|
||||
color: '#CCCCCC',
|
||||
};
|
||||
}
|
||||
return {
|
||||
value: entry.seconds,
|
||||
name: entry.description,
|
||||
color: entry.color ?? getRandomColorWithSeed(entry.description ?? 'none'),
|
||||
name: name,
|
||||
color: entry.color ?? getRandomColorWithSeed(name),
|
||||
};
|
||||
}) ?? []
|
||||
);
|
||||
@@ -143,21 +161,25 @@ const groupedPieChartData = computed(() => {
|
||||
const tableData = computed(() => {
|
||||
return aggregatedTableTimeEntries.value?.grouped_data?.map((entry) => {
|
||||
return {
|
||||
key: entry.key,
|
||||
seconds: entry.seconds,
|
||||
cost: entry.cost,
|
||||
description:
|
||||
entry.description ??
|
||||
emptyPlaceholder[aggregatedTableTimeEntries.value?.grouped_type ?? 'project'] ??
|
||||
'',
|
||||
description: resolveLabel(
|
||||
entry.description,
|
||||
entry.key,
|
||||
aggregatedTableTimeEntries.value?.grouped_type ?? 'project'
|
||||
),
|
||||
grouped_data:
|
||||
entry.grouped_data?.map((el) => {
|
||||
return {
|
||||
key: el.key,
|
||||
seconds: el.seconds,
|
||||
cost: el.cost,
|
||||
description:
|
||||
el.description ??
|
||||
emptyPlaceholder[entry.grouped_type ?? 'project'] ??
|
||||
'',
|
||||
description: resolveLabel(
|
||||
el.description,
|
||||
el.key,
|
||||
entry.grouped_type ?? 'project'
|
||||
),
|
||||
};
|
||||
}) ?? [],
|
||||
};
|
||||
@@ -219,7 +241,7 @@ onMounted(async () => {
|
||||
">
|
||||
<ReportingRow
|
||||
v-for="entry in tableData"
|
||||
:key="entry.description ?? 'none'"
|
||||
:key="entry.key ?? 'none'"
|
||||
:currency="reportCurrency"
|
||||
:currency-format="reportCurrencyFormat"
|
||||
:show-cost="true"
|
||||
|
||||
Reference in New Issue
Block a user