Copied to clipboard

Flag this post as spam?

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


  • Bo Jacobsen 610 posts 2409 karma points
    Jul 24, 2020 @ 09:01
    Bo Jacobsen
    0

    How to get document culture in controller to use in grid when using split view

    Hi all.

    How do i get the document i am currently editing culture in an angular property controller?

    I have created a custom property controller that are used in the grid, inserted with DocTypeGridEditor in the package.manifest like this:

    {
      "propertyEditors": [
        {
          "alias": "Custom.PropertyEditor.Culture",
          "name": "Readonly Culture",
          "icon": "icon-readonly color-red",
          "editor": {
            "view": "~/App_Plugins/CustomPlugin/propertyEditors/readonlyCulture/readonlyCulture.html"
          }
        }
      ],
      "gridEditors": [
        {
          "name": "List",
          "alias": "Custom.GridEditors.List",
          "view": "/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.html",
          "render": "/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditor.cshtml",
          "icon": "icon-bulleted-list color-green",
          "config": {
            "allowedDocTypes": [ "ListView" ],
            "nameTemplate": "",
            "enablePreview": true,
            "overlaySize": "small",
            "viewPath": "/Views/Partials/DocTypeGridEditor/",
            "previewViewPath": "/Views/Partials/DocTypeGridEditor/Previews/",
            "previewCssFilePath": "",
            "previewJsFilePath": ""
          }
        }
      ],
      "javascript": [
        "~/App_Plugins/CustomPlugin/propertyEditors/readonlyCulture/readonlyCulture.js"
      ]
    }
    

    My controller looks like this:

    (function () {
        "use strict";
    
        function readonlyCulture($scope, $routeParams) {
    
            $scope.model.value = $routeParams.cculture || $routeParams.mculture;   
        }
    
        angular.module("umbraco").controller("Custom.ReadonlyCulture.EditorController", readonlyCulture);
    })();
    

    There is a $routeParams.mculture and a $routeParams.cculture.

    When i am editing the main language i am only getting mculture as expected.

    And when i change to another language i am getting the cculture as expected.

    But when i am using splitview, i get am getting the same result on both documents.

    Example:

    URL: http://localhost:64556/umbraco/#/content/content/edit/1056?mculture=da-DK&cculture=en-US

    Split View: Left -> en-US. Right: da-DK enter image description here

    When i access the grid on both documents i am getting mculture=da-DK and cculture=en-US and can no longer tell the difference, because i do not know which one i am editing.

    I hope someone know what to do :)

  • Jacob Overgaard 3 posts 95 karma points c-trib
    Oct 25, 2020 @ 11:03
    Jacob Overgaard
    101

    Hello!

    First things first, the answer is:

    $scope.model.culture
    

    I'm on Umbraco 8.8.0, if that makes a difference, and it works both when changing the editor language and opening split view in my experience, and I tested it with the contentResource like this:

    contentResource.getChildren(nodeId, { cultureName: $scope.model.culture })
    

    I have to tell you, I stumbled upon your question having the same problem with split view, and I thought I had finally found the solution, and I was very distraught that no one had answered you yet. So I dived into the angular.directives.js file of Umbraco to try and see how the variant editors work, and I got lucky!

  • Bo Jacobsen 610 posts 2409 karma points
    Oct 25, 2020 @ 19:31
    Bo Jacobsen
    0

    Hi Jacob.

    Thank you for your reply.

    I will test it out tomorrow.

  • Bo Jacobsen 610 posts 2409 karma points
    Oct 26, 2020 @ 07:52
    Bo Jacobsen
    0

    In version 8.7.0 the $scope.model.culture is always null.

    The property exists but is just null.

    I am gonna try to upgrade to 8.8.0 now and see if it changes anything.

  • Bo Jacobsen 610 posts 2409 karma points
    Oct 26, 2020 @ 11:21
    Bo Jacobsen
    0

    I now upgraded to 8.8.0 and the $scope.model.culture is still null.

    Its because i use it in a property inside a DocTypeGridEditor element in the Grid.

    When i use it on a property directly on the document it works.

  • Jacob Overgaard 3 posts 95 karma points c-trib
    Oct 26, 2020 @ 11:29
    Jacob Overgaard
    0

    Hi, that could be a bug with DTGE, I suppose. I tested it in a standard grid editor controller.

    Does it work in your property editor outside of DTGE?

  • Bo Jacobsen 610 posts 2409 karma points
    Oct 26, 2020 @ 11:31
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies