Merge pull request #5881 from bjarnef/dev-v7-link-picker-url-anchors
v7: Fix link picker url and anchors
This commit is contained in:
@@ -172,7 +172,7 @@ function entityResource($q, $http, umbRequestHelper) {
|
||||
umbRequestHelper.getApiUrl(
|
||||
"entityApiBaseUrl",
|
||||
"GetUrlAndAnchors",
|
||||
{ id: id })),
|
||||
[{ id: id }])),
|
||||
'Failed to retrieve url and anchors data for id ' + id);
|
||||
},
|
||||
|
||||
|
||||
@@ -28,24 +28,23 @@ angular.module("umbraco").controller("Umbraco.Overlays.LinkPickerController",
|
||||
if (dialogOptions.currentTarget) {
|
||||
// clone the current target so we don't accidentally update the caller's model while manipulating $scope.model.target
|
||||
$scope.model.target = angular.copy(dialogOptions.currentTarget);
|
||||
//if we have a node ID, we fetch the current node to build the form data
|
||||
// if we have a node ID, we fetch the current node to build the form data
|
||||
if ($scope.model.target.id || $scope.model.target.udi) {
|
||||
|
||||
//will be either a udi or an int
|
||||
// will be either a udi or an int
|
||||
var id = $scope.model.target.udi ? $scope.model.target.udi : $scope.model.target.id;
|
||||
|
||||
// is it a content link?
|
||||
if (!$scope.model.target.isMedia) {
|
||||
// get the content path
|
||||
entityResource.getPath(id, "Document").then(function (path) {
|
||||
//now sync the tree to this path
|
||||
// now sync the tree to this path
|
||||
$scope.dialogTreeEventHandler.syncTree({
|
||||
path: path,
|
||||
tree: "content"
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
entityResource.getUrlAndAnchors(id).then(function(resp){
|
||||
$scope.anchorValues = resp.anchorValues;
|
||||
$scope.model.target.url = resp.url;
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace Umbraco.Web.Editors
|
||||
//id is passed in eventually we'll probably want to support GUID + Udi too
|
||||
new ParameterSwapControllerActionSelector.ParameterSwapInfo("GetPagedChildren", "id", typeof(int), typeof(string)),
|
||||
new ParameterSwapControllerActionSelector.ParameterSwapInfo("GetPath", "id", typeof(int), typeof(Guid), typeof(Udi)),
|
||||
new ParameterSwapControllerActionSelector.ParameterSwapInfo("GetUrlAndAnchors", "id", typeof(int), typeof(Guid), typeof(Udi)),
|
||||
new ParameterSwapControllerActionSelector.ParameterSwapInfo("GetById", "id", typeof(int), typeof(Guid), typeof(Udi)),
|
||||
new ParameterSwapControllerActionSelector.ParameterSwapInfo("GetByIds", "ids", typeof(int[]), typeof(Guid[]), typeof(Udi[]))));
|
||||
}
|
||||
@@ -281,9 +282,17 @@ namespace Umbraco.Web.Editors
|
||||
publishedContentExists: i => Umbraco.TypedContent(i) != null);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public UrlAndAnchors GetUrlAndAnchors(Udi id)
|
||||
{
|
||||
var nodeId = Umbraco.GetIdForUdi(id);
|
||||
var url = Umbraco.Url(nodeId);
|
||||
var anchorValues = Services.ContentService.GetAnchorValuesFromRTEs(nodeId);
|
||||
return new UrlAndAnchors(url, anchorValues);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public UrlAndAnchors GetUrlAndAnchors([FromUri]int id)
|
||||
public UrlAndAnchors GetUrlAndAnchors(int id)
|
||||
{
|
||||
var url = Umbraco.Url(id);
|
||||
var anchorValues = Services.ContentService.GetAnchorValuesFromRTEs(id);
|
||||
|
||||
@@ -492,6 +492,18 @@ namespace Umbraco.Web
|
||||
return Url(nodeId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string with a friendly url from a node.
|
||||
/// IE.: Instead of having /482 (id) as an url, you can have
|
||||
/// /screenshots/developer/macros (spoken url)
|
||||
/// </summary>
|
||||
/// <param name="guid">Identifier for the node that should be returned</param>
|
||||
/// <returns>String with a friendly url from a node</returns>
|
||||
public string NiceUrl(Guid guid)
|
||||
{
|
||||
return Url(guid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the url of a content identified by its identifier.
|
||||
/// </summary>
|
||||
@@ -502,6 +514,16 @@ namespace Umbraco.Web
|
||||
return UrlProvider.GetUrl(contentId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the url of a content identified by its identifier.
|
||||
/// </summary>
|
||||
/// <param name="contentGuid">The content identifier.</param>
|
||||
/// <returns>The url for the content.</returns>
|
||||
public string Url(Guid contentGuid)
|
||||
{
|
||||
return UrlProvider.GetUrl(contentGuid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the url of a content identified by its identifier, in a specified mode.
|
||||
/// </summary>
|
||||
@@ -513,6 +535,17 @@ namespace Umbraco.Web
|
||||
return UrlProvider.GetUrl(contentId, mode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the url of a content identified by its identifier, in a specified mode.
|
||||
/// </summary>
|
||||
/// <param name="contentGuid">The content identifier.</param>
|
||||
/// <param name="mode">The mode.</param>
|
||||
/// <returns>The url for the content.</returns>
|
||||
public string Url(Guid contentGuid, UrlProviderMode mode)
|
||||
{
|
||||
return UrlProvider.GetUrl(contentGuid, mode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method will always add the domain to the path if the hostnames are set up correctly.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user