diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/tree/umbtreesearchbox.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/tree/umbtreesearchbox.directive.js index b81e62a66b..4ba4cf96bb 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/tree/umbtreesearchbox.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/tree/umbtreesearchbox.directive.js @@ -12,7 +12,6 @@ function treeSearchBox(localizationService, searchService, $q) { searchFromName: "@", showSearch: "@", section: "@", - ignoreUserStartNodes: "@", hideSearchCallback: "=", searchCallback: "=" }, @@ -35,7 +34,6 @@ function treeSearchBox(localizationService, searchService, $q) { scope.showSearch = "false"; } - //used to cancel any request in progress if another one needs to take it's place var canceler = null; @@ -62,11 +60,6 @@ function treeSearchBox(localizationService, searchService, $q) { searchArgs["searchFrom"] = scope.searchFromId; } - //append ignoreUserStartNodes value if there is one - if (scope.ignoreUserStartNodes) { - searchArgs["ignoreUserStartNodes"] = scope.ignoreUserStartNodes; - } - searcher(searchArgs).then(function (data) { scope.searchCallback(data); //set back to null so it can be re-created diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js index 77e587bcc6..b695809eaa 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js @@ -1,795 +1,782 @@ -/** - * @ngdoc service - * @name umbraco.resources.contentResource - * @description Handles all transactions of content data - * from the angular application to the Umbraco database, using the Content WebApi controller - * - * all methods returns a resource promise async, so all operations won't complete untill .then() is completed. - * - * @requires $q - * @requires $http - * @requires umbDataFormatter - * @requires umbRequestHelper - * - * ##usage - * To use, simply inject the contentResource into any controller or service that needs it, and make - * sure the umbraco.resources module is accesible - which it should be by default. - * - *
- * contentResource.getById(1234)
- * .then(function(data) {
- * $scope.content = data;
- * });
- *
- **/
-
-function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
-
- /** internal method process the saving of data and post processing the result */
- function saveContentItem(content, action, files, restApiUrl) {
- return umbRequestHelper.postSaveContent({
- restApiUrl: restApiUrl,
- content: content,
- action: action,
- files: files,
- dataFormatter: function (c, a) {
- return umbDataFormatter.formatContentPostData(c, a);
- }
- });
- }
-
- return {
-
-
- savePermissions: function (saveModel) {
- if (!saveModel) {
- throw "saveModel cannot be null";
- }
- if (!saveModel.contentId) {
- throw "saveModel.contentId cannot be null";
- }
- if (!saveModel.permissions) {
- throw "saveModel.permissions cannot be null";
- }
-
- return umbRequestHelper.resourcePromise(
- $http.post(umbRequestHelper.getApiUrl("contentApiBaseUrl", "PostSaveUserGroupPermissions"),
- saveModel),
- 'Failed to save permissions');
- },
-
-
- getRecycleBin: function () {
- return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "GetRecycleBin")),
- 'Failed to retrieve data for content recycle bin');
- },
-
- /**
- * @ngdoc method
- * @name umbraco.resources.contentResource#sort
- * @methodOf umbraco.resources.contentResource
- *
- * @description
- * Sorts all children below a given parent node id, based on a collection of node-ids
- *
- * ##usage
- *
- * var ids = [123,34533,2334,23434];
- * contentResource.sort({ parentId: 1244, sortedIds: ids })
- * .then(function() {
- * $scope.complete = true;
- * });
- *
- * @param {Object} args arguments object
- * @param {Int} args.parentId the ID of the parent node
- * @param {Array} options.sortedIds array of node IDs as they should be sorted
- * @returns {Promise} resourcePromise object.
- *
- */
- sort: function (args) {
- if (!args) {
- throw "args cannot be null";
- }
- if (!args.parentId) {
- throw "args.parentId cannot be null";
- }
- if (!args.sortedIds) {
- throw "args.sortedIds cannot be null";
- }
-
- return umbRequestHelper.resourcePromise(
- $http.post(umbRequestHelper.getApiUrl("contentApiBaseUrl", "PostSort"),
- {
- parentId: args.parentId,
- idSortOrder: args.sortedIds
- }),
- 'Failed to sort content');
- },
-
- /**
- * @ngdoc method
- * @name umbraco.resources.contentResource#move
- * @methodOf umbraco.resources.contentResource
- *
- * @description
- * Moves a node underneath a new parentId
- *
- * ##usage
- *
- * contentResource.move({ parentId: 1244, id: 123 })
- * .then(function() {
- * alert("node was moved");
- * }, function(err){
- * alert("node didnt move:" + err.data.Message);
- * });
- *
- * @param {Object} args arguments object
- * @param {Int} args.idd the ID of the node to move
- * @param {Int} args.parentId the ID of the parent node to move to
- * @returns {Promise} resourcePromise object.
- *
- */
- move: function (args) {
- if (!args) {
- throw "args cannot be null";
- }
- if (!args.parentId) {
- throw "args.parentId cannot be null";
- }
- if (!args.id) {
- throw "args.id cannot be null";
- }
-
- return umbRequestHelper.resourcePromise(
- $http.post(umbRequestHelper.getApiUrl("contentApiBaseUrl", "PostMove"),
- {
- parentId: args.parentId,
- id: args.id
- }),
- 'Failed to move content');
- },
-
- /**
- * @ngdoc method
- * @name umbraco.resources.contentResource#copy
- * @methodOf umbraco.resources.contentResource
- *
- * @description
- * Copies a node underneath a new parentId
- *
- * ##usage
- *
- * contentResource.copy({ parentId: 1244, id: 123 })
- * .then(function() {
- * alert("node was copied");
- * }, function(err){
- * alert("node wasnt copy:" + err.data.Message);
- * });
- *
- * @param {Object} args arguments object
- * @param {Int} args.id the ID of the node to copy
- * @param {Int} args.parentId the ID of the parent node to copy to
- * @param {Boolean} args.relateToOriginal if true, relates the copy to the original through the relation api
- * @returns {Promise} resourcePromise object.
- *
- */
- copy: function (args) {
- if (!args) {
- throw "args cannot be null";
- }
- if (!args.parentId) {
- throw "args.parentId cannot be null";
- }
- if (!args.id) {
- throw "args.id cannot be null";
- }
-
- return umbRequestHelper.resourcePromise(
- $http.post(umbRequestHelper.getApiUrl("contentApiBaseUrl", "PostCopy"),
- args),
- 'Failed to copy content');
- },
-
- /**
- * @ngdoc method
- * @name umbraco.resources.contentResource#unPublish
- * @methodOf umbraco.resources.contentResource
- *
- * @description
- * Unpublishes a content item with a given Id
- *
- * ##usage
- *
- * contentResource.unPublish(1234)
- * .then(function() {
- * alert("node was unpulished");
- * }, function(err){
- * alert("node wasnt unpublished:" + err.data.Message);
- * });
- *
- * @param {Int} id the ID of the node to unpublish
- * @returns {Promise} resourcePromise object.
- *
- */
- unPublish: function (id) {
- if (!id) {
- throw "id cannot be null";
- }
-
- return umbRequestHelper.resourcePromise(
- $http.post(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "PostUnPublish",
- [{ id: id }])),
- 'Failed to publish content with id ' + id);
- },
- /**
- * @ngdoc method
- * @name umbraco.resources.contentResource#emptyRecycleBin
- * @methodOf umbraco.resources.contentResource
- *
- * @description
- * Empties the content recycle bin
- *
- * ##usage
- *
- * contentResource.emptyRecycleBin()
- * .then(function() {
- * alert('its empty!');
- * });
- *
- *
- * @returns {Promise} resourcePromise object.
- *
- */
- emptyRecycleBin: function () {
- return umbRequestHelper.resourcePromise(
- $http.post(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "EmptyRecycleBin")),
- 'Failed to empty the recycle bin');
- },
-
- /**
- * @ngdoc method
- * @name umbraco.resources.contentResource#deleteById
- * @methodOf umbraco.resources.contentResource
- *
- * @description
- * Deletes a content item with a given id
- *
- * ##usage
- *
- * contentResource.deleteById(1234)
- * .then(function() {
- * alert('its gone!');
- * });
- *
- *
- * @param {Int} id id of content item to delete
- * @returns {Promise} resourcePromise object.
- *
- */
- deleteById: function (id) {
- return umbRequestHelper.resourcePromise(
- $http.post(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "DeleteById",
- [{ id: id }])),
- 'Failed to delete item ' + id);
- },
-
- deleteBlueprint: function (id) {
- return umbRequestHelper.resourcePromise(
- $http.post(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "DeleteBlueprint",
- [{ id: id }])),
- 'Failed to delete blueprint ' + id);
- },
-
- /**
- * @ngdoc method
- * @name umbraco.resources.contentResource#getById
- * @methodOf umbraco.resources.contentResource
- *
- * @description
- * Gets a content item with a given id
- *
- * ##usage
- *
- * contentResource.getById(1234)
- * .then(function(content) {
- * var myDoc = content;
- * alert('its here!');
- * });
- *
- *
- * @param {Int} id id of content item to return
- * @param {Object} options optional options object
- * @param {Bool} options.ignoreUserStartNodes set to true to allow a user to choose nodes that they normally don't have access to
- * @returns {Promise} resourcePromise object containing the content item.
- *
- */
- getById: function (id, options) {
- var defaults = {
- ignoreUserStartNodes: false
- };
- if (options === undefined) {
- options = {};
- }
- //overwrite the defaults if there are any specified
- angular.extend(defaults, options);
- //now copy back to the options we will use
- options = defaults;
-
- return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "GetById",
- [{ id: id }, { ignoreUserStartNodes: options.ignoreUserStartNodes }])),
- 'Failed to retrieve data for content id ' + id);
- },
-
- getBlueprintById: function (id) {
- return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "GetBlueprintById",
- [{ id: id }])),
- 'Failed to retrieve data for content id ' + id);
- },
-
- getNotifySettingsById: function (id) {
- return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "GetNotificationOptions",
- [{ contentId: id }])),
- 'Failed to retrieve data for content id ' + id);
- },
-
- setNotifySettingsById: function (id, options) {
- if (!id) {
- throw "contentId cannot be null";
- }
- return umbRequestHelper.resourcePromise(
- $http.post(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "PostNotificationOptions",
- { contentId: id, notifyOptions: options })),
- 'Failed to set notify settings for content id ' + id);
- },
-
- /**
- * @ngdoc method
- * @name umbraco.resources.contentResource#getByIds
- * @methodOf umbraco.resources.contentResource
- *
- * @description
- * Gets an array of content items, given a collection of ids
- *
- * ##usage
- *
- * contentResource.getByIds( [1234,2526,28262])
- * .then(function(contentArray) {
- * var myDoc = contentArray;
- * alert('they are here!');
- * });
- *
- *
- * @param {Array} ids ids of content items to return as an array
- * @returns {Promise} resourcePromise object containing the content items array.
- *
- */
- getByIds: function (ids) {
-
- var idQuery = "";
- _.each(ids, function (item) {
- idQuery += "ids=" + item + "&";
- });
-
- return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "GetByIds",
- idQuery)),
- 'Failed to retrieve data for content with multiple ids');
- },
-
-
- /**
- * @ngdoc method
- * @name umbraco.resources.contentResource#getScaffold
- * @methodOf umbraco.resources.contentResource
- *
- * @description
- * Returns a scaffold of an empty content item, given the id of the content item to place it underneath and the content type alias.
- *
- * - Parent Id must be provided so umbraco knows where to store the content
- * - Content Type alias must be provided so umbraco knows which properties to put on the content scaffold
- *
- * The scaffold is used to build editors for content that has not yet been populated with data.
- *
- * ##usage
- *
- * contentResource.getScaffold(1234, 'homepage')
- * .then(function(scaffold) {
- * var myDoc = scaffold;
- * myDoc.name = "My new document";
- *
- * contentResource.publish(myDoc, true)
- * .then(function(content){
- * alert("Retrieved, updated and published again");
- * });
- * });
- *
- *
- * @param {Int} parentId id of content item to return
- * @param {String} alias contenttype alias to base the scaffold on
- * @returns {Promise} resourcePromise object containing the content scaffold.
- *
- */
- getScaffold: function (parentId, alias) {
-
- return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "GetEmpty",
- [{ contentTypeAlias: alias }, { parentId: parentId }])),
- 'Failed to retrieve data for empty content item type ' + alias);
- },
-
- getBlueprintScaffold: function (parentId, blueprintId) {
-
- return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "GetEmpty",
- [{ blueprintId: blueprintId }, { parentId: parentId}])),
- 'Failed to retrieve blueprint for id ' + blueprintId);
- },
-
- /**
- * @ngdoc method
- * @name umbraco.resources.contentResource#getNiceUrl
- * @methodOf umbraco.resources.contentResource
- *
- * @description
- * Returns a url, given a node ID
- *
- * ##usage
- *
- * contentResource.getNiceUrl(id)
- * .then(function(url) {
- * alert('its here!');
- * });
- *
- *
- * @param {Int} id Id of node to return the public url to
- * @returns {Promise} resourcePromise object containing the url.
- *
- */
- getNiceUrl: function (id) {
- return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "GetNiceUrl", [{ id: id }])),
- 'Failed to retrieve url for id:' + id);
- },
-
- /**
- * @ngdoc method
- * @name umbraco.resources.contentResource#getChildren
- * @methodOf umbraco.resources.contentResource
- *
- * @description
- * Gets children of a content item with a given id
- *
- * ##usage
- *
- * contentResource.getChildren(1234, {pageSize: 10, pageNumber: 2})
- * .then(function(contentArray) {
- * var children = contentArray;
- * alert('they are here!');
- * });
- *
- *
- * @param {Int} parentid id of content item to return children of
- * @param {Object} options optional options object
- * @param {Int} options.pageSize if paging data, number of nodes per page, default = 0
- * @param {Int} options.pageNumber if paging data, current page index, default = 0
- * @param {String} options.filter if provided, query will only return those with names matching the filter
- * @param {String} options.orderDirection can be `Ascending` or `Descending` - Default: `Ascending`
- * @param {String} options.orderBy property to order items by, default: `SortOrder`
- * @returns {Promise} resourcePromise object containing an array of content items.
- *
- */
- getChildren: function (parentId, options) {
-
- var defaults = {
- includeProperties: [],
- pageSize: 0,
- pageNumber: 0,
- filter: '',
- orderDirection: "Ascending",
- orderBy: "SortOrder",
- orderBySystemField: true
- };
- if (options === undefined) {
- options = {};
- }
- //overwrite the defaults if there are any specified
- angular.extend(defaults, options);
- //now copy back to the options we will use
- options = defaults;
- //change asc/desct
- if (options.orderDirection === "asc") {
- options.orderDirection = "Ascending";
- }
- else if (options.orderDirection === "desc") {
- options.orderDirection = "Descending";
- }
-
- //converts the value to a js bool
- function toBool(v) {
- if (angular.isNumber(v)) {
- return v > 0;
- }
- if (angular.isString(v)) {
- return v === "true";
- }
- if (typeof v === "boolean") {
- return v;
- }
- return false;
- }
-
- return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "GetChildren",
- {
- id: parentId,
- includeProperties: _.pluck(options.includeProperties, 'alias').join(","),
- pageNumber: options.pageNumber,
- pageSize: options.pageSize,
- orderBy: options.orderBy,
- orderDirection: options.orderDirection,
- orderBySystemField: toBool(options.orderBySystemField),
- filter: options.filter
- })),
- 'Failed to retrieve children for content item ' + parentId);
- },
-
- /**
- * @ngdoc method
- * @name umbraco.resources.contentResource#hasPermission
- * @methodOf umbraco.resources.contentResource
- *
- * @description
- * Returns true/false given a permission char to check against a nodeID
- * for the current user
- *
- * ##usage
- *
- * contentResource.hasPermission('p',1234)
- * .then(function() {
- * alert('You are allowed to publish this item');
- * });
- *
- *
- * @param {String} permission char representing the permission to check
- * @param {Int} id id of content item to delete
- * @returns {Promise} resourcePromise object.
- *
- */
- checkPermission: function (permission, id) {
- return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "HasPermission",
- [{ permissionToCheck: permission }, { nodeId: id }])),
- 'Failed to check permission for item ' + id);
- },
-
- getDetailedPermissions: function (contentId) {
- return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "GetDetailedPermissions", { contentId: contentId })),
- 'Failed to retrieve permissions for content item ' + contentId);
- },
-
- getPermissions: function (nodeIds) {
- return umbRequestHelper.resourcePromise(
- $http.post(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "GetPermissions"),
- nodeIds),
- 'Failed to get permissions');
- },
-
- /**
- * @ngdoc method
- * @name umbraco.resources.contentResource#save
- * @methodOf umbraco.resources.contentResource
- *
- * @description
- * Saves changes made to a content item to its current version, if the content item is new, the isNew paramater must be passed to force creation
- * if the content item needs to have files attached, they must be provided as the files param and passed separately
- *
- *
- * ##usage
- *
- * contentResource.getById(1234)
- * .then(function(content) {
- * content.name = "I want a new name!";
- * contentResource.save(content, false)
- * .then(function(content){
- * alert("Retrieved, updated and saved again");
- * });
- * });
- *
- *
- * @param {Object} content The content item object with changes applied
- * @param {Bool} isNew set to true to create a new item or to update an existing
- * @param {Array} files collection of files for the document
- * @returns {Promise} resourcePromise object containing the saved content item.
- *
- */
- save: function (content, isNew, files) {
- var endpoint = umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "PostSave");
- return saveContentItem(content, "save" + (isNew ? "New" : ""), files, endpoint);
- },
-
- saveBlueprint: function (content, isNew, files) {
- var endpoint = umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "PostSaveBlueprint");
- return saveContentItem(content, "save" + (isNew ? "New" : ""), files, endpoint);
- },
-
- /**
- * @ngdoc method
- * @name umbraco.resources.contentResource#publish
- * @methodOf umbraco.resources.contentResource
- *
- * @description
- * Saves and publishes changes made to a content item to a new version, if the content item is new, the isNew paramater must be passed to force creation
- * if the content item needs to have files attached, they must be provided as the files param and passed separately
- *
- *
- * ##usage
- *
- * contentResource.getById(1234)
- * .then(function(content) {
- * content.name = "I want a new name, and be published!";
- * contentResource.publish(content, false)
- * .then(function(content){
- * alert("Retrieved, updated and published again");
- * });
- * });
- *
- *
- * @param {Object} content The content item object with changes applied
- * @param {Bool} isNew set to true to create a new item or to update an existing
- * @param {Array} files collection of files for the document
- * @returns {Promise} resourcePromise object containing the saved content item.
- *
- */
- publish: function (content, isNew, files) {
- var endpoint = umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "PostSave");
- return saveContentItem(content, "publish" + (isNew ? "New" : ""), files, endpoint);
- },
-
-
- /**
- * @ngdoc method
- * @name umbraco.resources.contentResource#sendToPublish
- * @methodOf umbraco.resources.contentResource
- *
- * @description
- * Saves changes made to a content item, and notifies any subscribers about a pending publication
- *
- * ##usage
- *
- * contentResource.getById(1234)
- * .then(function(content) {
- * content.name = "I want a new name, and be published!";
- * contentResource.sendToPublish(content, false)
- * .then(function(content){
- * alert("Retrieved, updated and notication send off");
- * });
- * });
- *
- *
- * @param {Object} content The content item object with changes applied
- * @param {Bool} isNew set to true to create a new item or to update an existing
- * @param {Array} files collection of files for the document
- * @returns {Promise} resourcePromise object containing the saved content item.
- *
- */
- sendToPublish: function (content, isNew, files) {
- var endpoint = umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "PostSave");
- return saveContentItem(content, "sendPublish" + (isNew ? "New" : ""), files, endpoint);
- },
-
- /**
- * @ngdoc method
- * @name umbraco.resources.contentResource#publishByid
- * @methodOf umbraco.resources.contentResource
- *
- * @description
- * Publishes a content item with a given ID
- *
- * ##usage
- *
- * contentResource.publishById(1234)
- * .then(function(content) {
- * alert("published");
- * });
- *
- *
- * @param {Int} id The ID of the conten to publish
- * @returns {Promise} resourcePromise object containing the published content item.
- *
- */
- publishById: function (id) {
-
- if (!id) {
- throw "id cannot be null";
- }
-
- return umbRequestHelper.resourcePromise(
- $http.post(
- umbRequestHelper.getApiUrl(
- "contentApiBaseUrl",
- "PostPublishById",
- [{ id: id }])),
- 'Failed to publish content with id ' + id);
-
- },
-
- createBlueprintFromContent: function (contentId, name) {
- return umbRequestHelper.resourcePromise(
- $http.post(
- umbRequestHelper.getApiUrl("contentApiBaseUrl", "CreateBlueprintFromContent", {
- contentId: contentId, name: name
- })
- ),
- "Failed to create blueprint from content with id " + contentId
- );
- }
-
-
- };
-}
-
-angular.module('umbraco.resources').factory('contentResource', contentResource);
+/**
+ * @ngdoc service
+ * @name umbraco.resources.contentResource
+ * @description Handles all transactions of content data
+ * from the angular application to the Umbraco database, using the Content WebApi controller
+ *
+ * all methods returns a resource promise async, so all operations won't complete untill .then() is completed.
+ *
+ * @requires $q
+ * @requires $http
+ * @requires umbDataFormatter
+ * @requires umbRequestHelper
+ *
+ * ##usage
+ * To use, simply inject the contentResource into any controller or service that needs it, and make
+ * sure the umbraco.resources module is accesible - which it should be by default.
+ *
+ *
+ * contentResource.getById(1234)
+ * .then(function(data) {
+ * $scope.content = data;
+ * });
+ *
+ **/
+
+function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
+
+ /** internal method process the saving of data and post processing the result */
+ function saveContentItem(content, action, files, restApiUrl) {
+ return umbRequestHelper.postSaveContent({
+ restApiUrl: restApiUrl,
+ content: content,
+ action: action,
+ files: files,
+ dataFormatter: function (c, a) {
+ return umbDataFormatter.formatContentPostData(c, a);
+ }
+ });
+ }
+
+ return {
+
+
+ savePermissions: function (saveModel) {
+ if (!saveModel) {
+ throw "saveModel cannot be null";
+ }
+ if (!saveModel.contentId) {
+ throw "saveModel.contentId cannot be null";
+ }
+ if (!saveModel.permissions) {
+ throw "saveModel.permissions cannot be null";
+ }
+
+ return umbRequestHelper.resourcePromise(
+ $http.post(umbRequestHelper.getApiUrl("contentApiBaseUrl", "PostSaveUserGroupPermissions"),
+ saveModel),
+ 'Failed to save permissions');
+ },
+
+
+ getRecycleBin: function () {
+ return umbRequestHelper.resourcePromise(
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "GetRecycleBin")),
+ 'Failed to retrieve data for content recycle bin');
+ },
+
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentResource#sort
+ * @methodOf umbraco.resources.contentResource
+ *
+ * @description
+ * Sorts all children below a given parent node id, based on a collection of node-ids
+ *
+ * ##usage
+ *
+ * var ids = [123,34533,2334,23434];
+ * contentResource.sort({ parentId: 1244, sortedIds: ids })
+ * .then(function() {
+ * $scope.complete = true;
+ * });
+ *
+ * @param {Object} args arguments object
+ * @param {Int} args.parentId the ID of the parent node
+ * @param {Array} options.sortedIds array of node IDs as they should be sorted
+ * @returns {Promise} resourcePromise object.
+ *
+ */
+ sort: function (args) {
+ if (!args) {
+ throw "args cannot be null";
+ }
+ if (!args.parentId) {
+ throw "args.parentId cannot be null";
+ }
+ if (!args.sortedIds) {
+ throw "args.sortedIds cannot be null";
+ }
+
+ return umbRequestHelper.resourcePromise(
+ $http.post(umbRequestHelper.getApiUrl("contentApiBaseUrl", "PostSort"),
+ {
+ parentId: args.parentId,
+ idSortOrder: args.sortedIds
+ }),
+ 'Failed to sort content');
+ },
+
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentResource#move
+ * @methodOf umbraco.resources.contentResource
+ *
+ * @description
+ * Moves a node underneath a new parentId
+ *
+ * ##usage
+ *
+ * contentResource.move({ parentId: 1244, id: 123 })
+ * .then(function() {
+ * alert("node was moved");
+ * }, function(err){
+ * alert("node didnt move:" + err.data.Message);
+ * });
+ *
+ * @param {Object} args arguments object
+ * @param {Int} args.idd the ID of the node to move
+ * @param {Int} args.parentId the ID of the parent node to move to
+ * @returns {Promise} resourcePromise object.
+ *
+ */
+ move: function (args) {
+ if (!args) {
+ throw "args cannot be null";
+ }
+ if (!args.parentId) {
+ throw "args.parentId cannot be null";
+ }
+ if (!args.id) {
+ throw "args.id cannot be null";
+ }
+
+ return umbRequestHelper.resourcePromise(
+ $http.post(umbRequestHelper.getApiUrl("contentApiBaseUrl", "PostMove"),
+ {
+ parentId: args.parentId,
+ id: args.id
+ }),
+ 'Failed to move content');
+ },
+
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentResource#copy
+ * @methodOf umbraco.resources.contentResource
+ *
+ * @description
+ * Copies a node underneath a new parentId
+ *
+ * ##usage
+ *
+ * contentResource.copy({ parentId: 1244, id: 123 })
+ * .then(function() {
+ * alert("node was copied");
+ * }, function(err){
+ * alert("node wasnt copy:" + err.data.Message);
+ * });
+ *
+ * @param {Object} args arguments object
+ * @param {Int} args.id the ID of the node to copy
+ * @param {Int} args.parentId the ID of the parent node to copy to
+ * @param {Boolean} args.relateToOriginal if true, relates the copy to the original through the relation api
+ * @returns {Promise} resourcePromise object.
+ *
+ */
+ copy: function (args) {
+ if (!args) {
+ throw "args cannot be null";
+ }
+ if (!args.parentId) {
+ throw "args.parentId cannot be null";
+ }
+ if (!args.id) {
+ throw "args.id cannot be null";
+ }
+
+ return umbRequestHelper.resourcePromise(
+ $http.post(umbRequestHelper.getApiUrl("contentApiBaseUrl", "PostCopy"),
+ args),
+ 'Failed to copy content');
+ },
+
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentResource#unPublish
+ * @methodOf umbraco.resources.contentResource
+ *
+ * @description
+ * Unpublishes a content item with a given Id
+ *
+ * ##usage
+ *
+ * contentResource.unPublish(1234)
+ * .then(function() {
+ * alert("node was unpulished");
+ * }, function(err){
+ * alert("node wasnt unpublished:" + err.data.Message);
+ * });
+ *
+ * @param {Int} id the ID of the node to unpublish
+ * @returns {Promise} resourcePromise object.
+ *
+ */
+ unPublish: function (id) {
+ if (!id) {
+ throw "id cannot be null";
+ }
+
+ return umbRequestHelper.resourcePromise(
+ $http.post(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "PostUnPublish",
+ [{ id: id }])),
+ 'Failed to publish content with id ' + id);
+ },
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentResource#emptyRecycleBin
+ * @methodOf umbraco.resources.contentResource
+ *
+ * @description
+ * Empties the content recycle bin
+ *
+ * ##usage
+ *
+ * contentResource.emptyRecycleBin()
+ * .then(function() {
+ * alert('its empty!');
+ * });
+ *
+ *
+ * @returns {Promise} resourcePromise object.
+ *
+ */
+ emptyRecycleBin: function () {
+ return umbRequestHelper.resourcePromise(
+ $http.post(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "EmptyRecycleBin")),
+ 'Failed to empty the recycle bin');
+ },
+
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentResource#deleteById
+ * @methodOf umbraco.resources.contentResource
+ *
+ * @description
+ * Deletes a content item with a given id
+ *
+ * ##usage
+ *
+ * contentResource.deleteById(1234)
+ * .then(function() {
+ * alert('its gone!');
+ * });
+ *
+ *
+ * @param {Int} id id of content item to delete
+ * @returns {Promise} resourcePromise object.
+ *
+ */
+ deleteById: function (id) {
+ return umbRequestHelper.resourcePromise(
+ $http.post(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "DeleteById",
+ [{ id: id }])),
+ 'Failed to delete item ' + id);
+ },
+
+ deleteBlueprint: function (id) {
+ return umbRequestHelper.resourcePromise(
+ $http.post(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "DeleteBlueprint",
+ [{ id: id }])),
+ 'Failed to delete blueprint ' + id);
+ },
+
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentResource#getById
+ * @methodOf umbraco.resources.contentResource
+ *
+ * @description
+ * Gets a content item with a given id
+ *
+ * ##usage
+ *
+ * contentResource.getById(1234)
+ * .then(function(content) {
+ * var myDoc = content;
+ * alert('its here!');
+ * });
+ *
+ *
+ * @param {Int} id id of content item to return
+ * @returns {Promise} resourcePromise object containing the content item.
+ *
+ */
+ getById: function (id) {
+ return umbRequestHelper.resourcePromise(
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "GetById",
+ [{ id: id }])),
+ 'Failed to retrieve data for content id ' + id);
+ },
+
+ getBlueprintById: function (id) {
+ return umbRequestHelper.resourcePromise(
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "GetBlueprintById",
+ [{ id: id }])),
+ 'Failed to retrieve data for content id ' + id);
+ },
+
+ getNotifySettingsById: function (id) {
+ return umbRequestHelper.resourcePromise(
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "GetNotificationOptions",
+ [{ contentId: id }])),
+ 'Failed to retrieve data for content id ' + id);
+ },
+
+ setNotifySettingsById: function (id, options) {
+ if (!id) {
+ throw "contentId cannot be null";
+ }
+ return umbRequestHelper.resourcePromise(
+ $http.post(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "PostNotificationOptions",
+ { contentId: id, notifyOptions: options })),
+ 'Failed to set notify settings for content id ' + id);
+ },
+
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentResource#getByIds
+ * @methodOf umbraco.resources.contentResource
+ *
+ * @description
+ * Gets an array of content items, given a collection of ids
+ *
+ * ##usage
+ *
+ * contentResource.getByIds( [1234,2526,28262])
+ * .then(function(contentArray) {
+ * var myDoc = contentArray;
+ * alert('they are here!');
+ * });
+ *
+ *
+ * @param {Array} ids ids of content items to return as an array
+ * @returns {Promise} resourcePromise object containing the content items array.
+ *
+ */
+ getByIds: function (ids) {
+
+ var idQuery = "";
+ _.each(ids, function (item) {
+ idQuery += "ids=" + item + "&";
+ });
+
+ return umbRequestHelper.resourcePromise(
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "GetByIds",
+ idQuery)),
+ 'Failed to retrieve data for content with multiple ids');
+ },
+
+
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentResource#getScaffold
+ * @methodOf umbraco.resources.contentResource
+ *
+ * @description
+ * Returns a scaffold of an empty content item, given the id of the content item to place it underneath and the content type alias.
+ *
+ * - Parent Id must be provided so umbraco knows where to store the content
+ * - Content Type alias must be provided so umbraco knows which properties to put on the content scaffold
+ *
+ * The scaffold is used to build editors for content that has not yet been populated with data.
+ *
+ * ##usage
+ *
+ * contentResource.getScaffold(1234, 'homepage')
+ * .then(function(scaffold) {
+ * var myDoc = scaffold;
+ * myDoc.name = "My new document";
+ *
+ * contentResource.publish(myDoc, true)
+ * .then(function(content){
+ * alert("Retrieved, updated and published again");
+ * });
+ * });
+ *
+ *
+ * @param {Int} parentId id of content item to return
+ * @param {String} alias contenttype alias to base the scaffold on
+ * @returns {Promise} resourcePromise object containing the content scaffold.
+ *
+ */
+ getScaffold: function (parentId, alias) {
+
+ return umbRequestHelper.resourcePromise(
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "GetEmpty",
+ [{ contentTypeAlias: alias }, { parentId: parentId }])),
+ 'Failed to retrieve data for empty content item type ' + alias);
+ },
+
+ getBlueprintScaffold: function (parentId, blueprintId) {
+
+ return umbRequestHelper.resourcePromise(
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "GetEmpty",
+ [{ blueprintId: blueprintId }, { parentId: parentId}])),
+ 'Failed to retrieve blueprint for id ' + blueprintId);
+ },
+
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentResource#getNiceUrl
+ * @methodOf umbraco.resources.contentResource
+ *
+ * @description
+ * Returns a url, given a node ID
+ *
+ * ##usage
+ *
+ * contentResource.getNiceUrl(id)
+ * .then(function(url) {
+ * alert('its here!');
+ * });
+ *
+ *
+ * @param {Int} id Id of node to return the public url to
+ * @returns {Promise} resourcePromise object containing the url.
+ *
+ */
+ getNiceUrl: function (id) {
+ return umbRequestHelper.resourcePromise(
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "GetNiceUrl", [{ id: id }])),
+ 'Failed to retrieve url for id:' + id);
+ },
+
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentResource#getChildren
+ * @methodOf umbraco.resources.contentResource
+ *
+ * @description
+ * Gets children of a content item with a given id
+ *
+ * ##usage
+ *
+ * contentResource.getChildren(1234, {pageSize: 10, pageNumber: 2})
+ * .then(function(contentArray) {
+ * var children = contentArray;
+ * alert('they are here!');
+ * });
+ *
+ *
+ * @param {Int} parentid id of content item to return children of
+ * @param {Object} options optional options object
+ * @param {Int} options.pageSize if paging data, number of nodes per page, default = 0
+ * @param {Int} options.pageNumber if paging data, current page index, default = 0
+ * @param {String} options.filter if provided, query will only return those with names matching the filter
+ * @param {String} options.orderDirection can be `Ascending` or `Descending` - Default: `Ascending`
+ * @param {String} options.orderBy property to order items by, default: `SortOrder`
+ * @returns {Promise} resourcePromise object containing an array of content items.
+ *
+ */
+ getChildren: function (parentId, options) {
+
+ var defaults = {
+ includeProperties: [],
+ pageSize: 0,
+ pageNumber: 0,
+ filter: '',
+ orderDirection: "Ascending",
+ orderBy: "SortOrder",
+ orderBySystemField: true
+ };
+ if (options === undefined) {
+ options = {};
+ }
+ //overwrite the defaults if there are any specified
+ angular.extend(defaults, options);
+ //now copy back to the options we will use
+ options = defaults;
+ //change asc/desct
+ if (options.orderDirection === "asc") {
+ options.orderDirection = "Ascending";
+ }
+ else if (options.orderDirection === "desc") {
+ options.orderDirection = "Descending";
+ }
+
+ //converts the value to a js bool
+ function toBool(v) {
+ if (angular.isNumber(v)) {
+ return v > 0;
+ }
+ if (angular.isString(v)) {
+ return v === "true";
+ }
+ if (typeof v === "boolean") {
+ return v;
+ }
+ return false;
+ }
+
+ return umbRequestHelper.resourcePromise(
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "GetChildren",
+ {
+ id: parentId,
+ includeProperties: _.pluck(options.includeProperties, 'alias').join(","),
+ pageNumber: options.pageNumber,
+ pageSize: options.pageSize,
+ orderBy: options.orderBy,
+ orderDirection: options.orderDirection,
+ orderBySystemField: toBool(options.orderBySystemField),
+ filter: options.filter
+ })),
+ 'Failed to retrieve children for content item ' + parentId);
+ },
+
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentResource#hasPermission
+ * @methodOf umbraco.resources.contentResource
+ *
+ * @description
+ * Returns true/false given a permission char to check against a nodeID
+ * for the current user
+ *
+ * ##usage
+ *
+ * contentResource.hasPermission('p',1234)
+ * .then(function() {
+ * alert('You are allowed to publish this item');
+ * });
+ *
+ *
+ * @param {String} permission char representing the permission to check
+ * @param {Int} id id of content item to delete
+ * @returns {Promise} resourcePromise object.
+ *
+ */
+ checkPermission: function (permission, id) {
+ return umbRequestHelper.resourcePromise(
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "HasPermission",
+ [{ permissionToCheck: permission }, { nodeId: id }])),
+ 'Failed to check permission for item ' + id);
+ },
+
+ getDetailedPermissions: function (contentId) {
+ return umbRequestHelper.resourcePromise(
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "GetDetailedPermissions", { contentId: contentId })),
+ 'Failed to retrieve permissions for content item ' + contentId);
+ },
+
+ getPermissions: function (nodeIds) {
+ return umbRequestHelper.resourcePromise(
+ $http.post(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "GetPermissions"),
+ nodeIds),
+ 'Failed to get permissions');
+ },
+
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentResource#save
+ * @methodOf umbraco.resources.contentResource
+ *
+ * @description
+ * Saves changes made to a content item to its current version, if the content item is new, the isNew paramater must be passed to force creation
+ * if the content item needs to have files attached, they must be provided as the files param and passed separately
+ *
+ *
+ * ##usage
+ *
+ * contentResource.getById(1234)
+ * .then(function(content) {
+ * content.name = "I want a new name!";
+ * contentResource.save(content, false)
+ * .then(function(content){
+ * alert("Retrieved, updated and saved again");
+ * });
+ * });
+ *
+ *
+ * @param {Object} content The content item object with changes applied
+ * @param {Bool} isNew set to true to create a new item or to update an existing
+ * @param {Array} files collection of files for the document
+ * @returns {Promise} resourcePromise object containing the saved content item.
+ *
+ */
+ save: function (content, isNew, files) {
+ var endpoint = umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "PostSave");
+ return saveContentItem(content, "save" + (isNew ? "New" : ""), files, endpoint);
+ },
+
+ saveBlueprint: function (content, isNew, files) {
+ var endpoint = umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "PostSaveBlueprint");
+ return saveContentItem(content, "save" + (isNew ? "New" : ""), files, endpoint);
+ },
+
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentResource#publish
+ * @methodOf umbraco.resources.contentResource
+ *
+ * @description
+ * Saves and publishes changes made to a content item to a new version, if the content item is new, the isNew paramater must be passed to force creation
+ * if the content item needs to have files attached, they must be provided as the files param and passed separately
+ *
+ *
+ * ##usage
+ *
+ * contentResource.getById(1234)
+ * .then(function(content) {
+ * content.name = "I want a new name, and be published!";
+ * contentResource.publish(content, false)
+ * .then(function(content){
+ * alert("Retrieved, updated and published again");
+ * });
+ * });
+ *
+ *
+ * @param {Object} content The content item object with changes applied
+ * @param {Bool} isNew set to true to create a new item or to update an existing
+ * @param {Array} files collection of files for the document
+ * @returns {Promise} resourcePromise object containing the saved content item.
+ *
+ */
+ publish: function (content, isNew, files) {
+ var endpoint = umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "PostSave");
+ return saveContentItem(content, "publish" + (isNew ? "New" : ""), files, endpoint);
+ },
+
+
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentResource#sendToPublish
+ * @methodOf umbraco.resources.contentResource
+ *
+ * @description
+ * Saves changes made to a content item, and notifies any subscribers about a pending publication
+ *
+ * ##usage
+ *
+ * contentResource.getById(1234)
+ * .then(function(content) {
+ * content.name = "I want a new name, and be published!";
+ * contentResource.sendToPublish(content, false)
+ * .then(function(content){
+ * alert("Retrieved, updated and notication send off");
+ * });
+ * });
+ *
+ *
+ * @param {Object} content The content item object with changes applied
+ * @param {Bool} isNew set to true to create a new item or to update an existing
+ * @param {Array} files collection of files for the document
+ * @returns {Promise} resourcePromise object containing the saved content item.
+ *
+ */
+ sendToPublish: function (content, isNew, files) {
+ var endpoint = umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "PostSave");
+ return saveContentItem(content, "sendPublish" + (isNew ? "New" : ""), files, endpoint);
+ },
+
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentResource#publishByid
+ * @methodOf umbraco.resources.contentResource
+ *
+ * @description
+ * Publishes a content item with a given ID
+ *
+ * ##usage
+ *
+ * contentResource.publishById(1234)
+ * .then(function(content) {
+ * alert("published");
+ * });
+ *
+ *
+ * @param {Int} id The ID of the conten to publish
+ * @returns {Promise} resourcePromise object containing the published content item.
+ *
+ */
+ publishById: function (id) {
+
+ if (!id) {
+ throw "id cannot be null";
+ }
+
+ return umbRequestHelper.resourcePromise(
+ $http.post(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "PostPublishById",
+ [{ id: id }])),
+ 'Failed to publish content with id ' + id);
+
+ },
+
+ createBlueprintFromContent: function (contentId, name) {
+ return umbRequestHelper.resourcePromise(
+ $http.post(
+ umbRequestHelper.getApiUrl("contentApiBaseUrl", "CreateBlueprintFromContent", {
+ contentId: contentId, name: name
+ })
+ ),
+ "Failed to create blueprint from content with id " + contentId
+ );
+ }
+
+
+ };
+}
+
+angular.module('umbraco.resources').factory('contentResource', contentResource);
diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js
index 4875491dc6..72f8ad5539 100644
--- a/src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js
+++ b/src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js
@@ -292,29 +292,14 @@ function entityResource($q, $http, umbRequestHelper) {
* @returns {Promise} resourcePromise object containing the entity.
*
*/
- getAncestors: function (id, type, options) {
- var defaults = {
- ignoreUserStartNodes: false
- };
- if (options === undefined) {
- options = {};
- }
- //overwrite the defaults if there are any specified
- angular.extend(defaults, options);
- //now copy back to the options we will use
- options = defaults;
-
+ getAncestors: function (id, type) {
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"entityApiBaseUrl",
"GetAncestors",
- [
- { id: id },
- { type: type },
- { ignoreUserStartNodes: options.ignoreUserStartNodes }
- ])),
- 'Failed to retrieve ancestor data for id ' + id);
+ [{id: id}, {type: type}])),
+ 'Failed to retrieve ancestor data for id ' + id);
},
/**
@@ -446,8 +431,7 @@ function entityResource($q, $http, umbRequestHelper) {
pageNumber: 1,
filter: '',
orderDirection: "Ascending",
- orderBy: "SortOrder",
- ignoreUserStartNodes: false
+ orderBy: "SortOrder"
};
if (options === undefined) {
options = {};
@@ -476,8 +460,7 @@ function entityResource($q, $http, umbRequestHelper) {
pageSize: options.pageSize,
orderBy: options.orderBy,
orderDirection: options.orderDirection,
- filter: encodeURIComponent(options.filter),
- ignoreUserStartNodes: options.ignoreUserStartNodes
+ filter: encodeURIComponent(options.filter)
}
)),
'Failed to retrieve child data for id ' + parentId);
@@ -505,19 +488,12 @@ function entityResource($q, $http, umbRequestHelper) {
* @returns {Promise} resourcePromise object containing the entity array.
*
*/
- search: function (query, type, options, canceler) {
+ search: function (query, type, searchFrom, canceler) {
- var defaults = {
- searchFrom: null,
- ignoreUserStartNodes: false
- };
- if (options === undefined) {
- options = {};
+ var args = [{ query: query }, { type: type }];
+ if (searchFrom) {
+ args.push({ searchFrom: searchFrom });
}
- //overwrite the defaults if there are any specified
- angular.extend(defaults, options);
- //now copy back to the options we will use
- options = defaults;
var httpConfig = {};
if (canceler) {
@@ -529,12 +505,7 @@ function entityResource($q, $http, umbRequestHelper) {
umbRequestHelper.getApiUrl(
"entityApiBaseUrl",
"Search",
- {
- query: query,
- type: type,
- searchFrom: options.searchFrom,
- ignoreUserStartNodes: options.ignoreUserStartNodes
- }),
+ args),
httpConfig),
'Failed to retrieve entity data for query ' + query);
},
diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/media.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/media.resource.js
index e968913047..8c27f20aea 100644
--- a/src/Umbraco.Web.UI.Client/src/common/resources/media.resource.js
+++ b/src/Umbraco.Web.UI.Client/src/common/resources/media.resource.js
@@ -329,8 +329,7 @@ function mediaResource($q, $http, umbDataFormatter, umbRequestHelper) {
filter: '',
orderDirection: "Ascending",
orderBy: "SortOrder",
- orderBySystemField: true,
- ignoreUserStartNodes: false
+ orderBySystemField: true
};
if (options === undefined) {
options = {};
@@ -373,8 +372,7 @@ function mediaResource($q, $http, umbDataFormatter, umbRequestHelper) {
{ orderBy: options.orderBy },
{ orderDirection: options.orderDirection },
{ orderBySystemField: toBool(options.orderBySystemField) },
- { filter: options.filter },
- { ignoreUserStartNodes: options.ignoreUserStartNodes }
+ { filter: options.filter }
])),
'Failed to retrieve children for media item ' + parentId);
},
diff --git a/src/Umbraco.Web.UI.Client/src/common/services/search.service.js b/src/Umbraco.Web.UI.Client/src/common/services/search.service.js
index 0d00678282..8738c1011e 100644
--- a/src/Umbraco.Web.UI.Client/src/common/services/search.service.js
+++ b/src/Umbraco.Web.UI.Client/src/common/services/search.service.js
@@ -42,11 +42,7 @@ angular.module('umbraco.services')
throw "args.term is required";
}
- var options = {
- searchFrom: args.searchFrom
- }
-
- return entityResource.search(args.term, "Member", options).then(function (data) {
+ return entityResource.search(args.term, "Member", args.searchFrom).then(function (data) {
_.each(data, function (item) {
searchResultFormatter.configureMemberResult(item);
});
@@ -71,12 +67,7 @@ angular.module('umbraco.services')
throw "args.term is required";
}
- var options = {
- searchFrom: args.searchFrom,
- ignoreUserStartNodes: args.ignoreUserStartNodes
- }
-
- return entityResource.search(args.term, "Document", options, args.canceler).then(function (data) {
+ return entityResource.search(args.term, "Document", args.searchFrom, args.canceler).then(function (data) {
_.each(data, function (item) {
searchResultFormatter.configureContentResult(item);
});
@@ -101,12 +92,7 @@ angular.module('umbraco.services')
throw "args.term is required";
}
- var options = {
- searchFrom: args.searchFrom,
- ignoreUserStartNodes: args.ignoreUserStartNodes
- }
-
- return entityResource.search(args.term, "Media", options).then(function (data) {
+ return entityResource.search(args.term, "Media", args.searchFrom).then(function (data) {
_.each(data, function (item) {
searchResultFormatter.configureMediaResult(item);
});
@@ -171,4 +157,4 @@ angular.module('umbraco.services')
var currentSection = sectionAlias;
}
};
- });
+ });
\ No newline at end of file
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/overlays/contentpicker/contentpicker.html b/src/Umbraco.Web.UI.Client/src/views/common/overlays/contentpicker/contentpicker.html
index 4391e50c28..43eab532d4 100644
--- a/src/Umbraco.Web.UI.Client/src/views/common/overlays/contentpicker/contentpicker.html
+++ b/src/Umbraco.Web.UI.Client/src/views/common/overlays/contentpicker/contentpicker.html
@@ -9,7 +9,6 @@
search-from-id="{{searchInfo.searchFromId}}"
search-from-name="{{searchInfo.searchFromName}}"
show-search="{{searchInfo.showSearch}}"
- ignore-user-startnodes="{{searchInfo.ignoreUserStartNodes}}"
section="content">
@@ -46,4 +45,4 @@
on-close="closeMiniListView()">
-
+
\ No newline at end of file
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/overlays/linkpicker/linkpicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/overlays/linkpicker/linkpicker.controller.js
index 79b9362d3f..fcce34621b 100644
--- a/src/Umbraco.Web.UI.Client/src/views/common/overlays/linkpicker/linkpicker.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/common/overlays/linkpicker/linkpicker.controller.js
@@ -1,58 +1,57 @@
//used for the media picker dialog
angular.module("umbraco").controller("Umbraco.Overlays.LinkPickerController",
- function ($scope, eventsService, dialogService, entityResource, contentResource, mediaHelper, userService, localizationService, tinyMceService) {
- var dialogOptions = $scope.model;
+ function ($scope, eventsService, dialogService, entityResource, contentResource, mediaHelper, userService, localizationService, tinyMceService) {
+ var dialogOptions = $scope.model;
- var searchText = "Search...";
- localizationService.localize("general_search").then(function (value) {
- searchText = value + "...";
- });
+ var searchText = "Search...";
+ localizationService.localize("general_search").then(function (value) {
+ searchText = value + "...";
+ });
- if (!$scope.model.title) {
- $scope.model.title = localizationService.localize("defaultdialogs_selectLink");
- }
+ if (!$scope.model.title) {
+ $scope.model.title = localizationService.localize("defaultdialogs_selectLink");
+ }
- $scope.dialogTreeEventHandler = $({});
- $scope.model.target = {};
- $scope.searchInfo = {
- searchFromId: null,
- searchFromName: null,
- showSearch: false,
- ignoreUserStartNodes: dialogOptions.ignoreUserStartNodes,
- results: [],
- selectedSearchResults: []
- };
- $scope.customTreeParams = dialogOptions.ignoreUserStartNodes ? "ignoreUserStartNodes=" + dialogOptions.ignoreUserStartNodes : "";
- $scope.showTarget = $scope.model.hideTarget !== true;
+ $scope.dialogTreeEventHandler = $({});
+ $scope.model.target = {};
+ $scope.searchInfo = {
+ searchFromId: null,
+ searchFromName: null,
+ showSearch: false,
+ results: [],
+ selectedSearchResults: []
+ };
- 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 ($scope.model.target.id || $scope.model.target.udi) {
+ $scope.showTarget = $scope.model.hideTarget !== true;
- //will be either a udi or an int
- var id = $scope.model.target.udi ? $scope.model.target.udi : $scope.model.target.id;
+ 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 ($scope.model.target.id || $scope.model.target.udi) {
- // 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
- $scope.dialogTreeEventHandler.syncTree({
- path: path,
- tree: "content"
- });
- });
+ //will be either a udi or an int
+ var id = $scope.model.target.udi ? $scope.model.target.udi : $scope.model.target.id;
- // if a link exists, get the properties to build the anchor name list
- contentResource.getById(id, { ignoreUserStartNodes: dialogOptions.ignoreUserStartNodes }).then(function (resp) {
- $scope.model.target.url = resp.urls[0];
- $scope.anchorValues = tinyMceService.getAnchorNames(JSON.stringify(resp.properties));
- });
- }
- } else if ($scope.model.target.url.length) {
- // a url but no id/udi indicates an external link - trim the url to remove the anchor/qs
+ // 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
+ $scope.dialogTreeEventHandler.syncTree({
+ path: path,
+ tree: "content"
+ });
+ });
+
+ // get the content properties to build the anchor name list
+ contentResource.getById(id).then(function (resp) {
+ $scope.model.target.url = resp.urls[0];
+ $scope.anchorValues = tinyMceService.getAnchorNames(JSON.stringify(resp.properties));
+ });
+ }
+ } else if ($scope.model.target.url.length) {
+ // a url but no id/udi indicates an external link - trim the url to remove the anchor/qs
// only do the substring if there's a # or a ?
var indexOfAnchor = $scope.model.target.url.search(/(#|\?)/);
if (indexOfAnchor > -1) {
@@ -61,132 +60,124 @@ angular.module("umbraco").controller("Umbraco.Overlays.LinkPickerController",
// then rewrite the model and populate the link
$scope.model.target.url = $scope.model.target.url.substring(0, indexOfAnchor);
}
- }
- } else if (dialogOptions.anchors) {
- $scope.anchorValues = dialogOptions.anchors;
- }
+ }
+ } else if (dialogOptions.anchors) {
+ $scope.anchorValues = dialogOptions.anchors;
+ }
- function nodeSelectHandler(ev, args) {
- if (args && args.event) {
- args.event.preventDefault();
- args.event.stopPropagation();
- }
+ function nodeSelectHandler(ev, args) {
+ if (args && args.event) {
+ args.event.preventDefault();
+ args.event.stopPropagation();
+ }
- eventsService.emit("dialogs.linkPicker.select", args);
+ eventsService.emit("dialogs.linkPicker.select", args);
- if ($scope.currentNode) {
- //un-select if there's a current one selected
- $scope.currentNode.selected = false;
- }
+ if ($scope.currentNode) {
+ //un-select if there's a current one selected
+ $scope.currentNode.selected = false;
+ }
- $scope.currentNode = args.node;
- $scope.currentNode.selected = true;
- $scope.model.target.id = args.node.id;
- $scope.model.target.udi = args.node.udi;
- $scope.model.target.name = args.node.name;
+ $scope.currentNode = args.node;
+ $scope.currentNode.selected = true;
+ $scope.model.target.id = args.node.id;
+ $scope.model.target.udi = args.node.udi;
+ $scope.model.target.name = args.node.name;
- if (args.node.id < 0) {
- $scope.model.target.url = "/";
- } else {
- contentResource.getById(args.node.id, { ignoreUserStartNodes: dialogOptions.ignoreUserStartNodes }).then(function (resp) {
- $scope.model.target.url = resp.urls[0];
- $scope.anchorValues = tinyMceService.getAnchorNames(JSON.stringify(resp.properties));
- });
- }
+ if (args.node.id < 0) {
+ $scope.model.target.url = "/";
+ } else {
+ contentResource.getById(args.node.id).then(function (resp) {
+ $scope.model.target.url = resp.urls[0];
+ $scope.anchorValues = tinyMceService.getAnchorNames(JSON.stringify(resp.properties));
+ });
+ }
- if (!angular.isUndefined($scope.model.target.isMedia)) {
- delete $scope.model.target.isMedia;
- }
- }
+ if (!angular.isUndefined($scope.model.target.isMedia)) {
+ delete $scope.model.target.isMedia;
+ }
+ }
- function nodeExpandedHandler(ev, args) {
- // open mini list view for list views
- if (args.node.metaData.isContainer) {
- openMiniListView(args.node);
- }
- }
+ function nodeExpandedHandler(ev, args) {
+ // open mini list view for list views
+ if (args.node.metaData.isContainer) {
+ openMiniListView(args.node);
+ }
+ }
- $scope.switchToMediaPicker = function () {
- userService.getCurrentUser().then(function (userData) {
- var startNodeId = userData.startMediaIds.length !== 1 ? -1 : userData.startMediaIds[0];
- var startNodeIsVirtual = userData.startMediaIds.length !== 1;
+ $scope.switchToMediaPicker = function () {
+ userService.getCurrentUser().then(function (userData) {
+ $scope.mediaPickerOverlay = {
+ view: "mediapicker",
+ startNodeId: userData.startMediaIds.length !== 1 ? -1 : userData.startMediaIds[0],
+ startNodeIsVirtual: userData.startMediaIds.length !== 1,
+ show: true,
+ submit: function (model) {
+ var media = model.selectedImages[0];
- if (dialogOptions.ignoreUserStartNodes) {
- startNodeId = -1;
- startNodeIsVirtual = true;
- }
- $scope.mediaPickerOverlay = {
- view: "mediapicker",
- startNodeId: startNodeId,
- startNodeIsVirtual: startNodeIsVirtual,
- show: true,
- ignoreUserStartNodes: dialogOptions.ignoreUserStartNodes,
- submit: function (model) {
- var media = model.selectedImages[0];
+ $scope.model.target.id = media.id;
+ $scope.model.target.udi = media.udi;
+ $scope.model.target.isMedia = true;
+ $scope.model.target.name = media.name;
+ $scope.model.target.url = mediaHelper.resolveFile(media);
- $scope.model.target.id = media.id;
- $scope.model.target.udi = media.udi;
- $scope.model.target.isMedia = true;
- $scope.model.target.name = media.name;
- $scope.model.target.url = mediaHelper.resolveFile(media);
+ $scope.mediaPickerOverlay.show = false;
+ $scope.mediaPickerOverlay = null;
- $scope.mediaPickerOverlay.show = false;
- $scope.mediaPickerOverlay = null;
+ // make sure the content tree has nothing highlighted
+ $scope.dialogTreeEventHandler.syncTree({
+ path: "-1",
+ tree: "content"
+ });
+ }
+ };
+ });
+ };
- // make sure the content tree has nothing highlighted
- $scope.dialogTreeEventHandler.syncTree({
- path: "-1",
- tree: "content"
- });
- }
- };
- });
- };
+ $scope.hideSearch = function () {
+ $scope.searchInfo.showSearch = false;
+ $scope.searchInfo.searchFromId = null;
+ $scope.searchInfo.searchFromName = null;
+ $scope.searchInfo.results = [];
+ }
- $scope.hideSearch = function () {
- $scope.searchInfo.showSearch = false;
- $scope.searchInfo.searchFromId = null;
- $scope.searchInfo.searchFromName = null;
- $scope.searchInfo.results = [];
- }
+ // method to select a search result
+ $scope.selectResult = function (evt, result) {
+ result.selected = result.selected === true ? false : true;
+ nodeSelectHandler(evt, {
+ event: evt,
+ node: result
+ });
+ };
- // method to select a search result
- $scope.selectResult = function (evt, result) {
- result.selected = result.selected === true ? false : true;
- nodeSelectHandler(evt, {
- event: evt,
- node: result
- });
- };
+ //callback when there are search results
+ $scope.onSearchResults = function (results) {
+ $scope.searchInfo.results = results;
+ $scope.searchInfo.showSearch = true;
+ };
- //callback when there are search results
- $scope.onSearchResults = function (results) {
- $scope.searchInfo.results = results;
- $scope.searchInfo.showSearch = true;
- };
+ $scope.dialogTreeEventHandler.bind("treeNodeSelect", nodeSelectHandler);
+ $scope.dialogTreeEventHandler.bind("treeNodeExpanded", nodeExpandedHandler);
- $scope.dialogTreeEventHandler.bind("treeNodeSelect", nodeSelectHandler);
- $scope.dialogTreeEventHandler.bind("treeNodeExpanded", nodeExpandedHandler);
+ $scope.$on('$destroy', function () {
+ $scope.dialogTreeEventHandler.unbind("treeNodeSelect", nodeSelectHandler);
+ $scope.dialogTreeEventHandler.unbind("treeNodeExpanded", nodeExpandedHandler);
+ });
- $scope.$on('$destroy', function () {
- $scope.dialogTreeEventHandler.unbind("treeNodeSelect", nodeSelectHandler);
- $scope.dialogTreeEventHandler.unbind("treeNodeExpanded", nodeExpandedHandler);
- });
+ // Mini list view
+ $scope.selectListViewNode = function (node) {
+ node.selected = node.selected === true ? false : true;
+ nodeSelectHandler({}, {
+ node: node
+ });
+ };
- // Mini list view
- $scope.selectListViewNode = function (node) {
- node.selected = node.selected === true ? false : true;
- nodeSelectHandler({}, {
- node: node
- });
- };
+ $scope.closeMiniListView = function () {
+ $scope.miniListView = undefined;
+ };
- $scope.closeMiniListView = function () {
- $scope.miniListView = undefined;
- };
+ function openMiniListView(node) {
+ $scope.miniListView = node;
+ }
- function openMiniListView(node) {
- $scope.miniListView = node;
- }
-
- });
+ });
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/overlays/linkpicker/linkpicker.html b/src/Umbraco.Web.UI.Client/src/views/common/overlays/linkpicker/linkpicker.html
index c9f3ad54a7..deba19aa11 100644
--- a/src/Umbraco.Web.UI.Client/src/views/common/overlays/linkpicker/linkpicker.html
+++ b/src/Umbraco.Web.UI.Client/src/views/common/overlays/linkpicker/linkpicker.html
@@ -50,7 +50,6 @@
search-from-id="{{searchInfo.searchFromId}}"
search-from-name="{{searchInfo.searchFromName}}"
show-search="{{searchInfo.showSearch}}"
- ignore-user-startnodes="{{searchInfo.ignoreUserStartNodes}}"
section="{{section}}">
@@ -65,7 +64,6 @@