Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion resources/js/components/fieldtypes/TimeFieldtype.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<template>
<Button :text="__('Set Time')" icon="fieldtype-time" v-if="!isReadOnly && !hasTime" @click="addTime" />
<Button :text="__('Set Time')" icon="fieldtype-time" v-if="!isReadOnly && !config.disabled && !hasTime" @click="addTime" />

<TimePicker
v-if="hasTime"
ref="time"
:model-value="timePickerValue"
:granularity="useSeconds ? 'second' : 'minute'"
:disabled="config.disabled"
:read-only="isReadOnly"
@update:model-value="timePickerUpdated"
/>
</template>
Expand Down
11 changes: 9 additions & 2 deletions resources/js/components/ui/TimePicker/TimePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const props = defineProps({
granularity: { type: String, default: null },
/** When `true`, clear and "set to now" buttons are displayed. */
clearable: { type: Boolean, default: true },
/** When `true`, the time picker is disabled. */
disabled: { type: Boolean, default: false },
/** When `true`, the time picker is read-only. */
readOnly: { type: Boolean, default: false },
});

const setToNow = () => {
Expand All @@ -35,12 +39,15 @@ const setToNow = () => {
v-slot="{ segments }"
:locale="$date.locale"
:granularity="granularity"
:disabled="disabled || readOnly"
:class="[
'flex items-center w-full bg-white dark:bg-gray-900',
'border border-gray-300 dark:border-gray-700',
'leading-5 text-gray-600 dark:text-gray-300',
'shadow-ui-sm not-prose h-10 rounded-lg py-2 px-3 disabled:shadow-none',
'data-invalid:border-red-500',
disabled ? 'disabled:shadow-none disabled:opacity-50' : '',
readOnly ? 'border-dashed' : '',
]"
>
<div class="flex-1 flex items-center">
Expand All @@ -56,8 +63,8 @@ const setToNow = () => {
</template>
</div>
<div class="flex items-center gap-1">
<Button v-if="clearable" @click="setToNow" type="button" class="[&_svg]:opacity-80! dark:[&_svg]:opacity-70! hover:[&_svg]:opacity-100!" size="xs" v-tooltip="__('Set to now')" icon="time-now" />
<Button v-if="clearable" @click="emit('update:modelValue', null)" type="button" class="[&_svg]:opacity-80! dark:[&_svg]:opacity-70! hover:[&_svg]:opacity-100!" v-tooltip="__('Clear')" icon="x" size="xs" />
<Button v-if="clearable && !readOnly" @click="setToNow" type="button" class="[&_svg]:opacity-80! dark:[&_svg]:opacity-70! hover:[&_svg]:opacity-100!" size="xs" v-tooltip="__('Set to now')" icon="time-now" :disabled="disabled" />
<Button v-if="clearable && !readOnly" @click="emit('update:modelValue', null)" type="button" class="[&_svg]:opacity-80! dark:[&_svg]:opacity-70! hover:[&_svg]:opacity-100!" v-tooltip="__('Clear')" icon="x" size="xs" :disabled="disabled" />
</div>
</TimeFieldRoot>

Expand Down
Loading