diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/mediatype.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/mediatype.resource.js index 140995cd57..2d74676d9c 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/mediatype.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/mediatype.resource.js @@ -1,264 +1,272 @@ -/** - * @ngdoc service - * @name umbraco.resources.mediaTypeResource - * @description Loads in data for media types - **/ -function mediaTypeResource($q, $http, umbRequestHelper, umbDataFormatter) { - - return { - - getCount: function () { - return umbRequestHelper.resourcePromise( - $http.get( - umbRequestHelper.getApiUrl( - "mediaTypeApiBaseUrl", - "GetCount")), - 'Failed to retrieve count'); - }, - - getAvailableCompositeContentTypes: function (contentTypeId, filterContentTypes, filterPropertyTypes) { - if (!filterContentTypes) { - filterContentTypes = []; - } - if (!filterPropertyTypes) { - filterPropertyTypes = []; - } - - var query = { - contentTypeId: contentTypeId, - filterContentTypes: filterContentTypes, - filterPropertyTypes: filterPropertyTypes - }; - - return umbRequestHelper.resourcePromise( - $http.post( - umbRequestHelper.getApiUrl( - "mediaTypeApiBaseUrl", - "GetAvailableCompositeMediaTypes"), - query), - 'Failed to retrieve data for content type id ' + contentTypeId); - }, - /** - * @ngdoc method - * @name umbraco.resources.mediaTypeResource#getWhereCompositionIsUsedInContentTypes - * @methodOf umbraco.resources.mediaTypeResource - * - * @description - * Returns a list of media types which use a specific composition with a given id - * - * ##usage - *
-         * mediaTypeResource.getWhereCompositionIsUsedInContentTypes(1234)
-         *    .then(function(mediaTypeList) {
-         *        console.log(mediaTypeList);
-         *    });
-         * 
- * @param {Int} contentTypeId id of the composition content type to retrieve the list of the media types where it has been used - * @returns {Promise} resourcePromise object. - * - */ - getWhereCompositionIsUsedInContentTypes: function (contentTypeId) { - var query = { - contentTypeId: contentTypeId - }; - - return umbRequestHelper.resourcePromise( - $http.post( - umbRequestHelper.getApiUrl( - "mediaTypeApiBaseUrl", - "GetWhereCompositionIsUsedInContentTypes"), - query), - 'Failed to retrieve data for content type id ' + contentTypeId); - }, - /** - * @ngdoc method - * @name umbraco.resources.mediaTypeResource#getAllowedTypes - * @methodOf umbraco.resources.mediaTypeResource - * - * @description - * Returns a list of allowed media types underneath a media item with a given ID - * - * ##usage - *
-         * mediaTypeResource.getAllowedTypes(1234)
-         *    .then(function(array) {
-         *        $scope.type = type;
-         *    });
-         * 
- * @param {Int} mediaId id of the media item to retrive allowed child types for - * @returns {Promise} resourcePromise object. - * - */ - getAllowedTypes: function (mediaId) { - - return umbRequestHelper.resourcePromise( - $http.get( - umbRequestHelper.getApiUrl( - "mediaTypeApiBaseUrl", - "GetAllowedChildren", - [{ contentId: mediaId }])), - 'Failed to retrieve allowed types for media id ' + mediaId); - }, - - getById: function (id) { - - return umbRequestHelper.resourcePromise( - $http.get( - umbRequestHelper.getApiUrl( - "mediaTypeApiBaseUrl", - "GetById", - [{ id: id }])), - 'Failed to retrieve content type'); - }, - - getAll: function () { - - return umbRequestHelper.resourcePromise( - $http.get( - umbRequestHelper.getApiUrl( - "mediaTypeApiBaseUrl", - "GetAll")), - 'Failed to retrieve all content types'); - }, - - getScaffold: function (parentId) { - - return umbRequestHelper.resourcePromise( - $http.get( - umbRequestHelper.getApiUrl( - "mediaTypeApiBaseUrl", - "GetEmpty", { parentId: parentId })), - 'Failed to retrieve content type scaffold'); - }, - - deleteById: function (id) { - - return umbRequestHelper.resourcePromise( - $http.post( - umbRequestHelper.getApiUrl( - "mediaTypeApiBaseUrl", - "DeleteById", - [{ id: id }])), - 'Failed to retrieve content type'); - }, - - deleteContainerById: function (id) { - - return umbRequestHelper.resourcePromise( - $http.post( - umbRequestHelper.getApiUrl( - "mediaTypeApiBaseUrl", - "DeleteContainer", - [{ id: id }])), - 'Failed to delete content type contaier'); - }, - - /** - * @ngdoc method - * @name umbraco.resources.mediaTypeResource#save - * @methodOf umbraco.resources.mediaTypeResource - * - * @description - * Saves or update a media type - * - * @param {Object} content data type object to create/update - * @returns {Promise} resourcePromise object. - * - */ - save: function (contentType) { - - var saveModel = umbDataFormatter.formatContentTypePostData(contentType); - - return umbRequestHelper.resourcePromise( - $http.post(umbRequestHelper.getApiUrl("mediaTypeApiBaseUrl", "PostSave"), saveModel), - 'Failed to save data for content type id ' + contentType.id); - }, - - /** - * @ngdoc method - * @name umbraco.resources.mediaTypeResource#move - * @methodOf umbraco.resources.mediaTypeResource - * - * @description - * Moves a node underneath a new parentId - * - * ##usage - *
-         * mediaTypeResource.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("mediaTypeApiBaseUrl", "PostMove"), - { - parentId: args.parentId, - id: args.id - }), - 'Failed to move content'); - }, - - 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("mediaTypeApiBaseUrl", "PostCopy"), - { - parentId: args.parentId, - id: args.id - }), - 'Failed to copy content'); - }, - - createContainer: function(parentId, name) { - - return umbRequestHelper.resourcePromise( - $http.post( - umbRequestHelper.getApiUrl( - "mediaTypeApiBaseUrl", - "PostCreateContainer", - { parentId: parentId, name: encodeURIComponent(name) })), - 'Failed to create a folder under parent id ' + parentId); - }, - - renameContainer: function (id, name) { - - return umbRequestHelper.resourcePromise( - $http.post(umbRequestHelper.getApiUrl("mediaTypeApiBaseUrl", - "PostRenameContainer", - { id: id, name: name })), - "Failed to rename the folder with id " + id - ); - - } - - }; -} -angular.module('umbraco.resources').factory('mediaTypeResource', mediaTypeResource); +/** + * @ngdoc service + * @name umbraco.resources.mediaTypeResource + * @description Loads in data for media types + **/ +function mediaTypeResource($q, $http, umbRequestHelper, umbDataFormatter, localizationService) { + + return { + + getCount: function () { + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "mediaTypeApiBaseUrl", + "GetCount")), + 'Failed to retrieve count'); + }, + + getAvailableCompositeContentTypes: function (contentTypeId, filterContentTypes, filterPropertyTypes) { + if (!filterContentTypes) { + filterContentTypes = []; + } + if (!filterPropertyTypes) { + filterPropertyTypes = []; + } + + var query = { + contentTypeId: contentTypeId, + filterContentTypes: filterContentTypes, + filterPropertyTypes: filterPropertyTypes + }; + + return umbRequestHelper.resourcePromise( + $http.post( + umbRequestHelper.getApiUrl( + "mediaTypeApiBaseUrl", + "GetAvailableCompositeMediaTypes"), + query), + 'Failed to retrieve data for content type id ' + contentTypeId); + }, + /** + * @ngdoc method + * @name umbraco.resources.mediaTypeResource#getWhereCompositionIsUsedInContentTypes + * @methodOf umbraco.resources.mediaTypeResource + * + * @description + * Returns a list of media types which use a specific composition with a given id + * + * ##usage + *
+         * mediaTypeResource.getWhereCompositionIsUsedInContentTypes(1234)
+         *    .then(function(mediaTypeList) {
+         *        console.log(mediaTypeList);
+         *    });
+         * 
+ * @param {Int} contentTypeId id of the composition content type to retrieve the list of the media types where it has been used + * @returns {Promise} resourcePromise object. + * + */ + getWhereCompositionIsUsedInContentTypes: function (contentTypeId) { + var query = { + contentTypeId: contentTypeId + }; + + return umbRequestHelper.resourcePromise( + $http.post( + umbRequestHelper.getApiUrl( + "mediaTypeApiBaseUrl", + "GetWhereCompositionIsUsedInContentTypes"), + query), + 'Failed to retrieve data for content type id ' + contentTypeId); + }, + /** + * @ngdoc method + * @name umbraco.resources.mediaTypeResource#getAllowedTypes + * @methodOf umbraco.resources.mediaTypeResource + * + * @description + * Returns a list of allowed media types underneath a media item with a given ID + * + * ##usage + *
+         * mediaTypeResource.getAllowedTypes(1234)
+         *    .then(function(array) {
+         *        $scope.type = type;
+         *    });
+         * 
+ * @param {Int} mediaId id of the media item to retrive allowed child types for + * @returns {Promise} resourcePromise object. + * + */ + getAllowedTypes: function (mediaId) { + + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "mediaTypeApiBaseUrl", + "GetAllowedChildren", + [{ contentId: mediaId }])), + 'Failed to retrieve allowed types for media id ' + mediaId); + }, + + getById: function (id) { + + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "mediaTypeApiBaseUrl", + "GetById", + [{ id: id }])), + 'Failed to retrieve content type'); + }, + + getAll: function () { + + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "mediaTypeApiBaseUrl", + "GetAll")), + 'Failed to retrieve all content types'); + }, + + getScaffold: function (parentId) { + + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "mediaTypeApiBaseUrl", + "GetEmpty", { parentId: parentId })), + 'Failed to retrieve content type scaffold'); + }, + + deleteById: function (id) { + + return umbRequestHelper.resourcePromise( + $http.post( + umbRequestHelper.getApiUrl( + "mediaTypeApiBaseUrl", + "DeleteById", + [{ id: id }])), + 'Failed to retrieve content type'); + }, + + deleteContainerById: function (id) { + + return umbRequestHelper.resourcePromise( + $http.post( + umbRequestHelper.getApiUrl( + "mediaTypeApiBaseUrl", + "DeleteContainer", + [{ id: id }])), + 'Failed to delete content type contaier'); + }, + + /** + * @ngdoc method + * @name umbraco.resources.mediaTypeResource#save + * @methodOf umbraco.resources.mediaTypeResource + * + * @description + * Saves or update a media type + * + * @param {Object} content data type object to create/update + * @returns {Promise} resourcePromise object. + * + */ + save: function (contentType) { + + var saveModel = umbDataFormatter.formatContentTypePostData(contentType); + + return umbRequestHelper.resourcePromise( + $http.post(umbRequestHelper.getApiUrl("mediaTypeApiBaseUrl", "PostSave"), saveModel), + 'Failed to save data for content type id ' + contentType.id); + }, + + /** + * @ngdoc method + * @name umbraco.resources.mediaTypeResource#move + * @methodOf umbraco.resources.mediaTypeResource + * + * @description + * Moves a node underneath a new parentId + * + * ##usage + *
+         * mediaTypeResource.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"; + } + + var promise = localizationService.localize("media_moveFailed"); + + return umbRequestHelper.resourcePromise( + $http.post(umbRequestHelper.getApiUrl("mediaTypeApiBaseUrl", "PostMove"), + { + parentId: args.parentId, + id: args.id + }), + promise); + }, + + 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"; + } + + var promise = localizationService.localize("media_copyFailed"); + + return umbRequestHelper.resourcePromise( + $http.post(umbRequestHelper.getApiUrl("mediaTypeApiBaseUrl", "PostCopy"), + { + parentId: args.parentId, + id: args.id + }), + promise); + }, + + createContainer: function(parentId, name) { + + var promise = localizationService.localize("media_createFolderFailed", [parentId]); + + return umbRequestHelper.resourcePromise( + $http.post( + umbRequestHelper.getApiUrl( + "mediaTypeApiBaseUrl", + "PostCreateContainer", + { parentId: parentId, name: encodeURIComponent(name) })), + promise); + }, + + renameContainer: function (id, name) { + + var promise = localizationService.localize("media_renameFolderFailed", [id]); + + return umbRequestHelper.resourcePromise( + $http.post(umbRequestHelper.getApiUrl("mediaTypeApiBaseUrl", + "PostRenameContainer", + { id: id, name: name })), + promise + ); + + } + + }; +} +angular.module('umbraco.resources').factory('mediaTypeResource', mediaTypeResource); diff --git a/src/Umbraco.Web.UI.Client/src/views/mediatypes/create.controller.js b/src/Umbraco.Web.UI.Client/src/views/mediatypes/create.controller.js index bc0cf854c6..4fa96b8585 100644 --- a/src/Umbraco.Web.UI.Client/src/views/mediatypes/create.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/mediatypes/create.controller.js @@ -37,8 +37,7 @@ function MediaTypesCreateController($scope, $location, navigationService, mediaT var section = appState.getSectionState("currentSection"); }, function(err) { - - //TODO: Handle errors + $scope.error = err; }); }; } diff --git a/src/Umbraco.Web.UI.Client/src/views/mediatypes/create.html b/src/Umbraco.Web.UI.Client/src/views/mediatypes/create.html index afcb1ef787..9f8b2e033f 100644 --- a/src/Umbraco.Web.UI.Client/src/views/mediatypes/create.html +++ b/src/Umbraco.Web.UI.Client/src/views/mediatypes/create.html @@ -27,6 +27,13 @@ ng-submit="createContainer()" val-form-manager> +
+
+
{{error.errorMsg}}
+
{{error.data.message}}
+
+
+ diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/da.xml b/src/Umbraco.Web.UI/umbraco/config/lang/da.xml index 886662d17f..271144c7ec 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/da.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/da.xml @@ -266,6 +266,10 @@ Kan ikke uploade denne fil, den har ikke en godkendt filtype Maks filstørrelse er Medie rod + Flytning af mediet fejlede + Kopiering af mediet fejlede + Oprettelse af mappen under parent med id %0% fejlede + Omdøbning af mappen med id %0% fejlede Opret et nyt medlem diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml index 6f17bb4e8a..af8c302aff 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml @@ -274,6 +274,10 @@ Cannot upload this file, it does not have an approved file type Max file size is Media root + Failed to move media + Failed to copy media + Failed to create a folder under parent id %0% + Failed to rename the folder with id %0% Create a new member diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml index ba32e7f7d1..5355928f17 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml @@ -275,6 +275,10 @@ Cannot upload this file, it does not have an approved file type Max file size is Media root + Failed to move media + Failed to copy media + Failed to create a folder under parent id %0% + Failed to rename the folder with id %0% Create a new member