From 3fba00c1e5b827e8b47cd34417b59b893aa350c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Wed, 28 Aug 2019 14:00:28 +0200 Subject: [PATCH] Disable last step in UI for already sent standard emails [MAILPOET-2195] --- .../components/newsletterEditor/components/_save.scss | 2 +- assets/js/src/newsletter_editor/components/save.js | 11 +++++++++-- views/newsletter/editor.html | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/assets/css/src/components/newsletterEditor/components/_save.scss b/assets/css/src/components/newsletterEditor/components/_save.scss index 84a17376c3..f664ed48b0 100644 --- a/assets/css/src/components/newsletterEditor/components/_save.scss +++ b/assets/css/src/components/newsletterEditor/components/_save.scss @@ -97,7 +97,7 @@ color: $error-text-color; margin-top: 10px; text-align: right; - width: $sidebar-width - 20px; + width: $sidebar-width; } .mailpoet_save_dropdown_down { diff --git a/assets/js/src/newsletter_editor/components/save.js b/assets/js/src/newsletter_editor/components/save.js index 2cf4de27bf..4537cefade 100644 --- a/assets/js/src/newsletter_editor/components/save.js +++ b/assets/js/src/newsletter_editor/components/save.js @@ -248,6 +248,7 @@ Module.SaveView = Marionette.View.extend({ }, validateNewsletter: function (jsonObject) { var body = ''; + var newsletter; if (!App._contentContainer.isValid()) { this.showValidationError(App._contentContainer.validationError); return; @@ -263,7 +264,8 @@ Module.SaveView = Marionette.View.extend({ return; } - if ((App.getNewsletter().get('type') === 'notification') + newsletter = App.getNewsletter(); + if ((newsletter.get('type') === 'notification') && body.indexOf('"type":"automatedLatestContent"') < 0 && body.indexOf('"type":"automatedLatestContentLayout"') < 0 ) { @@ -271,11 +273,16 @@ Module.SaveView = Marionette.View.extend({ return; } + if (newsletter.get('type') === 'standard' && newsletter.get('status') === 'sent') { + this.showValidationError(MailPoet.I18n.t('emailAlreadySent')); + return; + } + this.hideValidationError(); }, showValidationError: function (message) { var $el = this.$('.mailpoet_save_error'); - $el.text(message); + $el.html(message.replace(/\. /g, '.
')); $el.removeClass('mailpoet_hidden'); this.$('.mailpoet_save_next').addClass('button-disabled'); diff --git a/views/newsletter/editor.html b/views/newsletter/editor.html index a694fa3257..21ff08e274 100644 --- a/views/newsletter/editor.html +++ b/views/newsletter/editor.html @@ -309,6 +309,7 @@ 'failedToFetchRenderedPosts': __('Failed to fetch rendered posts'), 'shortcodesWindowTitle': __('Select a shortcode'), 'unsubscribeLinkMissing': __('All emails must include an "Unsubscribe" link. Add a footer widget to your email to continue.'), + '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.'), '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'), 'newsletterPreviewEmailMissing': __('Enter an email address to send the preview newsletter to.'), 'newsletterPreviewSent': __('Your test email has been sent!'),