OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.44k stars 2.4k forks source link

Ability to override the description of BagPart #10851

Open MikeAlhayek opened 2 years ago

MikeAlhayek commented 2 years ago

Describe the bug

I attached two named BagPart like the following

_contentDefinitionManager.AlterTypeDefinition(LenderConstants.Guide, type => type
        .Listable()
        .Creatable()
        .WithPart("Evaluation", nameof(BagPart), part => part
            .WithDescription("")
            .WithDisplayName("Evaluations")
            .MergeSettings<BagPartSettings>(settings =>
            {
                 settings.ContainedContentTypes = new[] { "Evaluation" };
            })
        )
        .WithPart("Plan", nameof(BagPart), part => part
            .WithDescription("")
            .WithDisplayName("Plans")
            .MergeSettings<BagPartSettings>(settings =>
            {
                settings.ContainedContentTypes = new[] { "Plan" };
            })
        )
);

But I can't seems to clear out the default description of the attached part. Event when I removed the description from the UI, I'll keep coming back as "Provides a collection behavior for your content item where you can place other content items."

To Reproduce

Steps to reproduce the behavior:

  1. Edit any content type
  2. Attach BagPart to it not sure if you have to make it named part or not.
  3. Clear our the description of your part. it'll keep setting the default value

Expected behavior

I should not have to provide a description if I chose not to.

Screenshots

If applicable, add screenshots to help explain your problem. description-issue

sebastienros commented 2 years ago

Looks legit. Maybe if you debug it you can find where it's taking the description from and where the issue is?

ns8482e commented 2 years ago

@CrestApps It's by design

If named BagPart on content item sets empty description then it falls back to BagPart description. Set Description on BagPart as Empty.

image

MikeAlhayek commented 2 years ago

I am not sure if inheriting the description from BagPart is user friendly. IMO, since we attached a named Bag here, the description in the named part should be honored regardless.

ns8482e commented 2 years ago

@CrestApps hm may true.

May be not - having .WithDescription("") is equivalent of not having that statement at all.

Ideally in OOPs not overriding property means it's takes from base- Here In this case - null or empty string in your content type named part falls back to content part desc.

Skrypt commented 2 years ago

If you don't want to have anything you can try and add a " " whitespace in the description too. Have not tried but that may work and remove the inherited description.

ns8482e commented 2 years ago

-: If you prefere migration :- You can remove desc from base part ( i.e. BagPart) using migration from any module that has dependency on "Flow" with following code

 _contentDefinitionManager.AlterPartDefinition("BagPart", builder => builder
                .WithDescription(""));