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

GenericBlock not updating item title in the manager #1246

Closed
maxpowernz opened this issue Jun 24, 2020 · 8 comments
Closed

GenericBlock not updating item title in the manager #1246

maxpowernz opened this issue Jun 24, 2020 · 8 comments
Assignees
Milestone

Comments

@maxpowernz
Copy link

maxpowernz commented Jun 24, 2020

Hi,

not sure if its a bug or I am doing it wrong, but using the code below, the title doesnt show up in the item list until a page refresh, It could be onblur setting in vue? According to the docs: "No specific Vue component is needed to render block groups".

The same thing happens with a region as well, region i have:

using Piranha.Extend;
using Piranha.Extend.Blocks;
using Piranha.Extend.Fields;

[BlockGroupType(Name = "PDFFiles", Category = "Media", Icon = "fas fa-images")]
[BlockItemType(Type = typeof(AuthorBlock))]
public class MyBlockGroup : BlockGroup
{

}


[BlockType(Name = "Author", Category = "Media", Icon = "fas fa-fish")]
public class AuthorBlock : Block
{
    public StringField Title { get; set; }

    public HtmlField HtmlField { get; set; }

    public MediaField PdfFile { get; set; }

    public ImageField Image { get; set; }


    public override string GetTitle()
    {
        return Title;
    }
}

image

    [Region(ListTitle = "Title", ListExpand = false)]
    public IList<MyRegion> PDFFiles { get; set; }

image

@tidyui tidyui changed the title Title not displaying in item list with custom block type Title not displaying in item list with default vue-component Jun 24, 2020
@maxpowernz
Copy link
Author

it was my fault sorry, I needed a custom vue component to handle the blur, closing.

@tidyui
Copy link
Member

tidyui commented Jun 24, 2020

I'll reopen this issue as we should add support for updating list-title on generic block-components.

@tidyui tidyui reopened this Jun 24, 2020
@tidyui tidyui changed the title Title not displaying in item list with default vue-component GenericBlock not updating item title in the manager Jun 24, 2020
@tidyui tidyui added this to the Version 8.4 milestone Jun 24, 2020
@tidyui
Copy link
Member

tidyui commented Jun 24, 2020

The BlockAttribute needs a ListTitle property just like list-regions. generic-block.vue should listen to emitted update-title events from the specified field and emit it back to the possible block group containing it. Please note that ListTitle will only be used for blocks rendered with generic-block.vue. Blocks rendered by a custom component are responsible for emitting their own update-title to their parent.

@mikaellindemann
Copy link
Contributor

Does this deprecate the GetTitle() method on blocks then?

@tidyui
Copy link
Member

tidyui commented Jun 24, 2020

@mikaellindemann GetTitle() is currently used for calculating the title from C# when working when the models. It's also included to the UI when loaded from the backend. The different emits flying around is simply for updating the UI dynamically when changing field values in the manager.

@tidyui
Copy link
Member

tidyui commented Jun 24, 2020

And @mikaellindemann I see your point when going through the code but GetTitle() would still be needed for blocks with custom components, however it might be a good idea to have a default implementation that checks the ListTitle property.

I'll get back to you on that.

@tidyui
Copy link
Member

tidyui commented Jun 24, 2020

@mikaellindemann The class Piranha.Extend.Block currently has the default implementation:

public virtual string GetTitle()
{
    return "[Not Implemented]";
}

This implementation could be expanded to check if ListTitle is set, and if it is return the title for the specified field. If ListTitle are empty the current string "[Not Implemented]" could be returned. And for all blocks overriding this method it wouldn't make any difference.

@tidyui tidyui self-assigned this Jun 24, 2020
@tidyui
Copy link
Member

tidyui commented Jun 24, 2020

@mikaellindemann That worked perfectly. So in other words when setting the ListTitle property of the BlockTypeAttribute, overriding Block.GetTitle() is not necessary.

@tidyui tidyui closed this as completed in 67cc1e3 Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants