mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-13 02:32:15 +01:00
fix datepicker for report create/update, fix public_until update
This commit is contained in:
@@ -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',
|
||||
@@ -109,7 +114,10 @@ async function submit() {
|
||||
(optional)
|
||||
</div>
|
||||
</div>
|
||||
<DatePicker id="public_until" size="input"></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,9 +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"
|
||||
size="input"></DatePicker>
|
||||
<DatePicker
|
||||
id="public_until"
|
||||
v-model="report.public_until"
|
||||
size="input"></DatePicker>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -30,7 +30,9 @@ const handleChange = (date: DateValue | undefined) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const dayjs = getLocalizedDayJs(model.value);
|
||||
const dayjs = model.value
|
||||
? getLocalizedDayJs(model.value)
|
||||
: getLocalizedDayJs();
|
||||
model.value = dayjs
|
||||
.year(date.year)
|
||||
.month(date.month - 1) // CalendarDate uses 1-based months
|
||||
@@ -62,12 +64,15 @@ const organization = inject<ComputedRef<Organization>>('organization');
|
||||
]"
|
||||
: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'
|
||||
]" />
|
||||
: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
|
||||
|
||||
Reference in New Issue
Block a user