Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: UFM component filters #2246

Merged
merged 13 commits into from
Sep 11, 2024
Merged

Feature: UFM component filters #2246

merged 13 commits into from
Sep 11, 2024

Conversation

leekelleher
Copy link
Member

@leekelleher leekelleher commented Aug 28, 2024

Description

To support a "filter" feature to Umbraco-Flavored Markdown (UFM), this pull request adds an ufmFilter extension type and a base class (UmbUfmElementBase) for the UFM components in order to support reuse the filter logic.

Also in this pull request...

  • Syntax for content pickers, {~value}, to support document, media and member pickers (both single and arrays), rendering the entity's name as the label
  • Adds UFM filter functions (extensions), these are piped within the UFM curly bracket syntax; there is...
    • Fallback, i.e. {= value | fallback:No items }
    • Lowercase, i.e. {= value | lowercase }
    • Strip HTML, i.e. {= value | strip-html }
      • this is compatible with the RTE data structure, e.g. { markup, blocks }
    • Title Case, i.e. {= value | title-case }
    • Truncate, i.e. {= value | truncate:10:false }
      • this supports multiple arguments: length: number and tail: string (defaulting to "…", and omitted if "false")
    • Uppercase, i.e. {= value | uppercase }
    • Word Limit, i.e. {= value | word-limit:10 }
      • this supports a limit: number argument

Note, UFM filters can be piped together, e.g. {= value | strip-html | word-limit:30 }. The filters will also work for the localization and content picker UFM components, e.g. {#general_choose | uppercase}; {~value | title-case | fallback: No items }.

Types of changes

  • New feature (non-breaking change which adds functionality)

How to test?

For general testing of dynamic labels can be done within Collection Views, Block List/Grid and Document property descriptions.

For specific testing of the filters, e.g. in a Collection View, try adding the piped filter syntax to {=value} labels; also try piping filters, e.g. {= value | lowercase | uppercase | title-case | truncate:4:true}.

- Re-structures "ufm-components" folder
- Adds `ufmFilter` extension type
- Adds `UmbUfmElementBase` to support reusing filters
- Fallback
- Lowercase
- Strip HTML
- Title Case
- Truncate
- Uppercase
- Word Limit
@leekelleher
Copy link
Member Author

Failed conditions
❌ 9.8% Duplication on New Code (required ≤ 3%)

re: @sonarcloud's code duplication issue, this is in a manifest file, of which the duplication of JSON structure is intentional.

@iOvergaard
Copy link
Collaborator

iOvergaard commented Sep 9, 2024

Failed conditions
❌ 9.8% Duplication on New Code (required ≤ 3%)

re: @sonarcloud's code duplication issue, this is in a manifest file, of which the duplication of JSON structure is intentional.

I have added **/manifests?.ts to be excluded for further duplication detection in the SonarCloud settings.

leekelleher and others added 4 commits September 9, 2024 16:57
This moves the `UmbExtensionsApiInitializer` code from the `ufm-render`
and `ufm-element-base` components to the context, for optimization.
Copy link

sonarcloud bot commented Sep 11, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
8.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@leekelleher leekelleher merged commit 391b73e into main Sep 11, 2024
7 of 8 checks passed
@leekelleher leekelleher deleted the v14/feature/ufm-filters branch September 11, 2024 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants