Use validation for time intervals

[MAILPOET-3818]
This commit is contained in:
Jan Lysý
2021-10-20 13:37:02 +02:00
committed by Veljko V
parent 024f04750a
commit 44f08cd068
4 changed files with 12 additions and 0 deletions

View File

@@ -40,3 +40,7 @@ textarea.parsley-error {
.parsley-custom-error-message { .parsley-custom-error-message {
color: #b94a48; color: #b94a48;
} }
.mailpoet-form-errors {
padding: 0 16px;
}

View File

@@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import MailPoet from 'mailpoet';
import Selection from 'form/fields/selection.jsx'; import Selection from 'form/fields/selection.jsx';
import Text from 'form/fields/text.jsx'; import Text from 'form/fields/text.jsx';
import { timeDelayValues } from 'newsletters/scheduling/common.jsx'; import { timeDelayValues } from 'newsletters/scheduling/common.jsx';
@@ -106,6 +107,8 @@ class EventScheduling extends React.Component {
size: afterTimeNumberSize, size: afterTimeNumberSize,
validation: { validation: {
'data-parsley-required': true, 'data-parsley-required': true,
'data-parsley-errors-container': '.mailpoet-form-errors',
'data-parsley-scheduled-at': MailPoet.I18n.t('emailCanBeScheduledUpToFiveYears'),
}, },
}, },
item: {}, item: {},
@@ -136,6 +139,7 @@ class EventScheduling extends React.Component {
{this.displayAfterTimeNumberField()} {this.displayAfterTimeNumberField()}
{this.displayAfterTimeTypeOptions()} {this.displayAfterTimeTypeOptions()}
</div> </div>
<div className="mailpoet-form-errors" />
<div className="mailpoet-gap" /> <div className="mailpoet-gap" />
{ {
event.schedulingReadMoreLink event.schedulingReadMoreLink

View File

@@ -42,6 +42,8 @@ const afterTimeNumberField = {
size: 3, size: 3,
validation: { validation: {
'data-parsley-required': true, 'data-parsley-required': true,
'data-parsley-errors-container': '.mailpoet-form-errors',
'data-parsley-scheduled-at': MailPoet.I18n.t('emailCanBeScheduledUpToFiveYears'),
}, },
}; };
@@ -134,6 +136,7 @@ class WelcomeScheduling extends React.Component {
onValueChange={this.handleAfterTimeTypeChange} onValueChange={this.handleAfterTimeTypeChange}
/> />
</div> </div>
<div className="mailpoet-form-errors" />
<div className="mailpoet-gap" /> <div className="mailpoet-gap" />
</div> </div>
); );

View File

@@ -436,6 +436,7 @@
'newsletterIsEmpty': __('Poet, please add prose to your masterpiece before you send it to your followers.'), 'newsletterIsEmpty': __('Poet, please add prose to your masterpiece before you send it to your followers.'),
'automatedLatestContentMissing': _x('Please add an “Automatic Latest Content” widget to the email from the right sidebar.', '(Please reuse the current translation used for the string “Automatic Latest Content”) This Error message is displayed when a user tries to send a “Post Notification” email without any “Automatic Latest Content” widget inside'), 'automatedLatestContentMissing': _x('Please add an “Automatic Latest Content” widget to the email from the right sidebar.', '(Please reuse the current translation used for the string “Automatic Latest Content”) This Error message is displayed when a user tries to send a “Post Notification” email without any “Automatic Latest Content” widget inside'),
'emailAlreadySent': __('This email has already been sent. It can be edited, but not sent again. Duplicate this email if you want to send it again.'), 'emailAlreadySent': __('This email has already been sent. It can be edited, but not sent again. Duplicate this email if you want to send it again.'),
'emailCanBeScheduledUpToFiveYears': __('An email can only be scheduled up to 5 years in the future. Please choose a shorter period.'),
}) %> }) %>
<% include('mss_pitch_translations.html') %> <% include('mss_pitch_translations.html') %>
<% endblock %> <% endblock %>