Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

Commit

Permalink
Updates needed for 10.8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
skttl committed Feb 10, 2024
1 parent bddf6c4 commit 1329a25
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Logging;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.PublishedCache;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Web.BackOffice.Controllers;
using Umbraco.Cms.Web.BackOffice.Filters;
using Umbraco.Cms.Web.BackOffice.ModelBinders;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Cms.Core.Dictionary;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Core.Mapping;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Scoping;
using Microsoft.AspNetCore.Authorization;

namespace Our.Umbraco.DocTypeGridEditor.Controllers
{
[PluginController("DocTypeGridEditorApi")]
public class DocTypeGridEditorBlueprintApiController : UmbracoAuthorizedApiController
{
private readonly IContentService _contentService;
private ContentController _contentController;

public DocTypeGridEditorBlueprintApiController(ICultureDictionary cultureDictionary, ILoggerFactory loggerFactory, IShortStringHelper shortStringHelper, IEventMessagesFactory eventMessages, ILocalizedTextService localizedTextService, PropertyEditorCollection propertyEditors, IContentService contentService, IUserService userService, IBackOfficeSecurityAccessor backofficeSecurityAccessor, IContentTypeService contentTypeService, IUmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider, IDomainService domainService, IDataTypeService dataTypeService, ILocalizationService localizationService, IFileService fileService, INotificationService notificationService, ActionCollection actionCollection, ISqlContext sqlContext, IJsonSerializer serializer, ICoreScopeProvider scopeProvider, IAuthorizationService authorizationService, IContentVersionService contentVersionService, ICultureImpactFactory cultureImpactFactory)
{
_contentController = new ContentController(cultureDictionary, loggerFactory, shortStringHelper, eventMessages, localizedTextService, propertyEditors, contentService, userService, backofficeSecurityAccessor, contentTypeService, umbracoMapper, publishedUrlProvider, domainService, dataTypeService, localizationService, fileService, notificationService, actionCollection, sqlContext, serializer, scopeProvider, authorizationService, contentVersionService, cultureImpactFactory);
}

[FileUploadCleanupFilter]
[HttpPost]
public async Task<ActionResult<ContentItemDisplay<ContentVariantDisplay>?>?> PostSaveBlueprint([ModelBinder(typeof(BlueprintItemBinder))] ContentItemSave contentItem)
{
return await _contentController.PostSaveBlueprint(contentItem);
}
[HttpDelete]
[HttpPost]
public IActionResult DeleteBlueprint(int id)
{
var found = _contentService.GetBlueprintById(id);

if (found == null)
{
return BadRequest();
}

_contentService.DeleteBlueprint(found);

return Ok();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Product>Our.Umbraco.DocTypeGridEditor</Product>
<PackageTags>umbraco plugin package</PackageTags>

<Version>10.0.1</Version>
<Version>10.1.0-blackknight</Version>
<Authors>Søren Kottal</Authors>
<Company></Company>

Expand All @@ -20,7 +20,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Umbraco.Cms.Web.Website" Version="10.0.0" />
<PackageReference Include="Umbraco.Cms.Web.BackOffice" Version="10.0.0" />
<PackageReference Include="Umbraco.Cms.Web.Website" Version="10.8.4" />
<PackageReference Include="Umbraco.Cms.Web.BackOffice" Version="10.8.4" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.Dialogs.DocT
function cleanup() {
if ($scope.model.node && $scope.model.node.id > 0) {
// delete any temporary blueprints used for validation
contentResource.deleteBlueprint($scope.model.node.id);
dtgeResources.deleteBlueprint($scope.model.node.id);

// set current node id, so subsequent deletes, giving 404 errors is avoided
$scope.model.node.id = 0;
Expand All @@ -279,7 +279,7 @@ angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.Dialogs.DocT

// save the content as a blueprint, to trigger validation
var args = {
saveMethod: contentResource.saveBlueprint,
saveMethod: dtgeResources.saveBlueprint,
scope: $scope,
content: $scope.model.node,
create: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
angular.module('umbraco.resources').factory('Our.Umbraco.DocTypeGridEditor.Resources.DocTypeGridEditorResources',
function ($q, $http, umbRequestHelper) {
function ($q, $http, umbRequestHelper, umbDataFormatter) {
return {
getContentTypeAliasByGuid: function (guid) {
var url = Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + "/backoffice/DocTypeGridEditorApi/DocTypeGridEditorApi/GetContentTypeAliasByGuid?guid=" + guid;
Expand Down Expand Up @@ -52,6 +52,24 @@
'Content-Type': 'application/x-www-form-urlencoded'
}
});
},
saveBlueprint: function (content, isNew, files, showNotifications) {
var restApiUrl = Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + "/backoffice/DocTypeGridEditorApi/DocTypeGridEditorBlueprintApi/PostSaveBlueprint";
return umbRequestHelper.postSaveContent({
restApiUrl: restApiUrl,
content: content,
action: "save" + (isNew ? "New" : ""),
files: files,
showNotifications: showNotifications,
dataFormatter: function (c, a) {
return umbDataFormatter.formatContentPostData(c, a);
}
});
},
deleteBlueprint: function (id) {
var restApiUrl = Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + "/backoffice/DocTypeGridEditorApi/DocTypeGridEditorBlueprintApi/DeleteBlueprint";
var requestData = { id: id };
$http.post(restApiUrl, null, { params: requestData })
}
};
});

0 comments on commit 1329a25

Please sign in to comment.