Skip to content

Commit

Permalink
Merge pull request #2082 from UKHSA-Internal/task/cdd-2407cms-manual-…
Browse files Browse the repository at this point in the history
…date-text-input

CDD-2407: add manual date prefix for chart card and headline columns
  • Loading branch information
phill-stanley authored Jan 29, 2025
2 parents 5c2e01a + e50bb6e commit 78c7d99
Show file tree
Hide file tree
Showing 5 changed files with 2,025 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cms/dynamic_content/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

MINIMUM_ROWS_NUMBER_BLOCK_COUNT: int = 1
MAXIMUM_ROWS_NUMBER_BLOCK_COUNT: int = 2
METRIC_NUMBER_BLOCK_DATE_PREFIX_DEFAULT_TEXT = "Up to"


class HeadlineNumberBlockTypes(blocks.StreamBlock):
Expand All @@ -26,6 +27,11 @@ class Meta:

class MetricNumberBlockTypes(blocks.StructBlock):
title = blocks.TextBlock(required=True, help_text=help_texts.TITLE_FIELD)
date_prefix = blocks.TextBlock(
required=True,
default=METRIC_NUMBER_BLOCK_DATE_PREFIX_DEFAULT_TEXT,
help_text=help_texts.HEADLINE_DATE_PREFIX,
)
rows = HeadlineNumberBlockTypes(
required=True,
min_num=MINIMUM_ROWS_NUMBER_BLOCK_COUNT,
Expand Down
12 changes: 12 additions & 0 deletions cms/dynamic_content/cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
DEFAULT_SIMPLE_CHART_X_AXIS = "date"
DEFAULT_SIMPLE_CHART_Y_AXIS = "metric"

CHART_CARD_DATE_PREFIX_DEFAULT_TEXT = "Up to and including"


class TextCard(blocks.StructBlock):
body = blocks.RichTextBlock(
Expand Down Expand Up @@ -109,6 +111,11 @@ class ChartWithHeadlineAndTrendCard(blocks.StructBlock):
default=False,
required=False,
)
date_prefix = blocks.CharBlock(
required=True,
default=CHART_CARD_DATE_PREFIX_DEFAULT_TEXT,
help_text=help_texts.CHART_DATE_PREFIX,
)
chart = ChartComponent(help_text=help_texts.CHART_BLOCK_FIELD)
headline_number_columns = HeadlineNumberBlockTypes(
required=False,
Expand Down Expand Up @@ -211,6 +218,11 @@ class ChartCard(blocks.StructBlock):
default=False,
required=False,
)
date_prefix = blocks.CharBlock(
required=True,
default=CHART_CARD_DATE_PREFIX_DEFAULT_TEXT,
help_text=help_texts.CHART_DATE_PREFIX,
)
chart = ChartComponent(help_text=help_texts.CHART_BLOCK_FIELD)

class Meta:
Expand Down
8 changes: 8 additions & 0 deletions cms/dynamic_content/help_texts.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,11 @@
PAGE_LINK_SUB_TITLE: str = """
This is an optional short description of the page you're linking to.
"""

HEADLINE_DATE_PREFIX: str = """
This is the accompanying text for headline column dates Eg: `Up to` 27 Oct 2024
"""

CHART_DATE_PREFIX: str = """
This is the accompanying text for chart dates Eg: `Up to and including` 21 Oct 2024
"""
Loading

0 comments on commit 78c7d99

Please sign in to comment.