umbraco / Umbraco.UIBuilder.Issues

Back office UI builder for Umbraco
3 stars 2 forks source link

Entity Picker - The backoffice ordering isn't adhered to in code #70

Closed AndyBoot closed 10 months ago

AndyBoot commented 10 months ago

Describe the bug When using the entity picker against a doc type property, selecting the entities and pulling through the IEnumerable of entities in code, it isn't giving us a list of entities in the same order as per how they are selected in the content management section of the backoffice. It appears they're just being brought through as per their default order in the custom table.

Looking in the umbracoPropertyData table, it appears the property value is being stored as an integer comma-delimeted array, and in the correct order.

I've managed to work around this for the time being with some dirty code to look up the raw int array in the umbracoPropertyData table and reordering the IEnumerable based on the order of the Id's within the array. Ideally, I shouldn't need to do this.

Steps To Reproduce Steps to reproduce the behavior:

  1. Ensure there's at least one repository with data
  2. Apply the entity picker against a doc type property
  3. Add items via the content section in a scattered order
  4. Pull in the selected items via code which should give an IEnumerable<entity> object, loop through the selected items to be shown the items in the wrong order from how they were selected

Expected behavior The IEnumerable<entity> should match the order of the integer comma-delimeted array.

Environment (please complete the following information):

mattbrailsford commented 10 months ago

When you say "pull in the selected items via code" are you meaning just accessing the property on the doc type that returns the selected entities?

AndyBoot commented 10 months ago

Yes correct, i.e.

image

So in this example, Features is the property with the entity picker. So if the custom table had features 1 - 10 in that order, and I only selected features 7, 3, 9, & 1 then what instead gets returned is 1, 3, 7 & 9 when I'd imagine what we should get is the same order in which they were selected.

mattbrailsford commented 10 months ago

Ok, so I've pushed a preview release to https://nuget.outfield.digital/unstable/v3/index.json so if you want to grab the latest 1.6.7 beta I think this should fix it.

AndyBoot commented 10 months ago

Amazing! Yeah that appears to have done the trick. Thanks Matt!

mattbrailsford commented 10 months ago

Resolved in 10.0.1 and 12.0.1 of UI Builder (also in Konstrukt 1.6.7)