Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Leo Jebran 7 posts 110 karma points
    Mar 31, 2022 @ 14:19
    Leo Jebran
    0

    Block list items sorting on the Backoffice side

    Hey

    I have a Block list item that also contains a list of block items for a module I am creating.

    all worked so far fine and I am able to display the content correctly ordered on the front end

    The problem is on the Backoffice angular preview of the module

    when creating the module and adding the items it's fine

    but rearranging the items in the list by dragging them around doesn't seem to do anything for the list of times I am getting in the JS controller for the Backoffice. On the Frontend the order is changing correctly though.

    Any idea?

  • Mark Drake 134 posts 458 karma points c-trib
    Apr 01, 2022 @ 15:52
    Mark Drake
    0

    Hi Leo,

    Sounds like you may have found a bug!

    Can you provide some steps to replicate this issue, and/or a video demonstrating it in action?

    I have a similar setup with a set of element types, but I'm not using a custom renderer. To sort my "block list item that contains other blocks" I have to click into the first, and sort from there.

    Let me know how I and others may replicate what you're doing. Could be a bug!

  • Leo Jebran 7 posts 110 karma points
    Apr 16, 2022 @ 00:41
    Leo Jebran
    100

    Hey Mark,

    Sry for the very late response!

    after tinkering around with the problem, I think it's by design.

    The data returned for the items contain a sorted list of the item's UIDs called layout .

    I was able to sort the items in the Backoffice UI this way

    enter image description here

  • Stanislaw 2 posts 72 karma points
    Mar 26, 2024 @ 16:07
    Stanislaw
    0

    I also encountered such a problem. I solved it in this way. Umbraco version 13.2.2

    angular.module("umbraco").controller("headerBlockController", function ($scope) {
    
    function sortContentData() {
        const sortOrder = $scope.block.data.headerLinks.layout["Umbraco.BlockList"].map(block => block.contentUdi);
    
        $scope.block.data.headerLinks.contentData.sort((a, b) => {
            const indexA = sortOrder.indexOf(a.udi);
            const indexB = sortOrder.indexOf(b.udi);
            return indexA - indexB;
        });
    }
    
    sortContentData();
    
    $scope.$watch('block.data.headerLinks.layout["Umbraco.BlockList"]', (newValue, oldValue) => {
        if (newValue !== oldValue) {
            sortContentData();
        }
    }, true); });
    
Please Sign in or register to post replies

Write your reply to:

Draft