diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js index d69777464c..cec9cf191e 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js @@ -3,17 +3,17 @@ * @name umbraco.resources.contentTypeResource * @description Loads in data for content types **/ -function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter) { +function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter, localizationService, notificationsService) { return { getCount: function () { return umbRequestHelper.resourcePromise( - $http.get( - umbRequestHelper.getApiUrl( - "contentTypeApiBaseUrl", - "GetCount")), - 'Failed to retrieve count'); + $http.get( + umbRequestHelper.getApiUrl( + "contentTypeApiBaseUrl", + "GetCount")), + 'Failed to retrieve count'); }, getAvailableCompositeContentTypes: function (contentTypeId, filterContentTypes, filterPropertyTypes) { @@ -31,32 +31,32 @@ function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter) { }; return umbRequestHelper.resourcePromise( - $http.post( - umbRequestHelper.getApiUrl( - "contentTypeApiBaseUrl", - "GetAvailableCompositeContentTypes"), - query), - 'Failed to retrieve data for content type id ' + contentTypeId); + $http.post( + umbRequestHelper.getApiUrl( + "contentTypeApiBaseUrl", + "GetAvailableCompositeContentTypes"), + query), + 'Failed to retrieve data for content type id ' + contentTypeId); }, - /** - * @ngdoc method - * @name umbraco.resources.contentTypeResource#getWhereCompositionIsUsedInContentTypes - * @methodOf umbraco.resources.contentTypeResource - * - * @description - * Returns a list of content types which use a specific composition with a given id - * - * ##usage - *
- * contentTypeResource.getWhereCompositionIsUsedInContentTypes(1234)
- * .then(function(contentTypeList) {
- * console.log(contentTypeList);
- * });
- *
- * @param {Int} contentTypeId id of the composition content type to retrieve the list of the content types where it has been used
- * @returns {Promise} resourcePromise object.
- *
- */
+ /**
+ * @ngdoc method
+ * @name umbraco.resources.contentTypeResource#getWhereCompositionIsUsedInContentTypes
+ * @methodOf umbraco.resources.contentTypeResource
+ *
+ * @description
+ * Returns a list of content types which use a specific composition with a given id
+ *
+ * ##usage
+ *
+ * contentTypeResource.getWhereCompositionIsUsedInContentTypes(1234)
+ * .then(function(contentTypeList) {
+ * console.log(contentTypeList);
+ * });
+ *
+ * @param {Int} contentTypeId id of the composition content type to retrieve the list of the content types where it has been used
+ * @returns {Promise} resourcePromise object.
+ *
+ */
getWhereCompositionIsUsedInContentTypes: function (contentTypeId) {
var query = {
contentTypeId: contentTypeId
@@ -92,12 +92,12 @@ function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
getAllowedTypes: function (contentTypeId) {
return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentTypeApiBaseUrl",
- "GetAllowedChildren",
- [{ contentId: contentTypeId }])),
- 'Failed to retrieve data for content id ' + contentTypeId);
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentTypeApiBaseUrl",
+ "GetAllowedChildren",
+ [{ contentId: contentTypeId }])),
+ 'Failed to retrieve data for content id ' + contentTypeId);
},
@@ -115,64 +115,64 @@ function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
getAllPropertyTypeAliases: function () {
return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentTypeApiBaseUrl",
- "GetAllPropertyTypeAliases")),
- 'Failed to retrieve property type aliases');
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentTypeApiBaseUrl",
+ "GetAllPropertyTypeAliases")),
+ 'Failed to retrieve property type aliases');
},
getAllStandardFields: function () {
return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentTypeApiBaseUrl",
- "GetAllStandardFields")),
- 'Failed to retrieve standard fields');
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentTypeApiBaseUrl",
+ "GetAllStandardFields")),
+ 'Failed to retrieve standard fields');
},
- getPropertyTypeScaffold : function (id) {
- return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentTypeApiBaseUrl",
- "GetPropertyTypeScaffold",
- [{ id: id }])),
- 'Failed to retrieve property type scaffold');
+ getPropertyTypeScaffold: function (id) {
+ return umbRequestHelper.resourcePromise(
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentTypeApiBaseUrl",
+ "GetPropertyTypeScaffold",
+ [{ id: id }])),
+ 'Failed to retrieve property type scaffold');
},
getById: function (id) {
return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentTypeApiBaseUrl",
- "GetById",
- [{ id: id }])),
- 'Failed to retrieve content type');
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentTypeApiBaseUrl",
+ "GetById",
+ [{ id: id }])),
+ 'Failed to retrieve content type');
},
deleteById: function (id) {
return umbRequestHelper.resourcePromise(
- $http.post(
- umbRequestHelper.getApiUrl(
- "contentTypeApiBaseUrl",
- "DeleteById",
- [{ id: id }])),
- 'Failed to delete content type');
+ $http.post(
+ umbRequestHelper.getApiUrl(
+ "contentTypeApiBaseUrl",
+ "DeleteById",
+ [{ id: id }])),
+ 'Failed to delete content type');
},
deleteContainerById: function (id) {
return umbRequestHelper.resourcePromise(
- $http.post(
- umbRequestHelper.getApiUrl(
- "contentTypeApiBaseUrl",
- "DeleteContainer",
- [{ id: id }])),
- 'Failed to delete content type contaier');
+ $http.post(
+ umbRequestHelper.getApiUrl(
+ "contentTypeApiBaseUrl",
+ "DeleteContainer",
+ [{ id: id }])),
+ 'Failed to delete content type contaier');
},
/**
@@ -189,21 +189,21 @@ function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
getAll: function () {
return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentTypeApiBaseUrl",
- "GetAll")),
- 'Failed to retrieve all content types');
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentTypeApiBaseUrl",
+ "GetAll")),
+ 'Failed to retrieve all content types');
},
getScaffold: function (parentId) {
return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "contentTypeApiBaseUrl",
- "GetEmpty", { parentId: parentId })),
- 'Failed to retrieve content type scaffold');
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentTypeApiBaseUrl",
+ "GetEmpty", { parentId: parentId })),
+ 'Failed to retrieve content type scaffold');
},
/**
@@ -223,7 +223,7 @@ function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
var saveModel = umbDataFormatter.formatContentTypePostData(contentType);
return umbRequestHelper.resourcePromise(
- $http.post(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl", "PostSave"), saveModel),
+ $http.post(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl", "PostSave"), saveModel),
'Failed to save data for content type id ' + contentType.id);
},
@@ -270,7 +270,7 @@ function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
'Failed to move content');
},
- copy: function(args) {
+ copy: function (args) {
if (!args) {
throw "args cannot be null";
}
@@ -301,12 +301,12 @@ function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
createCollection: function (parentId, collectionName, collectionItemName, collectionIcon, collectionItemIcon) {
return umbRequestHelper.resourcePromise(
- $http.post(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl", "PostCreateCollection", { parentId: parentId, collectionName: collectionName, collectionItemName: collectionItemName, collectionIcon: collectionIcon, collectionItemIcon: collectionItemIcon})),
+ $http.post(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl", "PostCreateCollection", { parentId: parentId, collectionName: collectionName, collectionItemName: collectionItemName, collectionIcon: collectionIcon, collectionItemIcon: collectionItemIcon })),
'Failed to create collection under ' + parentId);
},
- renameContainer: function(id, name) {
+ renameContainer: function (id, name) {
return umbRequestHelper.resourcePromise(
$http.post(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl",
@@ -315,8 +315,25 @@ function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
"Failed to rename the folder with id " + id
);
- }
+ },
+ export: function (id) {
+ if (!id) {
+ throw "id cannot be null";
+ }
+
+ var url = umbRequestHelper.getApiUrl("contentTypeApiBaseUrl", "Export", { id: id });
+
+ return umbRequestHelper.downloadFile(url).then(function () {
+ localizationService.localize("speechBubbles_documentTypeExportedSuccess").then(function(value) {
+ notificationsService.success(value);
+ });
+ }, function (data) {
+ localizationService.localize("speechBubbles_documentTypeExportedError").then(function(value) {
+ notificationsService.error(value);
+ });
+ });
+ }
};
}
angular.module('umbraco.resources').factory('contentTypeResource', contentTypeResource);
diff --git a/src/Umbraco.Web.UI.Client/src/views/documenttypes/export.controller.js b/src/Umbraco.Web.UI.Client/src/views/documenttypes/export.controller.js
new file mode 100644
index 0000000000..630dfb3f7f
--- /dev/null
+++ b/src/Umbraco.Web.UI.Client/src/views/documenttypes/export.controller.js
@@ -0,0 +1,13 @@
+angular.module("umbraco")
+ .controller("Umbraco.Editors.DocumentTypes.ExportController",
+ function ($scope, contentTypeResource, navigationService) {
+
+ $scope.export = function () {
+ contentTypeResource.export($scope.currentNode.id);
+ navigationService.hideMenu();
+ };
+
+ $scope.cancel = function () {
+ navigationService.hideDialog();
+ };
+ });
diff --git a/src/Umbraco.Web.UI.Client/src/views/documenttypes/export.html b/src/Umbraco.Web.UI.Client/src/views/documenttypes/export.html
new file mode 100644
index 0000000000..54c7ff0efe
--- /dev/null
+++ b/src/Umbraco.Web.UI.Client/src/views/documenttypes/export.html
@@ -0,0 +1,10 @@
+