Added copy functionality for data types (#11867)
* Added copy functionality for data types * Fix errors * Add logic to default interface * PR Feedback * PR feedback * Fix error
This commit is contained in:
@@ -383,6 +383,30 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
public IActionResult PostCopy(MoveOrCopy copy)
|
||||
{
|
||||
var toCopy = _dataTypeService.GetDataType(copy.Id);
|
||||
if (toCopy is null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Attempt<OperationResult<MoveOperationStatusType, IDataType>?> result = _dataTypeService.Copy(toCopy, copy.ParentId);
|
||||
if (result.Success)
|
||||
{
|
||||
return Content(toCopy.Path, MediaTypeNames.Text.Plain, Encoding.UTF8);
|
||||
}
|
||||
|
||||
return result.Result?.Result switch
|
||||
{
|
||||
MoveOperationStatusType.FailedParentNotFound => NotFound(),
|
||||
MoveOperationStatusType.FailedCancelledByEvent => ValidationProblem(),
|
||||
MoveOperationStatusType.FailedNotAllowedByPath => ValidationProblem(
|
||||
_localizedTextService.Localize("moveOrCopy", "notAllowedByPath")),
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
}
|
||||
|
||||
public IActionResult PostRenameContainer(int id, string name)
|
||||
{
|
||||
var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity?.CurrentUser;
|
||||
|
||||
@@ -181,8 +181,9 @@ public class DataTypeTreeController : TreeController, ISearchableTree
|
||||
menu.Items.Add<ActionDelete>(LocalizedTextService, opensDialog: true, useLegacyIcon: false);
|
||||
}
|
||||
|
||||
menu.Items.Add<ActionMove>(LocalizedTextService, hasSeparator: true, opensDialog: true, useLegacyIcon: false);
|
||||
}
|
||||
menu.Items.Add<ActionMove>(LocalizedTextService, hasSeparator: true, opensDialog: true, useLegacyIcon: false);
|
||||
menu.Items.Add<ActionCopy>(LocalizedTextService, hasSeparator: true, opensDialog: true, useLegacyIcon: false);
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user