mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-17 20:52:14 +01:00
add aggregation/grouping of time entries with same attributes in time view
This commit is contained in:
8
package-lock.json
generated
8
package-lock.json
generated
@@ -13,7 +13,7 @@
|
|||||||
"@vue/eslint-config-prettier": "^9.0.0",
|
"@vue/eslint-config-prettier": "^9.0.0",
|
||||||
"@vue/eslint-config-typescript": "^13.0.0",
|
"@vue/eslint-config-typescript": "^13.0.0",
|
||||||
"@vueuse/core": "^10.9.0",
|
"@vueuse/core": "^10.9.0",
|
||||||
"dayjs": "^1.11.10",
|
"dayjs": "^1.11.11",
|
||||||
"echarts": "^5.5.0",
|
"echarts": "^5.5.0",
|
||||||
"parse-duration": "^1.1.0",
|
"parse-duration": "^1.1.0",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
@@ -2549,9 +2549,9 @@
|
|||||||
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="
|
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="
|
||||||
},
|
},
|
||||||
"node_modules/dayjs": {
|
"node_modules/dayjs": {
|
||||||
"version": "1.11.10",
|
"version": "1.11.11",
|
||||||
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz",
|
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.11.tgz",
|
||||||
"integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ=="
|
"integrity": "sha512-okzr3f11N6WuqYtZSvm+F776mB41wRZMhKP+hc34YdW+KmtYYK9iqvHSwo2k9FEH3fhGXvOPV6yz2IcSrfRUDg=="
|
||||||
},
|
},
|
||||||
"node_modules/de-indent": {
|
"node_modules/de-indent": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
"@vue/eslint-config-prettier": "^9.0.0",
|
"@vue/eslint-config-prettier": "^9.0.0",
|
||||||
"@vue/eslint-config-typescript": "^13.0.0",
|
"@vue/eslint-config-typescript": "^13.0.0",
|
||||||
"@vueuse/core": "^10.9.0",
|
"@vueuse/core": "^10.9.0",
|
||||||
"dayjs": "^1.11.10",
|
"dayjs": "^1.11.11",
|
||||||
"echarts": "^5.5.0",
|
"echarts": "^5.5.0",
|
||||||
"parse-duration": "^1.1.0",
|
"parse-duration": "^1.1.0",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Member } from '@/utils/api';
|
import type { Member } from '@/utils/api';
|
||||||
import { CheckCircleIcon, UserCircleIcon } from '@heroicons/vue/20/solid';
|
import { CheckCircleIcon, UserCircleIcon } from '@heroicons/vue/20/solid';
|
||||||
import { useClientsStore } from '@/utils/useClients';
|
|
||||||
import MemberMoreOptionsDropdown from '@/Components/Common/Member/MemberMoreOptionsDropdown.vue';
|
import MemberMoreOptionsDropdown from '@/Components/Common/Member/MemberMoreOptionsDropdown.vue';
|
||||||
import TableRow from '@/Components/TableRow.vue';
|
import TableRow from '@/Components/TableRow.vue';
|
||||||
import { capitalizeFirstLetter } from '../../../utils/format';
|
import { capitalizeFirstLetter } from '../../../utils/format';
|
||||||
@@ -10,13 +9,14 @@ import { api } from '../../../../../openapi.json.client';
|
|||||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||||
import { useNotificationsStore } from '@/utils/notification';
|
import { useNotificationsStore } from '@/utils/notification';
|
||||||
import { canInvitePlaceholderMembers } from '@/utils/permissions';
|
import { canInvitePlaceholderMembers } from '@/utils/permissions';
|
||||||
|
import { useMembersStore } from '@/utils/useMembers';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
member: Member;
|
member: Member;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
function removeMember() {
|
function removeMember() {
|
||||||
useClientsStore().deleteClient(props.member.id);
|
useMembersStore().removeMember(props.member.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function invitePlaceholder(id: string) {
|
async function invitePlaceholder(id: string) {
|
||||||
|
|||||||
@@ -0,0 +1,195 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import MainContainer from '@/Pages/MainContainer.vue';
|
||||||
|
import TimeTrackerStartStop from '@/Components/Common/TimeTrackerStartStop.vue';
|
||||||
|
import type { TimeEntry } from '@/utils/api';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
import TimeEntryDescriptionInput from '@/Components/Common/TimeEntry/TimeEntryDescriptionInput.vue';
|
||||||
|
import {
|
||||||
|
type TimeEntriesGroupedByType,
|
||||||
|
useTimeEntriesStore,
|
||||||
|
} from '@/utils/useTimeEntries';
|
||||||
|
import TimeEntryRowTagDropdown from '@/Components/Common/TimeEntry/TimeEntryRowTagDropdown.vue';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
import { useCurrentTimeEntryStore } from '@/utils/useCurrentTimeEntry';
|
||||||
|
import TimeEntryMoreOptionsDropdown from '@/Components/Common/TimeEntry/TimeEntryMoreOptionsDropdown.vue';
|
||||||
|
import TimeTrackerProjectTaskDropdown from '@/Components/Common/TimeTracker/TimeTrackerProjectTaskDropdown.vue';
|
||||||
|
import BillableToggleButton from '@/Components/Common/BillableToggleButton.vue';
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
import { twMerge } from 'tailwind-merge';
|
||||||
|
import {
|
||||||
|
formatHumanReadableDuration,
|
||||||
|
formatStartEnd,
|
||||||
|
} from '../../../utils/time';
|
||||||
|
import TimeEntryRow from '@/Components/Common/TimeEntry/TimeEntryRow.vue';
|
||||||
|
|
||||||
|
const currentTimeEntryStore = useCurrentTimeEntryStore();
|
||||||
|
const { stopTimer } = currentTimeEntryStore;
|
||||||
|
const { currentTimeEntry } = storeToRefs(currentTimeEntryStore);
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
timeEntry: TimeEntriesGroupedByType;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const { updateTimeEntry, createTimeEntry, fetchTimeEntries } =
|
||||||
|
useTimeEntriesStore();
|
||||||
|
|
||||||
|
async function onStartStopClick() {
|
||||||
|
if (props.timeEntry.start && !props.timeEntry.end) {
|
||||||
|
await updateTimeEntry({
|
||||||
|
...props.timeEntry,
|
||||||
|
end: dayjs().utc().format(),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (currentTimeEntry.value.id) {
|
||||||
|
await stopTimer();
|
||||||
|
}
|
||||||
|
await createTimeEntry({
|
||||||
|
...props.timeEntry,
|
||||||
|
start: dayjs().utc().format(),
|
||||||
|
end: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
useCurrentTimeEntryStore().fetchCurrentTimeEntry();
|
||||||
|
fetchTimeEntries();
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteTimeEntry() {
|
||||||
|
const timeEntries = props.timeEntry.timeEntries;
|
||||||
|
timeEntries.forEach((entry) => {
|
||||||
|
useTimeEntriesStore().deleteTimeEntry(entry.id);
|
||||||
|
});
|
||||||
|
fetchTimeEntries();
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateTimeEntryDescription(description: string) {
|
||||||
|
const timeEntries = props.timeEntry.timeEntries;
|
||||||
|
timeEntries.forEach((entry) => {
|
||||||
|
updateTimeEntry({ ...entry, description });
|
||||||
|
entry.description = description;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateTimeEntryTags(tags: string[]) {
|
||||||
|
const timeEntries = props.timeEntry.timeEntries as TimeEntry[];
|
||||||
|
timeEntries.forEach((entry) => {
|
||||||
|
updateTimeEntry({ ...entry, tags });
|
||||||
|
entry.tags = tags;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateTimeEntryBillable(billable: boolean) {
|
||||||
|
const timeEntries = props.timeEntry.timeEntries as TimeEntry[];
|
||||||
|
timeEntries.forEach((entry) => {
|
||||||
|
updateTimeEntry({ ...entry, billable });
|
||||||
|
entry.billable = billable;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateProjectAndTask(projectId: string, taskId: string) {
|
||||||
|
const timeEntries = props.timeEntry.timeEntries as TimeEntry[];
|
||||||
|
timeEntries.forEach((entry) => {
|
||||||
|
updateTimeEntry({
|
||||||
|
...entry,
|
||||||
|
project_id: projectId,
|
||||||
|
task_id: taskId,
|
||||||
|
});
|
||||||
|
entry.project_id = projectId;
|
||||||
|
entry.task_id = taskId;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const expanded = ref(false);
|
||||||
|
|
||||||
|
const expandedStatusClasses = computed(() => {
|
||||||
|
if (expanded.value) {
|
||||||
|
return 'border-card-border border bg-card-background-active text-white';
|
||||||
|
}
|
||||||
|
return 'border-card-border border bg-card-background text-muted';
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="border-b border-default-background-separator transition"
|
||||||
|
data-testid="time_entry_row">
|
||||||
|
<MainContainer>
|
||||||
|
<div class="sm:flex py-1.5 items-center justify-between group">
|
||||||
|
<div class="flex space-x-3 items-center">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
class="h-4 w-4 rounded bg-card-background border-input-border text-accent-500/80 focus:ring-accent-500/80" />
|
||||||
|
<button
|
||||||
|
@click="expanded = !expanded"
|
||||||
|
:class="
|
||||||
|
twMerge(
|
||||||
|
expandedStatusClasses,
|
||||||
|
'font-medium w-7 h-7 rounded flex items-center transition justify-center'
|
||||||
|
)
|
||||||
|
">
|
||||||
|
<span>
|
||||||
|
{{ timeEntry?.timeEntries?.length }}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
<TimeEntryDescriptionInput
|
||||||
|
@changed="updateTimeEntryDescription"
|
||||||
|
class="flex-1"
|
||||||
|
:modelValue="
|
||||||
|
timeEntry.description
|
||||||
|
"></TimeEntryDescriptionInput>
|
||||||
|
<TimeTrackerProjectTaskDropdown
|
||||||
|
:showBadgeBorder="false"
|
||||||
|
@changed="updateProjectAndTask"
|
||||||
|
:project="timeEntry.project_id"
|
||||||
|
:task="
|
||||||
|
timeEntry.task_id
|
||||||
|
"></TimeTrackerProjectTaskDropdown>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center font-medium space-x-2">
|
||||||
|
<TimeEntryRowTagDropdown
|
||||||
|
@changed="updateTimeEntryTags"
|
||||||
|
:modelValue="timeEntry.tags"></TimeEntryRowTagDropdown>
|
||||||
|
<BillableToggleButton
|
||||||
|
:modelValue="timeEntry.billable"
|
||||||
|
size="small"
|
||||||
|
@changed="
|
||||||
|
updateTimeEntryBillable
|
||||||
|
"></BillableToggleButton>
|
||||||
|
<div class="flex-1">
|
||||||
|
<button
|
||||||
|
@click="expanded = !expanded"
|
||||||
|
class="text-muted w-[110px] px-2 py-2 bg-transparent text-center hover:bg-card-background rounded-lg border border-transparent hover:border-card-border text-sm font-medium">
|
||||||
|
{{ formatStartEnd(timeEntry.start, timeEntry.end) }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
@click="expanded = !expanded"
|
||||||
|
class="text-white w-[100px] px-3 py-2 bg-transparent text-center hover:bg-card-background rounded-lg border border-transparent hover:border-card-border text-sm font-semibold">
|
||||||
|
{{
|
||||||
|
formatHumanReadableDuration(timeEntry.duration ?? 0)
|
||||||
|
}}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<TimeTrackerStartStop
|
||||||
|
@changed="onStartStopClick"
|
||||||
|
:active="!!(timeEntry.start && !timeEntry.end)"
|
||||||
|
class="opacity-20 hidden sm:flex group-hover:opacity-100"></TimeTrackerStartStop>
|
||||||
|
<TimeEntryMoreOptionsDropdown
|
||||||
|
@delete="
|
||||||
|
deleteTimeEntry
|
||||||
|
"></TimeEntryMoreOptionsDropdown>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</MainContainer>
|
||||||
|
<div
|
||||||
|
v-if="expanded"
|
||||||
|
class="w-full border-t border-default-background-separator bg-black/15">
|
||||||
|
<TimeEntryRow
|
||||||
|
indent
|
||||||
|
:key="subEntry.id"
|
||||||
|
v-for="subEntry in timeEntry.timeEntries"
|
||||||
|
:time-entry="subEntry"></TimeEntryRow>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
@@ -4,7 +4,9 @@ const emit = defineEmits(['changed']);
|
|||||||
|
|
||||||
function onChange(event: Event) {
|
function onChange(event: Event) {
|
||||||
const target = event.target as HTMLInputElement;
|
const target = event.target as HTMLInputElement;
|
||||||
emit('changed', target.value);
|
if (target.value !== value.value) {
|
||||||
|
emit('changed', target.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -13,7 +15,7 @@ function onChange(event: Event) {
|
|||||||
<label class="input-sizer text-sm font-medium" :data-value="value">
|
<label class="input-sizer text-sm font-medium" :data-value="value">
|
||||||
<input
|
<input
|
||||||
data-testid="time_entry_description"
|
data-testid="time_entry_description"
|
||||||
v-model="value"
|
:value="value"
|
||||||
@blur="onChange"
|
@blur="onChange"
|
||||||
@keydown.enter="onChange"
|
@keydown.enter="onChange"
|
||||||
placeholder="Add a description"
|
placeholder="Add a description"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import Dropdown from '@/Components/Dropdown.vue';
|
import Dropdown from '@/Components/Dropdown.vue';
|
||||||
import { defineProps, ref, watch } from 'vue';
|
import { defineProps, ref, watch } from 'vue';
|
||||||
import { formatTime } from '@/utils/time';
|
import { formatStartEnd } from '@/utils/time';
|
||||||
import TimePicker from '@/Components/Common/TimePicker.vue';
|
import TimePicker from '@/Components/Common/TimePicker.vue';
|
||||||
import { useFocusWithin } from '@vueuse/core';
|
import { useFocusWithin } from '@vueuse/core';
|
||||||
|
|
||||||
@@ -10,13 +10,6 @@ const props = defineProps<{
|
|||||||
end: string | null;
|
end: string | null;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
function formatStartEnd(start: string, end: string | null) {
|
|
||||||
if (end) {
|
|
||||||
return `${formatTime(start)} - ${formatTime(end)}`;
|
|
||||||
} else {
|
|
||||||
return `${formatTime(start)} - ...`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const emit = defineEmits(['changed']);
|
const emit = defineEmits(['changed']);
|
||||||
const tempStart = ref(props.start);
|
const tempStart = ref(props.start);
|
||||||
const tempEnd = ref(props.end || null);
|
const tempEnd = ref(props.end || null);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const { currentTimeEntry } = storeToRefs(currentTimeEntryStore);
|
|||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
timeEntry: TimeEntry;
|
timeEntry: TimeEntry;
|
||||||
|
indent?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const { updateTimeEntry, createTimeEntry, fetchTimeEntries } =
|
const { updateTimeEntry, createTimeEntry, fetchTimeEntries } =
|
||||||
@@ -69,6 +70,10 @@ function updateTimeEntryTags(tags: string[]) {
|
|||||||
updateTimeEntry({ ...props.timeEntry, tags });
|
updateTimeEntry({ ...props.timeEntry, tags });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateTimeEntryBillable(billable: boolean) {
|
||||||
|
updateTimeEntry({ ...props.timeEntry, billable });
|
||||||
|
}
|
||||||
|
|
||||||
function updateProjectAndTask(projectId: string, taskId: string) {
|
function updateProjectAndTask(projectId: string, taskId: string) {
|
||||||
updateTimeEntry({
|
updateTimeEntry({
|
||||||
...props.timeEntry,
|
...props.timeEntry,
|
||||||
@@ -88,13 +93,13 @@ function updateProjectAndTask(projectId: string, taskId: string) {
|
|||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
class="h-4 w-4 rounded bg-card-background border-input-border text-accent-500/80 focus:ring-accent-500/80" />
|
class="h-4 w-4 rounded bg-card-background border-input-border text-accent-500/80 focus:ring-accent-500/80" />
|
||||||
|
<div class="w-7 h-7" v-if="indent === true"></div>
|
||||||
<TimeEntryDescriptionInput
|
<TimeEntryDescriptionInput
|
||||||
@changed="updateTimeEntryDescription"
|
@changed="updateTimeEntryDescription"
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
:modelValue="
|
:modelValue="
|
||||||
timeEntry.description
|
timeEntry.description
|
||||||
"></TimeEntryDescriptionInput>
|
"></TimeEntryDescriptionInput>
|
||||||
|
|
||||||
<TimeTrackerProjectTaskDropdown
|
<TimeTrackerProjectTaskDropdown
|
||||||
:showBadgeBorder="false"
|
:showBadgeBorder="false"
|
||||||
@changed="updateProjectAndTask"
|
@changed="updateProjectAndTask"
|
||||||
@@ -111,10 +116,7 @@ function updateProjectAndTask(projectId: string, taskId: string) {
|
|||||||
:modelValue="timeEntry.billable"
|
:modelValue="timeEntry.billable"
|
||||||
size="small"
|
size="small"
|
||||||
@changed="
|
@changed="
|
||||||
updateTimeEntry({
|
updateTimeEntryBillable
|
||||||
...timeEntry,
|
|
||||||
billable: $event,
|
|
||||||
})
|
|
||||||
"></BillableToggleButton>
|
"></BillableToggleButton>
|
||||||
<div class="flex-1">
|
<div class="flex-1">
|
||||||
<TimeEntryRangeSelector
|
<TimeEntryRangeSelector
|
||||||
|
|||||||
@@ -54,28 +54,43 @@ withDefaults(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const filteredProjects = computed(() => {
|
const filteredProjects = computed(() => {
|
||||||
return projects.value.reduce((filtered: ProjectWithTasks[], project) => {
|
return projects.value.reduce(
|
||||||
const projectNameIncludesSearchTerm = project.name
|
(filtered: ProjectWithTasks[], project) => {
|
||||||
.toLowerCase()
|
const projectNameIncludesSearchTerm = project.name
|
||||||
.includes(searchValue.value?.toLowerCase()?.trim() || '');
|
|
||||||
|
|
||||||
// check if one of the project tasks
|
|
||||||
const projectTasks = tasks.value.filter((task) => {
|
|
||||||
return task.project_id === project.id;
|
|
||||||
});
|
|
||||||
|
|
||||||
const filteredTasks = projectTasks.filter((task) => {
|
|
||||||
return task.name
|
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.includes(searchValue.value?.toLowerCase()?.trim() || '');
|
.includes(searchValue.value?.toLowerCase()?.trim() || '');
|
||||||
});
|
|
||||||
|
|
||||||
if (projectNameIncludesSearchTerm || filteredTasks.length > 0) {
|
// check if one of the project tasks
|
||||||
filtered.push({ project: project, tasks: filteredTasks });
|
const projectTasks = tasks.value.filter((task) => {
|
||||||
}
|
return task.project_id === project.id;
|
||||||
|
});
|
||||||
|
|
||||||
return filtered;
|
const filteredTasks = projectTasks.filter((task) => {
|
||||||
}, []);
|
return task.name
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(searchValue.value?.toLowerCase()?.trim() || '');
|
||||||
|
});
|
||||||
|
|
||||||
|
if (projectNameIncludesSearchTerm || filteredTasks.length > 0) {
|
||||||
|
filtered.push({ project: project, tasks: filteredTasks });
|
||||||
|
}
|
||||||
|
|
||||||
|
return filtered;
|
||||||
|
},
|
||||||
|
[
|
||||||
|
{
|
||||||
|
project: {
|
||||||
|
id: '',
|
||||||
|
name: 'No Project',
|
||||||
|
color: 'var(--theme-color-icon-default)',
|
||||||
|
value: '',
|
||||||
|
client_id: null,
|
||||||
|
billable_rate: null,
|
||||||
|
},
|
||||||
|
tasks: [],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
async function addClientIfNoneExists() {
|
async function addClientIfNoneExists() {
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ const props = withDefaults(
|
|||||||
);
|
);
|
||||||
const buttonSizeClasses = {
|
const buttonSizeClasses = {
|
||||||
base: 'w-8 h-8 bg-accent-200/40 hover:scale-110 hover:bg-accent-300/70 ring-accent-200/10 focus:ring-accent-200/10 hover:ring-4',
|
base: 'w-8 h-8 bg-accent-200/40 hover:scale-110 hover:bg-accent-300/70 ring-accent-200/10 focus:ring-accent-200/10 hover:ring-4',
|
||||||
large: 'w-8 sm:w-11 h-8 sm:h-11 ring-accent-200/10 focus:ring-accent-200/20 ring-4 sm:ring-8 hover:scale-110',
|
large: 'w-11 h-11 ring-accent-200/10 focus:ring-accent-200/20 ring-4 sm:ring-8 hover:scale-110',
|
||||||
};
|
};
|
||||||
const iconClass = {
|
const iconClass = {
|
||||||
base: 'w-3.5 h-3.5',
|
base: 'w-3.5 h-3.5',
|
||||||
large: 'w-3.5 h-3.5 sm:w-4 sm:h-4',
|
large: 'w-4 h-4',
|
||||||
};
|
};
|
||||||
|
|
||||||
const buttonColorClasses = computed(() => {
|
const buttonColorClasses = computed(() => {
|
||||||
|
|||||||
@@ -8,18 +8,11 @@ const props = withDefaults(
|
|||||||
defineProps<{
|
defineProps<{
|
||||||
align: Placement;
|
align: Placement;
|
||||||
width: string;
|
width: string;
|
||||||
contentClasses?: string[];
|
|
||||||
closeOnContentClick: boolean;
|
closeOnContentClick: boolean;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
align: 'bottom-start',
|
align: 'bottom-start',
|
||||||
width: '48',
|
width: '48',
|
||||||
contentClasses: () => [
|
|
||||||
'overflow-none',
|
|
||||||
'bg-card-background',
|
|
||||||
'border',
|
|
||||||
'border-card-border',
|
|
||||||
],
|
|
||||||
closeOnContentClick: true,
|
closeOnContentClick: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -101,8 +94,7 @@ const { floatingStyles } = useFloating(reference, floating, {
|
|||||||
leave-to-class="transform opacity-0 scale-95">
|
leave-to-class="transform opacity-0 scale-95">
|
||||||
<div
|
<div
|
||||||
v-if="open"
|
v-if="open"
|
||||||
class="rounded-lg ring-1 relative ring-black ring-opacity-5"
|
class="rounded-lg ring-1 relative ring-black ring-opacity-5 border border-card-border overflow-none bg-card-background shadow-lg">
|
||||||
:class="contentClasses">
|
|
||||||
<slot name="content" />
|
<slot name="content" />
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ function switchToTimeEntryOrganization() {
|
|||||||
v-model="currentTimeEntry.description"
|
v-model="currentTimeEntry.description"
|
||||||
@keydown.enter="startTimerIfNotActive"
|
@keydown.enter="startTimerIfNotActive"
|
||||||
@blur="updateTimeEntry"
|
@blur="updateTimeEntry"
|
||||||
class="w-full rounded-l-lg py-2.5 px-3 border-b border-b-card-background-separator sm:px-4 text-sm sm:text-lg text-white focus:bg-card-background-active font-medium bg-transparent border-none placeholder-muted focus:ring-0 transition"
|
class="w-full rounded-l-lg py-4 sm:py-2.5 px-3 border-b border-b-card-background-separator sm:px-4 text-base sm:text-lg text-white focus:bg-card-background-active font-medium bg-transparent border-none placeholder-muted focus:ring-0 transition"
|
||||||
type="text" />
|
type="text" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center justify-between pl-2">
|
<div class="flex items-center justify-between pl-2">
|
||||||
|
|||||||
@@ -3,17 +3,21 @@ import AppLayout from '@/Layouts/AppLayout.vue';
|
|||||||
import TimeTracker from '@/Components/TimeTracker.vue';
|
import TimeTracker from '@/Components/TimeTracker.vue';
|
||||||
import { computed, onMounted, ref, watch } from 'vue';
|
import { computed, onMounted, ref, watch } from 'vue';
|
||||||
import MainContainer from '@/Pages/MainContainer.vue';
|
import MainContainer from '@/Pages/MainContainer.vue';
|
||||||
import { useTimeEntriesStore } from '@/utils/useTimeEntries';
|
import {
|
||||||
|
type TimeEntriesGroupedByType,
|
||||||
|
useTimeEntriesStore,
|
||||||
|
} from '@/utils/useTimeEntries';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import type { TimeEntry } from '@/utils/api';
|
import type { TimeEntry } from '@/utils/api';
|
||||||
import TimeEntryRowHeading from '@/Components/Common/TimeEntry/TimeEntryRowHeading.vue';
|
import TimeEntryRowHeading from '@/Components/Common/TimeEntry/TimeEntryRowHeading.vue';
|
||||||
import TimeEntryRow from '@/Components/Common/TimeEntry/TimeEntryRow.vue';
|
import TimeEntryRow from '@/Components/Common/TimeEntry/TimeEntryRow.vue';
|
||||||
import { useElementVisibility } from '@vueuse/core';
|
import { useElementVisibility } from '@vueuse/core';
|
||||||
import { ClockIcon } from '@heroicons/vue/20/solid';
|
import { ClockIcon } from '@heroicons/vue/20/solid';
|
||||||
import { getLocalizedDateFromTimestamp } from '@/utils/time';
|
import { getDayJsInstance, getLocalizedDateFromTimestamp } from '@/utils/time';
|
||||||
import SecondaryButton from '@/Components/SecondaryButton.vue';
|
import SecondaryButton from '@/Components/SecondaryButton.vue';
|
||||||
import { PlusIcon } from '@heroicons/vue/16/solid';
|
import { PlusIcon } from '@heroicons/vue/16/solid';
|
||||||
import TimeEntryCreateModal from '@/Components/Common/TimeEntry/TimeEntryCreateModal.vue';
|
import TimeEntryCreateModal from '@/Components/Common/TimeEntry/TimeEntryCreateModal.vue';
|
||||||
|
import TimeEntryAggregateRow from '@/Components/Common/TimeEntry/TimeEntryAggregateRow.vue';
|
||||||
|
|
||||||
const timeEntriesStore = useTimeEntriesStore();
|
const timeEntriesStore = useTimeEntriesStore();
|
||||||
const { timeEntries, allTimeEntriesLoaded } = storeToRefs(timeEntriesStore);
|
const { timeEntries, allTimeEntriesLoaded } = storeToRefs(timeEntriesStore);
|
||||||
@@ -38,14 +42,67 @@ onMounted(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const groupedTimeEntries = computed(() => {
|
const groupedTimeEntries = computed(() => {
|
||||||
const groupedEntries: Record<string, TimeEntry[]> = {};
|
const groupedEntriesByDay: Record<string, TimeEntry[]> = {};
|
||||||
for (const entry of timeEntries.value) {
|
for (const entry of timeEntries.value) {
|
||||||
const oldEntries =
|
const oldEntries =
|
||||||
groupedEntries[getLocalizedDateFromTimestamp(entry.start)];
|
groupedEntriesByDay[getLocalizedDateFromTimestamp(entry.start)];
|
||||||
const newEntries = [...(oldEntries ?? []), entry];
|
groupedEntriesByDay[getLocalizedDateFromTimestamp(entry.start)] = [
|
||||||
groupedEntries[getLocalizedDateFromTimestamp(entry.start)] = newEntries;
|
...(oldEntries ?? []),
|
||||||
|
entry,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
return groupedEntries;
|
const groupedEntriesByDayAndType: Record<
|
||||||
|
string,
|
||||||
|
TimeEntriesGroupedByType[]
|
||||||
|
> = {};
|
||||||
|
for (const dailyEntriesKey in groupedEntriesByDay) {
|
||||||
|
const dailyEntries = groupedEntriesByDay[dailyEntriesKey];
|
||||||
|
const newDailyEntries: TimeEntriesGroupedByType[] = [];
|
||||||
|
|
||||||
|
for (const entry of dailyEntries) {
|
||||||
|
// check if same entry already exists
|
||||||
|
const oldEntriesIndex = newDailyEntries.findIndex(
|
||||||
|
(e) =>
|
||||||
|
e.project_id === entry.project_id &&
|
||||||
|
e.task_id === entry.task_id &&
|
||||||
|
e.billable === entry.billable &&
|
||||||
|
e.description === entry.description
|
||||||
|
);
|
||||||
|
console.log(oldEntriesIndex);
|
||||||
|
if (oldEntriesIndex !== -1 && newDailyEntries[oldEntriesIndex]) {
|
||||||
|
newDailyEntries[oldEntriesIndex].timeEntries.push(entry);
|
||||||
|
|
||||||
|
// Add up durations for time entries of the same type
|
||||||
|
console.log(newDailyEntries[oldEntriesIndex], entry?.duration);
|
||||||
|
newDailyEntries[oldEntriesIndex].duration =
|
||||||
|
(newDailyEntries[oldEntriesIndex].duration ?? 0) +
|
||||||
|
(entry?.duration ?? 0);
|
||||||
|
|
||||||
|
// adapt start end times so they show the earliest start and latest end time
|
||||||
|
if (
|
||||||
|
getDayJsInstance()(entry.start).isBefore(
|
||||||
|
getDayJsInstance()(
|
||||||
|
newDailyEntries[oldEntriesIndex].start
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
newDailyEntries[oldEntriesIndex].start = entry.start;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
getDayJsInstance()(entry.end).isAfter(
|
||||||
|
getDayJsInstance()(newDailyEntries[oldEntriesIndex].end)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
newDailyEntries[oldEntriesIndex].end = entry.end;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newDailyEntries.push({ ...entry, timeEntries: [entry] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
groupedEntriesByDayAndType[dailyEntriesKey] = newDailyEntries;
|
||||||
|
}
|
||||||
|
return groupedEntriesByDayAndType;
|
||||||
});
|
});
|
||||||
const showManualTimeEntryModal = ref(false);
|
const showManualTimeEntryModal = ref(false);
|
||||||
</script>
|
</script>
|
||||||
@@ -66,17 +123,21 @@ const showManualTimeEntryModal = ref(false);
|
|||||||
class="w-full text-center flex justify-center"
|
class="w-full text-center flex justify-center"
|
||||||
@click="showManualTimeEntryModal = true"
|
@click="showManualTimeEntryModal = true"
|
||||||
:icon="PlusIcon"
|
:icon="PlusIcon"
|
||||||
>Manual time entry</SecondaryButton
|
>Manual time entry
|
||||||
>
|
</SecondaryButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</MainContainer>
|
</MainContainer>
|
||||||
<div v-for="(value, key) in groupedTimeEntries" :key="key">
|
<div v-for="(value, key) in groupedTimeEntries" :key="key">
|
||||||
<TimeEntryRowHeading :date="key"></TimeEntryRowHeading>
|
<TimeEntryRowHeading :date="key"></TimeEntryRowHeading>
|
||||||
<TimeEntryRow
|
<template v-for="entry in value" :key="entry.id">
|
||||||
:key="entry.id"
|
<TimeEntryAggregateRow
|
||||||
v-for="entry in value"
|
v-if="
|
||||||
:time-entry="entry"></TimeEntryRow>
|
'timeEntries' in entry && entry.timeEntries.length > 1
|
||||||
|
"
|
||||||
|
:time-entry="entry"></TimeEntryAggregateRow>
|
||||||
|
<TimeEntryRow v-else :time-entry="entry"></TimeEntryRow>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="Object.keys(groupedTimeEntries).length === 0"
|
v-if="Object.keys(groupedTimeEntries).length === 0"
|
||||||
|
|||||||
@@ -87,3 +87,11 @@ export function formatHumanReadableDate(date: string) {
|
|||||||
}
|
}
|
||||||
return dayjs(date).fromNow();
|
return dayjs(date).fromNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function formatStartEnd(start: string, end: string | null) {
|
||||||
|
if (end) {
|
||||||
|
return `${formatTime(start)} - ${formatTime(end)}`;
|
||||||
|
} else {
|
||||||
|
return `${formatTime(start)} - ...`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,9 +24,29 @@ export const useMembersStore = defineStore('members', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function removeMember(membershipId: string) {
|
||||||
|
const organization = getCurrentOrganizationId();
|
||||||
|
if (organization) {
|
||||||
|
await handleApiRequestNotifications(
|
||||||
|
api.removeMember(
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
params: {
|
||||||
|
organization: organization,
|
||||||
|
membership: membershipId,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
),
|
||||||
|
'Member deleted successfully',
|
||||||
|
'Failed to delete member'
|
||||||
|
);
|
||||||
|
await fetchMembers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const members = computed<Member[]>(() => {
|
const members = computed<Member[]>(() => {
|
||||||
return membersResponse.value?.data || [];
|
return membersResponse.value?.data || [];
|
||||||
});
|
});
|
||||||
|
|
||||||
return { members, fetchMembers };
|
return { members, fetchMembers, removeMember };
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { reactive, ref } from 'vue';
|
|||||||
import type { CreateTimeEntryBody, TimeEntry } from '@/utils/api';
|
import type { CreateTimeEntryBody, TimeEntry } from '@/utils/api';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useNotificationsStore } from '@/utils/notification';
|
import { useNotificationsStore } from '@/utils/notification';
|
||||||
|
export type TimeEntriesGroupedByType = TimeEntry & { timeEntries: TimeEntry[] };
|
||||||
|
|
||||||
export const useTimeEntriesStore = defineStore('timeEntries', () => {
|
export const useTimeEntriesStore = defineStore('timeEntries', () => {
|
||||||
const timeEntries = ref<TimeEntry[]>(reactive([]));
|
const timeEntries = ref<TimeEntry[]>(reactive([]));
|
||||||
|
|||||||
Reference in New Issue
Block a user