mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-15 03:32:15 +01:00
use prop function createTag instead of event to make sure it is handled by the parent
This commit is contained in:
@@ -21,13 +21,13 @@ const props = defineProps<{
|
||||
projects: Project[];
|
||||
tasks: Task[];
|
||||
tags: Tag[];
|
||||
createTag: (name: string) => Promise<Tag | undefined>;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
onStartStopClick: [timeEntry: TimeEntry];
|
||||
updateTimeEntries: [timeEntries: TimeEntry[]];
|
||||
deleteTimeEntries: [timeEntries: TimeEntry[]];
|
||||
createTag: [name: string, callback: (tag: Tag) => void];
|
||||
}>();
|
||||
|
||||
function updateTimeEntryDescription(description: string) {
|
||||
@@ -95,7 +95,7 @@ const expanded = ref(false);
|
||||
</div>
|
||||
<div class="flex items-center font-medium lg:space-x-2">
|
||||
<TimeEntryRowTagDropdown
|
||||
@createTag="(...args) => emit('createTag', ...args)"
|
||||
:createTag
|
||||
:tags="tags"
|
||||
@changed="updateTimeEntryTags"
|
||||
:modelValue="timeEntry.tags"></TimeEntryRowTagDropdown>
|
||||
@@ -142,7 +142,7 @@ const expanded = ref(false);
|
||||
@updateTimeEntry="(arg) => emit('updateTimeEntries', [arg])"
|
||||
@onStartStopClick="emit('onStartStopClick', subEntry)"
|
||||
@deleteTimeEntry="emit('deleteTimeEntries', [subEntry])"
|
||||
@createTag="(...args) => emit('createTag', ...args)"
|
||||
:createTag
|
||||
:key="subEntry.id"
|
||||
v-for="subEntry in timeEntry.timeEntries"
|
||||
:time-entry="subEntry"></TimeEntryRow>
|
||||
|
||||
@@ -17,7 +17,6 @@ import { storeToRefs } from 'pinia';
|
||||
import { useTasksStore } from '@/utils/useTasks';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import { useTagsStore } from '@/utils/useTags';
|
||||
import type { Tag } from '@/utils/api';
|
||||
const projectStore = useProjectsStore();
|
||||
const { projects } = storeToRefs(projectStore);
|
||||
const taskStore = useTasksStore();
|
||||
@@ -75,11 +74,8 @@ async function submit() {
|
||||
show.value = false;
|
||||
}
|
||||
const { tags } = storeToRefs(useTagsStore());
|
||||
async function createTag(tag: string, callback: (tag: Tag) => void) {
|
||||
const newTag = await useTagsStore().createTag(tag);
|
||||
if (newTag !== undefined) {
|
||||
callback(newTag);
|
||||
}
|
||||
async function createTag(tag: string) {
|
||||
return await useTagsStore().createTag(tag);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -118,7 +114,7 @@ async function createTag(tag: string, callback: (tag: Tag) => void) {
|
||||
<div class="flex items-center space-x-2 px-4">
|
||||
<TimeTrackerTagDropdown
|
||||
:tags="tags"
|
||||
@createTag="createTag"
|
||||
:createTag="createTag"
|
||||
v-model="timeEntry.tags"></TimeTrackerTagDropdown>
|
||||
<BillableToggleButton
|
||||
v-model="timeEntry.billable"></BillableToggleButton>
|
||||
|
||||
@@ -19,6 +19,7 @@ const props = defineProps<{
|
||||
projects: Project[];
|
||||
tasks: Task[];
|
||||
tags: Tag[];
|
||||
createTag: (name: string) => Promise<Tag | undefined>;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -26,7 +27,6 @@ const emit = defineEmits<{
|
||||
updateTimeEntries: [entries: TimeEntry[]];
|
||||
deleteTimeEntries: [entries: TimeEntry[]];
|
||||
createTimeEntry: [entry: Omit<CreateTimeEntryBody, 'member_id'>];
|
||||
createTag: [name: string, callback: (tag: Tag) => void];
|
||||
}>();
|
||||
|
||||
const groupedTimeEntries = computed(() => {
|
||||
@@ -118,14 +118,14 @@ function startTimeEntryFromExisting(entry: TimeEntry) {
|
||||
@onStartStopClick="startTimeEntryFromExisting(entry)"
|
||||
@updateTimeEntries="(arg) => emit('updateTimeEntries', arg)"
|
||||
@deleteTimeEntries="(arg) => emit('deleteTimeEntries', arg)"
|
||||
@createTag="(...args) => emit('createTag', ...args)"
|
||||
:createTag
|
||||
v-if="'timeEntries' in entry && entry.timeEntries.length > 1"
|
||||
:time-entry="entry"></TimeEntryAggregateRow>
|
||||
<TimeEntryRow
|
||||
:projects="projects"
|
||||
:tasks="tasks"
|
||||
:tags="tags"
|
||||
@createTag="(...args) => emit('createTag', ...args)"
|
||||
:createTag
|
||||
@updateTimeEntry="(arg) => emit('updateTimeEntry', arg)"
|
||||
@onStartStopClick="startTimeEntryFromExisting(entry)"
|
||||
@deleteTimeEntry="() => emit('deleteTimeEntries', [entry])"
|
||||
|
||||
@@ -16,13 +16,13 @@ const props = defineProps<{
|
||||
projects: Project[];
|
||||
tasks: Task[];
|
||||
tags: Tag[];
|
||||
createTag: (name: string) => Promise<Tag | undefined>;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
onStartStopClick: [];
|
||||
deleteTimeEntry: [];
|
||||
updateTimeEntry: [timeEntry: TimeEntry];
|
||||
createTag: [name: string, callback: (tag: Tag) => void];
|
||||
}>();
|
||||
|
||||
function updateTimeEntryDescription(description: string) {
|
||||
@@ -81,7 +81,7 @@ function updateProjectAndTask(projectId: string, taskId: string) {
|
||||
<div class="flex items-center font-medium lg:space-x-2">
|
||||
<TimeEntryRowTagDropdown
|
||||
@changed="updateTimeEntryTags"
|
||||
@createTag="(...args) => emit('createTag', ...args)"
|
||||
:createTag
|
||||
:tags="tags"
|
||||
:modelValue="timeEntry.tags"></TimeEntryRowTagDropdown>
|
||||
<BillableToggleButton
|
||||
|
||||
@@ -6,10 +6,10 @@ import type { Tag } from '@/utils/api';
|
||||
|
||||
const props = defineProps<{
|
||||
tags: Tag[];
|
||||
createTag: (name: string) => Promise<Tag | undefined>;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
createTag: [name: string, callback: (tag: Tag) => void];
|
||||
changed: [model: string[]];
|
||||
}>();
|
||||
|
||||
@@ -24,7 +24,7 @@ const timeEntryTags = computed<Tag[]>(() => {
|
||||
<template>
|
||||
<TagDropdown
|
||||
:tags="tags"
|
||||
@createTag="(...args) => emit('createTag', ...args)"
|
||||
:createTag
|
||||
@changed="emit('changed', model)"
|
||||
v-model="model">
|
||||
<template #trigger>
|
||||
|
||||
Reference in New Issue
Block a user