Adds GetCustomListView and GetByName to datatype service
This commit is contained in:
@@ -54,8 +54,8 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) {
|
||||
* ##usage
|
||||
* <pre>
|
||||
* dataTypeResource.getById(1234)
|
||||
* .then(function() {
|
||||
* alert('its gone!');
|
||||
* .then(function(datatype) {
|
||||
* alert('its here!');
|
||||
* });
|
||||
* </pre>
|
||||
*
|
||||
@@ -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
|
||||
* <pre>
|
||||
* dataTypeResource.getByName("upload")
|
||||
* .then(function(datatype) {
|
||||
* alert('its here!');
|
||||
* });
|
||||
* </pre>
|
||||
*
|
||||
* @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
|
||||
* <pre>
|
||||
* dataTypeResource.getCustomListView("home")
|
||||
* .then(function(listview) {
|
||||
* });
|
||||
* </pre>
|
||||
*
|
||||
* @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
|
||||
|
||||
@@ -140,6 +140,22 @@ namespace Umbraco.Web.Editors
|
||||
return Mapper.Map<IDataTypeDefinition, DataTypeDisplay>(dt);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a custom listview, based on a content type alias, if found
|
||||
/// </summary>
|
||||
/// <param name="contentTypeAlias"></param>
|
||||
/// <returns>a DataTypeDisplay</returns>
|
||||
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<IDataTypeDefinition, DataTypeDisplay>(dt);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the pre-values for the specified property editor
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user