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

BlockGroup fields are not initialized on load #836

Closed
tidyui opened this issue Sep 29, 2019 · 4 comments
Closed

BlockGroup fields are not initialized on load #836

tidyui opened this issue Sep 29, 2019 · 4 comments

Comments

@tidyui
Copy link
Member

tidyui commented Sep 29, 2019

This means that when adding new fields to existing Block Groups the fields are not initialized when loading an existing group.

@tidyui tidyui added this to the Version 7.0 SR 5 milestone Sep 29, 2019
@tidyui tidyui self-assigned this Sep 29, 2019
@tidyui tidyui changed the title BlockGroup fields are not created on load BlockGroup fields are not initialized on load Sep 29, 2019
@monsieurberry
Copy link

Hi Håkan!

Is this why my page doesn't save when my Custom BlockGroup has a field on it?

I get a console error in the browser...

Uncaught TypeError: Cannot set property 'visible' of undefined
at piranha.min.js:formatted:32301

Cheers!

Adam

@tidyui
Copy link
Member Author

tidyui commented Oct 1, 2019

If you’re getting the error saving an existing block that you’ve added fields to but not if you create a new block it’s this error.

To verify, create a new page and add the block group to it. If it saves ok then it’s the above error

@monsieurberry
Copy link

monsieurberry commented Oct 1, 2019

Thanks Håkan,

I tried with an existing block group and the field doesn't show at all.

I then created a new page and added the block group. The field then showed, but the page wouldn't save correctly and I got the console error as outlined above. Perhaps its something wrong with my setup of the Block and BlockGroup...

When I expand out the console error it takes me to the following JS and its on the e.style.visible = !0 line where it seems to be failing...

piranha.notifications = new Vue({
    el: "#notification-hub",
    data: {
        items: []
    },
    methods: {
        push: function(e) {
            e.style = {
                visible: !1,
                "notification-info": "info" === e.type,
                "notification-danger": "danger" === e.type,
                "notification-success": "success" === e.type,
                "notification-warning": "warning" === e.type
            },
            piranha.notifications.items.push(e),
            setTimeout(function() {
                e.style.visible = !0,
                e.hide && setTimeout(function() {
                    e.style.visible = !1,
                    setTimeout(function() {
                        piranha.notifications.items.shift()
                    }, 200)
                }, 5e3)
            }, 200)
        }
    }
}),

My Block Group class is as follows

[BlockGroupType(Name = "Destination Group", Category = "DigiRooms", Icon = "fas fa-map-marker-alt")]
[BlockItemType(Type = typeof(FeaturedDestinationBlock))]
public class FeaturedDestinationBlockGroup : BlockGroup
{
    public StringField Title { get; set; }
}

and my Block class is as follows...

[BlockType(Name = "Destination", Category = "DigiRooms", Icon = "fas fa-map-marker-alt", Component = "featured-destination-block")]
public class FeaturedDestinationBlock : Block
{
    public StringField Title { get; set; }
    public StringField DestinationSlug { get; set; }
    public DateField ArrivalDate { get; set; }
    public DateField DepartureDate { get; set; }
    public NumberField NumberOfProperties { get; set; }
    public StringField LinkText { get; set; }
    public ImageField Image { get; set; }
}

The Block works fine independently of the Block Group.

The Group also works if I comment out the Title field, but not with it included

I feel like I followed the docs 100% but I still must be missing something

Many Thanks

Adam

@monsieurberry
Copy link

monsieurberry commented Oct 1, 2019

Håkan please ignore the comment above - I solved my issue by updating Piranha.Manager to 7.0.4

Cheers

Adam

@tidyui tidyui closed this as completed in 5611a62 Oct 4, 2019
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

2 participants