Merge branch 'dev-v7.7' of https://github.com/umbraco/Umbraco-CMS into dev-v7.7

This commit is contained in:
Sebastiaan Janssen
2017-09-13 13:15:28 +02:00
6 changed files with 145 additions and 92 deletions

View File

@@ -156,6 +156,11 @@ namespace Umbraco.Core.Services
return RenameTypeContainer(id, name, Constants.ObjectTypes.MediaTypeContainerGuid);
}
public Attempt<OperationStatus<EntityContainer, OperationStatusType>> RenameDataTypeContainer(int id, string name, int userId = 0)
{
return RenameTypeContainer(id, name, Constants.ObjectTypes.DataTypeContainerGuid);
}
public Attempt<OperationStatus> SaveContentTypeContainer(EntityContainer container, int userId = 0)
{
return SaveContainer(
@@ -253,7 +258,7 @@ namespace Umbraco.Core.Services
public IEnumerable<EntityContainer> GetMediaTypeContainers(IMediaType mediaType)
{
var ancestorIds = mediaType.Path.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries)
var ancestorIds = mediaType.Path.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
.Select(x =>
{
var asInt = x.TryConvertTo<int>();
@@ -282,7 +287,7 @@ namespace Umbraco.Core.Services
public IEnumerable<EntityContainer> GetContentTypeContainers(IContentType contentType)
{
var ancestorIds = contentType.Path.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries)
var ancestorIds = contentType.Path.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
.Select(x =>
{
var asInt = x.TryConvertTo<int>();
@@ -479,7 +484,7 @@ namespace Umbraco.Core.Services
clone.Name = name;
var compositionAliases = clone.CompositionAliases().Except(new[] {alias}).ToList();
var compositionAliases = clone.CompositionAliases().Except(new[] { alias }).ToList();
//remove all composition that is not it's current alias
foreach (var a in compositionAliases)
{
@@ -902,7 +907,7 @@ namespace Umbraco.Core.Services
{
using (var uow = UowProvider.GetUnitOfWork())
{
var deleteEventArgs = new DeleteEventArgs<IContentType>(contentType);
var deleteEventArgs = new DeleteEventArgs<IContentType>(contentType);
if (uow.Events.DispatchCancelable(DeletingContentType, this, deleteEventArgs))
{
uow.Commit();
@@ -912,7 +917,7 @@ namespace Umbraco.Core.Services
var repository = RepositoryFactory.CreateContentTypeRepository(uow);
//If we are deleting this content type, we are also deleting it's descendents!
var deletedContentTypes = new List<IContentType> {contentType};
var deletedContentTypes = new List<IContentType> { contentType };
deletedContentTypes.AddRange(GetDescendants(contentType));
_contentService.DeleteContentOfTypes(deletedContentTypes.Select(x => x.Id), userId);

View File

@@ -30,6 +30,7 @@ namespace Umbraco.Core.Services
Attempt<OperationStatus<EntityContainer, OperationStatusType>> CreateContentTypeContainer(int parentId, string name, int userId = 0);
Attempt<OperationStatus<EntityContainer, OperationStatusType>> RenameContentTypeContainer(int id, string name, int userId = 0);
Attempt<OperationStatus<EntityContainer, OperationStatusType>> RenameDataTypeContainer(int id, string name, int userId = 0);
Attempt<OperationStatus<EntityContainer, OperationStatusType>> CreateMediaTypeContainer(int parentId, string name, int userId = 0);
Attempt<OperationStatus> SaveContentTypeContainer(EntityContainer container, int userId = 0);
Attempt<OperationStatus> SaveMediaTypeContainer(EntityContainer container, int userId = 0);

View File

@@ -35,12 +35,12 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) {
}
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"dataTypeApiBaseUrl",
"GetPreValues",
[{ editorAlias: editorAlias }, { dataTypeId: dataTypeId }])),
"Failed to retrieve pre values for editor alias " + editorAlias);
$http.get(
umbRequestHelper.getApiUrl(
"dataTypeApiBaseUrl",
"GetPreValues",
[{ editorAlias: editorAlias }, { dataTypeId: dataTypeId }])),
"Failed to retrieve pre values for editor alias " + editorAlias);
},
/**
@@ -66,12 +66,12 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) {
getById: function (id) {
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"dataTypeApiBaseUrl",
"GetById",
[{ id: id }])),
"Failed to retrieve data for data type id " + id);
$http.get(
umbRequestHelper.getApiUrl(
"dataTypeApiBaseUrl",
"GetById",
[{ id: id }])),
"Failed to retrieve data for data type id " + id);
},
/**
@@ -97,24 +97,24 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) {
getByName: function (name) {
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"dataTypeApiBaseUrl",
"GetByName",
[{ name: name }])),
"Failed to retrieve data for data type with name: " + name);
$http.get(
umbRequestHelper.getApiUrl(
"dataTypeApiBaseUrl",
"GetByName",
[{ name: name }])),
"Failed to retrieve data for data type with name: " + name);
},
getAll: function () {
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"dataTypeApiBaseUrl",
"GetAll")),
"Failed to retrieve data");
$http.get(
umbRequestHelper.getApiUrl(
"dataTypeApiBaseUrl",
"GetAll")),
"Failed to retrieve data");
},
getGroupedDataTypes: function () {
return umbRequestHelper.resourcePromise(
$http.get(
@@ -124,7 +124,7 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) {
"Failed to retrieve data");
},
getGroupedPropertyEditors : function(){
getGroupedPropertyEditors: function () {
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
@@ -173,11 +173,11 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) {
getScaffold: function (parentId) {
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"dataTypeApiBaseUrl",
"GetEmpty", { parentId: parentId })),
"Failed to retrieve data for empty datatype");
$http.get(
umbRequestHelper.getApiUrl(
"dataTypeApiBaseUrl",
"GetEmpty", { parentId: parentId })),
"Failed to retrieve data for empty datatype");
},
/**
* @ngdoc method
@@ -199,7 +199,7 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) {
* @returns {Promise} resourcePromise object.
*
*/
deleteById: function(id) {
deleteById: function (id) {
return umbRequestHelper.resourcePromise(
$http.post(
umbRequestHelper.getApiUrl(
@@ -212,12 +212,12 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) {
deleteContainerById: function (id) {
return umbRequestHelper.resourcePromise(
$http.post(
umbRequestHelper.getApiUrl(
"dataTypeApiBaseUrl",
"DeleteContainer",
[{ id: id }])),
'Failed to delete content type contaier');
$http.post(
umbRequestHelper.getApiUrl(
"dataTypeApiBaseUrl",
"DeleteContainer",
[{ id: id }])),
'Failed to delete content type contaier');
},
@@ -242,16 +242,16 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) {
*
*/
getCustomListView: function (contentTypeAlias) {
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"dataTypeApiBaseUrl",
"GetCustomListView",
{ contentTypeAlias: contentTypeAlias }
)),
"Failed to retrieve data for custom 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
@@ -271,16 +271,16 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) {
* @returns {Promise} resourcePromise object containing the listview datatype.
*
*/
createCustomListView: function (contentTypeAlias) {
return umbRequestHelper.resourcePromise(
createCustomListView: function (contentTypeAlias) {
return umbRequestHelper.resourcePromise(
$http.post(
umbRequestHelper.getApiUrl(
"dataTypeApiBaseUrl",
"PostCreateCustomListView",
{ contentTypeAlias: contentTypeAlias }
)),
)),
"Failed to create a custom listview datatype");
},
},
/**
* @ngdoc method
@@ -301,7 +301,7 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) {
var saveModel = umbDataFormatter.formatDataTypePostData(dataType, preValues, "save" + (isNew ? "New" : ""));
return umbRequestHelper.resourcePromise(
$http.post(umbRequestHelper.getApiUrl("dataTypeApiBaseUrl", "PostSave"), saveModel),
$http.post(umbRequestHelper.getApiUrl("dataTypeApiBaseUrl", "PostSave"), saveModel),
"Failed to save data for data type id " + dataType.id);
},
@@ -351,12 +351,22 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) {
createContainer: function (parentId, name) {
return umbRequestHelper.resourcePromise(
$http.post(
$http.post(
umbRequestHelper.getApiUrl(
"dataTypeApiBaseUrl",
"PostCreateContainer",
{ parentId: parentId, name: name })),
"dataTypeApiBaseUrl",
"PostCreateContainer",
{ parentId: parentId, name: name })),
'Failed to create a folder under parent id ' + parentId);
},
renameContainer: function (id, name) {
return umbRequestHelper.resourcePromise(
$http.post
(umbRequestHelper.getApiUrl(
"dataTypeApiBaseUrl",
"PostRenameContainer",
{ id: id, name: name })),
"Failed to rename the folder with id " + id);
}
};
}

View File

@@ -0,0 +1,22 @@
<div class="umbracoDialog umb-dialog-body with-footer" ng-controller="Umbraco.Editors.ContentTypeContainers.RenameController" ng-cloak>
<div class="umb-pane">
<form novalidate name="renameFolderForm"
ng-submit="renameContainer('dataTypeResource', 'datatypes')"
val-form-manager>
<div ng-show="error">
<h5 class="text-error">{{error.errorMsg}}</h5>
<p class="text-error">{{error.data.message}}</p>
</div>
<umb-control-group label="@renamecontainer_enterNewFolderName" hide-label="false">
<input type="text" name="folderName" ng-model="model.folderName" class="umb-textstring textstring input-block-level" umb-auto-focus required />
</umb-control-group>
<button type="submit" class="btn btn-primary"><localize key="general_rename">Rename</localize></button>
</form>
</div>
</div>

View File

@@ -22,8 +22,8 @@ using System.Net.Http;
using System.Text;
namespace Umbraco.Web.Editors
{
{
/// <summary>
/// The API controller used for editing data types
/// </summary>
@@ -75,8 +75,8 @@ namespace Umbraco.Web.Editors
if (foundType == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
}
Services.DataTypeService.Delete(foundType, Security.CurrentUser.Id);
return Request.CreateResponse(HttpStatusCode.OK);
@@ -111,17 +111,17 @@ namespace Umbraco.Web.Editors
/// <returns></returns>
public DataTypeDisplay PostCreateCustomListView(string contentTypeAlias)
{
var dt = Services.DataTypeService.GetDataTypeDefinitionByName(Constants.Conventions.DataTypes.ListViewPrefix + contentTypeAlias);
//if it doesnt exist yet, we will create it.
var dt = Services.DataTypeService.GetDataTypeDefinitionByName(Constants.Conventions.DataTypes.ListViewPrefix + contentTypeAlias);
//if it doesnt exist yet, we will create it.
if (dt == null)
{
dt = new DataTypeDefinition( Constants.PropertyEditors.ListViewAlias );
dt = new DataTypeDefinition(Constants.PropertyEditors.ListViewAlias);
dt.Name = Constants.Conventions.DataTypes.ListViewPrefix + contentTypeAlias;
Services.DataTypeService.Save(dt);
}
return Mapper.Map<IDataTypeDefinition, DataTypeDisplay>(dt);
return Mapper.Map<IDataTypeDefinition, DataTypeDisplay>(dt);
}
/// <summary>
@@ -161,7 +161,7 @@ namespace Umbraco.Web.Editors
}
//these are new pre-values, so just return the field editors with default values
return Mapper.Map<PropertyEditor, IEnumerable<PreValueFieldDisplay>>(propEd);
return Mapper.Map<PropertyEditor, IEnumerable<PreValueFieldDisplay>>(propEd);
}
/// <summary>
@@ -243,31 +243,40 @@ namespace Umbraco.Web.Editors
return Request.CreateResponse(HttpStatusCode.NotFound);
}
var result = Services.DataTypeService.Move(toMove, move.ParentId);
if (result.Success)
{
var response = Request.CreateResponse(HttpStatusCode.OK);
response.Content = new StringContent(toMove.Path, Encoding.UTF8, "application/json");
return response;
}
switch (result.Result.StatusType)
{
case MoveOperationStatusType.FailedParentNotFound:
return Request.CreateResponse(HttpStatusCode.NotFound);
var result = Services.DataTypeService.Move(toMove, move.ParentId);
if (result.Success)
{
var response = Request.CreateResponse(HttpStatusCode.OK);
response.Content = new StringContent(toMove.Path, Encoding.UTF8, "application/json");
return response;
}
switch (result.Result.StatusType)
{
case MoveOperationStatusType.FailedParentNotFound:
return Request.CreateResponse(HttpStatusCode.NotFound);
case MoveOperationStatusType.FailedCancelledByEvent:
//returning an object of INotificationModel will ensure that any pending
// notification messages are added to the response.
return Request.CreateValidationErrorResponse(new SimpleNotificationModel());
case MoveOperationStatusType.FailedNotAllowedByPath:
return Request.CreateValidationErrorResponse(new SimpleNotificationModel());
case MoveOperationStatusType.FailedNotAllowedByPath:
var notificationModel = new SimpleNotificationModel();
notificationModel.AddErrorNotification(Services.TextService.Localize("moveOrCopy/notAllowedByPath"), "");
notificationModel.AddErrorNotification(Services.TextService.Localize("moveOrCopy/notAllowedByPath"), "");
return Request.CreateValidationErrorResponse(notificationModel);
default:
throw new ArgumentOutOfRangeException();
default:
throw new ArgumentOutOfRangeException();
}
}
public HttpResponseMessage PostRenameContainer(int id, string name)
{
var result = Services.ContentTypeService.RenameDataTypeContainer(id, name, Security.CurrentUser.Id);
return result
? Request.CreateResponse(HttpStatusCode.OK, result.Result)
: Request.CreateNotificationValidationErrorResponse(result.Exception.Message);
}
#region ReadOnly actions to return basic data - allow access for: content ,media, members, settings, developer
/// <summary>
/// Gets the content json for all data types
@@ -308,7 +317,7 @@ namespace Umbraco.Web.Editors
foreach (var dataType in dataTypes)
{
var propertyEditor = propertyEditors.SingleOrDefault(x => x.Alias == dataType.Alias);
if(propertyEditor != null)
if (propertyEditor != null)
dataType.HasPrevalues = propertyEditor.PreValueEditor.Fields.Any(); ;
}
@@ -331,8 +340,8 @@ namespace Umbraco.Web.Editors
Constants.Applications.Settings, Constants.Applications.Developer)]
public IDictionary<string, IEnumerable<DataTypeBasic>> GetGroupedPropertyEditors()
{
var datatypes = new List<DataTypeBasic>();
var datatypes = new List<DataTypeBasic>();
var propertyEditors = PropertyEditorResolver.Current.PropertyEditors;
foreach (var propertyEditor in propertyEditors)
{

View File

@@ -105,12 +105,18 @@ namespace Umbraco.Web.Trees
menu.Items.Add<ActionNew>(Services.TextService.Localize(string.Format("actions/{0}", ActionNew.Instance.Alias)));
menu.Items.Add(new MenuItem("rename", Services.TextService.Localize(String.Format("actions/{0}", "rename")))
{
Icon = "icon icon-edit"
});
if (container.HasChildren() == false)
{
//can delete data type
menu.Items.Add<ActionDelete>(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias)));
}
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), hasSeparator: true);
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), hasSeparator: true);
}
else
{