Skip to content

Commit 4ed8f16

Browse files
committed
remove duplicates from recently tracked dropdown, improve focus handling
1 parent 0a956fd commit 4ed8f16

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
lines changed

resources/js/packages/ui/src/TimeEntry/TimeEntryAggregateRow.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ function onSelectChange(event: Event) {
129129
:project="timeEntry.project_id"
130130
:enable-estimated-time
131131
:currency="currency"
132-
class="border border-border-primary"
133132
:task="
134133
timeEntry.task_id
135134
"

resources/js/packages/ui/src/TimeEntry/TimeEntryRow.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ function onSelectChange(event: Event) {
119119
:show-badge-border="false"
120120
:project="timeEntry.project_id"
121121
:currency="currency"
122-
class="border border-border-primary"
123122
:enable-estimated-time
124123
:task="
125124
timeEntry.task_id

resources/js/packages/ui/src/TimeTracker/TimeTrackerControls.vue

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,14 @@ function setBillableDefaultForProject() {
103103
}
104104
}
105105
106+
const blockRefocus = ref(false);
107+
106108
function onToggleButtonPress(newState: boolean) {
107109
if (newState) {
108110
emit('startTimer');
109-
currentTimeEntryDescriptionInput.value?.focus();
111+
if (!blockRefocus.value){
112+
currentTimeEntryDescriptionInput.value?.focus();
113+
}
110114
} else {
111115
emit('stopTimer');
112116
}
@@ -129,11 +133,27 @@ function updateTimeEntryDescription() {
129133
130134
const {timeEntries} = storeToRefs(useTimeEntriesStore());
131135
const filteredRecentlyTrackedTimeEntries = computed(() => {
132-
return timeEntries.value.filter((item) => {
136+
// do not include running time entries
137+
const finishedTimeEntries = timeEntries.value.filter((item) => item.end !== null);
138+
139+
// filter out duplicates based on description, task, project, tags and billable
140+
const nonDuplicateTimeEntries = finishedTimeEntries.filter((item, index, self) => {
141+
return index === self.findIndex((t) => (
142+
t.description === item.description &&
143+
t.task_id === item.task_id &&
144+
t.project_id === item.project_id &&
145+
t.tags.length === item.tags.length &&
146+
t.tags.every((tag) => item.tags.includes(tag)) &&
147+
t.billable === item.billable
148+
));
149+
});
150+
151+
// filter time entries based on current description
152+
return nonDuplicateTimeEntries.filter((item) => {
133153
return item.description
134154
?.toLowerCase()
135155
?.includes(tempDescription.value?.toLowerCase()?.trim() || '');
136-
}).slice(0, 5);;
156+
}).slice(0, 5);
137157
});
138158
139159
const showDropdown = ref(false);
@@ -143,6 +163,14 @@ watch(focused, (focused) => {
143163
nextTick(() => {
144164
// make sure the click event on the dropdown does not get interrupted
145165
showDropdown.value = focused
166+
167+
// make sure that the input does not get refocused after the dropdown is closed
168+
if(!focused){
169+
blockRefocus.value = true;
170+
setTimeout(() => {
171+
blockRefocus.value = false;
172+
}, 100);
173+
}
146174
});
147175
});
148176

resources/js/packages/ui/src/TimeTracker/TimeTrackerRecentlyTrackedEntry.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ const task = computed(() => {
3030
tabindex="-1"
3131
:data-select-id="timeEntry.id"
3232
:class="twMerge('px-2 py-1.5 flex justify-between items-center space-x-2 w-full rounded', props.highlighted && 'bg-card-background-active')">
33-
<span class="text-sm font-medium">
33+
<span v-if="timeEntry.description !== ''" class="text-sm font-medium">
3434
{{
35-
timeEntry.description !== ''
36-
? timeEntry.description
37-
: 'No Description'
35+
timeEntry.description
3836
}}
3937
</span>
38+
<span v-else class="text-sm text-text-tertiary font-medium">
39+
No Description
40+
</span>
4041
<ProjectBadge
4142
ref="projectDropdownTrigger"
4243
:color="project?.color"

0 commit comments

Comments
 (0)