Ghost/ghost/admin/app/components/gh-publishmenu-draft.hbs
Kevin Ansfield e5c26aac89 Added newsletter dropdown to publish menu
closes https://github.com/TryGhost/Team/issues/1479

- updated post adapter to append `?newsletter_id=xyz` when passed a `newsletterId` adapterOption
- updated editor save task to pass `options.newsletterId` through as `adapterOptions.newsletterId`
- set up `post.newsletter` relationship ready for handling embedded newsletter association from the API
  - explicitly deleted when serializing back to the API as it doesn't yet ignore the attribute
- updated `<GhPublishmenu>` for newsletter support
  - fetches newsletters on first render so they are available in the dropdown
  - sets "default" (first in the ordered list) newsletter as the initially selected newsletter
  - adds newsletter dropdown to draft publish menu
  - passes `newsletterId` option to editor save task when it's set

This is a minimal implementation for testing. Not included:
- correct free/paid member counts based on selected newsletter
- correct member count in confirmation modal
- indication of selected newsletter for scheduled post
2022-04-06 10:22:06 +01:00

92 lines
5.0 KiB
Handlebars

<div ...attributes>
<header class="gh-publishmenu-heading" data-test-publishmenu-header>Ready to
{{#if @canSendEmail}}
<GhDistributionActionSelect
@distributionAction={{@distributionAction}}
@setDistributionAction={{@setDistributionAction}}
data-test-distribution-action-select
/>
{{else}}
publish
{{/if}}
this {{@post.displayName}}?
</header>
<section class="gh-publishmenu-content {{if this.disableEmailOption "no-border"}}">
<div class="gh-publishmenu-section">
<div class="gh-publishmenu-radio {{if (eq @saveType "publish") "active"}}" {{on "click" (fn this.setSaveType "publish")}}>
<div class="gh-publishmenu-radio-button" data-test-publishmenu-published-option></div>
<div class="gh-publishmenu-radio-content">
<div class="gh-publishmenu-radio-label">{{#if @emailOnly}}Send email now{{else}}Set it live now{{/if}}</div>
<div class="gh-publishmenu-radio-desc">{{#if @emailOnly}}Deliver this immediately{{else}}Publish this {{@post.displayName}} immediately{{/if}}</div>
</div>
</div>
<div class="gh-publishmenu-radio {{if (eq @saveType "schedule") "active"}}" {{on "click" (fn this.setSaveType "schedule")}}>
<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>
<GhDateTimePicker
@date={{@post.publishedAtBlogDate}}
@time={{@post.publishedAtBlogTime}}
@setDate={{this.setDate}}
@setTime={{this.setTime}}
@onDateError={{this.dateInputDidError}}
@onTimeError={{this.timeInputDidError}}
@setTypedDateError={{@setTypedDateError}}
@errors={{@post.errors}}
@dateErrorProperty="publishedAtBlogDate"
@timeErrorProperty="publishedAtBlogTime"
@minDate={{this._minDate}}
@isActive={{eq @saveType "schedule"}}
/>
<div class="gh-publishmenu-radio-desc">{{#if @emailOnly}}Send email at a specific time{{else}}Set automatic future publish date{{/if}}</div>
</div>
</div>
</div>
{{#if this.showEmailSection}}
<div class="gh-publishmenu-section {{if @isSendingEmailLimited "no-border"}}" {{did-insert (perform this.countTotalMembersTask)}}>
<div class="gh-publishmenu-email">
{{#if @isSendingEmailLimited}}
<p class="gh-box gh-box-alert">{{html-safe @sendingEmailLimitError}}</p>
{{else}}
<div class="gh-publishmenu-email-label">
<label class="gh-publishmenu-radio-label mb3">Send by email to</label>
{{#if this.disableEmailOption}}
<p class="gh-box gh-content-box">
<LinkTo @route="members">
Add members
</LinkTo>
to start sending newsletters!
</p>
{{else}}
<div class="form-group">
{{#if (and (feature "multipleNewsletters") (gt @availableNewsletters.length 1))}}
<div class="mb3">
<p>Newsletter</p>
<PowerSelect
@selected={{@selectedNewsletter}}
@options={{@availableNewsletters}}
@onChange={{@selectNewsletter}}
@triggerComponent="gh-power-select/trigger"
@renderInPlace={{true}}
as |newsletter|
>
{{newsletter.name}}
</PowerSelect>
</div>
{{/if}}
<GhMembersRecipientSelect
@filter={{@recipientsFilter}}
@onChange={{@setSendEmailWhenPublished}}
/>
</div>
{{/if}}
</div>
{{/if}}
</div>
</div>
{{/if}}
</section>
</div>