Can create blueprints from the tree

This commit is contained in:
Lars-Erik Aabech
2017-06-05 16:46:30 +02:00
parent 7f63919ba6
commit 88702f7e18
3 changed files with 31 additions and 5 deletions

View File

@@ -7,9 +7,28 @@
* The controller for the content editor
*/
function ContentBlueprintEditController($scope, $routeParams, contentResource) {
$scope.contentId = $routeParams.id;
var excludedProps = ["_umb_urls", "_umb_releasedate", "_umb_expiredate", "_umb_template"];
function getScaffold() {
return contentResource.getScaffold(-1, $routeParams.doctype)
.then(function (scaffold) {
var lastTab = scaffold.tabs[scaffold.tabs.length - 1];
lastTab.properties = _.filter(lastTab.properties,
function(p) {
return excludedProps.indexOf(p.alias) === -1;
});
scaffold.allowPreview = false;
scaffold.allowedActions = ["A", "S", "C"];
return scaffold;
});
}
$scope.contentId = $routeParams.id;
$scope.isNew = $routeParams.id === "-1";
$scope.saveMethod = contentResource.saveBlueprint;
$scope.getMethod = contentResource.getBlueprintById;
$scope.getScaffoldMethod = getScaffold;
}
angular.module("umbraco").controller("Umbraco.Editors.ContentBlueprint.EditController", ContentBlueprintEditController);

View File

@@ -2,6 +2,8 @@
<content-editor content-id="contentId"
save-method="saveMethod"
get-method="getMethod"
get-scaffold-method="getScaffoldMethod"
is-new="isNew"
tree-alias="contentblueprints">
</content-editor>
</div>

View File

@@ -6,6 +6,7 @@ using System.Net;
using System.Net.Http.Formatting;
using System.Web.Http;
using umbraco;
using umbraco.businesslogic.Actions;
using umbraco.BusinessLogic.Actions;
using Umbraco.Core;
using Umbraco.Core.Services;
@@ -91,17 +92,21 @@ namespace Umbraco.Web.Trees
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true);
return menu;
}
var ct = Services.EntityService.Get(int.Parse(id), UmbracoObjectTypes.DocumentType);
//only refresh if it's a content type
if (ct != null)
var cte = Services.EntityService.Get(int.Parse(id), UmbracoObjectTypes.DocumentType);
//only refresh & create if it's a content type
if (cte != null)
{
var ct = Services.ContentTypeService.GetContentType(cte.Id);
var createItem = menu.Items.Add<ActionCreateBlueprintFromContent>(Services.TextService.Localize(string.Format("actions/{0}", ActionCreateBlueprintFromContent.Instance.Alias)));
createItem.NavigateToRoute("/settings/contentBlueprints/edit/-1?create=true&doctype=" + ct.Alias);
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true);
return menu;
}
menu.Items.Add<ActionDelete>(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias)));
return menu;
}