mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-13 10:42:16 +01:00
add mass delete time entries frontend, closes ST-450
This commit is contained in:
@@ -57,9 +57,7 @@ async function startTimeEntry(
|
||||
}
|
||||
|
||||
function deleteTimeEntries(timeEntries: TimeEntry[]) {
|
||||
timeEntries.forEach((entry) => {
|
||||
useTimeEntriesStore().deleteTimeEntry(entry.id);
|
||||
});
|
||||
useTimeEntriesStore().deleteTimeEntries(timeEntries);
|
||||
fetchTimeEntries();
|
||||
}
|
||||
|
||||
|
||||
@@ -2325,6 +2325,54 @@ Users with the permission `time-entries:view:own` can only use this en
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
method: 'delete',
|
||||
path: '/v1/organizations/:organization/time-entries',
|
||||
alias: 'deleteTimeEntries',
|
||||
requestFormat: 'json',
|
||||
parameters: [
|
||||
{
|
||||
name: 'organization',
|
||||
type: 'Path',
|
||||
schema: z.string(),
|
||||
},
|
||||
{
|
||||
name: 'ids',
|
||||
type: 'Query',
|
||||
schema: z.array(z.string().uuid()),
|
||||
},
|
||||
],
|
||||
response: z
|
||||
.object({ success: z.string(), error: z.string() })
|
||||
.passthrough(),
|
||||
errors: [
|
||||
{
|
||||
status: 401,
|
||||
description: `Unauthenticated`,
|
||||
schema: z.object({ message: z.string() }).passthrough(),
|
||||
},
|
||||
{
|
||||
status: 403,
|
||||
description: `Authorization error`,
|
||||
schema: z.object({ message: z.string() }).passthrough(),
|
||||
},
|
||||
{
|
||||
status: 404,
|
||||
description: `Not found`,
|
||||
schema: z.object({ message: z.string() }).passthrough(),
|
||||
},
|
||||
{
|
||||
status: 422,
|
||||
description: `Validation error`,
|
||||
schema: z
|
||||
.object({
|
||||
message: z.string(),
|
||||
errors: z.record(z.array(z.string())),
|
||||
})
|
||||
.passthrough(),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
method: 'put',
|
||||
path: '/v1/organizations/:organization/time-entries/:timeEntry',
|
||||
|
||||
@@ -142,7 +142,7 @@ const expanded = ref(false);
|
||||
class="opacity-20 hidden sm:flex group-hover:opacity-100"></TimeTrackerStartStop>
|
||||
<TimeEntryMoreOptionsDropdown
|
||||
@delete="
|
||||
deleteTimeEntries(timeEntry.timeEntries)
|
||||
deleteTimeEntries(timeEntry?.timeEntries ?? [])
|
||||
"></TimeEntryMoreOptionsDropdown>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -168,6 +168,27 @@ export const useTimeEntriesStore = defineStore('timeEntries', () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteTimeEntries(timeEntries: TimeEntry[]) {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
const timeEntryIds = timeEntries.map((entry) => entry.id);
|
||||
if (organizationId) {
|
||||
await handleApiRequestNotifications(
|
||||
() =>
|
||||
api.deleteTimeEntries(undefined, {
|
||||
queries: {
|
||||
ids: timeEntryIds,
|
||||
},
|
||||
params: {
|
||||
organization: organizationId,
|
||||
},
|
||||
}),
|
||||
'Time entries deleted successfully',
|
||||
'Failed to delete time entries'
|
||||
);
|
||||
await fetchTimeEntries();
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
timeEntries,
|
||||
fetchTimeEntries,
|
||||
@@ -177,5 +198,6 @@ export const useTimeEntriesStore = defineStore('timeEntries', () => {
|
||||
fetchMoreTimeEntries,
|
||||
allTimeEntriesLoaded,
|
||||
updateTimeEntries,
|
||||
deleteTimeEntries,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user