diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/datatype.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/datatype.resource.js index 2492ac3309..27b331ba4c 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/datatype.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/datatype.resource.js @@ -54,8 +54,8 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) { * ##usage *
          * dataTypeResource.getById(1234)
-         *    .then(function() {
-         *        alert('its gone!');
+         *    .then(function(datatype) {
+         *        alert('its here!');
          *    });
          * 
* @@ -74,6 +74,37 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) { 'Failed to retrieve data for data type id ' + id); }, + /** + * @ngdoc method + * @name umbraco.resources.dataTypeResource#getByName + * @methodOf umbraco.resources.dataTypeResource + * + * @description + * Gets a data type item with a given name + * + * ##usage + *
+         * dataTypeResource.getByName("upload")
+         *    .then(function(datatype) {
+         *        alert('its here!');
+         *    });
+         * 
+ * + * @param {String} name Name of data type to retrieve + * @returns {Promise} resourcePromise object. + * + */ + getByName: function (name) { + + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "dataTypeApiBaseUrl", + "GetByName", + [{ name: name }])), + 'Failed to retrieve data for data type with name: ' + name); + }, + getAll: function () { return umbRequestHelper.resourcePromise( @@ -170,6 +201,39 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) { 'Failed to delete item ' + id); }, + + + /** + * @ngdoc method + * @name umbraco.resources.dataTypeResource#getCustomListView + * @methodOf umbraco.resources.dataTypeResource + * + * @description + * Returns a custom listview, given a content types alias + * + * + * ##usage + *
+         * dataTypeResource.getCustomListView("home")
+         *    .then(function(listview) {
+         *    });
+         * 
+ * + * @returns {Promise} resourcePromise object containing the listview datatype. + * + */ + + getCustomListView: function (contentTypeAlias) { + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "dataTypeApiBaseUrl", + "GetCustomListView", + { contentTypeAlias: contentTypeAlias } + )), + 'Failed to retrieve data for custom listview datatype'); + }, + /** * @ngdoc method * @name umbraco.resources.dataTypeResource#save diff --git a/src/Umbraco.Web/Editors/DataTypeController.cs b/src/Umbraco.Web/Editors/DataTypeController.cs index de47bbe90c..3a807feccf 100644 --- a/src/Umbraco.Web/Editors/DataTypeController.cs +++ b/src/Umbraco.Web/Editors/DataTypeController.cs @@ -140,6 +140,22 @@ namespace Umbraco.Web.Editors return Mapper.Map(dt); } + /// + /// Returns a custom listview, based on a content type alias, if found + /// + /// + /// a DataTypeDisplay + public DataTypeDisplay GetCustomListView(string contentTypeAlias) + { + var dt = Services.DataTypeService.GetDataTypeDefinitionByName(Constants.Conventions.DataTypes.ListViewPrefix + contentTypeAlias); + if (dt == null) + { + throw new HttpResponseException(HttpStatusCode.NotFound); + } + + return Mapper.Map(dt); + } + /// /// Returns the pre-values for the specified property editor ///