Copied to clipboard

Flag this post as spam?

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


  • Davy 12 posts 103 karma points
    Mar 15, 2019 @ 14:26
    Davy
    0

    In Umbraco 7, MenuItem.AdditionalData.Add("a", "a") worked just fine. But since I began using Umbraco 8, the data would not get registered in the $scope in my controller.js. Does anybody has a solution for this?

  • mmaty 109 posts 281 karma points
    Mar 19, 2019 @ 17:25
    mmaty
    0

    I have the same phenomenon. In my TreeController I have the following Code:

    MenuItem newItem = menu.Items.Add<ActionNew>("Neue Stildefinition ...", false);
    newItem.AdditionalData.Add( "cls", someData);
    newItem.AdditionalData.Add( "parent", someOtherData );
    newItem.AdditionalData.Add( "methodName", "AString" );
    

    In my controller I used to use this line to get the additional data:

    var metaData = $scope.currentAction.metaData;
    

    Now in Umbraco v8 currentAction is undefined.

    Any insights?

  • mmaty 109 posts 281 karma points
    Mar 19, 2019 @ 18:07
    mmaty
    102

    I got it:

    angular.module("umbraco").controller("MySampleController", 
        function(..., appState) {
        var metaData = [];
        var actions = appState.getMenuState("menuActions");
        _.each(actions, function (action) {
            if (action.alias === "create")
                metaData = action.metaData;
        });
    ...
    
  • mmaty 109 posts 281 karma points
    Mar 20, 2019 @ 11:34
    mmaty
    0

    The issue is still open. In the code sample above I get all menu actions for the current node. If I can create several different things, I don't know, which of the actions was chosen by the user.

    We definitely need a way to get the current action.

  • Davy 12 posts 103 karma points
    Mar 20, 2019 @ 13:24
    Davy
    1

    The current menu item has a dialogTitle field which I use as a way to get the current menuAction. I am not 100% sure this is the right way to do it, but for now it works fine for me.

    var menuActions = appState.getMenuState('menuActions')
    var menuTitle = appState.getMenuState('dialogTitle')
    
    var menuAction = menuActions.find(function (element) {
        if (element.name === menuTitle) {
            return element.name
        }
    }).metaData
    
  • mmaty 109 posts 281 karma points
    Mar 20, 2019 @ 15:39
    mmaty
    0

    @Davy: I analyzed the menu code and found that the dialogTitle solution is the only way to get the metaData. But this is far from being elegant.

    The current action should be added to the menu state in navigationService.showDialog:

    appState.setMenuState("currentAction", args.action);
    

    I think I'll open a ticket for this issue.

  • Tom Madden 252 posts 454 karma points MVP 4x c-trib
    Feb 18, 2021 @ 11:36
    Tom Madden
    0

    Did a ticket get opened for this?

Please Sign in or register to post replies

Write your reply to:

Draft