From c5f1d2d885b11f786aca190877d903d1c5684601 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Sat, 9 Mar 2019 22:58:32 +0100 Subject: [PATCH] Use standard pickers in MNTP config --- .../prevalueeditors/treesource.controller.js | 32 +++-- .../src/views/prevalueeditors/treesource.html | 125 +++++++++--------- 2 files changed, 83 insertions(+), 74 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/treesource.controller.js b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/treesource.controller.js index ba8902a017..e20f2f8d3a 100644 --- a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/treesource.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/treesource.controller.js @@ -20,17 +20,21 @@ angular.module('umbraco') } if($scope.model.value.id && $scope.model.value.type !== "member"){ - var ent = "Document"; - if($scope.model.value.type === "media"){ - ent = "Media"; - } - - entityResource.getById($scope.model.value.id, ent).then(function(item){ - item.icon = iconHelper.convertFromLegacyIcon(item.icon); - $scope.node = item; + entityResource.getById($scope.model.value.id, entityType()).then(function(item){ + populate(item); }); } + function entityType() { + var ent = "Document"; + if($scope.model.value.type === "media"){ + ent = "Media"; + } + else if ($scope.model.value.type === "member") { + ent = "Member"; + } + return ent; + } $scope.openContentPicker =function(){ var treePicker = { @@ -71,9 +75,13 @@ angular.module('umbraco') }); function populate(item){ - $scope.clear(); - item.icon = iconHelper.convertFromLegacyIcon(item.icon); - $scope.node = item; - $scope.model.value.id = $scope.model.config.idType === "udi" ? item.udi : item.id; + $scope.clear(); + item.icon = iconHelper.convertFromLegacyIcon(item.icon); + $scope.node = item; + $scope.node.path = ""; + $scope.model.value.id = $scope.model.config.idType === "udi" ? item.udi : item.id; + entityResource.getUrl(item.id, entityType()).then(function (data) { + $scope.node.path = data; + }); } }); diff --git a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/treesource.html b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/treesource.html index 4ad6fd5986..e693801495 100644 --- a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/treesource.html +++ b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/treesource.html @@ -6,75 +6,76 @@ - -
- - - + + - - - +
+ + + Choose a root node + + + -
    -
  • - - - Show xpath query help - + - -

    - Use Xpath query to set a root node on the tree, either based on a search from the root of the content tree, or by using a context-aware placeholder. -

    + -

    - Placeholders finds the nearest published ID and runs its query from there. so for instance: +

      +
    • + + + Show xpath query help + -
      $parent/newsArticle
      + +

      + Use Xpath query to set a root node on the tree, either based on a search from the root of the content tree, or by using a context-aware placeholder. +

      - Will try to get the parent if available, but will then fall back to the nearest ancestor and query for all news articles there. -

      +

      + Placeholders finds the nearest published ID and runs its query from there. so for instance: -

      - Available placeholders:
      - $current: current page or closest found ancestor
      - $parent: parent page or closest found ancestor
      - $root: root of the content tree
      - $site: Ancestor node at level 1
      -

      -
      -
    • -
    • - - Cancel and clear query -
    • -
    -
    -
+
$parent/newsArticle
+ + Will try to get the parent if available, but will then fall back to the nearest ancestor and query for all news articles there. +

+ +

+ Available placeholders:
+ $current: current page or closest found ancestor
+ $parent: parent page or closest found ancestor
+ $root: root of the content tree
+ $site: Ancestor node at level 1
+

+
+ +
  • + + Cancel and clear query +
  • + +
    +