Ghost/ghost/admin/app/templates/components/gh-publishmenu-draft.hbs
Kevin Ansfield 6fe159c8d9 Updated handling of send_email_when_published
refs 5fd2b7fed1

- sends `?send_email_when_published=true` query param when scheduling/publishing a post with the toggle turned on
  - adds support to the posts adapter for handling the `adapterOptions` option
  - updates the editor `save` task to pass through the required adapter option when a post is being published or scheduled with the toggle checked
- moves state for the email toggle into the publish menu so that we don't try to toggle the model attribute which should only be fetched from the API
- prevent `post.send_email_when_published` being sent to the API via the serializer as it's now a read-only attribute
2019-11-14 17:33:35 +00:00

63 lines
3.2 KiB
Handlebars

<header class="gh-publishmenu-heading">Ready to publish your {{post.displayName}}?</header>
<section class="gh-publishmenu-content">
<div class="gh-publishmenu-section">
<div class="gh-publishmenu-radio {{if (eq saveType "publish") "active"}}" {{action "setSaveType" "publish" on="click"}}>
<div class="gh-publishmenu-radio-button" data-test-publishmenu-published-option></div>
<div class="gh-publishmenu-radio-content">
<div class="gh-publishmenu-radio-label">Set it live now</div>
<div class="gh-publishmenu-radio-desc">Publish this {{post.displayName}} immediately</div>
</div>
</div>
<div class="gh-publishmenu-radio {{if (eq saveType "schedule") "active"}}" {{action "setSaveType" "schedule" on="click"}}>
<div class="gh-publishmenu-radio-button" data-test-publishmenu-scheduled-option></div>
<div class="gh-publishmenu-radio-content">
<div class="gh-publishmenu-radio-label">Schedule it for later</div>
{{gh-date-time-picker
date=post.publishedAtBlogDate
time=post.publishedAtBlogTime
setDate=(action "setDate")
setTime=(action "setTime")
errors=post.errors
dateErrorProperty="publishedAtBlogDate"
timeErrorProperty="publishedAtBlogTime"
minDate=_minDate
}}
<div class="gh-publishmenu-radio-desc">Set automatic future publish date</div>
</div>
</div>
</div>
{{#if this.canSendEmail}}
<div class="gh-publishmenu-section">
<div class="gh-publishmenu-radio gh-publishmenu-email">
{{#if this.backgroundLoader.isRunning}}
<div class="gh-loading-spinner" style="zoom: 50%"></div>
{{else}}
<div class="gh-publishmenu-email-label {{if disableEmailOption "pe-none"}}">
<label class="gh-publishmenu-radio-label {{unless this.memberCount "midgrey"}}" for="email-when-published-checkbox">Send by email</label>
{{#if this.memberCount}}
<div class="gh-publishmenu-radio-desc">Deliver post to members</div>
{{else}}
<div class="gh-publishmenu-radio-desc">You haven't got any members</div>
{{/if}}
</div>
<div class="for-switch small {{if disableEmailOption "pe-none"}}">
<div class="switch container" for="email-when-published-checkbox">
<Input
@checked={{this.sendEmailWhenPublished}}
@type="checkbox"
@id="email-when-published-checkbox"
@name="email-when-published"
@disabled={{disableEmailOption}}
/>
<span class="input-toggle-component gh-publishmenu-email-checkbox"
{{on "click" (toggle "sendEmailWhenPublished" this)}}></span>
</div>
</div>
{{/if}}
</div>
</div>
{{/if}}
</section>