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

[sitecore-jss] [sitecore-jss-angular] Default Placeholder Content for empty fields in editMode metadata #1916

Merged
merged 32 commits into from
Sep 6, 2024

Conversation

yavorsk
Copy link
Contributor

@yavorsk yavorsk commented Sep 3, 2024

Description / Motivation

This PR enhances the rendering of fields in editing mode for editMode metadata. When a field value is empty, a placeholder content should be rendered to signify that the field has no value. The placeholder should be interactable, so user can add value to the field. Additionally developers can provide their own custom empty field template via the field directive's emptyFieldEditingTemplate imput property, which will be rendered instead of the default one.
The fields with this functionality are:

  • [sitecore-jss-angular] image.directive.ts
  • [sitecore-jss-angular] date.directive.ts
  • [sitecore-jss-angular] rich-text.directive.ts
  • [sitecore-jss-angular] text.directive.ts
  • [sitecore-jss-angular] link.directive.ts
  • [sitecore-jss-angular] router-link.directive.ts
  • [sitecore-jss-angular] generic-link.directive.spec.ts

The PR also includes update to the GenericFieldValue base package type to accept Date type; this change has been made in order to make the base type compatible with the field date type defined in the angular package

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@yavorsk yavorsk added the do-not-review PR's not ready for review label Sep 3, 2024
…pe (in order to make it compatible with angular package types); updated isFieldValueEmpty function and unit tests for that change
@yavorsk yavorsk changed the title [sitecore-jss-angular] Default Placeholder Content for empty fields in editMode metadata [sitecore-jss] [sitecore-jss-angular] Default Placeholder Content for empty fields in editMode metadata Sep 4, 2024
@yavorsk yavorsk requested a review from a team September 4, 2024 09:00
@yavorsk yavorsk removed the do-not-review PR's not ready for review label Sep 4, 2024
Copy link
Contributor

@addy-pathania addy-pathania left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work. see some comments.

Copy link
Contributor

@illiakovalenko illiakovalenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good!

  • please, make sure to add jsdoc comments with the right explanation where it's possible and needed
  • build is failed

Also see some comments below

CHANGELOG.md Outdated Show resolved Hide resolved
packages/sitecore-jss/src/layout/utils.ts Outdated Show resolved Hide resolved
export abstract class BaseFieldDirective {
protected viewRef: EmbeddedViewRef<unknown>;
protected abstract field: RenderingField<GenericFieldValue>;
protected abstract emptyFieldEditingTemplate: TemplateRef<unknown>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just define an "input" here?

@Input('scDateEmptyFieldEditingTemplate') emptyFieldEditingTemplate: TemplateRef<unknown>;

so, we don't need to define this property on field level, since it's not used directly by field

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is it possible to initialize this input with the default value passed by the inherited class via the constructor? So we don't need to pass the default component via "renderEmpty" function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On your second comment: makes sense, Updated.
On your first comment: I tried but seems structural directives require the names of their inputs to be prefixed by the directive selector (see how the property is common but the input alias is different for each directive) - and I could not find a way around that; you can see it is done the same way for the existing inputs in link.directive and generic link directive

Copy link
Contributor

@illiakovalenko illiakovalenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@addy-pathania addy-pathania merged commit 971602e into dev Sep 6, 2024
1 check passed
@addy-pathania addy-pathania deleted the feature/jss-3554 branch September 6, 2024 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants