Prefill today's date
[MAILPOET-2453]
This commit is contained in:
committed by
Rostislav Wolný
parent
3230bff824
commit
b6d12d39c2
@ -1,4 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import moment from 'moment';
|
||||||
import {
|
import {
|
||||||
Panel,
|
Panel,
|
||||||
PanelBody,
|
PanelBody,
|
||||||
@ -10,6 +11,7 @@ import MailPoet from 'mailpoet';
|
|||||||
import { useDispatch, useSelect } from '@wordpress/data';
|
import { useDispatch, useSelect } from '@wordpress/data';
|
||||||
|
|
||||||
import CustomFieldSettings from './custom_field_settings.jsx';
|
import CustomFieldSettings from './custom_field_settings.jsx';
|
||||||
|
import FormFieldDate from '../../../form/fields/date.jsx';
|
||||||
|
|
||||||
const CustomDateEdit = ({ attributes, setAttributes }) => {
|
const CustomDateEdit = ({ attributes, setAttributes }) => {
|
||||||
const isSaving = useSelect(
|
const isSaving = useSelect(
|
||||||
@ -47,7 +49,7 @@ const CustomDateEdit = ({ attributes, setAttributes }) => {
|
|||||||
mandatory: params.mandatory,
|
mandatory: params.mandatory,
|
||||||
dateType: params.dateType,
|
dateType: params.dateType,
|
||||||
dateFormat: params.dateFormat,
|
dateFormat: params.dateFormat,
|
||||||
dateDefaultToday: params.defaultToday,
|
defaultToday: params.defaultToday,
|
||||||
}),
|
}),
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
@ -76,16 +78,24 @@ const CustomDateEdit = ({ attributes, setAttributes }) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{inspectorControls}
|
{inspectorControls}
|
||||||
<label className="mailpoet_text_label" data-automation-id="editor_custom_text_label" htmlFor="custom_text">
|
<label className="mailpoet_text_label mailpoet_custom_date" data-automation-id="editor_custom_date_label" htmlFor="custom_text">
|
||||||
{getLabel()}
|
{getLabel()}
|
||||||
<br />
|
<br />
|
||||||
<input
|
<FormFieldDate
|
||||||
id="custom_date"
|
field={{
|
||||||
className="mailpoet_date"
|
name: 'field',
|
||||||
type="text"
|
day_placeholder: MailPoet.I18n.t('customFieldDay'),
|
||||||
name="custom_date"
|
month_placeholder: MailPoet.I18n.t('customFieldMonth'),
|
||||||
disabled
|
year_placeholder: MailPoet.I18n.t('customFieldYear'),
|
||||||
data-automation-id="editor_custom_date_input"
|
params: {
|
||||||
|
date_type: attributes.dateType,
|
||||||
|
date_format: attributes.dateFormat,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
item={{
|
||||||
|
field: attributes.defaultToday ? moment().format('YYYY-MM-DD') : '',
|
||||||
|
}}
|
||||||
|
onValueChange={() => {}}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
</>
|
</>
|
||||||
|
Reference in New Issue
Block a user