Fixed email-cta card being auto-deleted when no content is set

refs https://github.com/TryGhost/Team/issues/928

- it's possible to set a button with no content in the CTA card but the auto-removal when exiting edit mode was only checking for presence of content
- updated to only remove the card when no content, button text, or button url has been set
This commit is contained in:
Kevin Ansfield 2021-07-28 18:00:01 +01:00
parent eed299d1f6
commit 2cf55cb307
3 changed files with 13 additions and 7 deletions

View File

@ -83,12 +83,14 @@
<div class="gh-email-cta-segment-indicator">
<p>{{capitalize this.selectedSegment.name}}</p>
</div>
<div class="relative">
<p>{{{this.formattedHtml}}}</p>
<div class="koenig-card-click-overlay"></div>
</div>
{{#if @payload.html}}
<div class="relative">
<p>{{{this.formattedHtml}}}</p>
<div class="koenig-card-click-overlay"></div>
</div>
{{/if}}
{{#if (and @payload.buttonText @payload.buttonUrl)}}
<div class="mt6"><a class="gh-btn gh-btn-accent" href="javascript:void(0)" data-tooltip={{@payload.buttonUrl}}><span>{{@payload.buttonText}}</span></a></div>
<div class="{{if @payload.html "mt6"}}"><a class="gh-btn gh-btn-accent" href="javascript:void(0)" data-tooltip={{@payload.buttonUrl}}><span>{{@payload.buttonText}}</span></a></div>
{{/if}}
{{/if}}
</KoenigCard>

View File

@ -100,7 +100,9 @@ export default class KoenigCardEmailCtaComponent extends Component {
@action
leaveEditMode() {
if (isBlank(this.args.payload.html)) {
const {html, buttonText, buttonUrl} = this.args.payload;
if (isBlank(html) && isBlank(buttonText) && isBlank(buttonUrl)) {
// afterRender is required to avoid double modification of `isSelected`
// TODO: see if there's a way to avoid afterRender
run.scheduleOnce('afterRender', this, this.args.deleteCard);

View File

@ -47,7 +47,9 @@ export default [
createComponentCard('markdown', {deleteIfEmpty: 'payload.markdown'}),
createComponentCard('gallery', {hasEditMode: false}),
createComponentCard('email', {deleteIfEmpty: 'payload.html'}),
createComponentCard('email-cta', {deleteIfEmpty: 'payload.html'}),
createComponentCard('email-cta', {deleteIfEmpty(card) {
return !card.payload.html && !card.payload.buttonText && !card.payload.buttonUrl;
}}),
createComponentCard('paywall', {hasEditMode: false, selectAfterInsert: false})
];