mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-06-15 05:22:44 +01:00
Compare commits
7 Commits
3caf7438b5
...
feature/12
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f79d995fdd | ||
|
|
a45c8a89f6 | ||
|
|
915204f7a6 | ||
|
|
4635fec016 | ||
|
|
f1cce79678 | ||
|
|
09f7fbccf6 | ||
|
|
0bd32dee39 |
@@ -148,6 +148,8 @@ class ReportController extends Controller
|
||||
$report->share_secret = null;
|
||||
$report->public_until = null;
|
||||
}
|
||||
} elseif ($report->is_public && $request->has('public_until')) {
|
||||
$report->public_until = $request->getPublicUntil();
|
||||
}
|
||||
$report->save();
|
||||
|
||||
|
||||
@@ -230,7 +230,9 @@ test('test that format settings are reflected in the dashboard', async ({
|
||||
await expect(page.getByText('0.00€')).toBeVisible();
|
||||
|
||||
// check that 00:00 is displayed
|
||||
await expect(page.getByText('0:00', { exact: true }).nth(0)).toBeVisible();
|
||||
await expect(
|
||||
page.getByText('0:00 h', { exact: true }).nth(0)
|
||||
).toBeVisible();
|
||||
// check that 0h 00min is not displayed
|
||||
await expect(
|
||||
page.getByText('0h 00min', { exact: true }).nth(0)
|
||||
|
||||
@@ -102,7 +102,7 @@ test('test that updating billable rate works with existing time entries', async
|
||||
|
||||
await page.getByRole('row').first().getByRole('button').click();
|
||||
await page.getByRole('menuitem').getByText('Edit').first().click();
|
||||
await page.getByText('Non-Billable').click();
|
||||
await page.getByText('Non-Billable').click();
|
||||
await page.getByText('Custom Rate').click();
|
||||
await page
|
||||
.getByPlaceholder('Billable Rate')
|
||||
@@ -136,6 +136,49 @@ test('test that updating billable rate works with existing time entries', async
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that creating and updating project time estimate works', async ({ page }) => {
|
||||
const newProjectName = 'New Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
const timeEstimate = '10';
|
||||
|
||||
await goToProjectsOverview(page);
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await page.getByLabel('Project Name').fill(newProjectName);
|
||||
await page.getByLabel('Time Estimated').fill(timeEstimate);
|
||||
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Create Project' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/projects') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201 &&
|
||||
(await response.json()).data.estimated_time === parseInt(timeEstimate) * 60 * 60
|
||||
),
|
||||
]);
|
||||
|
||||
// Check that time estimate is displayed in the projects table
|
||||
await expect(page.getByTestId('project_table')).toContainText(timeEstimate + 'h');
|
||||
|
||||
// Edit project to remove time estimate
|
||||
await page.getByRole('row').first().getByRole('button').click();
|
||||
await page.getByRole('menuitem').getByText('Edit').first().click();
|
||||
await page.getByLabel('Time Estimated').fill('');
|
||||
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Update Project' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/projects') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200 &&
|
||||
(await response.json()).data.estimated_time === null
|
||||
),
|
||||
]);
|
||||
|
||||
// Check that time estimate is no longer displayed
|
||||
await expect(page.getByTestId('project_table')).not.toContainText(timeEstimate + 'h');
|
||||
});
|
||||
|
||||
// Create new project with new Client
|
||||
|
||||
// Create new project with existing Client
|
||||
|
||||
@@ -15,6 +15,7 @@ import { api } from '@/packages/api/src';
|
||||
import { Checkbox } from '@/packages/ui/src';
|
||||
import DatePicker from '@/packages/ui/src/Input/DatePicker.vue';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
import { getLocalizedDayJs } from '@/packages/ui/src/utils/time';
|
||||
|
||||
const show = defineModel('show', { default: false });
|
||||
const saving = ref(false);
|
||||
@@ -47,10 +48,14 @@ const report = ref({
|
||||
const { handleApiRequestNotifications } = useNotificationsStore();
|
||||
|
||||
async function submit() {
|
||||
const { public_until, ...reportProperties } = report.value;
|
||||
await handleApiRequestNotifications(
|
||||
() =>
|
||||
createReportMutation.mutateAsync({
|
||||
...report.value,
|
||||
...reportProperties,
|
||||
public_until: public_until
|
||||
? getLocalizedDayJs(public_until).utc().format()
|
||||
: null,
|
||||
properties: { ...props.properties },
|
||||
}),
|
||||
'Success',
|
||||
@@ -103,13 +108,16 @@ async function submit() {
|
||||
<div
|
||||
v-if="report.is_public"
|
||||
class="flex items-center space-x-4">
|
||||
<div>
|
||||
<div class="w-full">
|
||||
<InputLabel for="public_until" value="Expires at" />
|
||||
<div class="text-text-tertiary font-medium">
|
||||
(optional)
|
||||
</div>
|
||||
</div>
|
||||
<DatePicker id="public_until"></DatePicker>
|
||||
<DatePicker
|
||||
id="public_until"
|
||||
v-model="report.public_until"
|
||||
size="input"></DatePicker>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,6 +13,7 @@ import { Checkbox } from '@/packages/ui/src';
|
||||
import DatePicker from '@/packages/ui/src/Input/DatePicker.vue';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
import type { Report } from '@/packages/api/src';
|
||||
import { getLocalizedDayJs } from '@/packages/ui/src/utils/time';
|
||||
|
||||
const show = defineModel('show', { default: false });
|
||||
const saving = ref(false);
|
||||
@@ -64,8 +65,15 @@ watch(
|
||||
const { handleApiRequestNotifications } = useNotificationsStore();
|
||||
|
||||
async function submit() {
|
||||
const { public_until, ...reportProperties } = report.value;
|
||||
await handleApiRequestNotifications(
|
||||
() => updateReportMutation.mutateAsync(report.value),
|
||||
() =>
|
||||
updateReportMutation.mutateAsync({
|
||||
...reportProperties,
|
||||
public_until: public_until
|
||||
? getLocalizedDayJs(public_until).utc().format()
|
||||
: null,
|
||||
}),
|
||||
'Success',
|
||||
'Error',
|
||||
() => {
|
||||
@@ -118,7 +126,10 @@ async function submit() {
|
||||
v-if="report.is_public"
|
||||
class="flex items-center space-x-4">
|
||||
<InputLabel for="public_until" value="Expires at" />
|
||||
<DatePicker id="public_until"></DatePicker>
|
||||
<DatePicker
|
||||
id="public_until"
|
||||
v-model="report.public_until"
|
||||
size="input"></DatePicker>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -119,7 +119,8 @@ function deleteSelected() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TimeEntryCreateModal
|
||||
<AppLayout title="Dashboard" data-testid="time_view">
|
||||
<TimeEntryCreateModal
|
||||
v-model:show="showManualTimeEntryModal"
|
||||
:enable-estimated-time="isAllowedToPerformPremiumAction()"
|
||||
:create-project="createProject"
|
||||
@@ -130,7 +131,6 @@ function deleteSelected() {
|
||||
:tasks
|
||||
:tags
|
||||
:clients></TimeEntryCreateModal>
|
||||
<AppLayout title="Dashboard" data-testid="time_view">
|
||||
<MainContainer
|
||||
class="pt-5 lg:pt-8 pb-4 lg:pb-6">
|
||||
<div
|
||||
|
||||
@@ -11,9 +11,10 @@ const emit = defineEmits(['submit']);
|
||||
<div class="pt-6">
|
||||
<div class="flex items-center space-x-1 mb-2">
|
||||
<ClockIcon class="text-text-quaternary w-4"></ClockIcon>
|
||||
<InputLabel for="billable" value="Time Estimated" />
|
||||
<InputLabel for="time-estimated" value="Time Estimated" />
|
||||
</div>
|
||||
<DurationInput
|
||||
id="time-estimated"
|
||||
v-model="model"
|
||||
class="max-w-[150px]"
|
||||
@submit="emit('submit')"></DurationInput>
|
||||
|
||||
@@ -1,76 +1,96 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue';
|
||||
import {
|
||||
getDayJsInstance,
|
||||
getLocalizedDayJs,
|
||||
} from '@/packages/ui/src/utils/time';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from '@/Components/ui/popover';
|
||||
import { Button, type ButtonVariants } from '@/Components/ui/button';
|
||||
import { Calendar } from '@/Components/ui/calendar';
|
||||
import { CalendarIcon } from 'lucide-vue-next';
|
||||
import { formatDateLocalized } from '@/packages/ui/src/utils/time';
|
||||
import { parseDate, type DateValue } from '@internationalized/date';
|
||||
import { computed, inject, type ComputedRef } from 'vue';
|
||||
import { type Organization } from '@/packages/api/src';
|
||||
import { getLocalizedDayJs } from '@/packages/ui/src/utils/time';
|
||||
|
||||
const props = defineProps<{
|
||||
class?: string;
|
||||
tabindex?: string;
|
||||
size: ButtonVariants['size'];
|
||||
}>();
|
||||
|
||||
// This has to be a localized timestamp, not UTC
|
||||
const model = defineModel<string | null>({
|
||||
default: null,
|
||||
});
|
||||
const model = defineModel<string | null>();
|
||||
const emit = defineEmits<{
|
||||
changed: [string];
|
||||
}>();
|
||||
|
||||
const tempDate = ref(getLocalizedDayJs(model.value).format('YYYY-MM-DD'));
|
||||
|
||||
watch(model, (value) => {
|
||||
tempDate.value = getLocalizedDayJs(value).format('YYYY-MM-DD');
|
||||
});
|
||||
|
||||
function updateDate(event: Event) {
|
||||
const target = event.target as HTMLInputElement;
|
||||
const newValue = target.value;
|
||||
const newDate = getDayJsInstance()(newValue);
|
||||
if (newDate.isValid()) {
|
||||
model.value = getLocalizedDayJs(model.value)
|
||||
.set('year', newDate.year())
|
||||
.set('month', newDate.month())
|
||||
.set('date', newDate.date())
|
||||
.format();
|
||||
emit('changed', model.value);
|
||||
const handleChange = (date: DateValue | undefined) => {
|
||||
if (!date) {
|
||||
model.value = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const datePicker = ref<HTMLInputElement | null>(null);
|
||||
const dayjs = model.value
|
||||
? getLocalizedDayJs(model.value)
|
||||
: getLocalizedDayJs();
|
||||
model.value = dayjs
|
||||
.year(date.year)
|
||||
.month(date.month - 1) // CalendarDate uses 1-based months
|
||||
.date(date.day)
|
||||
.format();
|
||||
emit('changed', model.value);
|
||||
};
|
||||
|
||||
function updateTempValue(event: Event) {
|
||||
const target = event.target as HTMLInputElement;
|
||||
tempDate.value = target.value;
|
||||
}
|
||||
const date = computed(() => {
|
||||
return model.value
|
||||
? parseDate(getLocalizedDayJs(model.value).format('YYYY-MM-DD'))
|
||||
: undefined;
|
||||
});
|
||||
|
||||
const emit = defineEmits(['changed']);
|
||||
const organization = inject<ComputedRef<Organization>>('organization');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center text-text-secondary">
|
||||
<input
|
||||
id="start"
|
||||
ref="datePicker"
|
||||
:tabindex="tabindex"
|
||||
:class="
|
||||
twMerge(
|
||||
'bg-input-background border text-text-primary border-input-border focus-visible:outline-0 focus-visible:border-input-border-active focus-visible:ring-0 rounded-md',
|
||||
props.class
|
||||
)
|
||||
"
|
||||
type="date"
|
||||
name="trip-start"
|
||||
:value="tempDate"
|
||||
@change="updateTempValue"
|
||||
@blur="updateDate"
|
||||
@keydown.enter="updateDate" />
|
||||
</div>
|
||||
<Popover>
|
||||
<PopoverTrigger as-child>
|
||||
<Button
|
||||
variant="input"
|
||||
:size="size"
|
||||
:class="[
|
||||
size === 'sm' ? 'gap-1.5' : 'gap-2',
|
||||
'w-full justify-center text-left font-normal',
|
||||
!model && 'text-muted-foreground',
|
||||
props.class,
|
||||
]"
|
||||
:tabindex="tabindex">
|
||||
<CalendarIcon
|
||||
:class="[
|
||||
size === 'xs'
|
||||
? 'h-3 w-3'
|
||||
: size === 'sm'
|
||||
? 'h-3 w-3'
|
||||
: size === 'lg'
|
||||
? 'h-4.5 w-4.5'
|
||||
: 'h-4 w-4',
|
||||
]" />
|
||||
<span class="text-center">
|
||||
{{
|
||||
model
|
||||
? formatDateLocalized(
|
||||
model,
|
||||
organization?.date_format
|
||||
)
|
||||
: 'Pick a date'
|
||||
}}
|
||||
</span>
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent class="w-auto p-0">
|
||||
<Calendar
|
||||
mode="single"
|
||||
:model-value="date"
|
||||
:initial-focus="true"
|
||||
@update:model-value="handleChange" />
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
input::-webkit-calendar-picker-indicator {
|
||||
filter: invert(1);
|
||||
|
||||
opacity: 0.2;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
import { computed, ref } from 'vue';
|
||||
import { TextInput } from '@/packages/ui/src';
|
||||
|
||||
defineProps<{
|
||||
id?: string;
|
||||
}>();
|
||||
|
||||
const model = defineModel<number | null>({
|
||||
default: null,
|
||||
});
|
||||
@@ -16,6 +20,8 @@ function updateDuration() {
|
||||
const hours = parseInt(temporaryCustomTimerEntry.value);
|
||||
if (!isNaN(hours)) {
|
||||
model.value = hours * 60 * 60;
|
||||
} else {
|
||||
model.value = null;
|
||||
}
|
||||
temporaryCustomTimerEntry.value = '';
|
||||
}
|
||||
@@ -54,6 +60,7 @@ function updateAndSubmit() {
|
||||
<template>
|
||||
<div class="relative">
|
||||
<TextInput
|
||||
:id="id"
|
||||
v-model="currentTime"
|
||||
class="w-full overflow-hidden pr-14"
|
||||
placeholder="0"
|
||||
|
||||
@@ -5,6 +5,7 @@ import { twMerge } from 'tailwind-merge';
|
||||
const props = defineProps<{
|
||||
name?: string;
|
||||
class?: string;
|
||||
id?: string;
|
||||
}>();
|
||||
|
||||
const input = ref<HTMLInputElement | null>(null);
|
||||
@@ -21,6 +22,7 @@ const model = defineModel();
|
||||
|
||||
<template>
|
||||
<input
|
||||
:id="id"
|
||||
ref="input"
|
||||
v-model="model"
|
||||
:class="
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue';
|
||||
import { getLocalizedDayJs } from '@/packages/ui/src/utils/time';
|
||||
import { ref, watch, inject, type ComputedRef } from 'vue';
|
||||
import { getLocalizedDayJs, formatTime } from '@/packages/ui/src/utils/time';
|
||||
import { useFocus } from '@vueuse/core';
|
||||
import { TextInput } from '@/packages/ui/src';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
import type { Organization } from '@/packages/api/src';
|
||||
|
||||
// This has to be a localized timestamp, not UTC
|
||||
const model = defineModel<string | null>({
|
||||
default: null,
|
||||
});
|
||||
|
||||
const organization = inject<ComputedRef<Organization>>('organization');
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
size?: 'base' | 'large';
|
||||
@@ -24,62 +27,95 @@ const props = withDefaults(
|
||||
function updateTime(event: Event) {
|
||||
const target = event.target as HTMLInputElement;
|
||||
const newValue = target.value.trim();
|
||||
|
||||
// Get current hours and minutes for comparison
|
||||
const currentTime = model.value ? getLocalizedDayJs(model.value) : null;
|
||||
const currentHours = currentTime?.hour() ?? 0;
|
||||
const currentMinutes = currentTime?.minute() ?? 0;
|
||||
|
||||
// Handle AM/PM format
|
||||
const amPmMatch = newValue.match(/^(\d{1,2}):?(\d{2})?\s*(AM|PM|am|pm)$/);
|
||||
if (amPmMatch) {
|
||||
let hours = amPmMatch[1];
|
||||
const minutes = amPmMatch[2] ?? '00';
|
||||
const period = amPmMatch[3];
|
||||
|
||||
hours = parseInt(hours).toString();
|
||||
if (period.toUpperCase() === 'PM' && hours !== '12') {
|
||||
hours = (parseInt(hours) + 12).toString();
|
||||
} else if (period.toUpperCase() === 'AM' && hours === '12') {
|
||||
hours = '0';
|
||||
}
|
||||
|
||||
const newHours = parseInt(hours);
|
||||
const newMinutes = parseInt(minutes);
|
||||
|
||||
if (newHours !== currentHours || newMinutes !== currentMinutes) {
|
||||
model.value = getLocalizedDayJs(model.value)
|
||||
.set('hours', newHours)
|
||||
.set('minutes', newMinutes)
|
||||
.set('seconds', 0)
|
||||
.format();
|
||||
emit('changed', model.value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle existing formats
|
||||
if (newValue.split(':').length === 2) {
|
||||
const [hours, minutes] = newValue.split(':');
|
||||
if (!isNaN(parseInt(hours)) && !isNaN(parseInt(minutes))) {
|
||||
model.value = getLocalizedDayJs(model.value)
|
||||
.set('hours', Math.min(parseInt(hours), 23))
|
||||
.set('minutes', Math.min(parseInt(minutes), 59))
|
||||
.format();
|
||||
emit('changed', model.value);
|
||||
const newHours = Math.min(parseInt(hours), 23);
|
||||
const newMinutes = Math.min(parseInt(minutes), 59);
|
||||
|
||||
if (newHours !== currentHours || newMinutes !== currentMinutes) {
|
||||
model.value = getLocalizedDayJs(model.value)
|
||||
.set('hours', newHours)
|
||||
.set('minutes', newMinutes)
|
||||
.set('seconds', 0)
|
||||
.format();
|
||||
emit('changed', model.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if input is only numbers
|
||||
else if (/^\d+$/.test(newValue)) {
|
||||
let newHours = currentHours;
|
||||
let newMinutes = currentMinutes;
|
||||
|
||||
if (newValue.length === 4) {
|
||||
// parse 1300 to 13:00
|
||||
const [hours, minutes] = [
|
||||
newValue.slice(0, 2),
|
||||
newValue.slice(2, 4),
|
||||
];
|
||||
model.value = getLocalizedDayJs(model.value)
|
||||
.set('hours', Math.min(parseInt(hours), 23))
|
||||
.set('minutes', Math.min(parseInt(minutes), 59))
|
||||
.format();
|
||||
emit('changed', model.value);
|
||||
newHours = Math.min(parseInt(newValue.slice(0, 2)), 23);
|
||||
newMinutes = Math.min(parseInt(newValue.slice(2, 4)), 59);
|
||||
} else if (newValue.length === 3) {
|
||||
// parse 130 to 01:30
|
||||
const [hours, minutes] = [
|
||||
newValue.slice(0, 1),
|
||||
newValue.slice(1, 3),
|
||||
];
|
||||
model.value = getLocalizedDayJs(model.value)
|
||||
.set('hours', Math.min(parseInt(hours), 23))
|
||||
.set('minutes', Math.min(parseInt(minutes), 59))
|
||||
.format();
|
||||
emit('changed', model.value);
|
||||
newHours = Math.min(parseInt(newValue.slice(0, 1)), 23);
|
||||
newMinutes = Math.min(parseInt(newValue.slice(1, 3)), 59);
|
||||
} else if (newValue.length === 2) {
|
||||
// parse 13 to 13:00
|
||||
model.value = getLocalizedDayJs(model.value)
|
||||
.set('hours', Math.min(parseInt(newValue), 23))
|
||||
.set('minutes', 0)
|
||||
.format();
|
||||
emit('changed', model.value);
|
||||
newHours = Math.min(parseInt(newValue), 23);
|
||||
newMinutes = 0;
|
||||
} else if (newValue.length === 1) {
|
||||
// parse 1 to 01:00
|
||||
newHours = Math.min(parseInt(newValue), 23);
|
||||
newMinutes = 0;
|
||||
}
|
||||
|
||||
if (newHours !== currentHours || newMinutes !== currentMinutes) {
|
||||
model.value = getLocalizedDayJs(model.value)
|
||||
.set('hours', Math.min(parseInt(newValue), 23))
|
||||
.set('minutes', 0)
|
||||
.set('hours', newHours)
|
||||
.set('minutes', newMinutes)
|
||||
.set('seconds', 0)
|
||||
.format();
|
||||
emit('changed', model.value);
|
||||
}
|
||||
}
|
||||
|
||||
inputValue.value = getLocalizedDayJs(model.value).format('HH:mm');
|
||||
}
|
||||
|
||||
watch(model, (value) => {
|
||||
inputValue.value = value ? getLocalizedDayJs(value).format('HH:mm') : null;
|
||||
inputValue.value = value
|
||||
? formatTime(value, organization?.value?.time_format || '24-hours')
|
||||
: null;
|
||||
});
|
||||
|
||||
const timeInput = ref<HTMLInputElement | null>(null);
|
||||
@@ -88,7 +124,12 @@ const emit = defineEmits(['changed']);
|
||||
useFocus(timeInput, { initialValue: props.focus });
|
||||
|
||||
const inputValue = ref(
|
||||
model.value ? getLocalizedDayJs(model.value).format('HH:mm') : null
|
||||
model.value
|
||||
? formatTime(
|
||||
model.value,
|
||||
organization?.value?.time_format || '24-hours'
|
||||
)
|
||||
: null
|
||||
);
|
||||
</script>
|
||||
|
||||
@@ -98,7 +139,7 @@ const inputValue = ref(
|
||||
ref="timeInput"
|
||||
v-model="inputValue"
|
||||
:class="
|
||||
twMerge('text-center w-24 px-3 py-2', size === 'large' && 'w-28')
|
||||
twMerge('text-center w-28 px-3 py-2', size === 'large' && 'w-28')
|
||||
"
|
||||
data-testid="time_picker_input"
|
||||
type="text"
|
||||
|
||||
@@ -52,26 +52,22 @@ watch(focused, (newValue, oldValue) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
<form
|
||||
ref="dropdownContent"
|
||||
class="grid grid-cols-2 divide-x divide-card-background-separator text-center py-2">
|
||||
<div
|
||||
class="px-2"
|
||||
@keydown.enter.prevent="nextTick(() => emit('close'))">
|
||||
<div class="font-semibold text-text-primary text-sm pb-2">Start</div>
|
||||
<div class="px-2">
|
||||
<div class="font-semibold text-text-primary text-sm pb-2">
|
||||
Start
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<TimePickerSimple
|
||||
v-model="tempStart"
|
||||
data-testid="time_entry_range_start"
|
||||
tabindex="0"
|
||||
:focus
|
||||
@keydown.enter.prevent="nextTick(() => emit('close'))"
|
||||
@keydown.exact.tab.shift.stop.prevent="emit('close')"
|
||||
@changed="updateTimeEntry"></TimePickerSimple>
|
||||
<DatePicker
|
||||
v-model="tempStart"
|
||||
class="text-xs text-text-tertiary max-w-24 px-1.5 py-1.5"
|
||||
@changed="updateTimeEntry"
|
||||
@blur.stop.prevent="emit('close')"></DatePicker>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
@@ -80,16 +76,31 @@ watch(focused, (newValue, oldValue) => {
|
||||
<TimePickerSimple
|
||||
v-model="tempEnd"
|
||||
data-testid="time_entry_range_end"
|
||||
@keydown.enter.prevent="nextTick(() => emit('close'))"
|
||||
@changed="updateTimeEntry"></TimePickerSimple>
|
||||
<DatePicker
|
||||
v-model="tempEnd"
|
||||
class="text-xs text-text-tertiary max-w-24 px-1.5 py-1.5"
|
||||
@changed="updateTimeEntry"></DatePicker>
|
||||
</div>
|
||||
<div v-else class="text-text-secondary">-- : --</div>
|
||||
<div tabindex="0" @focusin="emit('close')"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-2 pt-2">
|
||||
<DatePicker
|
||||
v-model="tempStart"
|
||||
size="sm"
|
||||
class="text-xs text-text-tertiary max-w-28 px-1.5 py-1.5"
|
||||
@changed="updateTimeEntry"></DatePicker>
|
||||
</div>
|
||||
<div class="px-2 pt-2">
|
||||
<DatePicker
|
||||
v-if="tempEnd !== null"
|
||||
v-model="tempEnd"
|
||||
size="sm"
|
||||
class="text-xs text-text-tertiary max-w-28 px-1.5 py-1.5"
|
||||
@changed="updateTimeEntry"></DatePicker>
|
||||
</div>
|
||||
<div
|
||||
tabindex="0"
|
||||
class="focus-visible:outline-none"
|
||||
@focusin="emit('close')"></div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<style></style>
|
||||
|
||||
@@ -29,7 +29,7 @@ import DurationHumanInput from '@/packages/ui/src/Input/DurationHumanInput.vue';
|
||||
|
||||
import { InformationCircleIcon } from '@heroicons/vue/20/solid';
|
||||
import type { Tag, Task } from '@/packages/api/src';
|
||||
import TimePickerSimple from "@/packages/ui/src/Input/TimePickerSimple.vue";
|
||||
import TimePickerSimple from '@/packages/ui/src/Input/TimePickerSimple.vue';
|
||||
|
||||
const show = defineModel('show', { default: false });
|
||||
const saving = ref(false);
|
||||
@@ -148,9 +148,7 @@ type BillableOption = {
|
||||
<div class="flex-1 min-w-0">
|
||||
<TimeTrackerProjectTaskDropdown
|
||||
v-model:project="timeEntry.project_id"
|
||||
v-model:task="
|
||||
timeEntry.task_id
|
||||
"
|
||||
v-model:task="timeEntry.task_id"
|
||||
:clients
|
||||
:create-project
|
||||
:create-client
|
||||
@@ -160,7 +158,9 @@ type BillableOption = {
|
||||
class="bg-input-background"
|
||||
:projects="projects"
|
||||
:tasks="tasks"
|
||||
:enable-estimated-time="enableEstimatedTime"></TimeTrackerProjectTaskDropdown>
|
||||
:enable-estimated-time="
|
||||
enableEstimatedTime
|
||||
"></TimeTrackerProjectTaskDropdown>
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<div class="flex-col">
|
||||
@@ -242,37 +242,33 @@ type BillableOption = {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="">
|
||||
<InputLabel>Start</InputLabel>
|
||||
<div class="flex flex-col items-center space-y-2 mt-1">
|
||||
<div class="grid gap-2 grid-cols-2">
|
||||
<div class="space-y-1">
|
||||
<InputLabel>Start</InputLabel>
|
||||
<TimePickerSimple
|
||||
|
||||
v-model="localStart"
|
||||
size="large"></TimePickerSimple>
|
||||
<DatePicker
|
||||
v-model="localStart"
|
||||
tabindex="1"
|
||||
class="text-xs text-text-tertiary max-w-28 px-1.5 py-1.5"></DatePicker>
|
||||
</div>
|
||||
</div>
|
||||
<div class="">
|
||||
<InputLabel>End</InputLabel>
|
||||
<div class="flex flex-col items-center space-y-2 mt-1">
|
||||
<div class="space-y-1">
|
||||
<InputLabel>End</InputLabel>
|
||||
<TimePickerSimple
|
||||
v-model="localEnd"
|
||||
size="large"></TimePickerSimple>
|
||||
<DatePicker
|
||||
v-model="localEnd"
|
||||
tabindex="1"
|
||||
class="text-xs text-text-tertiary max-w-28 px-1.5 py-1.5"></DatePicker>
|
||||
</div>
|
||||
<DatePicker
|
||||
v-model="localStart"
|
||||
size="sm"
|
||||
class="text-xs text-text-tertiary max-w-28 px-1.5 py-1.5"></DatePicker>
|
||||
<DatePicker
|
||||
v-model="localEnd"
|
||||
size="sm"
|
||||
class="text-xs text-text-tertiary max-w-28 px-1.5 py-1.5"></DatePicker>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
<SecondaryButton tabindex="2" @click="show = false"> Cancel</SecondaryButton>
|
||||
<SecondaryButton @click="show = false">Cancel</SecondaryButton>
|
||||
<PrimaryButton
|
||||
tabindex="2"
|
||||
class="ms-3"
|
||||
:class="{ 'opacity-25': saving }"
|
||||
:disabled="saving"
|
||||
|
||||
@@ -101,15 +101,19 @@ const startTime = computed(() => {
|
||||
const inputField = ref<HTMLInputElement | null>(null);
|
||||
|
||||
const timeRangeSelector = ref<HTMLElement | null>(null);
|
||||
const isMouseDown = ref(false);
|
||||
|
||||
function openModalOnTab(e: FocusEvent) {
|
||||
// check if the source is inside the dropdown
|
||||
|
||||
console.log(e.target);
|
||||
const source = e.relatedTarget as HTMLElement;
|
||||
if (
|
||||
source &&
|
||||
window.document.body
|
||||
.querySelector<HTMLElement>('#app')
|
||||
?.contains(source)
|
||||
?.contains(source) &&
|
||||
!isMouseDown.value
|
||||
) {
|
||||
open.value = true;
|
||||
}
|
||||
@@ -153,6 +157,8 @@ function closeAndFocusInput() {
|
||||
@keydown.exact.tab="focusNextElement"
|
||||
@keydown.exact.shift.tab="open = false"
|
||||
@blur="updateTimerAndStartLiveTimerUpdate"
|
||||
@mousedown="isMouseDown = true"
|
||||
@mouseup="isMouseDown = false"
|
||||
@keydown.enter="onTimeEntryEnterPress" />
|
||||
</template>
|
||||
<template #content>
|
||||
|
||||
@@ -13,7 +13,6 @@ import updateLocale from 'dayjs/plugin/updateLocale';
|
||||
import { computed } from 'vue';
|
||||
import { formatNumber } from './number';
|
||||
|
||||
|
||||
export type DateFormat =
|
||||
| 'point-separated-d-m-yyyy'
|
||||
| 'slash-separated-mm-dd-yyyy'
|
||||
@@ -28,7 +27,7 @@ const dateFormatMap: Record<DateFormat, string> = {
|
||||
'slash-separated-dd-mm-yyyy': 'DD/MM/YYYY',
|
||||
'hyphen-separated-dd-mm-yyyy': 'DD-MM-YYYY',
|
||||
'hyphen-separated-mm-dd-yyyy': 'MM-DD-YYYY',
|
||||
'hyphen-separated-yyyy-mm-dd': 'YYYY-MM-DD'
|
||||
'hyphen-separated-yyyy-mm-dd': 'YYYY-MM-DD',
|
||||
};
|
||||
|
||||
export type TimeFormat = '12-hours' | '24-hours';
|
||||
@@ -84,7 +83,7 @@ export function formatHumanReadableDuration(
|
||||
case 'hours-minutes':
|
||||
return `${hours}h ${minutes.toString().padStart(2, '0')}min`;
|
||||
case 'hours-minutes-colon-separated':
|
||||
return `${hours}:${minutes.toString().padStart(2, '0')}`;
|
||||
return `${hours}:${minutes.toString().padStart(2, '0')} h`;
|
||||
case 'hours-minutes-seconds-colon-separated':
|
||||
return `${hours}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
|
||||
default:
|
||||
@@ -129,7 +128,10 @@ export function getLocalizedDateFromTimestamp(timestamp: string) {
|
||||
* Returns a formatted date.
|
||||
* @param date - date in the format of 'YYYY-MM-DD'
|
||||
*/
|
||||
export function formatDate(date: string, format: DateFormat = 'point-separated-d-m-yyyy'): string {
|
||||
export function formatDate(
|
||||
date: string,
|
||||
format: DateFormat = 'point-separated-d-m-yyyy'
|
||||
): string {
|
||||
if (date?.includes('+')) {
|
||||
console.warn(
|
||||
'Date contains timezone information, use formatDateLocalized instead'
|
||||
@@ -142,11 +144,18 @@ export function formatDate(date: string, format: DateFormat = 'point-separated-d
|
||||
* Returns a formatted date.
|
||||
* @param date - date in the format of 'YYYY-MM-DD'
|
||||
*/
|
||||
export function formatDateLocalized(date: string, format: DateFormat = 'point-separated-d-m-yyyy'): string {
|
||||
export function formatDateLocalized(
|
||||
date: string,
|
||||
format: DateFormat = 'point-separated-d-m-yyyy'
|
||||
): string {
|
||||
return getLocalizedDayJs(date).format(dateFormatMap[format]);
|
||||
}
|
||||
|
||||
export function formatDateTimeLocalized(date: string, dateFormat?: DateFormat, timeFormat?: TimeFormat): string {
|
||||
export function formatDateTimeLocalized(
|
||||
date: string,
|
||||
dateFormat?: DateFormat,
|
||||
timeFormat?: TimeFormat
|
||||
): string {
|
||||
const format = `${dateFormatMap[dateFormat ?? 'point-separated-d-m-yyyy']} ${timeFormat === '12-hours' ? 'hh:mm A' : 'HH:mm'}`;
|
||||
return getLocalizedDayJs(date).format(format);
|
||||
}
|
||||
@@ -172,7 +181,11 @@ export function formatWeekday(date: string) {
|
||||
return dayjs(date).format('dddd');
|
||||
}
|
||||
|
||||
export function formatStartEnd(start: string, end: string | null, timeFormat: TimeFormat = '24-hours') {
|
||||
export function formatStartEnd(
|
||||
start: string,
|
||||
end: string | null,
|
||||
timeFormat: TimeFormat = '24-hours'
|
||||
) {
|
||||
if (end) {
|
||||
return `${formatTime(start, timeFormat)} - ${formatTime(end, timeFormat)}`;
|
||||
} else {
|
||||
|
||||
@@ -340,6 +340,35 @@ class ReportEndpointTest extends ApiEndpointTestAbstract
|
||||
);
|
||||
}
|
||||
|
||||
public function test_update_endpoint_can_update_public_until_without_changing_secret(): void
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
'reports:update',
|
||||
]);
|
||||
$report = Report::factory()->public()->forOrganization($data->organization)->create();
|
||||
$secret = $report->share_secret;
|
||||
$newPublicUntil = Carbon::now()->addDays(30)->toIso8601ZuluString();
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->putJson(route('api.v1.reports.update', [$data->organization->getKey(), $report->getKey()]), [
|
||||
'public_until' => $newPublicUntil,
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$report->refresh();
|
||||
$this->assertTrue($report->is_public);
|
||||
$this->assertSame($secret, $report->share_secret);
|
||||
$this->assertSame($newPublicUntil, $report->public_until->toIso8601ZuluString());
|
||||
$response->assertStatus(200);
|
||||
$response->assertJson(fn (AssertableJson $json) => $json
|
||||
->has('data')
|
||||
->where('data.is_public', true)
|
||||
->where('data.shareable_link', $report->getShareableLink())
|
||||
);
|
||||
}
|
||||
|
||||
public function test_update_endpoint_can_update_the_report_all_properties_set(): void
|
||||
{
|
||||
// Arrange
|
||||
|
||||
Reference in New Issue
Block a user