From 89f089e439ca943707910b6d8494ed0c110a6668 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Wed, 18 May 2022 09:42:44 +0100 Subject: [PATCH] Fixed incorrect member count and capitalisation in publish options for editors/authors no issue - `{{format-number}}` was showing "0" when passed in an empty/nullish string when it should have been showing nothing - used `{{if-empty}}` to fix capitalisation when the member count is missing - previously attempted a CSS-only fix with `:first-letter` and `text-transform: uppercase` but that broke the layout in Safari --- .../editor-labs/modals/publish-flow/options.hbs | 8 +++++--- ghost/admin/app/helpers/format-number.js | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ghost/admin/app/components/editor-labs/modals/publish-flow/options.hbs b/ghost/admin/app/components/editor-labs/modals/publish-flow/options.hbs index 2ed6f49b51..9f882b2b01 100644 --- a/ghost/admin/app/components/editor-labs/modals/publish-flow/options.hbs +++ b/ghost/admin/app/components/editor-labs/modals/publish-flow/options.hbs @@ -48,12 +48,14 @@ {{format-number countFetcher.count}} {{!-- @recipientType = none/free/paid/all/specific --}} - {{if (not-eq @recipientType "all") @recipientType}} + {{#let (if (not-eq @recipientType "all") @recipientType) as |recipientType|}} + {{if (is-empty countFetcher.count) (capitalize recipientType) recipientType}} + {{/let}} {{#if @publishOptions.onlyDefaultNewsletter}} - {{gh-pluralize countFetcher.count "subscriber" without-count=true}} + {{gh-pluralize countFetcher.count (if (is-empty countFetcher.count) "Subscriber" "subscriber") without-count=true}} {{else}} - {{gh-pluralize countFetcher.count "subscriber" without-count=true}} + {{gh-pluralize countFetcher.count (if (is-empty countFetcher.count) "Subscriber" "subscriber") without-count=true}} of {{@publishOptions.newsletter.name}} {{/if}} {{/let}} diff --git a/ghost/admin/app/helpers/format-number.js b/ghost/admin/app/helpers/format-number.js index 41f96719ec..195d74d7d4 100644 --- a/ghost/admin/app/helpers/format-number.js +++ b/ghost/admin/app/helpers/format-number.js @@ -1,6 +1,10 @@ import {helper} from '@ember/component/helper'; export function formatNumber(number) { + if (number === '' || number === null || number === undefined) { + return; + } + return Number(number).toLocaleString(); }