Moves GetPath to EntityController and entityResource since all entities can have a path not just content.
This commit is contained in:
@@ -401,35 +401,6 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
|
||||
'Failed to retrieve url for id:' + id);
|
||||
},
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.resources.contentResource#getPath
|
||||
* @methodOf umbraco.resources.contentResource
|
||||
*
|
||||
* @description
|
||||
* Returns a url, given a node ID
|
||||
*
|
||||
* ##usage
|
||||
* <pre>
|
||||
* contentResource.getPath(id)
|
||||
* .then(function(pathArray) {
|
||||
* alert('its here!');
|
||||
* });
|
||||
* </pre>
|
||||
*
|
||||
* @param {Int} id Id of node to return the public url to
|
||||
* @returns {Promise} resourcePromise object containing the url.
|
||||
*
|
||||
*/
|
||||
getPath: function (id) {
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"contentApiBaseUrl",
|
||||
"GetPath",[{id: id}])),
|
||||
'Failed to retrieve path for id:' + id);
|
||||
},
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.resources.contentResource#getChildren
|
||||
|
||||
@@ -35,6 +35,37 @@ function entityResource($q, $http, umbRequestHelper) {
|
||||
//the factory object returned
|
||||
return {
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.resources.entityResource#getPath
|
||||
* @methodOf umbraco.resources.entityResource
|
||||
*
|
||||
* @description
|
||||
* Returns a path, given a node ID and type
|
||||
*
|
||||
* ##usage
|
||||
* <pre>
|
||||
* entityResource.getPath(id)
|
||||
* .then(function(pathArray) {
|
||||
* alert('its here!');
|
||||
* });
|
||||
* </pre>
|
||||
*
|
||||
* @param {Int} id Id of node to return the public url to
|
||||
* @param {string} type Object type name
|
||||
* @returns {Promise} resourcePromise object containing the url.
|
||||
*
|
||||
*/
|
||||
getPath: function (id, type) {
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"entityApiBaseUrl",
|
||||
"GetPath",
|
||||
[{ id: id, type: type }])),
|
||||
'Failed to retrieve path for id:' + id);
|
||||
},
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.resources.entityResource#getById
|
||||
@@ -54,7 +85,7 @@ function entityResource($q, $http, umbRequestHelper) {
|
||||
* </pre>
|
||||
*
|
||||
* @param {Int} id id of entity to return
|
||||
* @param {string} type optional Object type name
|
||||
* @param {string} type Object type name
|
||||
* @returns {Promise} resourcePromise object containing the entity.
|
||||
*
|
||||
*/
|
||||
@@ -87,7 +118,7 @@ function entityResource($q, $http, umbRequestHelper) {
|
||||
* </pre>
|
||||
*
|
||||
* @param {Array} ids ids of entities to return as an array
|
||||
* @param {string} type optional type name
|
||||
* @param {string} type type name
|
||||
* @returns {Promise} resourcePromise object containing the entity array.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//used for the media picker dialog
|
||||
angular.module("umbraco").controller("Umbraco.Dialogs.LinkPickerController",
|
||||
function ($scope, eventsService, contentResource, $log) {
|
||||
function ($scope, eventsService, entityResource, contentResource, $log) {
|
||||
var dialogOptions = $scope.$parent.dialogOptions;
|
||||
|
||||
$scope.dialogTreeEventHandler = $({});
|
||||
@@ -12,10 +12,10 @@ angular.module("umbraco").controller("Umbraco.Dialogs.LinkPickerController",
|
||||
//if we a node ID, we fetch the current node to build the form data
|
||||
if($scope.target.id){
|
||||
|
||||
if(!$scope.target.path){
|
||||
contentResource.getPath($scope.target.id).then(function(path){
|
||||
$scope.target.path = path;
|
||||
})
|
||||
if(!$scope.target.path) {
|
||||
entityResource.getPath($scope.target.id, "Document").then(function (path) {
|
||||
$scope.target.path = path;
|
||||
});
|
||||
}
|
||||
|
||||
contentResource.getNiceUrl($scope.target.id).then(function(url){
|
||||
|
||||
Reference in New Issue
Block a user