-
-
Notifications
You must be signed in to change notification settings - Fork 391
add new datepicker to time entry picker, add am/pm support #790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Onatcer
wants to merge
7
commits into
main
Choose a base branch
from
feature/12_hour_format_timepicker_support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0bd32de
add new datepicker to time entry picker, add am/pm support
Onatcer 09f7fbc
improve hours-minutes-colon-seperated format
Onatcer f1cce79
improve DatePicker sizing in report create modal
Onatcer 4635fec
adapt test to respect new formatting for hours-minutes-colon-seperated
Onatcer 915204f
fix that timetracker duration popover instantly closes on click if an…
Onatcer a45c8a8
fix datepicker for report create/update, fix public_until update
Onatcer f79d995
make sure empty duration input updates v-model to null, fixes #816
Onatcer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 tempDate = ref(getLocalizedDayJs(model.value).format('YYYY-MM-DD')); | ||
|
|
||
| watch(model, (value) => { | ||
| tempDate.value = getLocalizedDayJs(value).format('YYYY-MM-DD'); | ||
| }); | ||
| const model = defineModel<string | null>(); | ||
| const emit = defineEmits<{ | ||
| changed: [string]; | ||
| }>(); | ||
|
|
||
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@korridor das update von public_until hat hier davor nicht funktioniert, außer wenn gleichzeitig public geändert wurde. passt das so oder überseh ich da wasß