Skip to content
Open
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
12 changes: 11 additions & 1 deletion resources/js/components/fieldtypes/DateFieldtype.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="datetime min-w-[145px]">
<div v-if="mounted" class="datetime min-w-[145px]">
<Button :text="__('Add Date')" icon="calendar" v-if="!isReadOnly && !isInline && !hasDate" @click="addDate" />

<Component
Expand Down Expand Up @@ -35,6 +35,7 @@ export default {

data() {
return {
mounted: false,
containerWidth: null,
focusedField: null,
localValue: null,
Expand Down Expand Up @@ -102,6 +103,15 @@ export default {
this.$events.$on(`container.${this.publishContainer.name}.saving`, this.triggerChangeOnFocusedField);
},

mounted() {
if (this.value === 'now') {
this.addDate();
this.$nextTick(() => this.injectedPublishContainer.clearDirtyState());
}

this.mounted = true;
},

unmounted() {
this.$events.$off(`container.${this.publishContainer.name}.saving`, this.triggerChangeOnFocusedField);
},
Expand Down
1 change: 1 addition & 0 deletions resources/js/components/ui/Publish/Container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ const provided = {
setRevealerField,
unsetRevealerField,
setHiddenField,
clearDirtyState,
};

provideContainerContext({ ...provided, container: provided });
Expand Down
2 changes: 1 addition & 1 deletion src/Fieldtypes/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private function preProcessSingle($value)
}

if ($value === 'now') {
return now('UTC')->toIso8601ZuluString('millisecond');
return 'now';
}

// If the value is an array, this field probably used to be a range. In this case, we'll use the start date.
Expand Down
2 changes: 1 addition & 1 deletion tests/Fieldtypes/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public static function preProcessProvider()
'UTC',
[],
'now', // this would happen if the value was null, but default was "now"
'2010-12-25T13:43:00.000Z', // current date
'now', // handled on the frontend
],
'date without time' => [
'UTC',
Expand Down