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

V15: Document Type Create Options #17669

Open
wants to merge 8 commits into
base: v15/dev
Choose a base branch
from

Conversation

leekelleher
Copy link
Member

Description

Creates an entityCreateOptionAction extension for each of the Document Type create actions. This builds on the work started in umbraco/Umbraco.CMS.Backoffice#2509, and replaces the existing "Document Type Create Options modal" (which has hardcoded options).

To align the UI/UX consistency for the existing Create Options, amends were required to the <umb-ref-item> component, (refactored to extend uui-ref-node rather than duplicate code/functionality). This mostly meant updating existing usage to add the select-only attribute.

// @madsrasmussen Tagging you in, as you may wish to cast an eye on these amends.

How to test?

Go to the Settings section, try creating a new document type:

  • Does the create modal appear?
  • Does it have any options?
  • Do they work?

if (this.icon) {
const umbIcon = document.createElement('umb-icon');
umbIcon.setAttribute('name', this.icon);
this.shadowRoot?.querySelector('#icon')?.replaceWith(umbIcon);
Copy link
Member

@nielslyngsoe nielslyngsoe Nov 28, 2024

Choose a reason for hiding this comment

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

I think this is a little dangerous,, cause what if something caused Lit to re-render.. then it would not be overriden any more..

Could you try to just add it as a direct child, not in the shadowRoot and then set the attribute slot='icon'?

Copy link
Member Author

Choose a reason for hiding this comment

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

It felt a bit hacky when I was developing that part. I did try a few other approaches, but I couldn't get the icon to display, the fallback icon kept being rendered.

For reference: https://github.com/umbraco/Umbraco.UI/blob/v1.12.2/packages/uui-ref-node/lib/uui-ref-node.element.ts#L109-L112

When you say "add it as a direct child", do you mean that it overrides the render() method? If so, I'm not quite sure how that would work.

I'm wondering if UUIRefNodeElement could have a protected renderIcon() method added to it, that may simplify this. 🤔


@property({ type: String })
detail = '';
const elementName = 'umb-ref-item';
Copy link
Member

Choose a reason for hiding this comment

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

I think we agreed not to do this any longer? :-D

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought we agreed the opposite, that we would do this. 😂 I'm cool with reverting this, just let me know.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, well the idea is to get rid of it in time. so I would say yes, lets not add it in this PR. :-)

@nielslyngsoe
Copy link
Member

Hi @leekelleher really great refactoring, that is so nice to get aligned and make extendable. so thanks for that. I just skimmed the code of interest, so not because I'm reviewing per say, but I had two minor comments :-)

@madsrasmussen
Copy link
Contributor

madsrasmussen commented Nov 28, 2024

Hi @leekelleher ,

It's fantastic to see that you have implemented the create options for Document Types. This is one of the more interesting cases! :D

Based on the current state of your PR, I would appreciate it if we could address these areas to ensure maximum flexibility for extensions and at the same time decouple our own code more. I suggest we move all template logic from the Document Type into the "Template"-module. This means that if the template package is not installed, all related logic around Document Types with templates would be removed (headless cms):

  • The "Document Type with Template"-create option should be registered within the "template"-module.

  • We need to find a solution for the hardcoded presets inside the Document Type workspace. Having these hardcoded limits the possibilities for the create option extension. One potential solution could be to introduce another extension point for "presets." A create option could pass a preset extension alias to the workspace, allowing the workspace to find the registered preset and execute any related logic.

  • Register the template workspace view from the template module, but I don’t think that’s directly relevant to this PR.

As we work on these changes, we should also consider how to implement a solution that can be reused across all workspaces. We already have a snippet/preset functionality for Partials Views which could utilize the same system.

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.

3 participants