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

Requires editor config to display List View properties #19

Closed
DanDiplo opened this issue Feb 12, 2018 · 6 comments
Closed

Requires editor config to display List View properties #19

DanDiplo opened this issue Feb 12, 2018 · 6 comments
Labels
Milestone

Comments

@DanDiplo
Copy link

First, I want to say this is an amazing project - jaw droppingly good! The number of features and quality of the code and documentation is stunning. I managed to get a simple List View working in about 20 mins from install to running in Umbraco, including reading docs. So that is a testament to how easy it is to use.

However, I was left scratching my head as to why some column data wasn't being displayed. For the project I was working on I only required a read-only list view of some data stored in a table within the Umbraco DB (T-SQL).

My POCO was this:

[TableName("GradedUrls")]
public class GradedUrl
{
    [PrimaryKeyColumn]
    public int Id { get; set; }

    public DateTime Date { get; set; }

    public string Url { get; set; }

    public string Domain { get; set; }

    public decimal TotalScorePercent { get; set; }

    public string Email { get; set; }
}

and the relevant bit of config I used was this:

treeConfig.AddCollection<GradedUrl>(p => p.Id, "Graded Url", "Graded URLs", "List of graded URLs", "icon-link", "icon-link", collectionConfig =>
{
    collectionConfig.SetNameProperty(p => p.Domain);
    collectionConfig.SetViewMode(FluidityViewMode.List);
    collectionConfig.SetDateCreatedProperty(p => p.Date);
    collectionConfig.SetSortProperty(p => p.Id, SortDirection.Descending);
    collectionConfig.MakeReadOnly();

    collectionConfig.ListView(listViewConfig =>
    {
        listViewConfig.AddField(p => p.Date, fc => fc.SetHeading("Date Submitted"));
        listViewConfig.AddField(p => p.Url);
        listViewConfig.AddField(p => p.TotalScorePercent, fc => fc.SetHeading("Score %"));
        listViewConfig.AddField(p => p.Email);
    });

});

When I ran this I got a list view, but only the Domain value (the name property) was showing any data. All the other column headings were there, but each row contained no data for any of the properties in the List View. They were completely empty (yet I knew the table contained data and the field names matched the POCO).

Eventually, I tried adding an Editor Config to the collectionConfig (to match your example in docs):

collectionConfig.Editor(editorConfig => {

    editorConfig.AddTab("General", tabConfig => {
        tabConfig.AddField(p => p.Url).MakeRequired();
    });
});

As soon as I did this the values for the columns were displayed correctly. I'm not quite clear why the editorConfig is needed for this. As I say, in my case I was using a read-only view that isn't editable, so I wouldn't have expected to require an editor config to see the values of the properties in the list view.

@mattbrailsford
Copy link
Owner

mattbrailsford commented Feb 12, 2018

Interesting! It shouldn't need an editor config in order to show list view fields. Is it possible you setup the listview config but forgot to compile? then when you added the editor config you did compile so it then worked?

PS Sorry for the dumb question, but need to rule out the simple stuff first

@DanDiplo
Copy link
Author

Hah, that's just the kind of thing I would do, but in this case, "no". I can easily reproduce by removing the editorConfig, compiling, and then I get:

image

As soon as I add it back, compile, I get data in all those blank columns.

@mattbrailsford
Copy link
Owner

Ok, I think I've found the problem. In the mapping code for the entity, for some reason I'm checking if the editor has tabs, which is completely irelivant for list views. I think it's probably left over from some copy paste thing https://github.com/umco/umbraco-fluidity/blob/master/src/Fluidity/Web/Models/Mappers/FluidityEntityMapper.cs#L72

I'll get it removed and get a nightly built

@DanDiplo
Copy link
Author

Thanks for looking so quickly. But there's no rush, honestly, it's easily worked around for me. I've just made the editor view read-only, too, which works perfectly (for my needs). Loving the possibilities for this! :)

@mattbrailsford
Copy link
Owner

mattbrailsford commented Feb 12, 2018

Hey @DanDiplo a new nightly is here https://ci.appveyor.com/project/UMCO/umbraco-fluidity/build/1.0.2.31/artifacts will get pushed out in the next release

@DanDiplo
Copy link
Author

Thanks, much appreciated - really enjoyed working with this!

@mattbrailsford mattbrailsford added this to the 1.0.2 milestone Mar 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants